@muyichengshayu/promptx 0.2.1 → 0.2.2
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/CHANGELOG.md +4 -0
- package/apps/web/dist/assets/{CodexSessionManagerDialog-Cprbem1C.js → CodexSessionManagerDialog-CELTkz9T.js} +1 -1
- package/apps/web/dist/assets/{TaskDiffReviewDialog-Bxxkkdld.js → TaskDiffReviewDialog-VwZmo00b.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchSettingsDialog-B046sue0.js → WorkbenchSettingsDialog-CThWkZHd.js} +1 -1
- package/apps/web/dist/assets/{WorkbenchView-BbyYTwTa.js → WorkbenchView-D6auwJnA.js} +4 -4
- package/apps/web/dist/assets/{index-BS3I37dk.js → index-8vfFmsVl.js} +2 -2
- package/apps/web/dist/assets/{index-CTHBQ5Ng.css → index-BPfQQtEB.css} +1 -1
- package/apps/web/dist/index.html +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-
|
|
2
|
-
import{u as St,t as We,f as xr,_ as ze,a as br,b as kr,g as Os,s as xa,c as ba}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-shiki-theme-github-dark-default-DBX58552.js","assets/vendor-shiki-core-1BqeTDsZ.js","assets/vendor-misc-u-M8sNMf.js","assets/vendor-misc-ClI1dyrl.css","assets/vendor-shiki-theme-github-light-RLAvZv0q.js","assets/vendor-shiki-lang-bash-zsQu0xn-.js","assets/vendor-shiki-lang-c-BDF8vgks.js","assets/vendor-shiki-lang-cpp-DyDAaXl6.js","assets/vendor-shiki-lang-csharp-BWfTXJXw.js","assets/vendor-shiki-lang-css-DbAm1fUO.js","assets/vendor-shiki-lang-diff-DmGC1G26.js","assets/vendor-shiki-lang-dockerfile-3x-8396r.js","assets/vendor-shiki-lang-dotenv--IVOlX2Q.js","assets/vendor-shiki-lang-fish-Bpv3hhJP.js","assets/vendor-shiki-lang-go-CIGC59jP.js","assets/vendor-shiki-lang-html-Bt_TLLZN.js","assets/vendor-shiki-lang-ini-BIllfys4.js","assets/vendor-shiki-lang-java-CXxu9crF.js","assets/vendor-shiki-lang-javascript-Cha7GNZm.js","assets/vendor-shiki-lang-json-CCZCjDUh.js","assets/vendor-shiki-lang-less-DAToytC5.js","assets/vendor-shiki-lang-markdown-C6lwMXFp.js","assets/vendor-shiki-lang-python-Bi9rmtY7.js","assets/vendor-shiki-lang-powershell-lrpuM0ez.js","assets/vendor-shiki-lang-rust-GTGDbY6A.js","assets/vendor-shiki-lang-sass-DFtHupN8.js","assets/vendor-shiki-lang-scss-BrfBNyyi.js","assets/vendor-shiki-lang-sql-H6--iFN-.js","assets/vendor-shiki-lang-toml-aTteTWYL.js","assets/vendor-shiki-lang-tsx-DoKZm6AV.js","assets/vendor-shiki-lang-typescript-B5awnqri.js","assets/vendor-shiki-lang-vue-CnrgQ7Z5.js","assets/vendor-shiki-lang-xml-Bv-TNPJt.js","assets/vendor-shiki-lang-yaml-DpxUxQ6M.js","assets/CodexSessionManagerDialog-CELTkz9T.js","assets/index-8vfFmsVl.js","assets/vendor-router-Dn8q3tJM.js","assets/index-BPfQQtEB.css","assets/vendor-ui-BwEQCho1.js","assets/vendor-markdown-9aQhqbjm.js","assets/vendor-tiptap-rwYdQb1L.js","assets/TaskDiffReviewDialog-VwZmo00b.js","assets/TaskDiffReviewDialog-CeGj0idf.css","assets/WorkbenchSettingsDialog-CThWkZHd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as St,t as We,f as xr,_ as ze,a as br,b as kr,g as Os,s as xa,c as ba}from"./index-8vfFmsVl.js";import{w as $e,ak as It,aD as g,aI as Ce,aG as ue,aJ as Je,aE as x,aK as Qe,aL as Se,aF as i,aM as Jt,u as a,aN as me,aO as _r,aP as os,c as W,aQ as S,aR as et,aS as ut,aT as cn,o as dn,aU as Gt,aV as kn,b as q,n as at,aW as Wt,aX as Xn,aY as jo,r as rs,aC as ka,aZ as an,f as _a,a_ as fo,a$ as $s,G as Ta,al as Ca,b0 as gn,b1 as hn}from"./vendor-misc-u-M8sNMf.js";import{X as Tr,T as Ea,L as Ht,C as ko,a as Is,B as Fo,S as Aa,P as Zn,b as Cr,c as $a,A as Ia,F as Dn,d as Sn,e as Er,f as Pa,E as Da,g as La,h as Uo,i as _o,j as Ps,k as Ba,l as Ma,m as Ra,U as Na,W as Oa,n as Ar,o as ja,p as Ds,q as js,I as $r,r as Fa,s as Ua,t as Va,u as za,G as Ha,v as qa,w as Ka,x as Wa,y as Ga}from"./vendor-ui-BwEQCho1.js";import{M as Ir}from"./vendor-markdown-9aQhqbjm.js";import{n as To,N as Pr,a as Co,i as Xa,V as Xs,b as Vo,u as Ya,c as Ja,E as Qa}from"./vendor-tiptap-rwYdQb1L.js";const Za="shell",ei=new Set(["!","!"]),zo="text";function Ss(e=""){return String(e||"").replace(/\r\n/g,`
|
|
3
3
|
`).trim()}function ti(e=""){const t=String(e||"");return ei.has(t.charAt(0))}function ni(e=""){const t=Ss(e);return t?t.charAt(0)==="!"?`!${t.slice(1)}`:t:""}function si(e={}){const n=(Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks:[]).filter(c=>!!Ss(c==null?void 0:c.content)),o=n.length>0,s=o?n.filter(c=>String((c==null?void 0:c.type)||"").trim()===zo).map(c=>Ss(c==null?void 0:c.content)).filter(Boolean).join(`
|
|
4
4
|
|
|
5
5
|
`).trim():Ss(e==null?void 0:e.prompt);if(!ti(s))return{mode:"",prompt:s,command:"",reason:""};if(o&&n.some(p=>String((p==null?void 0:p.type)||"").trim()!==zo))return{mode:"",prompt:s,command:"",reason:"unsupported_blocks"};const l=ni(s).slice(1).trim();return l?{mode:Za,prompt:s,command:l,reason:""}:{mode:"",prompt:s,command:"",reason:"empty_command"}}const Zt={NONE:"none",LATEST:"latest",ALL:"all"};function oi(e="",t={}){const n=String(e||"").trim().toLowerCase();return n===Zt.ALL?Zt.ALL:n===Zt.LATEST?Zt.LATEST:n===Zt.NONE?Zt.NONE:t.includeEvents?Zt.ALL:t.includeLatestEvents?Zt.LATEST:Zt.NONE}const Vt={SESSION:"session",SESSION_UPDATED:"session.updated",STATUS:"status",STDOUT:"stdout",STDERR:"stderr",AGENT_EVENT:"agent_event",COMPLETED:"completed",STOPPED:"stopped",ERROR:"error"};function Dr(e=""){const t=String(e||"").trim().toLowerCase();return t==="codex"?Vt.AGENT_EVENT:t}const vt={THREAD_STARTED:"thread.started",TURN_STARTED:"turn.started",TURN_COMPLETED:"turn.completed",TURN_FAILED:"turn.failed",ERROR:"error",ITEM_STARTED:"item.started",ITEM_UPDATED:"item.updated",ITEM_COMPLETED:"item.completed"},rt={REASONING:"reasoning",WEB_SEARCH:"web_search",COLLAB_TOOL_CALL:"collab_tool_call",FILE_CHANGE:"file_change",COMMAND_EXECUTION:"command_execution",TODO_LIST:"todo_list",AGENT_MESSAGE:"agent_message"},ri={none:{label:"不过期",hours:null}};Object.entries(ri).map(([e,t])=>({value:e,label:t.label}));const ws={CODEX:"codex",CLAUDE_CODE:"claude-code",OPENCODE:"opencode"},Eo=[{value:ws.CODEX,label:"Codex",enabled:!0},{value:ws.CLAUDE_CODE,label:"Claude Code",enabled:!0},{value:ws.OPENCODE,label:"OpenCode",enabled:!0}],$t={TEXT:"text",IMAGE:"image",IMPORTED_TEXT:"imported_text"},ai=[{value:"local",label:"跟随本机时区"}],ii={SKIP:"skip"},li=[{value:ii.SKIP,label:"已有运行时跳过本次"}],Ys={DINGTALK:"dingtalk",FEISHU:"feishu",WEBHOOK:"webhook"},ui=[{value:Ys.DINGTALK,label:"钉钉 Webhook"},{value:Ys.FEISHU,label:"飞书 Webhook"},{value:Ys.WEBHOOK,label:"通用 Webhook"}],Js={COMPLETED:"completed",SUCCESS:"success",ERROR:"error"},ci=[{value:Js.COMPLETED,label:"本次运行结束后"},{value:Js.SUCCESS,label:"本次运行成功后"},{value:Js.ERROR,label:"本次运行失败后"}],di={SUMMARY:"summary"},fi=[{value:di.SUMMARY,label:"摘要消息"}],Ho={ZH_CN:"zh-CN",EN_US:"en-US"},pi=[{value:Ho.ZH_CN,label:"简体中文"},{value:Ho.EN_US,label:"English"}];function Ls(e){var n;const t=String(e||"").trim().toLowerCase();return((n=Eo.find(o=>o.value===t))==null?void 0:n.value)||ws.CODEX}function ct(e){var t;return((t=Eo.find(n=>n.value===Ls(e)))==null?void 0:t.label)||"Codex"}function fy(e=""){const t=String(e||"").trim();if(!t)return"";const n=/^[a-z]:[\\/]/i.test(t)||t.includes("\\");let o=t.replace(/\\/g,"/");return o.length>1&&!/^[a-z]:\/$/i.test(o)&&(o=o.replace(/\/+$/,"")),n?o.toLowerCase():o}function mi(e=[],t=10){const n=e.find(o=>{var s;return(o.type===$t.TEXT||o.type===$t.IMPORTED_TEXT)&&((s=o.content)==null?void 0:s.trim())});return n?n.content.replace(/\s+/g," ").trim().slice(0,t):""}const gi={class:"min-w-0 flex-1"},hi={key:0,class:"flex items-center gap-2"},vi=["disabled"],Fs={__name:"DialogShell",props:{open:{type:Boolean,default:!1},backdropClass:{type:String,default:""},stackLevel:{type:Number,default:0},panelClass:{type:String,default:""},headerClass:{type:String,default:"px-4 py-4 sm:px-5"},bodyClass:{type:String,default:"min-h-0 flex-1"},showClose:{type:Boolean,default:!0},closeDisabled:{type:Boolean,default:!1},closeOnBackdrop:{type:Boolean,default:!0},closeOnEscape:{type:Boolean,default:!0},lockBodyScroll:{type:Boolean,default:!0}},emits:["close"],setup(e,{emit:t}){const n=e,o=t,s=W(()=>n.backdropClass?n.backdropClass:`${n.stackLevel>=4?"z-[90]":n.stackLevel===3?"z-[75]":n.stackLevel===2?"z-[70]":n.stackLevel===1?"z-[60]":"z-50"} items-end justify-center px-0 py-0 sm:items-center sm:px-4 sm:py-6`);function r(){n.closeDisabled||o("close")}function l(){!n.closeOnBackdrop||n.closeDisabled||o("close")}function c(p){!n.open||!n.closeOnEscape||n.closeDisabled||p.key==="Escape"&&o("close")}return $e(()=>n.open,p=>{if(n.lockBodyScroll&&document.body.classList.toggle("overflow-hidden",p),p&&n.closeOnEscape){window.addEventListener("keydown",c);return}window.removeEventListener("keydown",c)},{immediate:!0}),It(()=>{n.lockBodyScroll&&document.body.classList.remove("overflow-hidden"),window.removeEventListener("keydown",c)}),(p,w)=>(g(),Ce(os,{to:"body"},[ue(_r,{name:"dialog-shell"},{default:Je(()=>[e.open?(g(),x("div",{key:0,class:Se(["theme-modal-backdrop dialog-shell-backdrop fixed inset-0 flex",s.value]),onClick:Qe(l,["self"])},[i("section",{class:Se(["panel dialog-shell-panel flex min-h-0 w-full flex-col overflow-hidden",e.panelClass])},[p.$slots.title||p.$slots.header||p.$slots["header-actions"]||e.showClose?(g(),x("div",{key:0,class:Se(["theme-divider flex items-start justify-between gap-4 border-b",e.headerClass])},[i("div",gi,[Jt(p.$slots,"header",{},()=>[Jt(p.$slots,"title")])]),p.$slots["header-actions"]||e.showClose?(g(),x("div",hi,[Jt(p.$slots,"header-actions"),e.showClose?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-8 w-8 shrink-0",disabled:e.closeDisabled,onClick:r},[ue(a(Tr),{class:"h-4 w-4"})],8,vi)):me("",!0)])):me("",!0)],2)):me("",!0),i("div",{class:Se(e.bodyClass)},[Jt(p.$slots,"default")],2)],2)],2)):me("",!0)]),_:3})]))}},yi={class:"flex items-start gap-3"},Si={class:"theme-heading text-base font-semibold"},wi={key:0,class:"theme-muted-text mt-1 text-sm leading-6"},xi={class:"flex justify-end gap-2 px-5 py-4"},bi=["disabled"],ki=["disabled"],ps={__name:"ConfirmDialog",props:{open:{type:Boolean,default:!1},title:{type:String,default:""},description:{type:String,default:""},confirmText:{type:String,default:""},cancelText:{type:String,default:""},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1}},emits:["cancel","confirm"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.title||s("common.confirm")),l=W(()=>n.confirmText||s("common.confirm")),c=W(()=>n.cancelText||s("common.cancel"));return(p,w)=>(g(),Ce(Fs,{open:e.open,"stack-level":4,"panel-class":"max-w-md","header-class":"px-5 py-4","body-class":"flex flex-col","close-disabled":e.loading,"close-on-backdrop":!e.loading,"close-on-escape":!e.loading,onClose:w[2]||(w[2]=d=>o("cancel"))},{title:Je(()=>[i("div",yi,[i("span",{class:Se(["inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-sm border border-dashed",e.danger?"theme-status-danger":"theme-status-neutral"])},[ue(a(Ea),{class:"h-4 w-4"})],2),i("div",null,[i("h2",Si,S(r.value),1),e.description?(g(),x("p",wi,S(e.description),1)):me("",!0)])])]),default:Je(()=>[i("div",xi,[i("button",{type:"button",class:"tool-button px-4 py-2 text-sm",disabled:e.loading,onClick:w[0]||(w[0]=d=>o("cancel"))},S(c.value),9,bi),i("button",{type:"button",class:Se(["tool-button px-4 py-2 text-sm",e.danger?"tool-button-danger":"tool-button-primary"]),disabled:e.loading,onClick:w[1]||(w[1]=d=>o("confirm"))},S(e.loading?a(s)("common.processing"):l.value),11,ki)])]),_:1},8,["open","close-disabled","close-on-backdrop","close-on-escape"]))}},_i={class:"theme-divider settings-dialog-nav border-b px-3 py-3 sm:w-60 sm:shrink-0 sm:border-b-0 sm:border-r sm:px-4 sm:py-4"},Ti={class:"settings-nav flex gap-2 overflow-x-auto sm:flex-col sm:overflow-visible"},Ci=["onClick"],Ei={class:"min-w-0"},Ai={class:"text-sm font-medium"},$i={class:"theme-muted-text mt-1 hidden text-xs leading-5 sm:block"},Ii={__name:"DialogSideNav",props:{modelValue:{type:String,default:""},sections:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=t;function o(s=""){n("update:modelValue",String(s||""))}return(s,r)=>(g(),x("aside",_i,[i("nav",Ti,[(g(!0),x(et,null,ut(e.sections,l=>(g(),x("button",{key:l.id,type:"button",class:Se(["settings-nav__item flex min-w-0 items-start gap-3 rounded-sm border px-3 py-3 text-left transition sm:w-full",e.modelValue===l.id?"theme-card-selected":"theme-card-idle-muted border-dashed hover:border-[var(--theme-borderStrong)] hover:bg-[var(--theme-appPanelStrong)]"]),onClick:c=>o(l.id)},[(g(),Ce(cn(l.icon),{class:"mt-0.5 h-4 w-4 shrink-0"})),i("div",Ei,[i("div",Ai,S(l.label),1),i("p",$i,S(l.description),1)])],10,Ci))),128))])]))}},Pi=["aria-label","disabled","onKeydown"],Di={class:"min-w-0 flex-1"},Li={class:"theme-muted-text text-sm"},Bi={class:"flex min-h-0 w-full flex-col"},Mi={class:"min-h-0 flex-1 space-y-2 overflow-y-auto p-2"},Ri=["onClick"],Ni={class:"theme-empty-state px-3 py-4 text-sm"},en={__name:"WorkbenchSelect",props:{modelValue:{type:[String,Number],default:""},options:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:""},emptyText:{type:String,default:""},ariaLabel:{type:String,default:""},getOptionValue:{type:Function,default:e=>(e==null?void 0:e.id)??(e==null?void 0:e.value)??""},triggerClass:{type:String,default:""}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(null),l=q(null),c=q(!1),p=q(!1),w=q({}),d=W(()=>{const U=String(n.modelValue??"");return n.options.find(se=>String(n.getOptionValue(se)??"")===U)||null}),m=W(()=>n.placeholder||s("common.select")),f=W(()=>n.emptyText||s("common.noOptions"));function b(U){return U&&typeof U=="object"&&Object.prototype.hasOwnProperty.call(U,"label")?String(U.label||""):String(n.getOptionValue(U)??"")}function v(){n.disabled||(c.value||o("refresh-intent"),c.value=!0)}function P(){c.value=!1}function ne(){if(c.value){P();return}v()}function y(U){o("update:modelValue",String(n.getOptionValue(U)??"").trim()),P()}function L(){if(!c.value||!r.value||typeof window>"u")return;const U=r.value.getBoundingClientRect(),se=window.innerWidth,A=window.innerHeight,G=8,ce=8,pe=160,I=360,Q=Math.max(0,A-U.bottom-ce),le=Math.max(0,U.top-ce);p.value=Q<260&&le>Q;const ie=p.value?le-G:Q-G,ve=Math.max(Math.min(I,Math.max(ie,0)),Math.min(pe,p.value?le:Q)),_=Math.min(U.width,se-ce*2),H=Math.min(Math.max(ce,U.left),Math.max(ce,se-ce-_));w.value={left:`${H}px`,top:p.value?`${U.top-G}px`:`${U.bottom+G}px`,width:`${_}px`,maxHeight:`${Math.max(ve,120)}px`,transform:p.value?"translateY(-100%)":"none"}}function O(U){var se;!c.value||!r.value||r.value.contains(U.target)||(se=l.value)!=null&&se.contains(U.target)||P()}function z(U){U.key==="Escape"&&P()}return $e(()=>n.disabled,U=>{U&&P()}),$e(c,async U=>{U&&(await at(),L())}),dn(()=>{document.addEventListener("pointerdown",O),document.addEventListener("keydown",z),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0)}),It(()=>{document.removeEventListener("pointerdown",O),document.removeEventListener("keydown",z),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}),(U,se)=>(g(),x("div",{ref_key:"rootRef",ref:r,class:"relative min-w-0"},[i("button",{type:"button",class:Se(["workbench-select-trigger flex w-full items-center gap-3 rounded-sm border px-3 py-2 text-left transition focus:outline-none focus:ring-2",[n.triggerClass,e.disabled?"cursor-not-allowed border-[color-mix(in_srgb,var(--theme-borderDefault)_88%,var(--theme-textMuted))] bg-[color-mix(in_srgb,var(--theme-appPanelMuted)_82%,var(--theme-appBg))] text-[var(--theme-textMuted)]":"theme-input-shell text-[var(--theme-textPrimary)] hover:border-[var(--theme-borderStrong)] focus:border-[var(--theme-borderStrong)] focus:ring-[var(--theme-focusRing)]"]]),"aria-label":n.ariaLabel||void 0,disabled:e.disabled,onClick:ne,onKeydown:[Gt(Qe(v,["prevent"]),["down"]),Gt(Qe(ne,["prevent"]),["enter"]),Gt(Qe(ne,["prevent"]),["space"])]},[i("div",Di,[Jt(U.$slots,"trigger",{selectedOption:d.value,open:c.value,loading:e.loading,disabled:e.disabled},()=>[i("div",Li,S(d.value?b(d.value):m.value),1)])]),i("div",{class:Se(["flex shrink-0 items-center gap-2",e.disabled?"text-[var(--theme-textMuted)] opacity-80":"theme-muted-text"])},[e.loading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):me("",!0),ue(a(ko),{class:Se(["h-4 w-4 transition",c.value?"rotate-180":""])},null,8,["class"])],2)],42,Pi),(g(),Ce(os,{to:"body"},[c.value?(g(),x("div",{key:0,ref_key:"panelRef",ref:l,class:"workbench-select-panel theme-popover fixed z-[90] flex overflow-hidden rounded-sm border",style:kn(w.value)},[i("div",Bi,[Jt(U.$slots,"header",{loading:e.loading,options:e.options}),i("div",Mi,[e.options.length?(g(!0),x(et,{key:0},ut(e.options,A=>Jt(U.$slots,"option",{key:String(e.getOptionValue(A)??""),option:A,selected:String(e.getOptionValue(A)??"")===String(e.modelValue??""),select:()=>y(A)},()=>[i("button",{type:"button",class:"workbench-select-option theme-filter-idle w-full rounded-sm border border-dashed px-3 py-2 text-left text-sm",onClick:G=>y(A)},S(b(A)),9,Ri)])),128)):Jt(U.$slots,"empty",{key:1},()=>[i("div",Ni,S(f.value),1)])])])],4)):me("",!0)]))],512))}},qo={},Lr=typeof import.meta<"u"&&qo?qo:{};function Oi(){if(typeof window>"u")return"http://localhost:3000";const e=new URL(window.location.origin),t=String(Lr.VITE_API_PORT||"").trim();if(t)return e.port=t,e.toString().replace(/\/$/,"");const n=String(e.port||"");return new Set(["4173","5173","5174"]).has(n)?(e.port="3000",e.toString().replace(/\/$/,"")):e.toString().replace(/\/$/,"")}const Ao=(Lr.VITE_API_BASE_URL||Oi()).replace(/\/$/,"");function $o(e={},t="errors.requestFailed"){const n=String((e==null?void 0:e.messageKey)||"").trim();if(n){const o=We(n);if(o&&o!==n)return o}return(e==null?void 0:e.message)||We(t)}async function Ze(e,t={}){const n=typeof t.body<"u"&&!(t.body instanceof FormData),o=await fetch(`${Ao}${e}`,{headers:{...n?{"Content-Type":"application/json"}:{},...t.headers||{}},...t});if(!o.ok){const r=await o.json().catch(()=>({}));throw new Error($o(r))}return o.status===204?null:(o.headers.get("content-type")||"").includes("application/json")?o.json():o.text()}function Io(){return Ao}function xs(e){return e?e.startsWith("http")?e:`${Ao}${e}`:""}function py(){return Ze("/api/meta",{cache:"no-store"})}function ji(){return Ze("/api/tasks")}function Fi(e=30){const t=new URLSearchParams,n=Math.max(1,Number(e)||30);return t.set("limit",String(n)),Ze(`/api/tasks/workspace-diff-summaries?${t.toString()}`,{cache:"no-store"})}function Ui(e){return Ze("/api/tasks",{method:"POST",body:JSON.stringify(e)})}function Vi(e=[]){return Ze("/api/tasks/reorder",{method:"POST",body:JSON.stringify({slugs:e})})}function Br(e){return Ze(`/api/tasks/${e}`)}function Mr(e,t){return Ze(`/api/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)})}function zi(e){return Ze(`/api/tasks/${e}`,{method:"DELETE"})}const Rr=Io();async function Hi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/uploads`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.uploadFailed"))}return n.json()}async function qi(e){const t=new FormData;t.append("file",e);const n=await fetch(`${Rr}/api/imports/pdf`,{method:"POST",body:t});if(!n.ok){const o=await n.json().catch(()=>({}));throw new Error($o(o,"errors.pdfImportFailed"))}return n.json()}function Ki(){return Ze("/api/codex/sessions")}function Wi(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim();n&&t.set("engine",n);const o=t.toString();return Ze(`/api/codex/workspaces${o?`?${o}`:""}`)}function my(e={}){const t=new URLSearchParams,n=String(e.engine||"").trim(),o=String(e.cwd||"").trim(),s=Number(e.limit||0);n&&t.set("engine",n),o&&t.set("cwd",o),Number.isFinite(s)&&s>0&&t.set("limit",String(s));const r=t.toString();return Ze(`/api/codex/session-candidates${r?`?${r}`:""}`,{cache:"no-store",signal:e.signal})}function gy(e={}){const t=new URLSearchParams,n=String(e.path||"").trim(),o=Number(e.limit||0);n&&t.set("path",n),Number.isFinite(o)&&o>0&&t.set("limit",String(o));const s=t.toString();return Ze(`/api/codex/directories/tree${s?`?${s}`:""}`,{cache:"no-store",signal:e.signal})}function hy(e,t={}){const n=new URLSearchParams,o=String(e||"").trim(),s=String(t.path||"").trim(),r=Number(t.limit||0);o&&n.set("q",o),s&&n.set("path",s),Number.isFinite(r)&&r>0&&n.set("limit",String(r));const l=n.toString();return Ze(`/api/codex/directories/search${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function Gi(e){return Ze("/api/codex/sessions",{method:"POST",body:JSON.stringify(e)})}function Xi(e,t){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t)})}function Yi(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}`,{method:"DELETE"})}function Ji(e){return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/reset`,{method:"POST"})}function Qi(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=String(t.refreshToken||"").trim();o&&n.set("path",o),s&&n.set("_",s);const r=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/tree${r?`?${r}`:""}`,{cache:"no-store",signal:t.signal})}function Zi(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||60),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function el(e,t={}){const n=new URLSearchParams,o=String(t.path||"").trim(),s=Number(t.limit||0),r=String(t.refreshToken||"").trim();o&&n.set("path",o),Number.isFinite(s)&&s>0&&n.set("limit",String(s)),r&&n.set("_",r);const l=n.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content${l?`?${l}`:""}`,{cache:"no-store",signal:t.signal})}function tl(e,t,n={}){const o=new URLSearchParams,s=String(t||"").trim(),r=Number(n.limit||80),l=String(n.refreshToken||"").trim();s&&o.set("q",s),Number.isFinite(r)&&r>0&&o.set("limit",String(r)),l&&o.set("_",l);const c=o.toString();return Ze(`/api/codex/sessions/${encodeURIComponent(e)}/files/content-search${c?`?${c}`:""}`,{cache:"no-store",signal:n.signal})}function nl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-session`,{method:"POST",body:JSON.stringify({sessionId:t})})}function sl(e,t={}){const n=new URLSearchParams,o=Number(t.limit||20),s=oi(t.events,t);Number.isFinite(o)&&o>0&&n.set("limit",String(o)),n.set("events",s);const r=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs${r?`?${r}`:""}`,{cache:"no-store"})}function ol(e,t={}){const n=new URLSearchParams,o=Math.max(0,Number(t.afterSeq)||0),s=Math.max(1,Number(t.limit)||5e3);o>0&&n.set("afterSeq",String(o)),s>0&&n.set("limit",String(s));const r=n.toString();return Ze(`/api/codex/runs/${encodeURIComponent(e)}/events${r?`?${r}`:""}`,{cache:"no-store"})}function vy(e,t={}){const n=new URLSearchParams,o=String(t.scope||"workspace").trim(),s=String(t.runId||"").trim(),r=String(t.filePath||"").trim(),l=t.includeFiles!==!1,c=t.includeStats!==!1;o==="run"?n.set("scope","run"):o==="task"?n.set("scope","task"):n.set("scope","workspace"),s&&n.set("runId",s),r&&n.set("filePath",r),l||n.set("includeFiles","false"),c||n.set("includeStats","false");const p=n.toString();return Ze(`/api/tasks/${encodeURIComponent(e)}/git-diff${p?`?${p}`:""}`,{cache:"no-store"})}function rl(e,t){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"POST",body:JSON.stringify(t)})}function al(e){return Ze(`/api/tasks/${encodeURIComponent(e)}/codex-runs`,{method:"DELETE"})}function il(e){return Ze(`/api/codex/runs/${encodeURIComponent(e)}/stop`,{method:"POST"})}const ll={class:"theme-heading inline-flex items-center gap-2 text-sm font-medium"},ul={class:"theme-muted-text mt-1 text-xs"},cl={class:"min-h-0 flex flex-1 flex-col overflow-hidden sm:flex-row"},dl={class:"settings-dialog-content min-h-0 flex-1 overflow-y-auto px-5 py-5"},fl={key:0,class:"theme-muted-text flex items-center gap-2 py-4 text-sm"},pl={key:1,class:"space-y-4"},ml={key:0,class:"space-y-4"},gl={class:"theme-heading text-base font-medium"},hl={class:"theme-muted-text mt-1 text-xs leading-5"},vl={class:"settings-section-card px-4 py-4"},yl={class:"block space-y-1.5"},Sl={class:"theme-muted-text text-xs"},wl=["placeholder"],xl={key:1,class:"space-y-4"},bl={class:"flex items-start justify-between gap-3"},kl={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},_l={class:"theme-muted-text mt-1 text-xs leading-5"},Tl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Cl={class:"settings-section-card px-4 py-4"},El={class:"grid gap-4 sm:grid-cols-2"},Al={class:"space-y-1.5 sm:col-span-2"},$l={class:"theme-muted-text text-xs"},Il={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Pl={class:"space-y-1.5"},Dl={class:"theme-muted-text text-xs"},Ll=["disabled"],Bl={key:0,class:"space-y-1.5"},Ml={class:"theme-muted-text text-xs"},Rl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Nl={class:"space-y-1.5"},Ol={class:"theme-muted-text text-xs"},jl={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Fl={class:"theme-muted-text text-xs"},Ul={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Vl={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},zl={key:2,class:"space-y-4"},Hl={class:"flex items-start justify-between gap-3"},ql={class:"theme-heading inline-flex items-center gap-2 text-base font-medium"},Kl={class:"theme-muted-text mt-1 text-xs leading-5"},Wl={class:"inline-flex items-center gap-2 text-sm text-[var(--theme-textPrimary)]"},Gl={class:"settings-section-card px-4 py-4"},Xl={class:"grid gap-4 sm:grid-cols-2"},Yl={class:"space-y-1.5"},Jl={class:"theme-muted-text text-xs"},Ql={class:"truncate text-sm text-[var(--theme-textPrimary)]"},Zl={class:"space-y-1.5"},eu={class:"theme-muted-text text-xs"},tu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},nu={class:"space-y-1.5 sm:col-span-2"},su={class:"theme-muted-text text-xs"},ou=["placeholder","disabled"],ru={class:"space-y-1.5"},au={class:"theme-muted-text text-xs"},iu=["placeholder","disabled"],lu={class:"space-y-1.5"},uu={class:"theme-muted-text text-xs"},cu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},du={class:"space-y-1.5"},fu={class:"theme-muted-text text-xs"},pu={class:"truncate text-sm text-[var(--theme-textPrimary)]"},mu={class:"theme-muted-text mt-3 space-y-1 text-xs leading-6"},gu={key:0,class:"theme-danger-text"},hu={key:3,class:"theme-danger-text text-sm"},vu={class:"theme-divider flex flex-col gap-3 border-t px-5 py-4 sm:flex-row sm:items-center sm:justify-between"},yu={class:"theme-muted-text theme-note-text"},Su={class:"flex items-center justify-end gap-2"},wu=["disabled"],xu=["disabled"],bu="0 9 * * 1-5",Qs="weekdays",Wn="09:00",An="1",ku={__name:"EditTaskDialog",props:{open:{type:Boolean,default:!1},taskSlug:{type:String,default:""},taskTitle:{type:String,default:""}},emits:["close","saved"],setup(e,{emit:t}){const n=e,o=t,{locale:s,t:r}=St(),l=q(!1),c=q(!1),p=q(""),w=q("basic"),d=rs({title:"",automationEnabled:!1,automationMode:Qs,automationTime:Wn,automationWeekday:An,automationTimezone:"local",automationConcurrencyPolicy:"skip",automationLastTriggeredAt:"",automationNextTriggerAt:"",notificationEnabled:!1,notificationChannelType:"dingtalk",notificationWebhookUrl:"",notificationSecret:"",notificationTriggerOn:"completed",notificationLocale:"zh-CN",notificationMessageMode:"summary",notificationLastStatus:"",notificationLastError:"",notificationLastSentAt:""}),m=W(()=>String(n.taskTitle||"").trim()||r("workbench.untitledTask")),f=W(()=>[{id:"basic",label:r("taskDialog.sections.basic.label"),description:r("taskDialog.sections.basic.description"),icon:Zn},{id:"automation",label:r("taskDialog.sections.automation.label"),description:r("taskDialog.sections.automation.description"),icon:Is},{id:"notification",label:r("taskDialog.sections.notification.label"),description:r("taskDialog.sections.notification.description"),icon:Fo}]),b=W(()=>[{value:"daily",label:r("taskDialog.sections.automation.modeDaily")},{value:"weekdays",label:r("taskDialog.sections.automation.modeWeekdays")},{value:"weekly",label:r("taskDialog.sections.automation.modeWeekly")}]),v=W(()=>[{value:"1",label:r("taskDialog.sections.automation.weekday1")},{value:"2",label:r("taskDialog.sections.automation.weekday2")},{value:"3",label:r("taskDialog.sections.automation.weekday3")},{value:"4",label:r("taskDialog.sections.automation.weekday4")},{value:"5",label:r("taskDialog.sections.automation.weekday5")},{value:"6",label:r("taskDialog.sections.automation.weekday6")},{value:"0",label:r("taskDialog.sections.automation.weekday0")}]),P=W(()=>ai.map(_=>({..._,label:_.value==="local"?r("taskDialog.sections.automation.timezoneLocal"):_.label}))),ne=W(()=>li.map(_=>({..._,label:_.value==="skip"?r("taskDialog.sections.automation.concurrencySkip"):_.label}))),y=W(()=>ui.map(_=>({..._,label:_.value==="dingtalk"?r("taskDialog.sections.notification.channelDingtalk"):_.value==="feishu"?r("taskDialog.sections.notification.channelFeishu"):_.value==="webhook"?r("taskDialog.sections.notification.channelWebhook"):_.label}))),L=W(()=>ci.map(_=>({..._,label:_.value==="completed"?r("taskDialog.sections.notification.triggerCompleted"):_.value==="success"?r("taskDialog.sections.notification.triggerSuccess"):_.value==="error"?r("taskDialog.sections.notification.triggerError"):_.label}))),O=W(()=>fi.map(_=>({..._,label:_.value==="summary"?r("taskDialog.sections.notification.messageSummary"):_.label}))),z=W(()=>pi.map(_=>({..._,label:_.value==="zh-CN"?r("taskDialog.sections.notification.localeZhCn"):_.value==="en-US"?r("taskDialog.sections.notification.localeEnUs"):_.label}))),U=W(()=>d.notificationEnabled?d.notificationLastStatus==="success"?r("taskDialog.sections.notification.statusSuccess"):d.notificationLastStatus==="error"?r("taskDialog.sections.notification.statusError"):r("taskDialog.sections.notification.statusPending"):r("taskDialog.sections.notification.statusDisabled"));function se(){d.title="",d.automationEnabled=!1,d.automationMode=Qs,d.automationTime=Wn,d.automationWeekday=An,d.automationTimezone="local",d.automationConcurrencyPolicy="skip",d.automationLastTriggeredAt="",d.automationNextTriggerAt="",d.notificationEnabled=!1,d.notificationChannelType="dingtalk",d.notificationWebhookUrl="",d.notificationSecret="",d.notificationTriggerOn="completed",d.notificationLocale=String(s.value||"zh-CN"),d.notificationMessageMode="summary",d.notificationLastStatus="",d.notificationLastError="",d.notificationLastSentAt=""}function A(_=0){return String(_).padStart(2,"0")}function G(_=""){const H=String(_||"").trim().replace(/\s+/g," ");let F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* 1-5$/);return F?{mode:"weekdays",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* \*$/),F?{mode:"daily",time:`${A(F[2])}:${A(F[1])}`,weekday:An}:(F=H.match(/^(\d{1,2}) (\d{1,2}) \* \* ([0-6])$/),F?{mode:"weekly",time:`${A(F[2])}:${A(F[1])}`,weekday:String(F[3])}:{mode:Qs,time:Wn,weekday:An}))}function ce(_=""){const F=String(_||"").trim().match(/^(\d{1,2}):(\d{2})$/);if(!F)return Wn;const He=Number(F[1]),De=Number(F[2]);return!Number.isInteger(He)||!Number.isInteger(De)||He<0||He>23||De<0||De>59?Wn:`${A(He)}:${A(De)}`}function pe(){var Fe;const _=ce(d.automationTime),[H,F]=_.split(":"),He=Number(H),De=Number(F);if(d.automationMode==="daily")return`${De} ${He} * * *`;if(d.automationMode==="weekly"){const je=((Fe=v.value.find(Ke=>Ke.value===String(d.automationWeekday||"")))==null?void 0:Fe.value)||An;return`${De} ${He} * * ${je}`}return`${De} ${He} * * 1-5`}function I(_={}){var F,He,De,Fe,je,Ke,tt,xe,R,J,fe,_e,ge,Ie,Ae,Be;d.title=String(_.title||""),d.automationEnabled=!!((F=_.automation)!=null&&F.enabled);const H=G(((He=_.automation)==null?void 0:He.cron)||bu);d.automationMode=H.mode,d.automationTime=H.time,d.automationWeekday=H.weekday,d.automationTimezone=String(((De=_.automation)==null?void 0:De.timezone)||"local"),d.automationConcurrencyPolicy=String(((Fe=_.automation)==null?void 0:Fe.concurrencyPolicy)||"skip"),d.automationLastTriggeredAt=String(((je=_.automation)==null?void 0:je.lastTriggeredAt)||""),d.automationNextTriggerAt=String(((Ke=_.automation)==null?void 0:Ke.nextTriggerAt)||""),d.notificationEnabled=!!((tt=_.notification)!=null&&tt.enabled),d.notificationChannelType=String(((xe=_.notification)==null?void 0:xe.channelType)||"dingtalk"),d.notificationWebhookUrl=String(((R=_.notification)==null?void 0:R.webhookUrl)||""),d.notificationSecret=String(((J=_.notification)==null?void 0:J.secret)||""),d.notificationTriggerOn=String(((fe=_.notification)==null?void 0:fe.triggerOn)||"completed"),d.notificationLocale=String(((_e=_.notification)==null?void 0:_e.locale)||s.value||"zh-CN"),d.notificationMessageMode=String(((ge=_.notification)==null?void 0:ge.messageMode)||"summary"),d.notificationLastStatus=String(((Ie=_.notification)==null?void 0:Ie.lastStatus)||""),d.notificationLastError=String(((Ae=_.notification)==null?void 0:Ae.lastError)||""),d.notificationLastSentAt=String(((Be=_.notification)==null?void 0:Be.lastSentAt)||"")}async function Q(){const _=String(n.taskSlug||"").trim();if(!_){se();return}l.value=!0,p.value="";try{const H=await Br(_);I(H)}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.loadFailed")}finally{l.value=!1}}function le(){return{title:d.title,automation:{enabled:d.automationEnabled,cron:pe(),timezone:d.automationTimezone,concurrencyPolicy:d.automationConcurrencyPolicy},notification:{enabled:d.notificationEnabled,channelType:d.notificationChannelType,webhookUrl:d.notificationWebhookUrl,secret:d.notificationSecret,triggerOn:d.notificationTriggerOn,locale:d.notificationLocale,messageMode:d.notificationMessageMode}}}async function ie(){const _=String(n.taskSlug||"").trim();if(!(!_||l.value||c.value)){c.value=!0,p.value="";try{const H=await Mr(_,le());I(H),o("saved",H),o("close")}catch(H){p.value=(H==null?void 0:H.message)||r("taskDialog.saveFailed")}finally{c.value=!1}}}function ve(_=""){if(!_)return r("common.notAvailable");const H=new Date(_);return Number.isNaN(H.getTime())?r("common.notAvailable"):xr(H.toISOString(),{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return $e(()=>n.open,_=>{if(_){w.value="basic",Q();return}},{immediate:!0}),$e(()=>n.taskSlug,()=>{n.open&&Q()}),(_,H)=>(g(),Ce(Fs,{open:e.open,"stack-level":3,"panel-class":"settings-dialog-panel h-full max-w-5xl sm:h-[42rem] sm:max-h-[88vh]","header-class":"settings-dialog-header px-5 py-4","body-class":"settings-dialog-body min-h-0 flex flex-1 flex-col overflow-hidden",onClose:H[16]||(H[16]=F=>o("close"))},{title:Je(()=>[i("div",null,[i("div",ll,[ue(a(Zn),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.title")),1)]),i("p",ul,S(a(r)("taskDialog.currentTask",{title:m.value})),1)])]),default:Je(()=>[i("div",cl,[ue(Ii,{modelValue:w.value,"onUpdate:modelValue":H[0]||(H[0]=F=>w.value=F),sections:f.value},null,8,["modelValue","sections"]),i("div",dl,[l.value?(g(),x("div",fl,[ue(a(Ht),{class:"h-4 w-4 animate-spin"}),i("span",null,S(a(r)("taskDialog.loading")),1)])):(g(),x("div",pl,[w.value==="basic"?(g(),x("section",ml,[i("div",null,[i("div",gl,S(a(r)("taskDialog.sections.basic.title")),1),i("p",hl,S(a(r)("taskDialog.sections.basic.intro")),1)]),i("section",vl,[i("label",yl,[i("span",Sl,S(a(r)("taskDialog.sections.basic.taskTitle")),1),Wt(i("input",{"onUpdate:modelValue":H[1]||(H[1]=F=>d.title=F),type:"text",maxlength:"140",class:"tool-input",placeholder:a(r)("taskDialog.sections.basic.taskTitlePlaceholder")},null,8,wl),[[Xn,d.title]])])])])):w.value==="automation"?(g(),x("section",xl,[i("div",bl,[i("div",null,[i("div",kl,[ue(a(Is),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.sections.automation.title")),1)]),i("p",_l,S(a(r)("taskDialog.sections.automation.intro")),1)]),i("label",Tl,[Wt(i("input",{"onUpdate:modelValue":H[2]||(H[2]=F=>d.automationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.automationEnabled]]),i("span",null,S(a(r)("taskDialog.enabled")),1)])]),i("section",Cl,[i("div",El,[i("label",Al,[i("span",$l,S(a(r)("taskDialog.sections.automation.mode")),1),ue(en,{modelValue:d.automationMode,"onUpdate:modelValue":H[3]||(H[3]=F=>d.automationMode=F),options:b.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Il,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Pl,[i("span",Dl,S(a(r)("taskDialog.sections.automation.time")),1),Wt(i("input",{"onUpdate:modelValue":H[4]||(H[4]=F=>d.automationTime=F),type:"time",class:"tool-input",disabled:!d.automationEnabled},null,8,Ll),[[Xn,d.automationTime]])]),d.automationMode==="weekly"?(g(),x("label",Bl,[i("span",Ml,S(a(r)("taskDialog.sections.automation.weekday")),1),ue(en,{modelValue:d.automationWeekday,"onUpdate:modelValue":H[5]||(H[5]=F=>d.automationWeekday=F),options:v.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Rl,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])):me("",!0),i("label",Nl,[i("span",Ol,S(a(r)("taskDialog.sections.automation.timezone")),1),ue(en,{modelValue:d.automationTimezone,"onUpdate:modelValue":H[6]||(H[6]=F=>d.automationTimezone=F),options:P.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",jl,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",{class:Se(["space-y-1.5",d.automationMode==="weekly"?"":"sm:col-span-2"])},[i("span",Fl,S(a(r)("taskDialog.sections.automation.concurrencyPolicy")),1),ue(en,{modelValue:d.automationConcurrencyPolicy,"onUpdate:modelValue":H[7]||(H[7]=F=>d.automationConcurrencyPolicy=F),options:ne.value,disabled:!d.automationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ul,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])],2)]),i("div",Vl,[i("p",null,S(a(r)("taskDialog.sections.automation.lastTriggered",{value:ve(d.automationLastTriggeredAt)})),1),i("p",null,S(a(r)("taskDialog.sections.automation.nextTriggered",{value:ve(d.automationNextTriggerAt)})),1)])])])):(g(),x("section",zl,[i("div",Hl,[i("div",null,[i("div",ql,[ue(a(Fo),{class:"h-4 w-4"}),i("span",null,S(a(r)("taskDialog.sections.notification.title")),1)]),i("p",Kl,S(a(r)("taskDialog.sections.notification.intro")),1)]),i("label",Wl,[Wt(i("input",{"onUpdate:modelValue":H[8]||(H[8]=F=>d.notificationEnabled=F),type:"checkbox",class:"h-4 w-4"},null,512),[[jo,d.notificationEnabled]]),i("span",null,S(a(r)("taskDialog.enabled")),1)])]),i("section",Gl,[i("div",Xl,[i("label",Yl,[i("span",Jl,S(a(r)("taskDialog.sections.notification.channelType")),1),ue(en,{modelValue:d.notificationChannelType,"onUpdate:modelValue":H[9]||(H[9]=F=>d.notificationChannelType=F),options:y.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",Ql,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",Zl,[i("span",eu,S(a(r)("taskDialog.sections.notification.triggerOn")),1),ue(en,{modelValue:d.notificationTriggerOn,"onUpdate:modelValue":H[10]||(H[10]=F=>d.notificationTriggerOn=F),options:L.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",tu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",nu,[i("span",su,S(a(r)("taskDialog.sections.notification.webhookUrl")),1),Wt(i("input",{"onUpdate:modelValue":H[11]||(H[11]=F=>d.notificationWebhookUrl=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.webhookUrlPlaceholder"),disabled:!d.notificationEnabled},null,8,ou),[[Xn,d.notificationWebhookUrl]])]),i("label",ru,[i("span",au,S(a(r)("taskDialog.sections.notification.secret")),1),Wt(i("input",{"onUpdate:modelValue":H[12]||(H[12]=F=>d.notificationSecret=F),type:"text",class:"tool-input",placeholder:a(r)("taskDialog.sections.notification.secretPlaceholder"),disabled:!d.notificationEnabled},null,8,iu),[[Xn,d.notificationSecret]])]),i("label",lu,[i("span",uu,S(a(r)("taskDialog.sections.notification.locale")),1),ue(en,{modelValue:d.notificationLocale,"onUpdate:modelValue":H[13]||(H[13]=F=>d.notificationLocale=F),options:z.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",cu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])]),i("label",du,[i("span",fu,S(a(r)("taskDialog.sections.notification.messageMode")),1),ue(en,{modelValue:d.notificationMessageMode,"onUpdate:modelValue":H[14]||(H[14]=F=>d.notificationMessageMode=F),options:O.value,disabled:!d.notificationEnabled,"get-option-value":F=>F.value},{trigger:Je(({selectedOption:F})=>[i("div",pu,S((F==null?void 0:F.label)||a(r)("common.select")),1)]),_:1},8,["modelValue","options","disabled","get-option-value"])])]),i("div",mu,[i("p",null,S(a(r)("taskDialog.sections.notification.status",{value:U.value})),1),i("p",null,S(a(r)("taskDialog.sections.notification.lastSent",{value:ve(d.notificationLastSentAt)})),1),d.notificationLastError?(g(),x("p",gu,S(a(r)("taskDialog.sections.notification.lastError",{value:d.notificationLastError})),1)):me("",!0)])])])),p.value?(g(),x("p",hu,S(p.value),1)):me("",!0)]))])]),i("div",vu,[i("p",yu,S(a(r)("taskDialog.footerHint")),1),i("div",Su,[i("button",{type:"button",class:"tool-button px-3 py-2 text-sm",disabled:c.value,onClick:H[15]||(H[15]=F=>o("close"))},S(a(r)("common.cancel")),9,wu),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex items-center gap-2 px-3 py-2 text-sm",disabled:c.value||l.value,onClick:ie},[c.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Aa),{key:1,class:"h-4 w-4"})),i("span",null,S(c.value?a(r)("common.saving"):a(r)("taskDialog.saveTaskConfig")),1)],8,xu)])])]),_:1},8,["open"]))}};function _u(e=[]){return(Array.isArray(e)&&e.length?e:Eo).filter(n=>n&&typeof n=="object").map(n=>{const o=Ls(n.value);return{...n,value:o,label:String(n.label||ct(o)).trim()||ct(o),enabled:n.enabled!==!1,available:n.available!==!1}})}function Tu(e=[]){return _u(e).filter(t=>t.enabled&&t.available)}async function yy(){const e=await Ze("/api/meta",{cache:"no-store"});return Tu(e==null?void 0:e.agentEngineOptions)}function Nr(e={},t={}){const{defaultLabel:n="默认",prefix:o=""}=t,s=ct(e==null?void 0:e.engine),r=`${String(o||"")}${s}`;return e!=null&&e.isDefault?`${r} · ${n}`:r}const Cu={key:0,class:"flex items-center gap-2 text-sm"},Eu={class:"min-w-0 flex-1 truncate"},Au={class:"theme-muted-text ml-2 hidden font-mono text-[11px] sm:inline"},$u={class:"theme-status-neutral hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex"},Iu={key:1,class:"theme-muted-text text-sm"},Pu={class:"theme-divider theme-muted-text flex items-center justify-between gap-3 border-b border-dashed px-3 py-2 text-[11px]"},Du=["onClick"],Lu={class:"flex items-center gap-3"},Bu={class:"min-w-0 flex-1"},Mu={class:"flex items-center gap-2 text-sm sm:hidden"},Ru={class:"min-w-0 flex-1 truncate font-medium text-[var(--theme-textPrimary)]"},Nu={class:"hidden items-center gap-2 text-sm sm:flex"},Ou={class:"min-w-0 flex-1 truncate"},ju={class:"font-medium text-[var(--theme-textPrimary)]"},Fu={class:"theme-muted-text ml-2 font-mono text-[11px]"},Uu={class:"theme-status-neutral inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]"},Vu={__name:"CodexSessionSelect",props:{modelValue:{type:String,default:""},sessions:{type:Array,default:()=>[]},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","refresh-intent"],setup(e,{emit:t}){const n=t,{t:o}=St();function s(d){return(d==null?void 0:d.title)||o("projectManager.untitledProject")}function r(d){return(d==null?void 0:d.cwd)||o("projectManager.notSet")}function l(d){return d!=null&&d.running?o("projectManager.running"):o("projectManager.idle")}function c(d){return d!=null&&d.running?"theme-status-warning":"theme-status-success"}function p(d){var f;const m=Math.max(0,Number((f=d==null?void 0:d.agentBindings)==null?void 0:f.length)||0);return m>1?o("projectManager.agentCount",{count:m}):ct(d==null?void 0:d.engine)}function w(d){return d?"theme-filter-active":"theme-filter-idle"}return(d,m)=>(g(),Ce(en,{"model-value":e.modelValue,options:e.sessions,loading:e.loading,disabled:e.disabled,"trigger-class":"h-9",placeholder:a(o)("projectManager.selectProject"),"empty-text":a(o)("projectManager.noProjectsInSelect"),"get-option-value":f=>(f==null?void 0:f.id)||"","onUpdate:modelValue":m[0]||(m[0]=f=>n("update:modelValue",f)),onRefreshIntent:m[1]||(m[1]=f=>n("refresh-intent"))},{trigger:Je(({selectedOption:f,disabled:b})=>[f?(g(),x("div",Cu,[i("span",Eu,[i("span",{class:Se(["font-medium",b?"theme-muted-text":"text-[var(--theme-textPrimary)]"])},S(s(f)),3),i("span",Au,S(r(f)),1)]),i("span",$u,S(p(f)),1),i("span",{class:Se(["hidden items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px] sm:inline-flex",c(f)])},S(l(f)),3)])):(g(),x("div",Iu,S(e.loading?a(o)("projectManager.syncingProjects"):a(o)("projectManager.selectProject")),1))]),header:Je(()=>[i("div",Pu,[i("span",null,S(e.loading?a(o)("projectManager.syncingLatestProjects"):a(o)("projectManager.projectCount",{count:e.sessions.length})),1),e.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):me("",!0)])]),option:Je(({option:f,selected:b,select:v})=>[i("button",{type:"button",class:Se(["w-full rounded-sm border border-dashed p-3 text-left transition",w(b)]),onClick:v},[i("div",Lu,[i("div",Bu,[i("div",Mu,[i("span",Ru,S(s(f)),1)]),i("div",Nu,[i("span",Ou,[i("span",ju,S(s(f)),1),i("span",Fu,S(r(f)),1)]),i("span",Uu,S(p(f)),1),i("span",{class:Se(["inline-flex items-center rounded-sm border border-dashed px-1.5 py-0.5 text-[10px]",c(f)])},S(l(f)),3)])]),b?(g(),Ce(a(Cr),{key:0,class:"h-4 w-4 shrink-0 text-[var(--theme-textSecondary)]"})):me("",!0)])],10,Du)]),_:1},8,["model-value","options","loading","disabled","placeholder","empty-text","get-option-value"]))}},zu=["disabled"],Hu=["disabled"],qu=["src","alt"],Or={__name:"ImagePreviewOverlay",props:{modelValue:{type:String,default:""},images:{type:Array,default:()=>[]}},emits:["update:modelValue"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=q(1),l=W(()=>n.images.map(y=>String(y||"").trim()).filter(Boolean)),c=W(()=>l.value.findIndex(y=>y===n.modelValue)),p=W(()=>c.value>=0?l.value[c.value]:"");function w(){o("update:modelValue",""),r.value=1}function d(y){o("update:modelValue",String(y||"").trim()),r.value=1}function m(){c.value<=0||d(l.value[c.value-1])}function f(){c.value<0||c.value>=l.value.length-1||d(l.value[c.value+1])}function b(y){const L=Math.min(3,Math.max(.5,r.value+y));r.value=Math.round(L*100)/100}function v(){r.value=1}function P(y){p.value&&(y.preventDefault(),b(y.deltaY<0?.1:-.1))}function ne(y){if(p.value){if(y.key==="Escape"){y.preventDefault(),w();return}if(y.key==="ArrowLeft"){y.preventDefault(),m();return}if(y.key==="ArrowRight"){y.preventDefault(),f();return}if(y.key==="+"||y.key==="="){y.preventDefault(),b(.1);return}if(y.key==="-"){y.preventDefault(),b(-.1);return}y.key==="0"&&(y.preventDefault(),v())}}return $e(()=>n.modelValue,y=>{y||(r.value=1)}),$e(l,y=>{if(n.modelValue){if(!y.length){w();return}if(!y.includes(n.modelValue)){const L=Math.min(c.value,y.length-1);d(y[L]||y[0])}}},{immediate:!0}),dn(()=>{window.addEventListener("keydown",ne)}),It(()=>{window.removeEventListener("keydown",ne)}),(y,L)=>(g(),Ce(os,{to:"body"},[p.value?(g(),x("div",{key:0,class:"theme-modal-backdrop image-preview-overlay fixed inset-0 z-50 flex items-center justify-center p-6",onClick:w,onWheel:P},[i("div",{class:"absolute left-4 top-4 flex items-center gap-2",onClick:L[2]||(L[2]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[0]||(L[0]=O=>b(-.1))},S(a(s)("imagePreview.zoomOut")),1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:v},S(Math.round(r.value*100))+"% ",1),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:L[1]||(L[1]=O=>b(.1))},S(a(s)("imagePreview.zoomIn")),1)]),i("div",{class:"absolute right-4 top-4 flex items-center gap-2",onClick:L[3]||(L[3]=Qe(()=>{},["stop"]))},[i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<=0,onClick:m},S(a(s)("imagePreview.previous")),9,zu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition disabled:cursor-not-allowed disabled:opacity-40",disabled:c.value<0||c.value>=l.value.length-1,onClick:f},S(a(s)("imagePreview.next")),9,Hu),i("button",{type:"button",class:"image-preview-overlay__button rounded-sm border px-3 py-2 text-sm transition",onClick:w},S(a(s)("imagePreview.close")),1)]),i("img",{src:p.value,alt:a(s)("imagePreview.alt"),class:"image-preview-overlay__image max-h-[90vh] max-w-[90vw] object-contain shadow-2xl transition-transform",style:kn({transform:`scale(${r.value})`}),onClick:L[4]||(L[4]=Qe(()=>{},["stop"]))},null,12,qu)],32)):me("",!0)]))}};let Zs=null;const Sy={maxLines:2e3,maxChars:2e5},eo={maxLines:2e3,maxChars:2e5},Ku={"github-dark-default":()=>ze(()=>import("./vendor-shiki-theme-github-dark-default-DBX58552.js"),__vite__mapDeps([0,1,2,3])).then(e=>e.default),"github-light":()=>ze(()=>import("./vendor-shiki-theme-github-light-RLAvZv0q.js"),__vite__mapDeps([4,1,2,3])).then(e=>e.default)},Wu={bash:()=>ze(()=>import("./vendor-shiki-lang-bash-zsQu0xn-.js"),__vite__mapDeps([5,1,2,3])).then(e=>e.default),c:()=>ze(()=>import("./vendor-shiki-lang-c-BDF8vgks.js"),__vite__mapDeps([6,1,2,3])).then(e=>e.default),cpp:()=>ze(()=>import("./vendor-shiki-lang-cpp-DyDAaXl6.js"),__vite__mapDeps([7,1,2,3])).then(e=>e.default),csharp:()=>ze(()=>import("./vendor-shiki-lang-csharp-BWfTXJXw.js"),__vite__mapDeps([8,1,2,3])).then(e=>e.default),css:()=>ze(()=>import("./vendor-shiki-lang-css-DbAm1fUO.js"),__vite__mapDeps([9,1,2,3])).then(e=>e.default),diff:()=>ze(()=>import("./vendor-shiki-lang-diff-DmGC1G26.js"),__vite__mapDeps([10,1,2,3])).then(e=>e.default),dockerfile:()=>ze(()=>import("./vendor-shiki-lang-dockerfile-3x-8396r.js"),__vite__mapDeps([11,1,2,3])).then(e=>e.default),dotenv:()=>ze(()=>import("./vendor-shiki-lang-dotenv--IVOlX2Q.js"),__vite__mapDeps([12,1,2,3])).then(e=>e.default),fish:()=>ze(()=>import("./vendor-shiki-lang-fish-Bpv3hhJP.js"),__vite__mapDeps([13,1,2,3])).then(e=>e.default),go:()=>ze(()=>import("./vendor-shiki-lang-go-CIGC59jP.js"),__vite__mapDeps([14,1,2,3])).then(e=>e.default),html:()=>ze(()=>import("./vendor-shiki-lang-html-Bt_TLLZN.js"),__vite__mapDeps([15,1,2,3])).then(e=>e.default),ini:()=>ze(()=>import("./vendor-shiki-lang-ini-BIllfys4.js"),__vite__mapDeps([16,1,2,3])).then(e=>e.default),java:()=>ze(()=>import("./vendor-shiki-lang-java-CXxu9crF.js"),__vite__mapDeps([17,1,2,3])).then(e=>e.default),javascript:()=>ze(()=>import("./vendor-shiki-lang-javascript-Cha7GNZm.js"),__vite__mapDeps([18,1,2,3])).then(e=>e.default),json:()=>ze(()=>import("./vendor-shiki-lang-json-CCZCjDUh.js"),__vite__mapDeps([19,1,2,3])).then(e=>e.default),less:()=>ze(()=>import("./vendor-shiki-lang-less-DAToytC5.js"),__vite__mapDeps([20,1,2,3])).then(e=>e.default),markdown:()=>ze(()=>import("./vendor-shiki-lang-markdown-C6lwMXFp.js"),__vite__mapDeps([21,1,2,3])).then(e=>e.default),python:()=>ze(()=>import("./vendor-shiki-lang-python-Bi9rmtY7.js"),__vite__mapDeps([22,1,2,3])).then(e=>e.default),powershell:()=>ze(()=>import("./vendor-shiki-lang-powershell-lrpuM0ez.js"),__vite__mapDeps([23,1,2,3])).then(e=>e.default),rust:()=>ze(()=>import("./vendor-shiki-lang-rust-GTGDbY6A.js"),__vite__mapDeps([24,1,2,3])).then(e=>e.default),sass:()=>ze(()=>import("./vendor-shiki-lang-sass-DFtHupN8.js"),__vite__mapDeps([25,1,2,3])).then(e=>e.default),scss:()=>ze(()=>import("./vendor-shiki-lang-scss-BrfBNyyi.js"),__vite__mapDeps([26,1,2,3])).then(e=>e.default),sql:()=>ze(()=>import("./vendor-shiki-lang-sql-H6--iFN-.js"),__vite__mapDeps([27,1,2,3])).then(e=>e.default),toml:()=>ze(()=>import("./vendor-shiki-lang-toml-aTteTWYL.js"),__vite__mapDeps([28,1,2,3])).then(e=>e.default),tsx:()=>ze(()=>import("./vendor-shiki-lang-tsx-DoKZm6AV.js"),__vite__mapDeps([29,1,2,3])).then(e=>e.default),typescript:()=>ze(()=>import("./vendor-shiki-lang-typescript-B5awnqri.js"),__vite__mapDeps([30,1,2,3])).then(e=>e.default),vue:()=>ze(()=>import("./vendor-shiki-lang-vue-CnrgQ7Z5.js"),__vite__mapDeps([31,1,2,3])).then(e=>e.default),xml:()=>ze(()=>import("./vendor-shiki-lang-xml-Bv-TNPJt.js"),__vite__mapDeps([32,1,2,3])).then(e=>e.default),yaml:()=>ze(()=>import("./vendor-shiki-lang-yaml-DpxUxQ6M.js"),__vite__mapDeps([33,1,2,3])).then(e=>e.default)};function jr(e=0){return Number(e)>9999?"3.4rem":"2.6rem"}function Po(e=[]){const t=Array.isArray(e)?e.map(o=>String(o??"")):[],n=t.reduce((o,s)=>o+s.length,0);return{lines:t,lineCount:t.length,charCount:n}}function Do(e={},t={}){const n=Number(t.maxHighlightLines||0),o=Number(t.maxHighlightChars||0);return n>0&&Number(e.lineCount||0)>n||o>0&&Number(e.charCount||0)>o}function Gu(e=[],t={}){const n=Po(e);return Do(n,{maxHighlightLines:t.maxLines,maxHighlightChars:t.maxChars})}function Xu(e="",t={}){const n=String(e||"").replace(/\r\n/g,`
|
|
@@ -36,7 +36,7 @@ ${o}`:o}function es(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.labe
|
|
|
36
36
|
${N("原始错误","Raw error")}: ${o.rawMessage}`:n}function yo(e,t=0){if(!e||t>4)return"";if(typeof e=="string")return On(e).trim();if(typeof e!="object")return"";const n=["message","detail","error","last_error","cause","reason","stderr","text","summary"];for(const o of n){if(!Object.prototype.hasOwnProperty.call(e,o))continue;const s=yo(e[o],t+1);if(s)return s}for(const o of Object.values(e)){const s=yo(o,t+1);if(s)return s}return""}function ss(e={}){return yo(e)}function Jf(e={},t="Codex",n="codex"){var r,l,c,p;const o=String(e.type||"").trim(),s=e.item||{};if(!o)return{title:N(`收到 ${t} 事件`,`Received ${t} event`),detail:""};if(o===vt.THREAD_STARTED){const w=e.thread_id?N(`线程 ID: ${e.thread_id}`,`Thread ID: ${e.thread_id}`):"";return{title:N(`${t} 会话已创建`,`${t} session created`),detail:w,detailBlocks:w?[es([{label:"ID",value:e.thread_id}])]:[]}}if(o===vt.TURN_STARTED)return{title:N(`${t} 开始执行`,`${t} started`),detail:""};if(o===vt.TURN_COMPLETED){const w=e.usage?[N(`输入 ${Dt(e.usage.input_tokens)}`,`Input ${Dt(e.usage.input_tokens)}`),e.usage.cached_input_tokens?N(`缓存 ${Dt(e.usage.cached_input_tokens)}`,`Cached ${Dt(e.usage.cached_input_tokens)}`):"",N(`输出 ${Dt(e.usage.output_tokens)}`,`Output ${Dt(e.usage.output_tokens)}`)].filter(Boolean).join(" / "):"";return{title:N(`${t} 执行完成`,`${t} completed`),detail:w,detailBlocks:e.usage?[es([{label:N("输入","Input"),value:Dt(e.usage.input_tokens)},e.usage.cached_input_tokens?{label:N("缓存","Cached"),value:Dt(e.usage.cached_input_tokens)}:null,{label:N("输出","Output"),value:Dt(e.usage.output_tokens)}])]:[]}}if(o==="claude.system"&&!String(e.detail||"").trim())return{title:"",detail:""};if(o===vt.ERROR||o===vt.TURN_FAILED){const w=ss(e)||N(`${t} 执行失败`,`${t} failed`),d=o===vt.ERROR?No(w):null;if(d)return{kind:"info",title:N(`网络异常,正在重试 (${d.attempt}/${d.total})`,`Network error, retrying (${d.attempt}/${d.total})`),detail:tn(d.reason||d.rawMessage,n),detailBlocks:bn(tn(d.reason||d.rawMessage,n),{preferMarkdown:!0})};const m=Nn(w,n);return{kind:"error",title:(m==null?void 0:m.title)||(o===vt.TURN_FAILED?N("本轮运行失败","This run failed"):N(`${t} 返回错误`,`${t} returned an error`)),detail:tn(w,n),detailBlocks:bn(tn(w,n),{preferMarkdown:!0})}}if(o===vt.ITEM_STARTED)return s.type===rt.REASONING?{kind:"reasoning",title:N("思考过程","Thinking"),detail:s.text||"",detailBlocks:bn(s.text||"",{preferMarkdown:!0}),groupType:"reasoning",phase:"updated"}:s.type===rt.WEB_SEARCH?{...nr(s,"started"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((r=s.action)==null?void 0:r.query)||((l=s.action)==null?void 0:l.url)||"").trim(),phase:"started"}:s.type===rt.COLLAB_TOOL_CALL?{...sr(s,"started"),detailBlocks:er(s)}:s.type===rt.FILE_CHANGE?{...or(s,"started"),detailBlocks:tr(s)}:s.type===rt.COMMAND_EXECUTION?In(s).groupType==="todo"?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(ts(s)),detailBlocks:gs(s,!1,n),groupType:"todo",phase:"started"}:{kind:"command",title:N("开始执行命令","Command started"),detail:s.command||"",detailBlocks:gs(s,!1,n),...In(s),phase:"started"}:s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"started"}:{title:N(`开始处理 ${s.type||"未知项目"}`,`Started handling ${s.type||"unknown item"}`),detail:""};if(o===vt.ITEM_UPDATED&&s.type===rt.TODO_LIST)return{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"updated"};if(o===vt.ITEM_COMPLETED){if(s.type===rt.AGENT_MESSAGE&&s.text)return{kind:"result",title:N(`${t} 已返回结果`,`${t} returned a result`),detail:""};if(s.type===rt.WEB_SEARCH)return{...nr(s,"completed"),detailBlocks:Zo(s),groupType:"web",groupTarget:String(s.query||((c=s.action)==null?void 0:c.query)||((p=s.action)==null?void 0:p.url)||"").trim(),phase:"completed"};if(s.type===rt.COLLAB_TOOL_CALL)return{...sr(s,"completed"),detailBlocks:er(s)};if(s.type===rt.FILE_CHANGE)return{...or(s,"completed"),detailBlocks:tr(s)};if(s.type===rt.COMMAND_EXECUTION){if(In(s).groupType==="todo"){const m=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:m?"todo":"error",title:m?N("更新待办列表","Update todo list"):N("更新待办列表失败","Todo list update failed"),detail:yn(ts(s)),detailBlocks:gs(s,!0,n),groupType:"todo",phase:"completed"}}const d=typeof s.exit_code=="number"?s.exit_code===0:s.status==="completed";return{kind:d?"command":"error",title:d?N("命令执行完成","Command completed"):N(`命令执行失败(exit ${s.exit_code??"?"})`,`Command failed (exit ${s.exit_code??"?"})`),detail:[s.command,ra(s.aggregated_output)].filter(Boolean).join(`
|
|
37
37
|
|
|
38
38
|
`),detailBlocks:gs(s,!0,n),...In(s),phase:"completed"}}return s.type===rt.TODO_LIST?{kind:"todo",title:N("更新待办列表","Update todo list"),detail:yn(s.items),detailBlocks:oo(s),groupType:"todo",phase:"completed"}:{title:N(`完成 ${s.type||"未知项目"}`,`Completed ${s.type||"unknown item"}`),detail:""}}return{title:N(`事件: ${o}`,`Event: ${o}`),detail:""}}function Qf(e){return e.status==="queued"?N("排队中","Queued"):e.status==="starting"?N("启动中","Starting"):e.status==="stopping"?N("停止中","Stopping"):e.status==="running"?N("进行中","Running"):e.status==="error"?N("失败","Failed"):e.status==="interrupted"?N("已中断","Interrupted"):e.status==="stopped"?N("已停止","Stopped"):e.status==="stop_timeout"?N("停止超时","Stop timeout"):N("已完成","Completed")}function ga(e={},t){if(typeof e=="string"){const r=e.trim();return r?{id:t(),kind:"info",title:r,detail:""}:null}const n=String(e.title||"").trim(),o=String(e.detail||"").trim(),s=Array.isArray(e.detailBlocks)&&e.detailBlocks.length?e.detailBlocks.filter(Boolean):o?bn(o,{preferMarkdown:e.kind==="error"}):[];return!n&&!o?null:{id:t(),kind:e.kind||"info",title:n||o,detail:n?o:"",detailBlocks:s,groupType:String(e.groupType||"").trim(),groupTarget:String(e.groupTarget||"").trim(),toolName:String(e.toolName||"").trim(),phase:String(e.phase||"").trim()}}function Zf(e={},t){const n=Array.isArray(e.promptBlocks)?e.promptBlocks.map(o=>({...o,meta:o!=null&&o.meta?{...o.meta}:{},content:(o==null?void 0:o.type)==="image"?xs(o.content):o.content})):[];return{id:t(),runId:String(e.id||"").trim(),engine:String(e.engine||"").trim(),displayEngine:String(e.displayEngine||"").trim(),prompt:String(e.prompt||"").trim(),promptBlocks:n,status:"completed",startedAt:e.startedAt||e.createdAt||"",finishedAt:e.finishedAt||"",events:[],eventCount:Math.max(0,Number(e.eventCount)||(Array.isArray(e.events)?e.events.length:0)),eventsLoaded:!!e.eventsIncluded,eventsLoading:!1,responseMessage:"",errorMessage:"",lastEventSeq:0,summary:jn()}}function vn(e,t,n){const o=ga(t,n);o&&(e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120))}function ep(e,t,n){var s;const o=ga(t,n);if(o){for(let r=e.events.length-1;r>=0;r-=1){const l=N("网络异常,正在重试","Network error, retrying");if(String(((s=e.events[r])==null?void 0:s.title)||"").startsWith(l)){e.events.splice(r,1,o);return}}e.events.push(o),e.events.length>120&&e.events.splice(0,e.events.length-120)}}function tp(e,t={},n,o=()=>{}){var r,l,c,p,w,d,m,f,b;const s=Dr(t.type);if(s===Vt.SESSION){o(t.session);return}if(s===Vt.SESSION_UPDATED){o(t.session);return}if(s===Vt.STATUS){if(t.stage==="starting"||t.stage==="resuming")return;vn(e,{title:t.message||N("状态已更新","Status updated"),detail:""},n);return}if(s===Vt.STDERR){const v=Nn(t.text,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||"stderr",detail:tn(t.text,e.engine)},n);return}if(s===Vt.STDOUT){vn(e,{kind:"command",title:"stdout",detail:t.text},n);return}if(s===Vt.AGENT_EVENT){if(Wf(e,t.event),((r=t.event)==null?void 0:r.type)===vt.THREAD_STARTED)return;const v=Jf(t.event,Lt(e),e.engine);String(v.title||"").startsWith(N("网络异常,正在重试","Network error, retrying"))?ep(e,v,n):vn(e,v,n),((l=t.event)==null?void 0:l.type)===vt.ITEM_COMPLETED&&((p=(c=t.event)==null?void 0:c.item)==null?void 0:p.type)===rt.AGENT_MESSAGE&&((d=(w=t.event)==null?void 0:w.item)!=null&&d.text)&&(e.responseMessage=t.event.item.text);const P=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);if(!(((m=t.event)==null?void 0:m.type)==="error"?No(P):null)&&(((f=t.event)==null?void 0:f.type)===vt.ERROR||((b=t.event)==null?void 0:b.type)===vt.TURN_FAILED)){const y=ss(t.event)||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`);e.errorMessage=tn(y,e.engine),e.status="error"}return}if(s===Vt.COMPLETED){vn(e,{kind:"result",title:N("本轮执行结束","Run finished"),detail:""},n),t.message&&(e.responseMessage=t.message);return}if(s===Vt.STOPPED){vn(e,{title:t.message||N("执行已手动停止","Execution stopped manually"),detail:""},n);return}if(s===Vt.ERROR){const v=Nn(t.message,e.engine);vn(e,{kind:"error",title:(v==null?void 0:v.title)||N("执行失败","Execution failed"),detail:tn(t.message||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`),e.engine)},n)}}function np(e="",t="",n="codex"){const o=String(e||"").trim(),s=String(t||"").trim();if(!s)return!1;if(!o||/no last agent message|wrote empty content/i.test(o)||/执行失败[。.]?$/i.test(o))return!0;const r=Nn(o,n),l=Nn(s,n);return!r&&!!l}function sp(e,t={}){e.status=t.status||"completed",e.responseMessage=String(t.responseMessage||e.responseMessage||""),e.finishedAt=String(t.finishedAt||e.finishedAt||"");const n=tn(String(t.errorMessage||""),e.engine),o=String(e.errorMessage||"");return e.errorMessage=np(t.errorMessage,o,e.engine)?o:n,e.status==="completed"&&!e.responseMessage&&(e.responseMessage=N(`本轮 ${Lt(e)} 执行已完成,没有返回额外文本。`,`${Lt(e)} completed in this run without returning additional text.`)),e}function Oo(e,t={},n,o=()=>{}){const s=Math.max(0,Number(t==null?void 0:t.seq)||0);if(s&&s<=Number(e.lastEventSeq||0))return!1;const r=(t==null?void 0:t.payload)||{};tp(e,r,n,o);const l=Dr(r.type);return l===Vt.COMPLETED?(e.status="completed",e.finishedAt=new Date().toISOString()):l===Vt.STOPPED?(e.status="stopped",e.errorMessage="",e.finishedAt=new Date().toISOString()):l===Vt.ERROR&&(e.status="error",e.errorMessage=tn(String(r.message||e.errorMessage||N(`${Lt(e)} 执行失败`,`${Lt(e)} failed`)),e.engine),e.finishedAt=new Date().toISOString()),s&&(e.lastEventSeq=s),e.eventCount=Math.max(Math.max(0,Number(e.eventCount)||0),s,Array.isArray(e.events)?e.events.length:0),(s||Array.isArray(e.events)&&e.events.length)&&(e.eventsLoaded=!0),!0}function rr(e,t,n,o){const s=Zf(e,t);return(e.events||[]).forEach(r=>{Oo(s,r,n,o)}),sp(s,e)}const op=1800,ar=7200,rp=15e3,ro={clearTaskCodexRuns:al,listCodexRunEvents:ol,listTaskCodexRuns:sl};function Qn(e={},t=!0){const n={id:String((e==null?void 0:e.runId)||(e==null?void 0:e.id)||"").trim(),prompt:String((e==null?void 0:e.prompt)||"").trim(),promptBlocks:Array.isArray(e==null?void 0:e.promptBlocks)?e.promptBlocks.map(o=>({type:String((o==null?void 0:o.type)||"").trim(),content:String((o==null?void 0:o.content)||"")})):[],responseMessage:String((e==null?void 0:e.responseMessage)||""),errorMessage:String((e==null?void 0:e.errorMessage)||"")};return t?{...n,status:String((e==null?void 0:e.status)||"").trim(),updatedAt:String((e==null?void 0:e.updatedAt)||""),eventCount:Math.max(0,Number(e==null?void 0:e.eventCount)||0),lastEventSeq:Math.max(0,Number(e==null?void 0:e.lastEventSeq)||0)}:n}function ap(e=[],t=!0){const n=Array.isArray(e)?e:[];return JSON.stringify(n.map(o=>Qn(o,t)))}function ip(){return{commandCount:0,webSearchCount:0,fileChangeCount:0,subAgentCount:0,waitingAgentCount:0,currentActivity:"",latestActivity:"",latestDetail:""}}function lp(e={}){const{props:t,turns:n,sessions:o,sending:s,sendingStartedAt:r,currentRunningRunId:l,sessionError:c,supportsServerEvents:p,scheduleScrollToBottom:w,resetAutoStickToBottom:d,mergeSessionRecord:m,mergeSession:f,loadSessions:b,showProcessLogs:v}=e;let P=0,ne=0,y=null,L="",O=null,z=null,U="",se=!!(v!=null&&v.value),A=0;const G=new Map;function ce(){return P+=1,P}function pe(){return ne+=1,ne}function I(){O&&(window.clearInterval(O),O=null)}function Q(){z&&(window.clearInterval(z),z=null)}function le(){A=Date.now()}function ie(){G.clear(),n.value=[],s.value=!1,r.value=0,l.value="",U="",L="",P=0,ne=0,d()}function ve(){const R=[...n.value].reverse().find(J=>ns(J.status))||null;if(l.value=(R==null?void 0:R.runId)||"",s.value=!!R,R!=null&&R.startedAt){const J=Date.parse(String(R.startedAt||""));r.value=Number.isFinite(J)?J:Date.now();return}r.value=0}function _(R=null){return R?{...R}:ip()}function H(R,J=null){if(!(J!=null&&J.runId)||R.eventsLoaded||!J.eventsLoaded)return G.has(R.runId)&&(R.eventsLoading=!0),R;const fe=Math.max(Math.max(0,Number(J.lastEventSeq)||0),Math.max(0,Number(J.eventCount)||0),Array.isArray(J.events)?J.events.length:0),_e=Math.max(0,Number(R.eventCount)||0);return fe<_e?(G.has(R.runId)&&(R.eventsLoading=!0),R):(R.events=Array.isArray(J.events)?[...J.events]:[],R.eventCount=Math.max(Math.max(0,Number(R.eventCount)||0),Math.max(0,Number(J.eventCount)||0),R.events.length),R.eventsLoaded=!0,R.eventsLoading=G.has(R.runId),R.lastEventSeq=Math.max(0,Number(J.lastEventSeq)||0),R.summary=_(J.summary),R)}function F(R,J){const fe=vo(n.value,R);return fe?(fe.eventsLoading=!!J,n.value=[...n.value],fe):null}async function He(R,J={}){const fe=String((R==null?void 0:R.runId)||"").trim(),{force:_e=!1}=J;if(!fe)return[];const ge=vo(n.value,fe)||R;if(ge!=null&&ge.eventsLoaded&&!_e)return ge.events;if(G.has(fe))return G.get(fe);F(fe,!0);const Ie=(async()=>{var Ae;try{const Be=Qn(ge,!!(v!=null&&v.value)),Xe=await ro.listCodexRunEvents(fe,{limit:5e3}),Pe=qf(n.value,fe,Xe,pe,Me=>{f(Me,{preserveRunning:!0})});if(!Pe)return Array.isArray(ge==null?void 0:ge.events)?ge.events:[];const it=JSON.stringify(Be)!==JSON.stringify(Qn(Pe,!!(v!=null&&v.value)));return n.value=[...n.value],it&&t.active&&((Ae=n.value.at(-1))==null?void 0:Ae.runId)===fe&&w(),Pe.events}catch(Be){throw c.value=Be.message,Be}finally{F(fe,!1),G.delete(fe)}})();return G.set(fe,Ie),Ie}function De(R,J){const fe=String(R||"").trim();if(!fe||!J)return!1;const _e=n.value.findIndex(Xe=>Xe.runId===fe);if(_e<0)return!1;const ge=n.value[_e],Ie=Qn(ge,!!(v!=null&&v.value));if(!Oo(ge,J,pe,Xe=>{f(Xe,{preserveRunning:!0})}))return!0;const Be=JSON.stringify(Ie)!==JSON.stringify(Qn(ge,!!(v!=null&&v.value)));return n.value=[...n.value],ve(),Be&&w(),!0}function Fe(){if(I(),Q(),!(!t.active||!s.value||!t.taskSlug)){if(p){z=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},rp);return}O=window.setInterval(()=>{Ke({force:!0}).catch(()=>{});const R=Date.now();R-A<ar||(A=R,b({force:!0}).catch(()=>{}))},op)}}function je(R=[]){const J=[...o.value],fe=new Map(n.value.filter(ge=>String((ge==null?void 0:ge.runId)||"").trim()).map(ge=>[String(ge.runId||"").trim(),ge])),_e=ge=>{if(!(ge!=null&&ge.id))return;const Ie=J.findIndex(Ae=>Ae.id===ge.id);Ie>=0?J[Ie]=m(J[Ie],ge,{preserveRunning:!0}):J.unshift(m(null,ge,{preserveRunning:!0}))};P=0,ne=0,n.value=[...R||[]].reverse().map(ge=>{const Ie=rr(ge,ce,pe,_e);return H(Ie,fe.get(String((ge==null?void 0:ge.id)||"").trim())||null)}),o.value=J,ve()}async function Ke(R={}){const{force:J=!1,scrollToLatest:fe=!1}=R,_e=String(t.taskSlug||"").trim();if(!(!_e||!t.active&&!J))return y&&L===_e||y&&!J||(L=_e,y=(async()=>{try{const Ie=(await ro.listTaskCodexRuns(_e,{limit:30,events:"latest"})).items||[],Ae=!!(v!=null&&v.value),Be=ap(Ie,Ae),Xe=fe||U&&se===Ae&&Be!==U;je(Ie),U=Be,se=Ae,Fe();const Pe=n.value.at(-1)||null;if(Pe!=null&&Pe.runId&&!Pe.eventsLoaded){const it=Pe.runId;He(Pe).catch(()=>{}).finally(()=>{var Me;fe&&t.active&&((Me=n.value.at(-1))==null?void 0:Me.runId)===it&&w({force:!0})})}Xe&&w({force:fe})}catch(ge){c.value=ge.message}finally{y=null,L=""}})()),y}function tt(R={}){const J=(R==null?void 0:R.run)||null,fe=(R==null?void 0:R.session)||null;if(fe&&f(fe,{preserveRunning:!0}),!(J!=null&&J.id)){ve(),w({force:!0});return}const ge=rr(J,ce,pe,Ae=>{f(Ae,{preserveRunning:!0})}),Ie=n.value.findIndex(Ae=>Ae.runId===ge.runId);if(Ie>=0){const Ae=[...n.value];Ae.splice(Ie,1,ge),n.value=Ae}else n.value=[...n.value,ge];ve(),w({force:!0})}async function xe(){if(!(!t.taskSlug||s.value))try{await ro.clearTaskCodexRuns(t.taskSlug),ie(),w({force:!0})}catch(R){c.value=R.message}}return{applyCreatedRun:tt,applyIncomingRunEvent:De,clearRealtimeReconcileTimer:Q,clearRunPollTimer:I,clearTurns:xe,loadTurnEvents:He,markFallbackSessionPollNow:le,refreshRunHistory:Ke,resetRunHistoryState:ie,syncRunningStateFromTurns:ve,updatePollingState:Fe}}const up=1500,cp=3e4;function dp(e={}){const{props:t,sessions:n,workspaces:o,loading:s,managerBusy:r,sending:l,stopping:c,sessionError:p,showManager:w,selectedSessionId:d,currentRunningRunId:m,supportsServerEvents:f,mergeSession:b,applyCreatedRun:v,refreshRunHistory:P,markFallbackSessionPollNow:ne,showToast:y,getActiveAgentBinding:L=null}=e;let O=null,z=null,U=0,se=0;const A=W(()=>typeof t.buildPrompt=="function"||!!String(t.prompt||"").trim()),G=W(()=>n.value.length>0),ce=W(()=>Jo(n.value,d.value)),pe=W(()=>G.value?"":We("projectManager.noProjects"));async function I(xe={}){const{force:R=!1}=xe;if(O)return O;const J=Date.now();return!R&&U&&J-U<up?{items:n.value,workspaces:o.value}:(O=(async()=>{s.value=!0,p.value="";try{const _e=(await Ki()).items||[];return n.value=_e,U=Date.now(),{items:_e,workspaces:o.value}}catch(fe){throw p.value=fe.message,fe}finally{s.value=!1,O=null}})(),O)}async function Q(xe={}){const{force:R=!1}=xe;if(z)return z;const J=Date.now();return!R&&se&&J-se<cp?{items:o.value}:(z=(async()=>{try{const fe=await Wi();return o.value=fe.items||[],se=Date.now(),{items:o.value}}finally{z=null}})(),z)}async function le(xe={}){const{forceSessions:R=!1,forceWorkspaces:J=!1}=xe,[fe,_e]=await Promise.all([I({force:R}),Q({force:J})]);return{items:(fe==null?void 0:fe.items)||n.value,workspaces:(_e==null?void 0:_e.items)||o.value}}function ie(xe=""){const R=String(xe||"").trim();!R||o.value.includes(R)||(o.value=[R,...o.value])}function ve(){w.value=!0,Q().catch(()=>{})}function _(){w.value=!1}function H(xe){const R=String(xe||"").trim();if(t.sessionSelectionLocked&&R&&R!==d.value){p.value=t.sessionSelectionLockReason||We("taskActions.sessionLocked");return}d.value=R}function F(){le({forceSessions:!0,forceWorkspaces:!0}).catch(()=>{})}async function He(xe){r.value=!0,p.value="";try{const R=await Gi(xe);return b(R),ie(R.cwd),d.value=R.id,R}catch(R){throw p.value=R.message,R}finally{r.value=!1}}async function De(xe,R){r.value=!0,p.value="";try{const J=await Xi(xe,R);return b(J),ie(J.cwd),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Fe(xe){var J;const R=String(xe||"").trim();if(!R)return{deletedSessionId:"",selectedSessionId:d.value};r.value=!0,p.value="";try{await Yi(R);const fe=n.value.filter(ge=>ge.id!==R);n.value=fe;let _e=d.value;return d.value===R&&(_e=((J=Jo(fe,"")[0])==null?void 0:J.id)||"",d.value=_e),{deletedSessionId:R,selectedSessionId:_e}}catch(fe){throw p.value=fe.message,fe}finally{r.value=!1}}async function je(xe){const R=String(xe||"").trim();if(!R)return null;r.value=!0,p.value="";try{const J=await Ji(R);return J!=null&&J.session&&b(J.session),ne(),await Promise.all([P({force:!0}),I({force:!0})]),y==null||y({message:We("projectManager.sessionReset"),type:"success"}),J}catch(J){throw p.value=J.message,J}finally{r.value=!1}}async function Ke(){if(!t.taskSlug||!A.value||l.value||c.value)return!1;if(!d.value){const xe=We("projectManager.selectProject");return p.value=xe,y==null||y({message:xe,type:"warning"}),!1}p.value="";try{await le({forceSessions:!0});const xe=n.value.find(Pe=>Pe.id===d.value)||null;if(!xe)return p.value=We("projectManager.projectMissing"),!1;if(xe.running)return p.value=We("sessionTurns.currentProjectRunning"),!1;const R=typeof t.buildPrompt=="function"?await t.buildPrompt():t.prompt,J=typeof t.buildPromptBlocks=="function"?await t.buildPromptBlocks():[],fe=si({prompt:R,promptBlocks:J});if(fe.reason){const Pe=fe.reason==="unsupported_blocks"?We("sessionPanel.shellUnsupportedBlocks"):We("sessionPanel.shellEmptyCommand");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}if(!String(R||"").trim())return p.value=We("sessionTurns.noPromptToSend"),!1;const _e=fp(xe),ge=typeof L=="function"?L(xe):null,Ie=String((ge==null?void 0:ge.engine)||"").trim();if(Ie&&!_e.some(Pe=>Pe.engine===Ie)){const Pe=We("sessionPanel.agentNotEnabled");return p.value=Pe,y==null||y({message:Pe,type:"warning"}),!1}const Ae=ge,Be=String(fe.mode==="shell"?d.value:(Ae==null?void 0:Ae.sessionRecordId)||d.value).trim(),Xe=await rl(t.taskSlug,{projectSessionId:d.value,sessionId:Be,displayEngine:Ie,prompt:fe.mode==="shell"?fe.prompt:R,promptBlocks:J,commandMode:fe.mode,command:fe.command});return v(Xe),typeof t.afterSend=="function"&&Promise.resolve(t.afterSend()).catch(Pe=>{console.error("[promptx] afterSend failed",Pe)}),f||(ne(),Promise.all([P({force:!0}),I({force:!0})]).catch(Pe=>{p.value=Pe.message})),!0}catch(xe){return p.value=xe.message,!1}}async function tt(){if(!(!m.value||c.value))try{c.value=!0,await il(m.value),f||(ne(),await Promise.all([P({force:!0}),I({force:!0})]))}catch(xe){c.value=!1,p.value=xe.message}}return{closeManager:_,handleCreateSession:He,handleDeleteSession:Fe,handleResetSession:je,handleSelectSession:H,handleSend:Ke,handleUpdateSession:De,hasPrompt:A,helperText:pe,loadSessions:I,loadSessionResources:le,loadWorkspaces:Q,openManager:ve,refreshSessionsForSelection:F,sortedSessions:ce,stopSending:tt}}function fp(e={}){return Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length?e.agentBindings:e!=null&&e.id?[{engine:pp(e.engine),sessionRecordId:e.id,sessionId:e.sessionId||"",isDefault:!0,running:!!e.running,started:!!e.started}]:[]}function pp(e=""){const t=String(e||"").trim().toLowerCase();return t==="claude"||t==="claudecode"?"claude-code":t==="opencode"||t==="open-code"?"opencode":t==="claude-code"?"claude-code":"codex"}function mp(e={}){const{transcriptRef:t,hasNewerMessages:n,threshold:o=48}=e;let s=0,r=[],l=!1,c=!1,p=0,w=!0;function d(){if(typeof window>"u"||!r.length){r=[];return}r.forEach(ce=>{window.cancelAnimationFrame(ce)}),r=[]}function m(){s+=1,d()}function f(ce){c=!!ce,(n==null?void 0:n.value)!==void 0&&(n.value=c)}function b(){l=!1,p+=1,w=!0,f(!1)}function v(ce=t==null?void 0:t.value){return ce?ce.scrollHeight-ce.scrollTop-ce.clientHeight<=o:!0}function P(){return w&&!l}function ne(){w&&!l&&f(!1)}function y(){if(w=v(),!w){m();return}ne()}function L(){p+=1,l=!0,m()}function O(){const ce=p+1;p=ce,at(()=>{ce===p&&requestAnimationFrame(()=>{ce===p&&(l=!1,w=v(),ne())})})}function z(){l=!0,m()}function U(){O()}function se(ce={}){const{force:pe=!1}=ce;pe&&b(),m();const I=s;at(()=>{if(!(t==null?void 0:t.value)||I!==s)return;if(!pe&&!P()){f(!0);return}const le=()=>{const ve=t==null?void 0:t.value;!ve||I!==s||(ve.scrollTop=ve.scrollHeight,w=!0,f(!1))};le(),r=[requestAnimationFrame(()=>{le(),r=[requestAnimationFrame(le)]})]})}function A(){se({force:!0})}function G(){p+=1,m()}return{cancelScheduledScrollToBottom:m,destroy:G,handleTranscriptScroll:y,handleTranscriptTouchEnd:U,handleTranscriptTouchMove:z,handleTranscriptTouchStart:L,isTranscriptNearBottom:v,resetAutoStickToBottom:b,scheduleScrollToBottom:se,scrollToBottom:A}}const gp=150,ha="promptx:session-panel:show-process";function hp(e){return!(e==="0"||e==="false")}function vp(){if(typeof window>"u")return!0;try{return hp(window.localStorage.getItem(ha))}catch{return!0}}function yp(e,t,n={}){const{preserveRunning:o=!1}=n;if(!(t!=null&&t.id))return e||null;const s={...e||{},...t};return(!Array.isArray(t==null?void 0:t.agentBindings)||!t.agentBindings.length)&&Array.isArray(e==null?void 0:e.agentBindings)&&e.agentBindings.length&&(s.agentBindings=e.agentBindings),o&&(s.running=!!(e!=null&&e.running)),s}function Sp(e,t){const n=oa(),o=q([]),s=q([]),r=q(!1),l=q(!1),c=q(!1),p=q(!1),w=q(""),d=q([]),m=q(null),f=q(0),b=q(0),v=q(!1),P=q(""),ne=q(!1),y=q(vp()),L=typeof window<"u"&&typeof window.EventSource<"u";function O(re=""){const Le=typeof re=="object"&&re!==null?String(re.message||"").trim():String(re||"").trim();Le&&t("toast",typeof re=="object"&&re!==null?{...re,message:Le}:Le)}let z=null,U=null,se=null,A={sessions:!1,runs:!1};const G=W({get(){return String(e.selectedSessionId||"").trim()},set(re){t("selected-session-change",String(re||"").trim())}}),ce=W(()=>p.value?We("sessionPanel.stopping"):`${We("projectManager.running")} (${la(b.value)})`),pe=W(()=>o.value.find(re=>re.id===G.value)||null),I=W(()=>{var Le;if(Array.isArray((Le=pe.value)==null?void 0:Le.agentBindings)&&pe.value.agentBindings.length)return pe.value.agentBindings;const re=pe.value;return re!=null&&re.id?[{engine:re.engine,sessionRecordId:re.id,sessionId:re.sessionId||"",started:!!re.started,running:!!re.running,isDefault:!0}]:[]}),Q=W({get(){var Le,ot;const re=ao(e.selectedAgentEngine,I.value);return re||((Le=I.value.find(xt=>xt.isDefault))==null?void 0:Le.engine)||((ot=I.value[0])==null?void 0:ot.engine)||""},set(re){const Le=ao(re,I.value);Le&&t("update:selectedAgentEngine",Le)}}),le=W(()=>I.value.find(re=>re.engine===Q.value)||I.value[0]||null),{destroy:ie,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,resetAutoStickToBottom:He,scheduleScrollToBottom:De,scrollToBottom:Fe}=mp({transcriptRef:m,hasNewerMessages:ne});function je(re,Le,ot={}){return yp(re,Le,ot)}function Ke(re,Le={}){if(!(re!=null&&re.id))return;const ot=[...o.value],xt=ot.findIndex(Et=>Et.id===re.id);xt>=0?ot[xt]=je(ot[xt],re,Le):ot.unshift(je(null,re,Le)),o.value=ot}const{applyCreatedRun:tt,applyIncomingRunEvent:xe,clearRealtimeReconcileTimer:R,clearRunPollTimer:J,clearTurns:fe,loadTurnEvents:_e,markFallbackSessionPollNow:ge,refreshRunHistory:Ie,resetRunHistoryState:Ae,updatePollingState:Be}=lp({props:e,turns:d,sessions:o,sending:c,sendingStartedAt:f,currentRunningRunId:P,sessionError:w,supportsServerEvents:L,scheduleScrollToBottom:De,resetAutoStickToBottom:He,showProcessLogs:y,mergeSessionRecord:je,mergeSession:Ke,loadSessions:(...re)=>dt(...re)}),{closeManager:Xe,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,helperText:ht,loadSessions:dt,loadSessionResources:wt,loadWorkspaces:Ct,openManager:T,refreshSessionsForSelection:j,sortedSessions:te,stopSending:ye}=dp({props:e,sessions:o,workspaces:s,loading:r,managerBusy:l,sending:c,stopping:p,sessionError:w,showManager:v,selectedSessionId:G,currentRunningRunId:P,supportsServerEvents:L,mergeSession:Ke,applyCreatedRun:tt,refreshRunHistory:Ie,markFallbackSessionPollNow:ge,showToast:O,getActiveAgentBinding:()=>le.value});function Oe(){z&&(window.clearInterval(z),z=null)}function Re(){Oe(),f.value||(f.value=Date.now()),b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3)),z=window.setInterval(()=>{b.value=Math.max(0,Math.floor((Date.now()-f.value)/1e3))},1e3)}function Ge(){se&&(window.clearTimeout(se),se=null)}function Ye(){Ge();const re=A;A={sessions:!1,runs:!1},re.sessions&&dt({force:!0}).catch(()=>{}),re.runs&&Ie({force:!0}).catch(()=>{})}function nt(re={}){typeof window>"u"||(A={sessions:A.sessions||!!re.sessions,runs:A.runs||!!re.runs},!(se||!A.sessions&&!A.runs)&&(se=window.setTimeout(()=>{Ye()},gp)))}function yt(re){return fa(re,{currentRunningRunId:P.value,runningElapsedSeconds:b.value,nowMs:Date.now()})}function st(re=""){if(!re)return"";const Le=new Date(re);return Number.isNaN(Le.getTime())?"":Le.toLocaleTimeString(Os(),{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ft(re){return re.status==="error"||re.status==="stop_timeout"?"theme-process-error":re.status==="interrupted"||re.status==="stopped"?"theme-process-stopped":re.status==="completed"?"theme-process-completed":"theme-process-running"}function _t(){y.value=!y.value}function Bt(re){return!!(re.responseMessage||re.errorMessage||re.status==="completed")}return $e(y,re=>{if(!(typeof window>"u"))try{window.localStorage.setItem(ha,re?"true":"false")}catch{}},{immediate:!0}),$e(c,re=>{re?(f.value||(f.value=Date.now()),Re()):(Oe(),f.value=0,b.value=0,p.value=!1),Be(),t("sending-change",re)},{immediate:!0}),$e(()=>!!e.taskRunning,re=>{!e.active||re||!c.value||nt({sessions:!0,runs:!0})}),$e(()=>e.active,re=>{if(re){wt({forceSessions:!0}).catch(()=>{});return}Ge(),R(),J()},{immediate:!0}),$e(()=>e.taskSlug,()=>{Ae(),v.value=!1,w.value="",e.active&&Ie({force:!0,scrollToLatest:!0}).catch(()=>{})},{immediate:!0}),$e(()=>{var re;return[((re=pe.value)==null?void 0:re.id)||"",I.value.map(Le=>Le.engine).join(","),e.selectedAgentEngine||""].join(`
|
|
39
|
-
`)},()=>{var pt,V,X;const re=String(((pt=pe.value)==null?void 0:pt.id)||"").trim(),Le=I.value,ot=Q.value;if(t("agent-bindings-change",{sessionId:re,bindings:Le,selectedEngine:ot}),!re||ao(e.selectedAgentEngine,Le))return;const Et=((V=Le.find(de=>de.isDefault))==null?void 0:V.engine)||((X=Le[0])==null?void 0:X.engine)||"";Et&&t("update:selectedAgentEngine",Et)},{immediate:!0}),It(()=>{Oe(),R(),J(),Ge(),ie(),U==null||U()}),$e(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!v.value||(v.value&&Ct().catch(()=>{}),nt({sessions:!0,runs:!!re}))}),$e(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!v.value||nt({sessions:!0})}),$e(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||nt({sessions:!0,runs:!0})}),$e(()=>String(e.taskSlug||"").trim(),re=>{U==null||U(),U=null,re&&(U=Cf(re,({runId:Le,event:ot})=>{if(!e.active)return;xe(Le,ot)||nt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:Q,clearTurns:fe,closeManager:Xe,formatTurnTime:st,getProcessCardClass:ft,getProcessStatus:Qf,getTurnAgentLabel:Lt,getTurnSummaryDetail:ma,getDisplayTurnSummaryItems:yt,getTurnSummaryStatus:pa,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,loadTurnEvents:_e,hasTurnSummary:Xf,helperText:ht,loading:r,managerBusy:l,openManager:T,refreshSessionsForSelection:j,selectedSessionId:G,sending:c,showProcessLogs:y,stopping:p,sessionError:w,shouldShowResponse:Bt,showManager:v,sortedSessions:te,stopSending:ye,toggleProcessLogs:_t,hasNewerMessages:ne,transcriptRef:m,turns:d,workspaces:s,workingLabel:ce,sessions:o,loadSessions:dt,currentProjectAgentBindings:I,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,scheduleScrollToBottom:De,scrollToBottom:Fe}}function ao(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const wp=8,xp=320,bp=10,kp=400;function ir(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function _p(e={}){const{turns:t,loadTurnEvents:n}=e,o=q({}),s=q({}),r=q({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function c(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function w(A){return!ns(A==null?void 0:A.status)&&!c(A)&&p(A)>3}function d(A){return ir(A==null?void 0:A.prompt,wp,xp)}function m(A){return!ns(A==null?void 0:A.status)&&!c(A)&&d(A)}function f(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function b(A){return ir(f(A),bp,kp)}function v(A){return!(A!=null&&A.errorMessage)&&!c(A)&&b(A)}function P(A){return p(A)>0}function ne(A=[]){const G=new Set((A||[]).map(I=>l(I)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([I])=>G.has(I))),s.value=Object.fromEntries(Object.entries(s.value).filter(([I])=>G.has(I))),r.value=Object.fromEntries(Object.entries(r.value).filter(([I])=>G.has(I)));const ce=(A||[]).at(-1)||null,pe=l(ce);pe&&(Object.prototype.hasOwnProperty.call(o.value,pe)||(o.value={...o.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(s.value,pe)||(s.value={...s.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(r.value,pe)||(r.value={...r.value,[pe]:!1}))}function y(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:w(A):!1}async function L(A){const G=l(A);if(!G)return;const ce=!y(A);o.value={...o.value,[G]:ce},!ce&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function O(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:m(A):!1}function z(A){const G=l(A);!G||!d(A)||(s.value={...s.value,[G]:!O(A)})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:v(A):!1}function se(A){const G=l(A);!G||!b(A)||(r.value={...r.value,[G]:!U(A)})}return $e(t,A=>{ne(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:b,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:c,isPromptCollapsed:O,isResponseCollapsed:U,isTurnEventsCollapsed:y,togglePrompt:z,toggleResponse:se,toggleTurnEvents:L}}function Tp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Cp(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function Ep(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function io(e="",t=0){const n=Math.max(1,Number(t)||0);return e==="read"?`连续读取 ${n} 项`:e==="grep"?`连续检索 ${n} 次`:e==="list"?`连续列出 ${n} 处`:e==="web"?`连续网页检索 ${n} 次`:e==="todo"?"待办列表":e==="reasoning"?"思考过程":`连续处理 ${n} 项`}function lo(e="",t=[],n=[]){var l;const o=Tp(t.map(c=>c.groupTarget)),s=[];if(e==="todo"){const c=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return c?[c]:[]}if(e==="reasoning"){const c=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=c==null?void 0:c.detailBlocks)!=null&&l.length?c.detailBlocks:[]}const r=Cp([{label:"类型",value:Ep(e)},{label:"次数",value:String(t.length)}]);return r&&s.push(r),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function va(e=[]){if(!e.length)return[];const[t]=e,n=String(t.groupType||"").trim();if(!n)return e;if(n==="reasoning"){if(e.length===1)return e;const s=e[e.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,e),isGrouped:!0,groupedCount:e.length}]}const o=e.filter(s=>s.phase==="completed"||s.phase==="updated"||s.kind==="error");if(!o.length)return[e[e.length-1]];if(n==="todo"){if(e.length===1)return e;const s=o[o.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,o),isGrouped:!0,groupedCount:e.length}]}return o.length===1&&e.length<=2?[o[0]]:[{...o[o.length-1],id:`${o[o.length-1].id}-group`,title:io(n,o.length),detail:"",detailBlocks:lo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Ap(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(r=>String((r==null?void 0:r.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=va(n);if(!o)return t;const s=t.reduce((r,l,c)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?c:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function $p(e=[]){var o;const t=Ap(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const r=t[s],l=String((r==null?void 0:r.groupType)||"").trim();if(!l){n.push(r);continue}const c=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)c.push(t[s+1]),s+=1;n.push(...va(c))}return n}const Ip={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Pp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Dp={class:"flex flex-col gap-2"},Lp={class:"flex items-center gap-2"},Bp=["title"],Mp={class:"flex shrink-0 items-center gap-1.5"},Rp=["aria-pressed","aria-label","title"],Np=["disabled"],Op={class:"hidden sm:inline"},jp=["disabled"],Fp={class:"hidden sm:inline"},Up=["aria-label"],Vp=["aria-pressed"],zp=["aria-pressed","title","onClick"],Hp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},qp={class:"min-h-0 flex-1"},Kp={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Wp={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Gp=["data-turn-id","data-run-id"],Xp={class:"flex justify-end"},Yp={class:"transcript-card transcript-card--prompt min-w-0 w-full rounded-sm bg-[var(--theme-promptBg)] px-4 py-3 font-mono text-sm text-[var(--theme-promptText)]"},Jp={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Qp={class:"font-semibold"},Zp={class:"flex items-center gap-2"},em=["onClick"],tm={class:"relative mt-2"},nm={key:0,class:"space-y-3"},sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},om=["onClick"],rm=["src","alt"],am={key:1,class:"whitespace-pre-wrap break-words leading-7"},im={key:0,class:"flex min-w-0 justify-start"},lm={class:"flex items-center justify-between gap-3 text-xs"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["disabled","onClick"],fm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},pm={key:1,class:"mt-2 min-w-0 space-y-2"},mm={class:"text-sm font-medium leading-6"},gm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},hm={key:3,class:"mt-2 text-xs text-current"},vm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},ym={key:0,class:"leading-5"},Sm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},wm={key:2,class:"mt-2 flex flex-wrap gap-2"},xm={class:"font-medium"},bm={key:1,class:"flex justify-start"},km={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},_m={class:"font-semibold"},Tm={class:"flex items-center gap-2"},Cm=["onClick"],Em=["onClick"],Am={class:"relative mt-2"},$m={key:0,class:"whitespace-pre-wrap break-words"},Im=["innerHTML"],Pm={class:"pointer-events-none absolute bottom-1 right-1 z-10 flex flex-col items-end gap-1.5 sm:bottom-3 sm:right-3"},Dm=["disabled"],Lm={key:2,class:"task-loading-dots","aria-hidden":"true"},Bm={__name:"CodexSessionPanel",props:{prompt:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},beforeSend:{type:Function,default:null},afterSend:{type:Function,default:null},taskSlug:{type:String,default:""},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},active:{type:Boolean,default:!1},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1}},emits:["agent-bindings-change","insert-code-context","project-created","selected-session-change","sending-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=fo(()=>ze(()=>import("./CodexSessionManagerDialog-Cprbem1C.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:c,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:d,getDisplayTurnSummaryItems:m,getTurnSummaryDetail:f,getTurnSummaryStatus:b,handleCreateSession:v,handleDeleteSession:P,handleResetSession:ne,handleSelectSession:y,handleSend:L,handleTranscriptScroll:O,handleTranscriptTouchEnd:z,handleTranscriptTouchMove:U,handleTranscriptTouchStart:se,handleUpdateSession:A,helperText:G,loadTurnEvents:ce,loading:pe,managerBusy:I,openManager:Q,refreshSessionsForSelection:le,selectedSessionId:ie,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:F,hasNewerMessages:He,sessionError:De,shouldShowResponse:Fe,showManager:je,sortedSessions:Ke,stopSending:tt,toggleProcessLogs:xe,transcriptRef:R,turns:J,workspaces:fe,sessions:_e,loadSessions:ge,currentProjectAgentBindings:Ie,scheduleScrollToBottom:Ae,scrollToBottom:Be}=Sp(r,s),Xe=q(null),Pe=q(!1),it=q(""),Me=q(""),Ne=q("all"),{t:Ee}=St(),{isDark:lt}=kr(),ht=W(()=>lt.value?"dark":"light"),dt=W(()=>{const h=new Set;return(Array.isArray(Ie.value)?Ie.value:[]).filter(Y=>{const D=String((Y==null?void 0:Y.engine)||"").trim();return!D||h.has(D)?!1:(h.add(D),!0)})}),wt=W(()=>dt.value.length>1),Ct=W(()=>{const h=String(Ne.value||"").trim();return!wt.value||h==="all"?J.value:J.value.filter(Y=>da(Y)===h)}),{selectionAction:T,clearSelectionState:j,handleSelectionMouseUp:te}=Yr({getContainer:()=>R.value,isActive:()=>!!(r.active&&J.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:h=>[...h.querySelectorAll("[data-response-selection-root]")],getCodeLeft:h=>{var Y,D;return((D=(Y=h==null?void 0:h.getBoundingClientRect)==null?void 0:Y.call(h))==null?void 0:D.left)||0},debounceMs:72});$e([Ne,()=>dt.value.map(h=>h.engine).join(`
|
|
39
|
+
`)},()=>{var pt,V,X;const re=String(((pt=pe.value)==null?void 0:pt.id)||"").trim(),Le=I.value,ot=Q.value;if(t("agent-bindings-change",{sessionId:re,bindings:Le,selectedEngine:ot}),!re||ao(e.selectedAgentEngine,Le))return;const Et=((V=Le.find(de=>de.isDefault))==null?void 0:V.engine)||((X=Le[0])==null?void 0:X.engine)||"";Et&&t("update:selectedAgentEngine",Et)},{immediate:!0}),It(()=>{Oe(),R(),J(),Ge(),ie(),U==null||U()}),$e(()=>n.readyVersion.value,()=>{const re=String(e.taskSlug||"").trim();!e.active&&!v.value||(v.value&&Ct().catch(()=>{}),nt({sessions:!0,runs:!!re}))}),$e(()=>n.sessionsSyncVersion.value,()=>{!e.active&&!v.value||nt({sessions:!0})}),$e(()=>n.getTaskRunSyncVersion(e.taskSlug),()=>{!e.active||!e.taskSlug||nt({sessions:!0,runs:!0})}),$e(()=>String(e.taskSlug||"").trim(),re=>{U==null||U(),U=null,re&&(U=Cf(re,({runId:Le,event:ot})=>{if(!e.active)return;xe(Le,ot)||nt({sessions:!0,runs:!0})}))},{immediate:!0}),{activeAgentBinding:le,activeAgentEngine:Q,clearTurns:fe,closeManager:Xe,formatTurnTime:st,getProcessCardClass:ft,getProcessStatus:Qf,getTurnAgentLabel:Lt,getTurnSummaryDetail:ma,getDisplayTurnSummaryItems:yt,getTurnSummaryStatus:pa,handleCreateSession:Pe,handleDeleteSession:it,handleResetSession:Me,handleSelectSession:Ne,handleSend:Ee,handleUpdateSession:lt,loadTurnEvents:_e,hasTurnSummary:Xf,helperText:ht,loading:r,managerBusy:l,openManager:T,refreshSessionsForSelection:j,selectedSessionId:G,sending:c,showProcessLogs:y,stopping:p,sessionError:w,shouldShowResponse:Bt,showManager:v,sortedSessions:te,stopSending:ye,toggleProcessLogs:_t,hasNewerMessages:ne,transcriptRef:m,turns:d,workspaces:s,workingLabel:ce,sessions:o,loadSessions:dt,currentProjectAgentBindings:I,handleTranscriptScroll:ve,handleTranscriptTouchEnd:_,handleTranscriptTouchMove:H,handleTranscriptTouchStart:F,scheduleScrollToBottom:De,scrollToBottom:Fe}}function ao(e="",t=[]){const n=String(e||"").trim();return n&&t.some(o=>o.engine===n)?n:""}const wp=8,xp=320,bp=10,kp=400;function ir(e,t,n){const o=String(e||"").trimEnd();return o?o.split(/\r?\n/).length>t||o.length>n:!1}function _p(e={}){const{turns:t,loadTurnEvents:n}=e,o=q({}),s=q({}),r=q({});function l(A){return String((A==null?void 0:A.runId)||(A==null?void 0:A.id)||"").trim()}function c(A){const G=l(A);return!!G&&G===l(t.value.at(-1))}function p(A){return Math.max(0,Number(A==null?void 0:A.eventCount)||0,Array.isArray(A==null?void 0:A.events)?A.events.length:0)}function w(A){return!ns(A==null?void 0:A.status)&&!c(A)&&p(A)>3}function d(A){return ir(A==null?void 0:A.prompt,wp,xp)}function m(A){return!ns(A==null?void 0:A.status)&&!c(A)&&d(A)}function f(A){return String((A==null?void 0:A.errorMessage)||(A==null?void 0:A.responseMessage)||"")}function b(A){return ir(f(A),bp,kp)}function v(A){return!(A!=null&&A.errorMessage)&&!c(A)&&b(A)}function P(A){return p(A)>0}function ne(A=[]){const G=new Set((A||[]).map(I=>l(I)).filter(Boolean));o.value=Object.fromEntries(Object.entries(o.value).filter(([I])=>G.has(I))),s.value=Object.fromEntries(Object.entries(s.value).filter(([I])=>G.has(I))),r.value=Object.fromEntries(Object.entries(r.value).filter(([I])=>G.has(I)));const ce=(A||[]).at(-1)||null,pe=l(ce);pe&&(Object.prototype.hasOwnProperty.call(o.value,pe)||(o.value={...o.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(s.value,pe)||(s.value={...s.value,[pe]:!1}),Object.prototype.hasOwnProperty.call(r.value,pe)||(r.value={...r.value,[pe]:!1}))}function y(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(o.value,G)?!!o.value[G]:w(A):!1}async function L(A){const G=l(A);if(!G)return;const ce=!y(A);o.value={...o.value,[G]:ce},!ce&&P(A)&&!A.eventsLoaded&&!A.eventsLoading&&await n(A).catch(()=>{})}function O(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(s.value,G)?!!s.value[G]:m(A):!1}function z(A){const G=l(A);!G||!d(A)||(s.value={...s.value,[G]:!O(A)})}function U(A){const G=l(A);return G?Object.prototype.hasOwnProperty.call(r.value,G)?!!r.value[G]:v(A):!1}function se(A){const G=l(A);!G||!b(A)||(r.value={...r.value,[G]:!U(A)})}return $e(t,A=>{ne(A)},{immediate:!0,deep:!0}),{canCollapsePrompt:d,canCollapseResponse:b,getTurnEventCollapseKey:l,getTurnEventCount:p,hasTurnEventHistory:P,isLatestTurn:c,isPromptCollapsed:O,isResponseCollapsed:U,isTurnEventsCollapsed:y,togglePrompt:z,toggleResponse:se,toggleTurnEvents:L}}function Tp(e=[]){return[...new Set((Array.isArray(e)?e:[]).map(t=>String(t||"").trim()).filter(Boolean))]}function Cp(e=[]){const t=e.map(n=>({label:String((n==null?void 0:n.label)||"").trim(),value:String((n==null?void 0:n.value)||"").trim()})).filter(n=>n.label&&n.value);return t.length?{type:"meta",items:t}:null}function Ep(e=""){return e==="read"?"读取":e==="grep"?"检索":e==="list"?"列出":e==="web"?"网页":e==="todo"?"待办":e==="reasoning"?"思考":e}function io(e="",t=0){const n=Math.max(1,Number(t)||0);return e==="read"?`连续读取 ${n} 项`:e==="grep"?`连续检索 ${n} 次`:e==="list"?`连续列出 ${n} 处`:e==="web"?`连续网页检索 ${n} 次`:e==="todo"?"待办列表":e==="reasoning"?"思考过程":`连续处理 ${n} 项`}function lo(e="",t=[],n=[]){var l;const o=Tp(t.map(c=>c.groupTarget)),s=[];if(e==="todo"){const c=[...n].reverse().flatMap(p=>Array.isArray(p==null?void 0:p.detailBlocks)?p.detailBlocks:[]).find(p=>(p==null?void 0:p.type)==="checklist");return c?[c]:[]}if(e==="reasoning"){const c=[...t].reverse().find(p=>Array.isArray(p==null?void 0:p.detailBlocks)&&p.detailBlocks.length);return(l=c==null?void 0:c.detailBlocks)!=null&&l.length?c.detailBlocks:[]}const r=Cp([{label:"类型",value:Ep(e)},{label:"次数",value:String(t.length)}]);return r&&s.push(r),o.length&&s.push({type:"bullet_list",items:o.slice(0,8),totalCount:o.length,hiddenCount:Math.max(0,o.length-8)}),s}function va(e=[]){if(!e.length)return[];const[t]=e,n=String(t.groupType||"").trim();if(!n)return e;if(n==="reasoning"){if(e.length===1)return e;const s=e[e.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,e),isGrouped:!0,groupedCount:e.length}]}const o=e.filter(s=>s.phase==="completed"||s.phase==="updated"||s.kind==="error");if(!o.length)return[e[e.length-1]];if(n==="todo"){if(e.length===1)return e;const s=o[o.length-1];return[{...s,id:`${s.id}-group`,title:io(n,e.length),detail:"",detailBlocks:lo(n,e,o),isGrouped:!0,groupedCount:e.length}]}return o.length===1&&e.length<=2?[o[0]]:[{...o[o.length-1],id:`${o[o.length-1].id}-group`,title:io(n,o.length),detail:"",detailBlocks:lo(n,o,o),isGrouped:!0,groupedCount:o.length}]}function Ap(e=[]){const t=Array.isArray(e)?e:[],n=t.filter(r=>String((r==null?void 0:r.groupType)||"").trim()==="todo");if(n.length<=1)return t;const[o]=va(n);if(!o)return t;const s=t.reduce((r,l,c)=>String((l==null?void 0:l.groupType)||"").trim()==="todo"?c:r,-1);return s<0?t:t.flatMap((r,l)=>String((r==null?void 0:r.groupType)||"").trim()!=="todo"?[r]:l===s?[o]:[])}function $p(e=[]){var o;const t=Ap(Array.isArray(e)?e.filter(Boolean):[]),n=[];for(let s=0;s<t.length;s+=1){const r=t[s],l=String((r==null?void 0:r.groupType)||"").trim();if(!l){n.push(r);continue}const c=[r];for(;s+1<t.length&&String(((o=t[s+1])==null?void 0:o.groupType)||"").trim()===l;)c.push(t[s+1]),s+=1;n.push(...va(c))}return n}const Ip={class:"workbench-activity-shell panel relative flex h-full min-h-0 flex-col overflow-hidden"},Pp={class:"workbench-panel-header theme-divider theme-muted-panel border-b p-3"},Dp={class:"flex flex-col gap-2"},Lp={class:"flex items-center gap-2"},Bp=["title"],Mp={class:"flex shrink-0 items-center gap-1.5"},Rp=["aria-pressed","aria-label","title"],Np=["disabled"],Op={class:"hidden sm:inline"},jp=["disabled"],Fp={class:"hidden sm:inline"},Up=["aria-label"],Vp=["aria-pressed"],zp=["aria-pressed","title","onClick"],Hp={key:1,class:"theme-danger-text inline-flex items-center gap-2 text-sm"},qp={class:"min-h-0 flex-1"},Kp={key:0,class:"theme-empty-state px-4 py-6 text-sm"},Wp={key:1,class:"theme-empty-state px-4 py-6 text-sm"},Gp=["data-turn-id","data-run-id"],Xp={class:"flex justify-end"},Yp={class:"transcript-card transcript-card--prompt min-w-0 w-full rounded-sm bg-[var(--theme-promptBg)] px-4 py-3 font-mono text-sm text-[var(--theme-promptText)]"},Jp={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},Qp={class:"font-semibold"},Zp={class:"flex items-center gap-2"},em=["onClick"],tm={class:"relative mt-2"},nm={key:0,class:"space-y-3"},sm={key:0,class:"whitespace-pre-wrap break-words leading-7"},om=["onClick"],rm=["src","alt"],am={key:1,class:"whitespace-pre-wrap break-words leading-7"},im={key:0,class:"flex min-w-0 justify-start"},lm={class:"flex items-center justify-between gap-3 text-xs"},um={class:"font-semibold"},cm={class:"flex items-center gap-2"},dm=["disabled","onClick"],fm={key:0,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},pm={key:1,class:"mt-2 min-w-0 space-y-2"},mm={class:"text-sm font-medium leading-6"},gm={key:2,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},hm={key:3,class:"mt-2 text-xs text-current"},vm={key:4,class:"transcript-card__subtle mt-2 rounded-sm bg-[var(--theme-appPanelStrong)] px-3 py-2 text-xs text-current"},ym={key:0,class:"leading-5"},Sm={key:1,class:"mt-1 whitespace-pre-wrap break-words leading-5"},wm={key:2,class:"mt-2 flex flex-wrap gap-2"},xm={class:"font-medium"},bm={key:1,class:"flex justify-start"},km={class:"flex items-center justify-between gap-3 text-xs opacity-75 font-sans"},_m={class:"font-semibold"},Tm={class:"flex items-center gap-2"},Cm=["onClick"],Em=["onClick"],Am={class:"relative mt-2"},$m={key:0,class:"whitespace-pre-wrap break-words"},Im=["innerHTML"],Pm={class:"pointer-events-none absolute bottom-1 right-1 z-10 flex flex-col items-end gap-1.5 sm:bottom-3 sm:right-3"},Dm=["disabled"],Lm={key:2,class:"task-loading-dots","aria-hidden":"true"},Bm={__name:"CodexSessionPanel",props:{prompt:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},beforeSend:{type:Function,default:null},afterSend:{type:Function,default:null},taskSlug:{type:String,default:""},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},active:{type:Boolean,default:!1},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1}},emits:["agent-bindings-change","insert-code-context","project-created","selected-session-change","sending-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=fo(()=>ze(()=>import("./CodexSessionManagerDialog-CELTkz9T.js"),__vite__mapDeps([34,35,2,3,36,37,38,39,40]))),s=n,r=e,{closeManager:l,formatTurnTime:c,getProcessCardClass:p,getProcessStatus:w,getTurnAgentLabel:d,getDisplayTurnSummaryItems:m,getTurnSummaryDetail:f,getTurnSummaryStatus:b,handleCreateSession:v,handleDeleteSession:P,handleResetSession:ne,handleSelectSession:y,handleSend:L,handleTranscriptScroll:O,handleTranscriptTouchEnd:z,handleTranscriptTouchMove:U,handleTranscriptTouchStart:se,handleUpdateSession:A,helperText:G,loadTurnEvents:ce,loading:pe,managerBusy:I,openManager:Q,refreshSessionsForSelection:le,selectedSessionId:ie,sending:ve,showProcessLogs:_,stopping:H,hasTurnSummary:F,hasNewerMessages:He,sessionError:De,shouldShowResponse:Fe,showManager:je,sortedSessions:Ke,stopSending:tt,toggleProcessLogs:xe,transcriptRef:R,turns:J,workspaces:fe,sessions:_e,loadSessions:ge,currentProjectAgentBindings:Ie,scheduleScrollToBottom:Ae,scrollToBottom:Be}=Sp(r,s),Xe=q(null),Pe=q(!1),it=q(""),Me=q(""),Ne=q("all"),{t:Ee}=St(),{isDark:lt}=kr(),ht=W(()=>lt.value?"dark":"light"),dt=W(()=>{const h=new Set;return(Array.isArray(Ie.value)?Ie.value:[]).filter(Y=>{const D=String((Y==null?void 0:Y.engine)||"").trim();return!D||h.has(D)?!1:(h.add(D),!0)})}),wt=W(()=>dt.value.length>1),Ct=W(()=>{const h=String(Ne.value||"").trim();return!wt.value||h==="all"?J.value:J.value.filter(Y=>da(Y)===h)}),{selectionAction:T,clearSelectionState:j,handleSelectionMouseUp:te}=Yr({getContainer:()=>R.value,isActive:()=>!!(r.active&&J.value.length),rowSelector:"[data-response-selection-root]",getOrderedRowElements:h=>[...h.querySelectorAll("[data-response-selection-root]")],getCodeLeft:h=>{var Y,D;return((D=(Y=h==null?void 0:h.getBoundingClientRect)==null?void 0:Y.call(h))==null?void 0:D.left)||0},debounceMs:72});$e([Ne,()=>dt.value.map(h=>h.engine).join(`
|
|
40
40
|
`)],()=>{Ne.value!=="all"&&(dt.value.some(h=>h.engine===Ne.value)||(Ne.value="all"))},{immediate:!0}),$e(Ne,()=>{j({clearBrowserSelection:!0}),Ae({force:!0})});function ye(h={}){if((h==null?void 0:h.kind)==="reasoning")return!0;const Y=String((h==null?void 0:h.title)||"").trim();return Y?[/^已连接项目:/,/^工作目录:/,/^项目会话已更新$/,/^Codex 会话已创建$/,/^Claude Code 会话已创建$/,/^OpenCode 会话已创建$/,/^事件: claude\.system$/,/^线程 ID:/,/^Thread ID:/,/^Connected project:/,/^Working directory:/,/^Project session updated$/,/ session created$/,/^Event: claude\.system$/,/ 已返回结果$/,/ returned a result$/,/^本轮执行结束$/,/^Run finished$/].some(D=>D.test(Y)):!1}function Oe(h={}){return Ee("sessionPanel.promptTitleWithAgent",{agent:d(h)})}function Re(h={}){return h.errorMessage?Ee("sessionPanel.errorSuffix",{agent:d(h)}):Ee("sessionPanel.responseSuffix",{agent:d(h)})}const{getTurnEventCount:Ge,hasTurnEventHistory:Ye,isTurnEventsCollapsed:nt,toggleTurnEvents:yt}=_p({turns:J,loadTurnEvents:ce});function st(h){return String((h==null?void 0:h.runId)||(h==null?void 0:h.id)||"").trim()}function ft(h){h!=null&&h.runId&&s("open-diff",{scope:"run",runId:h.runId})}function _t(){s("open-diff",{scope:"workspace",runId:""})}const{getRenderedHtml:Bt}=pf({items:J,themeKey:ht,getCacheKey:st,getSource:h=>String((h==null?void 0:h.responseMessage)||""),shouldRender:h=>!!(h!=null&&h.responseMessage)&&!(h!=null&&h.errorMessage),renderAsync:h=>ac(h,{isDark:lt.value,copyLabel:Ee("sessionPanel.copyCode"),copyAriaLabel:Ee("sessionPanel.copyCodeAria")}),renderFallback:h=>Wr(h),onRendered:h=>{const Y=J.value.at(-1)||null;!r.active||!(Y!=null&&Y.runId)||Y.runId!==(h==null?void 0:h.runId)||Ae()}});function re(h){Me.value=String(h||"").trim()}async function Le(h){var D;if((D=navigator.clipboard)!=null&&D.writeText&&window.isSecureContext){await navigator.clipboard.writeText(h);return}const Y=document.createElement("textarea");Y.value=h,Y.setAttribute("readonly","true"),Y.style.position="fixed",Y.style.opacity="0",Y.style.pointerEvents="none",document.body.appendChild(Y),Y.select(),document.execCommand("copy"),document.body.removeChild(Y)}function ot(h={}){const D=(Array.isArray(h==null?void 0:h.promptBlocks)?h.promptBlocks:[]).filter(be=>(be==null?void 0:be.type)==="text"||(be==null?void 0:be.type)==="imported_text").map(be=>String((be==null?void 0:be.content)||"").replace(/\u200b/g,"").trim()).filter(Boolean).join(`
|
|
41
41
|
|
|
42
42
|
`);return D||String((h==null?void 0:h.prompt)||"").replace(/\u200b/g,"").trim()}function xt(h={}){const Y=ot(h);Y&&s("insert-code-context",{source:"response",content:Y})}async function Et(h){var jt,Ft,Ut,Pt,mt;const Y=(Ft=(jt=h==null?void 0:h.target)==null?void 0:jt.closest)==null?void 0:Ft.call(jt,'[data-copy-code="1"]');if(!Y)return;const D=Y.closest(".codex-code-block"),be=(Ut=D==null?void 0:D.querySelector)==null?void 0:Ut.call(D,"pre code"),Mt=String((be==null?void 0:be.textContent)||"").replace(/\u200b/g,"");if(Mt){(Pt=h.preventDefault)==null||Pt.call(h),(mt=h.stopPropagation)==null||mt.call(h);try{await Le(Mt),s("toast",{message:Ee("sessionPanel.codeCopied"),type:"success"})}catch{s("toast",{message:Ee("errors.requestFailed"),type:"warning"})}}}function pt(){if(!T.value.visible)return;const h=String(T.value.content||"").replace(/\u200b/g,"").trim();if(!h){j({clearBrowserSelection:!0});return}s("insert-code-context",{source:"response",content:h}),j({clearBrowserSelection:!0})}function V(h={}){if(h!=null&&h.errorMessage)return;const Y=String((h==null?void 0:h.responseMessage)||"").replace(/\u200b/g,"").trim();Y&&s("insert-code-context",{source:"response",content:Y})}const X=W(()=>J.value.flatMap(h=>(Array.isArray(h==null?void 0:h.promptBlocks)?h.promptBlocks:[]).filter(Y=>(Y==null?void 0:Y.type)==="image").map(Y=>Y.content)));function de(h){const D=(Array.isArray(h==null?void 0:h.events)?h.events:[]).filter(be=>!ye(be));return $p(D)}function he(h){return Ge(h)}function Ue(h){return h!=null&&h.eventsLoaded?he(h)>0:Ye(h)}function Tt(h){return!!(h!=null&&h.eventsLoading)}function qt(h){return!!(h!=null&&h.eventsLoaded)&&de(h).length>0&&!nt(h)}function At(h){return!!(h!=null&&h.eventsLoaded)&&he(h)>0&&nt(h)}function Ot(h){return Ye(h)&&!(h!=null&&h.eventsLoaded)&&!(h!=null&&h.eventsLoading)}function Qt(h={}){return Nr(h,{defaultLabel:Ee("sessionPanel.defaultAgent")})}function nn(h={}){return!Kf(h)}function E(h={}){return"bg-[var(--theme-appPanelStrong)]"}function k(h=null){const Y=String((h==null?void 0:h.id)||"").trim();if(Y)return _e.value.find(be=>be.id===Y)||null;const D=String(ie.value||"").trim();return D?_e.value.find(be=>be.id===D)||null:Ke.value[0]||null}function K(h=null){const Y=k(h);return Y!=null&&Y.cwd?(it.value=Y.id,Pe.value=!0,!0):!1}function ae(){return I.value?!1:(Q(),!0)}function ee(){var h,Y;return Pe.value?(Pe.value=!1,!0):(Y=(h=Xe.value)==null?void 0:h.closeTopDialog)!=null&&Y.call(h)?!0:je.value?(l(),!0):!1}return t({closeTopDialog:ee,openProjectManager:ae,openSourceBrowser:K,send:L,scrollToBottom:Be,stop:tt}),(h,Y)=>(g(),x("section",Ip,[ue(ff,{open:Pe.value,session:a(_e).find(D=>D.id===it.value)||null,onInsertCodeContext:Y[0]||(Y[0]=D=>s("insert-code-context",D)),onClose:Y[1]||(Y[1]=D=>Pe.value=!1)},null,8,["open","session"]),ue(a(o),{ref_key:"managerDialogRef",ref:Xe,open:a(je),sessions:a(_e),workspaces:a(fe),"selected-session-id":a(ie),"selection-locked":e.sessionSelectionLocked,"selection-lock-reason":e.sessionSelectionLockReason,loading:a(pe),sending:a(ve),"on-refresh":a(ge),"on-create":a(v),"on-update":a(A),"on-delete":a(P),"on-reset":a(ne),onClose:a(l),onOpenSourceBrowser:Y[2]||(Y[2]=D=>K(D)),onProjectCreated:Y[3]||(Y[3]=D=>s("project-created",D)),onSelectSession:a(y)},null,8,["open","sessions","workspaces","selected-session-id","selection-locked","selection-lock-reason","loading","sending","on-refresh","on-create","on-update","on-delete","on-reset","onClose","onSelectSession"]),i("div",Pp,[i("div",Dp,[i("div",Lp,[i("div",{class:"min-w-0 flex-1",title:a(G)||""},[ue(Vu,{modelValue:a(ie),"onUpdate:modelValue":Y[4]||(Y[4]=D=>_a(ie)?ie.value=D:null),sessions:a(Ke),loading:a(pe),disabled:a(ve)||a(I)||e.sessionSelectionLocked,onRefreshIntent:a(le)},null,8,["modelValue","sessions","loading","disabled","onRefreshIntent"])],8,Bp),i("div",Mp,[i("button",{type:"button",class:Se(["tool-button inline-flex h-9 w-9 items-center justify-center whitespace-nowrap px-0 py-0 text-xs",a(_)?"tool-button-accent-subtle":""]),"aria-pressed":a(_)?"true":"false","aria-label":a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),title:a(_)?a(Ee)("sessionPanel.hideProcessToggle"):a(Ee)("sessionPanel.showProcessToggle"),onClick:Y[5]||(Y[5]=(...D)=>a(xe)&&a(xe)(...D))},[a(_)?(g(),Ce(a(Da),{key:0,class:"h-4 w-4"})):(g(),Ce(a(La),{key:1,class:"h-4 w-4"}))],10,Rp),e.diffSupported?(g(),x("button",{key:0,type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:!e.taskSlug,onClick:_t},[ue(a(Uo),{class:"h-4 w-4"}),Y[17]||(Y[17]=i("span",{class:"sm:hidden"},"代码",-1)),i("span",Op,S(a(Ee)("sessionPanel.diff")),1)],8,Np)):me("",!0),i("button",{type:"button",class:"tool-button inline-flex items-center gap-1.5 whitespace-nowrap px-2.5 py-2 text-xs sm:gap-2 sm:px-3",disabled:a(I),onClick:Y[6]||(Y[6]=(...D)=>a(Q)&&a(Q)(...D))},[ue(a(Zn),{class:"h-4 w-4"}),Y[18]||(Y[18]=i("span",{class:"sm:hidden"},"项目",-1)),i("span",Fp,S(a(Ee)("sessionPanel.manageProjects")),1)],8,jp)])]),wt.value?(g(),x("div",{key:0,class:"flex max-w-full items-center gap-1.5 overflow-x-auto pb-0.5","aria-label":a(Ee)("sessionPanel.agentFilter")},[i("button",{type:"button",class:Se(["theme-agent-selector-button",Ne.value==="all"?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value==="all"?"true":"false",onClick:Y[7]||(Y[7]=D=>Ne.value="all")},S(a(Ee)("sessionPanel.allAgents")),11,Vp),(g(!0),x(et,null,ut(dt.value,D=>(g(),x("button",{key:D.engine,type:"button",class:Se(["theme-agent-selector-button",Ne.value===D.engine?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":Ne.value===D.engine?"true":"false",title:Qt(D),onClick:be=>Ne.value=D.engine},S(Qt(D)),11,zp))),128))],8,Up)):me("",!0),a(De)?(g(),x("p",Hp,[ue(a(_o),{class:"h-4 w-4"}),i("span",null,S(a(De)),1)])):me("",!0)])]),i("div",qp,[i("div",{ref_key:"transcriptRef",ref:R,"data-promptx-transcript":"1",class:"workbench-transcript relative flex h-full flex-col gap-3 overflow-x-hidden overflow-y-auto px-4 py-4",onScroll:Y[9]||(Y[9]=(...D)=>a(O)&&a(O)(...D)),onTouchstartPassive:Y[10]||(Y[10]=(...D)=>a(se)&&a(se)(...D)),onTouchmovePassive:Y[11]||(Y[11]=(...D)=>a(U)&&a(U)(...D)),onTouchendPassive:Y[12]||(Y[12]=(...D)=>a(z)&&a(z)(...D)),onTouchcancelPassive:Y[13]||(Y[13]=(...D)=>a(z)&&a(z)(...D))},[a(J).length?Ct.value.length?me("",!0):(g(),x("div",Wp,S(a(Ee)("sessionPanel.emptyAgentFilter")),1)):(g(),x("div",Kp,S(a(Ee)("sessionPanel.empty")),1)),(g(!0),x(et,null,ut(Ct.value,D=>(g(),x("div",{key:D.id,"data-promptx-turn":"1","data-turn-id":D.id,"data-run-id":D.runId||"",class:"flex min-w-0 flex-col gap-3"},[i("div",Xp,[i("div",Yp,[i("div",Jp,[i("span",Qp,S(Oe(D)),1),i("div",Zp,[ot(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>xt(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.insert")),1)],8,em)):me("",!0),i("span",null,S(a(c)(D.startedAt)),1)])]),i("div",tm,[Array.isArray(D.promptBlocks)&&D.promptBlocks.length?(g(),x("div",nm,[(g(!0),x(et,null,ut(D.promptBlocks,(be,Mt)=>(g(),x(et,{key:`${D.id}-prompt-${Mt}`},[be.type==="text"||be.type==="imported_text"?(g(),x("pre",sm,S(be.content),1)):(g(),x("button",{key:1,type:"button",class:"inline-flex cursor-zoom-in justify-center rounded-sm",onClick:jt=>re(be.content)},[i("img",{src:be.content,alt:a(Ee)("sessionPanel.promptImageAlt"),class:"max-h-52 w-auto max-w-full rounded-sm object-contain shadow-sm"},null,8,rm)],8,om))],64))),128))])):(g(),x("pre",am,S(D.prompt),1))])])]),a(_)&&nn(D)?(g(),x("div",im,[i("div",{class:Se(["transcript-card transcript-card--process min-w-0 w-full rounded-sm px-4 py-3",a(p)(D)])},[i("div",lm,[i("span",um,S(a(Ee)("sessionPanel.processTitle")),1),i("div",cm,[Ue(D)?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",disabled:D.eventsLoading,onClick:be=>a(yt)(D)},[Tt(D)?(g(),Ce(a(Ht),{key:0,class:"h-3 w-3 animate-spin"})):a(nt)(D)?(g(),Ce(a(ko),{key:1,class:"h-3 w-3"})):(g(),Ce(a(Ba),{key:2,class:"h-3 w-3"})),i("span",null,S(D.eventsLoading?a(Ee)("sessionPanel.loading"):a(nt)(D)?`${a(Ee)("sessionPanel.expand")} (${he(D)})`:a(Ee)("sessionPanel.collapse")),1)],8,dm)):me("",!0),i("span",null,S(a(w)(D)),1)])]),Tt(D)?(g(),x("div",fm,S(a(Ee)("sessionPanel.loadingEvents")),1)):qt(D)?(g(),x("div",pm,[(g(!0),x(et,null,ut(de(D),be=>(g(),x("div",{key:be.id,class:Se(["transcript-event-card min-w-0 rounded-sm px-3 py-2",E(be)])},[i("div",mm,S(be.title),1),be.detail||Array.isArray(be.detailBlocks)&&be.detailBlocks.length?(g(),Ce(zc,{key:0,detail:be.detail,blocks:be.detailBlocks,kind:be.kind,class:"mt-2"},null,8,["detail","blocks","kind"])):me("",!0)],2))),128))])):At(D)||Ot(D)?(g(),x("div",gm,S(D.eventsLoaded?a(Ee)("sessionPanel.hiddenEventsLoaded",{count:he(D)}):a(Ee)("sessionPanel.hiddenEventsLoadLater",{count:he(D)})),1)):(g(),x("p",hm,S(["queued","starting","running","stopping"].includes(D.status)?a(Ee)("sessionPanel.waitingEvents",{agent:a(d)(D)}):a(Ee)("sessionPanel.noEvents")),1)),a(F)(D)?(g(),x("div",vm,[a(b)(D)?(g(),x("div",ym,S(a(b)(D)),1)):me("",!0),a(f)(D)?(g(),x("div",Sm,S(a(f)(D)),1)):me("",!0),a(m)(D).length?(g(),x("div",wm,[(g(!0),x(et,null,ut(a(m)(D),be=>(g(),x("span",{key:be.key,class:"transcript-card__pill inline-flex items-center gap-1 rounded-sm border border-dashed border-[var(--theme-borderDefault)] px-2 py-1"},[i("span",null,S(be.label),1),i("span",xm,S(be.value),1)]))),128))])):me("",!0)])):me("",!0)],2)])):me("",!0),a(Fe)(D)?(g(),x("div",bm,[i("div",{class:Se(["transcript-card transcript-card--response min-w-0 w-full rounded-sm px-4 py-3 text-sm leading-7",D.errorMessage?"bg-[var(--theme-dangerSoft)] text-[var(--theme-dangerText)]":"bg-[var(--theme-responseBg)] text-[var(--theme-responseText)]"])},[i("div",km,[i("span",_m,S(Re(D)),1),i("div",Tm,[e.diffSupported&&D.runId?(g(),x("button",{key:0,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>ft(D)},[ue(a(Uo),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.view")),1)],8,Cm)):me("",!0),D.responseMessage&&!D.errorMessage?(g(),x("button",{key:1,type:"button",class:"transcript-card__toggle inline-flex items-center gap-1 rounded-sm px-2 py-1 text-[11px] transition hover:bg-[var(--theme-appPanelStrong)]",onClick:be=>V(D)},[ue(a(Ps),{class:"h-3 w-3"}),i("span",null,S(a(Ee)("sessionPanel.insert")),1)],8,Em)):me("",!0),i("span",null,S(a(c)(D.finishedAt||D.startedAt)),1)])]),i("div",Am,[D.errorMessage?(g(),x("div",$m,S(D.errorMessage),1)):(g(),x("div",{key:1,class:"prose-like codex-markdown","data-response-selection-root":"1",onMouseup:Y[8]||(Y[8]=(...be)=>a(te)&&a(te)(...be)),onClick:Et,innerHTML:a(Bt)(D)},null,40,Im))])],2)])):me("",!0)],8,Gp))),128)),a(T).visible?(g(),Ce(Gr,{key:2,top:a(T).top,left:a(T).left,label:a(Ee)("sourceBrowser.insertSelection"),onClick:pt},null,8,["top","left","label"])):me("",!0)],544),i("div",Pm,[a(He)?(g(),x("button",{key:0,type:"button",class:Se([a(ve)?"mb-10 sm:mb-8":"","tool-button pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur"]),onClick:Y[14]||(Y[14]=(...D)=>a(Be)&&a(Be)(...D))},[ue(a(Ma),{class:"h-3.5 w-3.5"}),i("span",null,S(a(Ee)("sessionPanel.jumpToLatest")),1)],2)):me("",!0),a(ve)?(g(),x("button",{key:1,type:"button",class:"tool-button tool-button-warning-subtle pointer-events-auto inline-flex items-center gap-1.5 border-[var(--theme-borderStrong)] bg-[var(--theme-appOverlay)] px-2.5 py-1.5 text-[11px] shadow-sm backdrop-blur",disabled:a(H),onClick:Y[15]||(Y[15]=(...D)=>a(tt)&&a(tt)(...D))},[a(H)?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Ra),{key:1,class:"h-3.5 w-3.5"})),i("span",null,S(a(H)?a(Ee)("sessionPanel.stopping"):a(Ee)("sessionPanel.stop")),1),a(H)?me("",!0):(g(),x("span",Lm,[...Y[19]||(Y[19]=[i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1),i("span",{class:"task-loading-dots__dot"},null,-1)])]))],8,Dm)):me("",!0)])]),ue(Or,{modelValue:Me.value,"onUpdate:modelValue":Y[16]||(Y[16]=D=>Me.value=D),images:X.value},null,8,["modelValue","images"])]))}},Mm={key:0,class:"h-full min-h-0"},Rm={key:1,class:"panel theme-muted-text flex h-full items-center px-5 py-4 text-sm"},lr={__name:"WorkbenchActivityPanel",props:{taskSlug:{type:String,default:""},buildPrompt:{type:Function,default:null},buildPromptBlocks:{type:Function,default:null},selectedSessionId:{type:String,default:""},selectedAgentEngine:{type:String,default:""},sessionSelectionLocked:{type:Boolean,default:!1},sessionSelectionLockReason:{type:String,default:""},diffSupported:{type:Boolean,default:!1},taskRunning:{type:Boolean,default:!1},emptyMessage:{type:String,default:""}},emits:["agent-bindings-change","insert-code-context","sending-change","project-created","selected-session-change","open-diff","toast","update:selectedAgentEngine"],setup(e,{expose:t,emit:n}){const o=n,s=q(null);function r(){var m,f;return(f=(m=s.value)==null?void 0:m.send)==null?void 0:f.call(m)}function l(){var m,f;(f=(m=s.value)==null?void 0:m.stop)==null||f.call(m)}function c(){var m,f;(f=(m=s.value)==null?void 0:m.scrollToBottom)==null||f.call(m)}function p(){var m,f;return((f=(m=s.value)==null?void 0:m.openProjectManager)==null?void 0:f.call(m))||!1}function w(){var m,f;return((f=(m=s.value)==null?void 0:m.openSourceBrowser)==null?void 0:f.call(m))||!1}function d(){var m,f;return((f=(m=s.value)==null?void 0:m.closeTopDialog)==null?void 0:f.call(m))||!1}return t({closeTopDialog:d,openProjectManager:p,openSourceBrowser:w,send:r,stop:l,scrollToBottom:c}),(m,f)=>e.taskSlug?(g(),x("div",Mm,[ue(Bm,{ref_key:"panelRef",ref:s,active:!!e.taskSlug,"task-slug":e.taskSlug,"build-prompt":e.buildPrompt||(()=>""),"build-prompt-blocks":e.buildPromptBlocks||(()=>[]),"selected-session-id":e.selectedSessionId,"selected-agent-engine":e.selectedAgentEngine,"session-selection-locked":e.sessionSelectionLocked,"session-selection-lock-reason":e.sessionSelectionLockReason,"diff-supported":e.diffSupported,"task-running":e.taskRunning,onAgentBindingsChange:f[0]||(f[0]=b=>o("agent-bindings-change",b)),onInsertCodeContext:f[1]||(f[1]=b=>o("insert-code-context",b)),onProjectCreated:f[2]||(f[2]=b=>o("project-created",b)),onSendingChange:f[3]||(f[3]=b=>o("sending-change",b)),onSelectedSessionChange:f[4]||(f[4]=b=>o("selected-session-change",b)),"onUpdate:selectedAgentEngine":f[5]||(f[5]=b=>o("update:selectedAgentEngine",b)),onOpenDiff:f[6]||(f[6]=b=>o("open-diff",b)),onToast:f[7]||(f[7]=b=>o("toast",b))},null,8,["active","task-slug","build-prompt","build-prompt-blocks","selected-session-id","selected-agent-engine","session-selection-locked","session-selection-lock-reason","diff-supported","task-running"])])):e.emptyMessage?(g(),x("section",Rm,S(e.emptyMessage),1)):me("",!0)}},Nm=["title"],Om={class:"flex min-w-0 items-center gap-1.5"},jm=["aria-pressed","title","data-agent-engine","onClick"],ur={__name:"WorkbenchAgentSelector",props:{agentBindings:{type:Array,default:()=>[]},selectedAgentEngine:{type:String,default:""},align:{type:String,default:"start"}},emits:["update:selectedAgentEngine"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>{const d=new Set;return(Array.isArray(n.agentBindings)?n.agentBindings:[]).filter(m=>{const f=String((m==null?void 0:m.engine)||"").trim();return!f||d.has(f)?!1:(d.add(f),!0)})}),l=W(()=>r.value.length>1),c=W(()=>{var m,f;const d=String(n.selectedAgentEngine||"").trim();return r.value.some(b=>b.engine===d)?d:((m=r.value.find(b=>b.isDefault))==null?void 0:m.engine)||((f=r.value[0])==null?void 0:f.engine)||""}),p=W(()=>n.align==="end"?"sm:justify-end":n.align==="center"?"sm:justify-center":"sm:justify-start");function w(d={}){return Nr(d,{prefix:"→ ",defaultLabel:s("sessionPanel.defaultAgent")})}return(d,m)=>l.value?(g(),x("div",{key:0,class:Se(["flex w-full overflow-x-auto pb-0.5",p.value]),title:a(s)("editor.selectAgent"),"data-promptx-agent-targets":"",onMousedown:m[1]||(m[1]=Qe(()=>{},["stop"]))},[i("div",Om,[(g(!0),x(et,null,ut(r.value,f=>(g(),x("button",{key:f.engine,type:"button",class:Se(["theme-agent-selector-button",f.engine===c.value?"theme-filter-active":"theme-filter-idle"]),"aria-pressed":f.engine===c.value,title:w(f),"data-agent-engine":f.engine,onMousedown:m[0]||(m[0]=Qe(()=>{},["prevent"])),onClick:b=>o("update:selectedAgentEngine",f.engine)},S(w(f)),43,jm))),128))])],42,Nm)):me("",!0)}},Fm={class:"flex w-full flex-col gap-2 sm:w-auto sm:flex-row sm:flex-wrap sm:items-center sm:justify-end sm:gap-2","data-promptx-editor-actions":""},Um={class:"grid w-full grid-cols-5 gap-2 sm:flex sm:w-full sm:flex-wrap sm:justify-end sm:gap-2"},Vm=["disabled","title","aria-label"],zm={class:"sr-only sm:not-sr-only sm:inline"},Hm=["title","aria-label"],qm={class:"sr-only sm:not-sr-only sm:inline"},Km=["disabled","title","aria-label"],Wm={class:"sr-only sm:not-sr-only sm:inline"},Gm=["title","aria-label"],Xm={class:"sr-only sm:not-sr-only sm:inline"},Ym={key:0,class:"absolute right-1 top-1 min-w-[1rem] rounded-full bg-[var(--theme-primaryBg)] px-1 text-[10px] font-semibold leading-4 text-[var(--theme-primaryText)] sm:hidden"},Jm=["disabled","title","aria-label"],Qm={class:"sr-only sm:not-sr-only sm:inline"},cr={__name:"WorkbenchEditorActions",props:{canAddTodo:{type:Boolean,default:!1},uploading:{type:Boolean,default:!1},isCurrentTaskSending:{type:Boolean,default:!1},sendState:{type:String,default:"idle"},todoCount:{type:Number,default:0}},emits:["add-todo","open-file-picker","clear-request","copy-request","manage-todo","send-request"],setup(e,{emit:t}){const n=e,o=t,{t:s}=St(),r=W(()=>n.sendState==="sending"||n.sendState==="running");function l(){return n.todoCount>0?s("editor.todoWithCount",{count:n.todoCount}):s("editor.todo")}return(c,p)=>(g(),x("div",Fm,[i("div",Um,[i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.uploading,title:a(s)("editor.chooseFiles"),"aria-label":a(s)("editor.chooseFiles"),"data-promptx-editor-action":"files",onMousedown:p[0]||(p[0]=Qe(()=>{},["prevent"])),onClick:p[1]||(p[1]=w=>o("open-file-picker"))},[e.uploading?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(Na),{key:1,class:"h-4 w-4"})),i("span",zm,S(a(s)("editor.chooseFiles")),1)],40,Vm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:a(s)("editor.clear"),"aria-label":a(s)("editor.clear"),"data-promptx-editor-action":"clear",onMousedown:p[2]||(p[2]=Qe(()=>{},["prevent"])),onClick:p[3]||(p[3]=w=>o("clear-request"))},[ue(a(Oa),{class:"h-4 w-4"}),i("span",qm,S(a(s)("editor.clear")),1)],40,Hm),i("button",{type:"button",class:"tool-button inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:!e.canAddTodo,title:a(s)("editor.todo"),"aria-label":a(s)("editor.todo"),"data-promptx-editor-action":"todo-add",onMousedown:p[4]||(p[4]=Qe(()=>{},["prevent"])),onClick:p[5]||(p[5]=w=>o("add-todo"))},[ue(a(Ps),{class:"h-4 w-4"}),i("span",Wm,S(a(s)("editor.todo")),1)],40,Km),i("button",{type:"button",class:"tool-button relative inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",title:l(),"aria-label":l(),"data-promptx-editor-action":"todo-manage",onMousedown:p[6]||(p[6]=Qe(()=>{},["prevent"])),onClick:p[7]||(p[7]=w=>o("manage-todo"))},[ue(a(Ar),{class:"h-4 w-4"}),i("span",Xm,S(l()),1),e.todoCount>0?(g(),x("span",Ym,S(e.todoCount>9?"9+":e.todoCount),1)):me("",!0)],40,Gm),i("button",{type:"button",class:"tool-button tool-button-primary inline-flex h-9 min-w-0 items-center justify-center gap-1.5 px-0 text-xs sm:w-auto sm:px-3",disabled:e.isCurrentTaskSending,title:a(s)("editor.send"),"aria-label":a(s)("editor.send"),"data-promptx-editor-action":"send",onMousedown:p[8]||(p[8]=Qe(()=>{},["prevent"])),onClick:p[9]||(p[9]=w=>o("send-request"))},[r.value?(g(),Ce(a(Ht),{key:0,class:"h-4 w-4 animate-spin"})):(g(),Ce(a(ja),{key:1,class:"h-4 w-4"})),i("span",Qm,S(a(s)("editor.send")),1)],40,Jm)])]))}};function Zm(e){const{props:t,panelRef:n,onClose:o}=e,s=q({left:"12px",top:"12px",width:"560px",maxHeight:"420px"}),r=q(!1),l=q("bottom");function c(){o==null||o()}function p(b=!1){const v=window.innerWidth,P=window.innerHeight,ne=12,y=8,L=320,O=560,z=420,U=180,se=Math.min(O,Math.max(L,v-ne*2)),A=Math.min(se,v-ne*2),G=t.anchorRect||{left:(v-A)/2,top:P/2,bottom:P/2};let ce=G.left;ce+A>v-ne&&(ce=v-ne-A),ce<ne&&(ce=ne);const pe=Math.max(0,P-ne-(G.bottom+y)),I=Math.max(0,G.top-y-ne);b?l.value=pe>=I?"bottom":"top":l.value==="bottom"&&pe<U&&I>pe+24?l.value="top":l.value==="top"&&I<U&&pe>I+24&&(l.value="bottom");const Q=l.value,le=Q==="bottom"?pe:I,ie=Math.max(140,P-ne*2),ve=Math.min(ie,Math.max(Math.min(z,le||z),U)),_={left:`${Math.round(ce)}px`,width:`${Math.round(A)}px`,maxHeight:`${Math.round(ve)}px`,top:"auto",bottom:"auto"};return Q==="bottom"?_.top=`${Math.round(Math.max(ne,G.bottom+y))}px`:_.bottom=`${Math.round(Math.max(ne,P-G.top+y))}px`,_}function w(b=!1){const v=p(b);s.value={...s.value,left:v.left,top:v.top,bottom:v.bottom,width:v.width,maxHeight:v.maxHeight}}function d(){return!t.open||!t.anchorRect?!1:(l.value="bottom",w(!0),r.value=!0,!0)}function m(){r.value=!1}function f(b){!t.open||!n.value||n.value.contains(b.target)||c()}return dn(()=>{document.addEventListener("pointerdown",f)}),It(()=>{document.removeEventListener("pointerdown",f)}),{closePicker:c,initializePanel:d,panelReady:r,panelStyle:s,resetPanel:m,updatePanelPosition:w}}function eg(e){const{props:t,panelRef:n,onClose:o,onSelect:s}=e,{closePicker:r,initializePanel:l,panelReady:c,panelStyle:p,resetPanel:w,updatePanelPosition:d}=Zm({props:t,panelRef:n,onClose:o}),m=Qr({getMode:()=>String(t.query||"").trim()?"search":"tree",props:t,onSelect:s});return $e(()=>t.open,f=>{if(!f){m.resetData(),w();return}w(),t.anchorRect&&l()&&m.initializeData()},{flush:"sync"}),$e(()=>t.anchorRect,f=>{if(!(!t.open||!f)){if(!c.value){l()&&m.initializeData();return}d(!1)}},{flush:"sync"}),$e(()=>t.sessionId,()=>{m.handleSessionChange()},{flush:"sync",immediate:!0}),$e(()=>t.query,()=>{m.handleQueryChange()},{immediate:!0}),$e(m.visibleItems,()=>{m.handleVisibleItemsChange()},{immediate:!0}),{...m,closePicker:r,panelReady:c,panelStyle:p}}const tg={class:"theme-divider flex items-center justify-end gap-2 border-b border-dashed px-2.5 py-2"},ng={class:"flex shrink-0 items-center gap-2"},sg={class:"min-h-0 flex-1 overflow-y-auto p-2"},og={key:0,class:"theme-empty-state px-3 py-4 text-xs"},rg={key:1,class:"theme-status-danger rounded-sm border border-dashed px-3 py-3 text-xs"},ag={key:2,class:"theme-empty-state px-3 py-4 text-xs"},ig={key:3,class:"theme-empty-state px-3 py-4 text-xs"},lg={key:4,class:"theme-empty-state px-3 py-4 text-xs"},ug={key:5,class:"space-y-1"},cg={key:0,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},dg=["onClick"],fg={class:"min-w-0 flex-1"},pg=["innerHTML"],mg=["innerHTML"],gg={key:1,class:"theme-muted-text px-1 py-0.5 text-[10px] uppercase tracking-[0.12em]"},hg=["onClick"],vg={class:"min-w-0 flex-1"},yg=["innerHTML"],Sg=["innerHTML"],wg={key:6,class:"space-y-1"},xg={class:"flex items-start gap-1.5"},bg=["onClick"],kg={key:1,class:"block h-5 w-5 shrink-0"},_g=["onClick"],Tg={class:"min-w-0 flex-1"},Cg={class:"flex items-center gap-1.5"},Eg={__name:"PathMentionPicker",props:{open:{type:Boolean,default:!1},sessionId:{type:String,default:""},query:{type:String,default:""},anchorRect:{type:Object,default:null}},emits:["close","select"],setup(e,{expose:t,emit:n}){const o=e,s=n,r=q(null),{t:l}=St(),{activeKey:c,closePicker:p,collapseActiveDirectory:w,confirmActive:d,currentError:m,currentLoading:f,emitSelect:b,expandActiveDirectory:v,getDisplayName:P,getHighlightedName:ne,getHighlightedPath:y,moveActive:L,normalSearchItems:O,normalizedQuery:z,panelReady:U,panelStyle:se,recentSearchItems:A,setItemRef:G,showSearchEmptyState:ce,showTreeEmptyState:pe,toggleDirectory:I,treeItems:Q,visibleItems:le}=eg({props:o,panelRef:r,onClose:()=>s("close"),onSelect:ie=>s("select",ie)});return t({collapseActiveDirectory:w,moveActive:L,confirmActive:d,expandActiveDirectory:v}),(ie,ve)=>(g(),Ce(os,{to:"body"},[e.open&&a(U)?(g(),x("div",{key:0,ref_key:"panelRef",ref:r,class:"theme-popover fixed z-40 flex flex-col overflow-hidden rounded-sm border shadow-lg",style:kn(a(se))},[i("div",tg,[i("div",ng,[i("div",{class:Se(["theme-muted-text inline-flex h-7 w-7 items-center justify-center",a(f)?"opacity-100":"opacity-0"])},[ue(a(Ht),{class:"h-3.5 w-3.5 animate-spin"})],2),i("button",{type:"button",class:"tool-button inline-flex h-7 w-7 items-center justify-center",onClick:ve[0]||(ve[0]=(..._)=>a(p)&&a(p)(..._))},[ue(a(Tr),{class:"h-4 w-4"})])])]),i("div",sg,[e.sessionId?a(m)?(g(),x("div",rg,S(a(m)),1)):a(ce)?(g(),x("div",ag,S(a(l)("pathPicker.noResults")),1)):a(pe)?(g(),x("div",ig,S(a(l)("pathPicker.emptyDirectory")),1)):a(f)&&!a(le).length?(g(),x("div",lg,S(a(l)("pathPicker.loading")),1)):a(z)?(g(),x("div",ug,[a(A).length?(g(),x("div",cg,S(a(l)("pathPicker.recent")),1)):me("",!0),(g(!0),x(et,null,ut(a(A),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",fg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,pg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,mg)])],10,dg))),128)),a(z)&&a(O).length?(g(),x("div",gg,S(a(l)("pathPicker.results")),1)):me("",!0),(g(!0),x(et,null,ut(a(O),_=>(g(),x("button",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),type:"button",class:Se(["theme-list-row focus:outline-none",a(c)===_.path?"theme-list-item-active":"theme-list-item-hover"]),onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:"theme-list-item-icon"})),i("div",vg,[i("div",null,[i("span",{class:"theme-list-item-title block break-all",innerHTML:a(ne)(_)},null,8,yg)]),i("div",{class:"theme-list-item-subtitle theme-list-item-subtitle--mono break-all",innerHTML:a(y)(_)},null,8,Sg)])],10,hg))),128))])):(g(),x("div",wg,[(g(!0),x(et,null,ut(a(Q),_=>(g(),x("div",{key:_.path,ref_for:!0,ref:H=>a(G)(_.path,H),class:Se(["theme-list-tree-item outline-none focus:outline-none focus-visible:outline-none",a(c)===_.path?"theme-list-item-active":_.type==="directory"&&_.expanded?"theme-list-item-expanded":"theme-list-item-hover"]),style:kn({paddingLeft:`${_.depth*16+6}px`})},[i("div",xg,[_.type==="directory"?(g(),x("button",{key:0,type:"button",class:"theme-icon-button h-5 w-5 shrink-0",onClick:Qe(H=>a(I)(_.path),["stop"])},[_.loading?(g(),Ce(a(Ht),{key:0,class:"h-3.5 w-3.5 animate-spin"})):(g(),Ce(a(Er),{key:1,class:Se(["h-3.5 w-3.5 transition",_.expanded?"rotate-90 text-[var(--theme-textPrimary)]":""])},null,8,["class"]))],8,bg)):(g(),x("span",kg)),i("button",{type:"button",class:"flex min-w-0 flex-1 items-start gap-1.5 rounded-sm px-0.5 py-0.5 text-left",onClick:H=>a(b)(_)},[(g(),Ce(cn(_.type==="directory"?a(Dn):a(Sn)),{class:Se(["h-4 w-4 shrink-0",_.type==="directory"&&_.expanded?"text-[var(--theme-textPrimary)]":"text-[var(--theme-textMuted)]"])},null,8,["class"])),i("div",Tg,[i("div",Cg,[i("span",{class:Se(["theme-list-item-title truncate",_.type==="directory"?"font-medium text-[var(--theme-textPrimary)]":"text-[var(--theme-textPrimary)]"])},S(a(P)(_)),3)])])],8,_g)])],6))),128))])):(g(),x("div",og,S(a(l)("pathPicker.selectProjectFirst")),1))])],4)):me("",!0)]))}},Ag={__name:"TiptapTextBlockView",props:To,setup(e){return(t,n)=>(g(),Ce(a(Co),{"data-promptx-node":"text"},{default:Je(()=>[ue(a(Pr),{"data-promptx-node-content":"text",class:"min-h-[40px] whitespace-pre-wrap break-words border-0 bg-transparent p-0 text-[15px] leading-8 text-[var(--theme-textPrimary)] outline-none",as:"div"})]),_:1}))}},ya={__name:"TiptapSpecialBlockFrame",props:{frameClass:{type:String,default:""},headerPaddingClass:{type:String,default:"px-4 py-3"},headerClass:{type:String,default:""},selected:{type:Boolean,default:!1}},setup(e){const t=e,n=W(()=>t.selected?"ring-1 ring-inset ring-[var(--theme-borderStrong)]":""),o=W(()=>t.selected?"opacity-100":"opacity-100 sm:opacity-45 sm:group-hover:opacity-100 sm:focus-within:opacity-100");return(s,r)=>(g(),x("div",{class:Se(["overflow-hidden rounded-sm transition",[e.frameClass,n.value]])},[i("div",{class:Se(["theme-divider border-b text-xs",[e.headerPaddingClass,e.headerClass]])},[Jt(s.$slots,"header",{actionsStateClass:o.value})],2),Jt(s.$slots,"default")],2))}},kt={DOC:"doc",TEXT_BLOCK:"paragraph",IMPORTED_TEXT_BLOCK:"promptxImportedTextBlock",IMAGE_BLOCK:"promptxImageBlock",TEXT:"text",HARD_BREAK:"hardBreak"};function $g(){var e,t;return((t=(e=globalThis.crypto)==null?void 0:e.randomUUID)==null?void 0:t.call(e))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function Mn(e={}){return{...e,clientId:String((e==null?void 0:e.clientId)||(e==null?void 0:e.id)||$g()),meta:e!=null&&e.meta?{...e.meta}:{}}}function Pn(e=""){return Mn({type:$t.TEXT,content:e,meta:{}})}function hs(e){return e&&e.type!==$t.TEXT}function xn(e=[]){const t=Array.isArray(e)?e.filter(Boolean):[];if(!t.length)return[Pn("")];const n=[];return t.forEach((o,s)=>{const r=Mn(o),l=n[n.length-1];!l&&hs(r)&&n.push(Pn("")),l&&hs(l)&&hs(r)&&n.push(Pn("")),n.push(r),s===t.length-1&&hs(r)&&n.push(Pn(""))}),n}function So(e=""){const t=String(e||"").split(`
|
|
@@ -54,7 +54,7 @@ ${N("原始错误","Raw error")}: ${o.rawMessage}`:n}function yo(e,t=0){if(!e||t
|
|
|
54
54
|
`).trim()}function Cv(e,t){return Tv(e,t)}const xo="promptx:active-task-slug",Ev=150,Av=1500;function Rs(e=null){return!e||typeof e!="object"?null:{supported:!!e.supported,fileCount:Math.max(0,Number(e.fileCount)||0),additions:Math.max(0,Number(e.additions)||0),deletions:Math.max(0,Number(e.deletions)||0),statsComplete:!!e.statsComplete}}function un(e=[]){return(e||[]).map(t=>{var n,o;return{...t,clientId:String((t==null?void 0:t.clientId)||(t==null?void 0:t.id)||((o=(n=globalThis.crypto)==null?void 0:n.randomUUID)==null?void 0:o.call(n))||`block-${Date.now()}-${Math.random().toString(36).slice(2,8)}`),meta:t!=null&&t.meta?{...t.meta}:{}}})}function Nt(e=[]){return(e||[]).map(t=>({id:String((t==null?void 0:t.id)||"").trim(),createdAt:String((t==null?void 0:t.createdAt)||""),blocks:un((t==null?void 0:t.blocks)||[])}))}function hr(e={}){return{title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),blocks:un(e.blocks||[]),todoItems:Nt(e.todoItems||[])}}function wa(e=[]){return un(e).filter(t=>(t==null?void 0:t.type)===$t.IMAGE?!!String(t.content||"").trim():!!String((t==null?void 0:t.content)||"").trim())}function $v(e=[]){return wa(e).length>0}function Iv(){var t,n;const e=(n=(t=globalThis.crypto)==null?void 0:t.randomUUID)==null?void 0:n.call(t);return e?`todo-${e}`:`todo-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function vr(){return un([{type:$t.TEXT,content:"",meta:{}}])}function bo(e=[],t=16){return mi(e,t)||""}function Pv(e=[],t=120){const n=e.find(o=>((o==null?void 0:o.type)==="text"||(o==null?void 0:o.type)==="imported_text")&&String(o.content||"").trim());return String((n==null?void 0:n.content)||"").replace(/\s+/g," ").trim().slice(0,t)}function yr(e={},t=[]){const n=String((e==null?void 0:e.title)||"").trim();if(n)return n;const o=String((e==null?void 0:e.autoTitle)||"").trim();if(o)return o;const s=bo(t);if(s)return s;const r=String((e==null?void 0:e.preview)||"").trim();return r?r.slice(0,16):We("workbench.untitledTask")}function Ns(e={}){return!!(e!=null&&e.running)}function Dv(e={},t=!1){return t&&!Ns(e)?"sending":Ns(e)?"running":"idle"}function Lv(e=""){return["queued","starting","running","stopping"].includes(String(e||"").trim())}function Sr(e="",t=72){return String(e||"").replace(/\s+/g," ").trim().slice(0,t)}function Bv(e=[],t=[]){const n=Array.isArray(e)?[...e]:[],o=Array.isArray(t)?t.map(c=>String(c||"").trim()).filter(Boolean):[];if(!o.length)return n;const s=new Map(n.map(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p?[p,c]:null}).filter(Boolean)),r=o.map(c=>s.get(c)||null).filter(Boolean),l=n.filter(c=>{const p=String((c==null?void 0:c.slug)||"").trim();return p&&!o.includes(p)});return[...r,...l]}function wr(e=[],t=[]){const n=new Map((e||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim();return r?[r,s]:null}).filter(Boolean));return(t||[]).map(s=>{const r=String((s==null?void 0:s.slug)||"").trim(),l=String((s==null?void 0:s.codexSessionId)||"").trim();if(!r)return s;if(Object.prototype.hasOwnProperty.call(s,"workspaceDiffSummary"))return{...s,workspaceDiffSummary:Rs(s.workspaceDiffSummary)};if(!l)return{...s,workspaceDiffSummary:null};const c=n.get(r),p=String((c==null?void 0:c.codexSessionId)||"").trim();return p&&p===l?{...s,workspaceDiffSummary:Rs(c.workspaceDiffSummary)}:{...s,workspaceDiffSummary:null}})}function Mv(e=[],t=[]){const n=Array.isArray(e)?e:[],o=Array.isArray(t)?t:[];if(!o.length)return!1;if(n.length!==o.length)return!0;const s=new Map(n.map(r=>{const l=String((r==null?void 0:r.slug)||"").trim();return l?[l,r]:null}).filter(Boolean));return o.some(r=>{const l=String((r==null?void 0:r.slug)||"").trim();if(!l)return!0;const c=s.get(l);if(!c)return!0;const p=String((r==null?void 0:r.codexSessionId)||"").trim(),w=String((c==null?void 0:c.codexSessionId)||"").trim();return!!(p!==w||!!(r!=null&&r.running)!=!!(c!=null&&c.running)||p&&!Object.prototype.hasOwnProperty.call(c||{},"workspaceDiffSummary")||p&&(c==null?void 0:c.workspaceDiffSummary)==null)})}function ys(e){if(typeof window>"u")return;const t=String(e||"").trim();if(t){window.localStorage.setItem(xo,t);return}window.localStorage.removeItem(xo)}function Rv(){return typeof window>"u"?"":String(window.localStorage.getItem(xo)||"").trim()}function Nv(){if(typeof window>"u")return"";try{const e=new URL(window.location.href);return String(e.searchParams.get("task")||"").trim()}catch{return""}}function Ov(){if(!(typeof window>"u"))try{const e=new URL(window.location.href);if(!e.searchParams.has("task"))return;e.searchParams.delete("task");const t=`${e.pathname}${e.search}${e.hash}`;window.history.replaceState({},"",t||"/")}catch{}}function $n(e){const t={slug:e.slug,sortOrder:Number(e.sortOrder)||0,title:String(e.title||""),autoTitle:String(e.autoTitle||""),lastPromptPreview:String(e.lastPromptPreview||""),codexSessionId:String(e.codexSessionId||""),codexRunCount:Math.max(0,Number(e.codexRunCount)||0),todoCount:Math.max(0,Number(e.todoCount)||0),running:!!e.running,preview:String(e.lastPromptPreview||""),updatedAt:e.updatedAt||e.createdAt||new Date().toISOString(),createdAt:e.createdAt||e.updatedAt||new Date().toISOString(),automation:e!=null&&e.automation?{enabled:!!e.automation.enabled,cron:String(e.automation.cron||""),nextTriggerAt:String(e.automation.nextTriggerAt||"")}:void 0,notification:e!=null&&e.notification?{enabled:!!e.notification.enabled,channelType:String(e.notification.channelType||""),triggerOn:String(e.notification.triggerOn||""),lastStatus:String(e.notification.lastStatus||""),lastSentAt:String(e.notification.lastSentAt||"")}:void 0};return Object.prototype.hasOwnProperty.call(e,"workspaceDiffSummary")&&(t.workspaceDiffSummary=Rs(e.workspaceDiffSummary)),t}function jv(e={}){const{clearToast:t=()=>{},flashToast:n=()=>{},scrollCurrentPanelToBottom:o=()=>{}}=e,s=Io(),r=oa(),l=q(null),c=q([]),p=q({}),w=q({}),d=q({}),m=q(""),f=q({title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]}),b=q(!0),v=q(!1),P=q(!1),ne=q(!1),y=q(!1),L=q(!1),O=q(""),z=q(!1),U=q("");let se=null,A=null,G=0,ce=null,pe=0,I=null,Q=0,le={};const ie=W(()=>bo(f.value.blocks)),ve=W(()=>yr({title:f.value.title,autoTitle:f.value.autoTitle,preview:Pv(f.value.blocks)},f.value.blocks));function _(E,k={}){const K=String(E||"").trim();if(!K)return"";const ae=k.summary||Ae(K),ee=k.cachedDraft===void 0?Be(K):k.cachedDraft,h=K===m.value;return Object.prototype.hasOwnProperty.call(w.value,K)?String(w.value[K]||"").trim():h?String(f.value.codexSessionId||(ae==null?void 0:ae.codexSessionId)||"").trim():String((ee==null?void 0:ee.codexSessionId)||(ae==null?void 0:ae.codexSessionId)||"").trim()}const H=W(()=>_(m.value)),F=W(()=>Dv(Ae(m.value),d.value[m.value])),He=W(()=>F.value!=="idle"),De=W(()=>c.value.some(E=>Ns(E))||Object.values(d.value).some(Boolean)),Fe=W(()=>$v(f.value.blocks)),je=W(()=>Nt(f.value.todoItems)),Ke=W(()=>ve.value||We("workbench.untitledTask")),tt=W(()=>c.value.map(E=>it(E)));function xe(E=""){return!E||!E.startsWith(s)?E:E.slice(s.length)}function R(E=""){const k=String(E||"").replace(/\r\n/g,`
|
|
55
55
|
`).split(`
|
|
56
56
|
`);for(;k.length&&!String(k[0]||"").trim();)k.shift();for(;k.length&&!String(k[k.length-1]||"").trim();)k.pop();return k.join(`
|
|
57
|
-
`)}function J(E=[]){return E.map(k=>({id:Number.isInteger(Number(k==null?void 0:k.id))?Number(k.id):null,type:k==null?void 0:k.type,content:(k==null?void 0:k.type)==="image"?xe(k.content):R(k.content),meta:k!=null&&k.meta?{...k.meta}:{}}))}function fe(E=[]){return(E||[]).map(k=>({id:String((k==null?void 0:k.id)||"").trim(),createdAt:String((k==null?void 0:k.createdAt)||""),blocks:J((k==null?void 0:k.blocks)||[])}))}function _e(E=f.value.title,k=f.value.autoTitle,K=f.value.lastPromptPreview,ae=f.value.todoItems,ee=f.value.codexSessionId,h=f.value.blocks){return JSON.stringify({title:String(E||""),autoTitle:String(k||""),lastPromptPreview:String(K||""),todoItems:fe(ae),codexSessionId:String(ee||""),blocks:J(h)})}function ge(){return _e()!==U.value}function Ie(){var E,k;return!!((k=(E=l.value)==null?void 0:E.isEditing)!=null&&k.call(E))}function Ae(E){return c.value.find(k=>k.slug===E)||null}function Be(E){return E&&p.value[E]||null}function Xe(E,k=""){const K=String(E||"").trim();K&&(le={...le,[K]:String(k||"").trim()})}function Pe(E=""){var ee;const k=String(E||"").trim();if(!k)return!1;const K=String(((ee=Ae(k))==null?void 0:ee.updatedAt)||"").trim(),ae=String(le[k]||"").trim();return!!(K&&ae&&K===ae)}function it(E){const k=Be(E.slug),K=E.slug===m.value?f.value.blocks:(k==null?void 0:k.blocks)||[],ae=E.slug===m.value?f.value.title:(k==null?void 0:k.title)??E.title,ee=E.slug===m.value?f.value.autoTitle:(k==null?void 0:k.autoTitle)??E.autoTitle,h=E.slug===m.value?Nt(f.value.todoItems).length:Nt((k==null?void 0:k.todoItems)||[]).length||Number(E.todoCount||0),Y=E.slug===m.value?f.value.lastPromptPreview||E.lastPromptPreview||"":(k==null?void 0:k.lastPromptPreview)||E.lastPromptPreview||"",D=_(E.slug,{summary:E,cachedDraft:k});return{...E,title:ae,autoTitle:ee,todoCount:h,preview:Y,codexSessionId:D,sessionSelectionLocked:!!(D&&Number(E.codexRunCount||0)>0),sessionSelectionLockReason:D&&Number(E.codexRunCount||0)>0?We("taskActions.sessionLocked"):"",displayTitle:yr({title:ae,autoTitle:ee,preview:Y},K),sending:Ns(E)}}function Me(E,k={}){const{insertAtStart:K=!1}=k;if(!(E!=null&&E.slug))return;const ae=[...c.value],ee=ae.findIndex(h=>h.slug===E.slug);if(ee>=0){ae.splice(ee,1,{...ae[ee],...E}),c.value=ae;return}K?ae.unshift(E):ae.push(E),c.value=ae}function Ne(E,k){E&&(p.value={...p.value,[E]:hr(k)})}function Ee(E){return E?`${s}/api/tasks/${E}/raw`:`${s}/api/tasks/`}function lt(E=""){const k=String(E||"").trim();if(!k)return;const K=Ae(k),ae=r.getTaskRunChange(k);if(!K||!(ae!=null&&ae.status))return;const ee=Lv(ae.status);!!K.running!==ee&&Me({...K,running:ee})}function ht(E,k){d.value={...d.value,[E]:!!k}}function dt(E=c.value){const k={};(E||[]).forEach(K=>{K!=null&&K.slug&&(k[K.slug]=!!K.running)}),d.value=k}function wt(E,k){E&&(w.value={...w.value,[E]:String(k||"").trim()})}async function Ct(E,k){const K=String(E||"").trim();if(!K)return;const ae=String(k||"").trim(),ee=Ae(K),h=w.value[K]||(ee==null?void 0:ee.codexSessionId)||"";if(!!(h&&Number((ee==null?void 0:ee.codexRunCount)||0)>0)&&ae!==h){O.value=We("taskActions.sessionLocked");return}wt(K,ae);const D=Be(K);D&&Ne(K,{...D,codexSessionId:ae}),ee&&Me({...ee,codexSessionId:ae,workspaceDiffSummary:ae&&ae===h?ee.workspaceDiffSummary:null}),K===m.value&&(f.value={...f.value,codexSessionId:ae});try{await nl(K,ae)}catch(be){wt(K,h),D&&Ne(K,{...D,codexSessionId:h}),ee&&Me({...ee,codexSessionId:h}),K===m.value&&(f.value={...f.value,codexSessionId:h}),O.value=be.message}}function T(){se&&(window.clearTimeout(se),se=null)}function j(){ce&&(window.clearTimeout(ce),ce=null)}function te(){T(),!(v.value||!m.value)&&(se=window.setTimeout(()=>{Bt({auto:!0,silent:!0})},1500))}function ye(){if(!m.value)return;const E=Ae(m.value)||{slug:m.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};Me({...E,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Nt(f.value.todoItems).length,codexSessionId:H.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(E={}){const k=String((E==null?void 0:E.slug)||"").trim();if(!k)return;const K=$n(E);Me(K),Xe(k,K.updatedAt||E.updatedAt||""),k===m.value&&(Object.prototype.hasOwnProperty.call(E,"title")&&(f.value.title=String(E.title||"")),Object.prototype.hasOwnProperty.call(E,"autoTitle")&&(f.value.autoTitle=String(E.autoTitle||"")),Ne(k,{...f.value}))}function Re(E=[]){const k=new Map((E||[]).map(K=>{const ae=String((K==null?void 0:K.slug)||"").trim();return ae?[ae,Rs(K.workspaceDiffSummary)]:null}).filter(Boolean));k.size&&(c.value=c.value.map(K=>k.has(K.slug)?{...K,workspaceDiffSummary:k.get(K.slug)}:K))}async function Ge(E=c.value){const k=Array.isArray(E)?E:[],K=k.filter(ee=>String((ee==null?void 0:ee.codexSessionId)||"").trim()),ae=++pe;if(!K.length){c.value=k.map(ee=>Object.prototype.hasOwnProperty.call(ee,"workspaceDiffSummary")?ee:{...ee,workspaceDiffSummary:null});return}try{const ee=await Fi(k.length||30);if(ae!==pe)return;Re(ee.items||[])}catch{}}async function Ye(E={}){const{silent:k=!1}=E;k||(b.value=!0,O.value="");try{const K=c.value,ae=await ji(),ee=wr(K,(ae.items||[]).map($n));c.value=ee,dt(ee),Mv(K,ee)&&Ge(ee)}catch(K){k||(O.value=K.message)}finally{k||(b.value=!1)}}async function nt(E=[]){const k=Bv(c.value,E),K=c.value.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean),ae=k.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean);if(!ae.length||ae.join(",")===K.join(","))return!1;const ee=c.value;c.value=k;try{const h=await Vi(ae);Q=Date.now()+Av;const Y=wr(ee,(h.items||[]).map($n));return c.value=Y,dt(Y),!0}catch(h){return c.value=ee,O.value=h.message,!1}}async function yt(E=""){const k=String(m.value||"").trim(),K=String(E||"").trim();if(!k)return;if(!c.value.some(ee=>ee.slug===k)){if(c.value.length){await _t(c.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1;return}K&&K!==k||K&&(Ie()||ge()||z.value||y.value||L.value||v.value||await _t(k,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function st(E=""){const k=String(E||"").trim();I===null?I=k:I!==k&&(I=""),!ce&&(ce=window.setTimeout(async()=>{const K=I;I=null,ce=null,await Ye({silent:!0}),await yt(K||"")},Ev))}async function ft(E){const k=await Br(E),K=(k.blocks||[]).map(ee=>({...ee,content:ee.type==="image"?xs(ee.content):ee.content}));return{state:{title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:K,todoItems:Nt(k.todoItems||[])},summary:$n({...k,blocks:K}),updatedAt:String(k.updatedAt||"")}}async function _t(E,k={}){const{focusEditor:K=!1,force:ae=!1,skipIfDirtyOnApply:ee=!1,skipIfEditingOnApply:h=!1,scrollPanelToBottom:Y=!1}=k,D=String(E||"").trim();if(!D)return!1;const be=++G;v.value=!0,O.value="",t();try{const Mt=String(m.value||"").trim(),jt=Be(D),Ft=ae&&jt&&Pe(D);let Ut=ae&&!Ft?null:jt,Pt=null;if(!Ut){const mt=await ft(D);Ut=(mt==null?void 0:mt.state)||null,Pt=(mt==null?void 0:mt.summary)||null,Xe(D,(mt==null?void 0:mt.updatedAt)||(Pt==null?void 0:Pt.updatedAt)||"")}return be!==G||ee&&D===m.value&&(ge()||z.value)||h&&D===m.value&&Ie()?!1:(m.value=D,ys(D),f.value=hr(Ut),Ne(D,Ut),Pt&&Me(Pt),wt(D,Ut.codexSessionId),U.value=_e(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),z.value=!1,K&&at(()=>{var mt,Xt;return(Xt=(mt=l.value)==null?void 0:mt.focusEditor)==null?void 0:Xt.call(mt)}),(Y||D!==Mt)&&o(),!0)}catch(Mt){return be===G&&(O.value=Mt.message),!1}finally{be===G&&(v.value=!1)}}async function Bt(E={}){const{auto:k=!1,silent:K=!1}=E;return m.value?_e()===U.value?!0:A||(T(),y.value=!0,O.value="",A=(async()=>{try{const ee=await Mr(m.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Nt(f.value.todoItems),codexSessionId:H.value,expiry:"none",visibility:"private",blocks:J(f.value.blocks)}),h={title:String(ee.title||""),autoTitle:String(ee.autoTitle||""),lastPromptPreview:String(ee.lastPromptPreview||""),todoItems:Nt(ee.todoItems||f.value.todoItems||[]),codexSessionId:H.value||String(ee.codexSessionId||"").trim(),blocks:un(f.value.blocks)};return Ne(m.value,h),U.value=_e(h.title,h.autoTitle,h.lastPromptPreview,h.todoItems,h.codexSessionId,h.blocks),z.value=!1,Me($n(ee)),Xe(m.value,ee.updatedAt||""),!k&&!K&&n({message:We("taskActions.taskSaved"),type:"success"}),!0}catch(ee){return O.value=ee.message,!1}finally{y.value=!1,A=null,_e()!==U.value&&(z.value=!0,te())}})(),A):!1}async function re(){return L.value?(O.value=We("taskActions.fileProcessing"),!1):A||(z.value?Bt({auto:!1,silent:!0}):!0)}async function Le(){if(!await re()&&m.value)return!1;P.value=!0,O.value="";try{const E=await Ui({title:"",expiry:"none",visibility:"private"}),k={title:String(E.title||""),autoTitle:String(E.autoTitle||""),lastPromptPreview:String(E.lastPromptPreview||""),codexSessionId:String(E.codexSessionId||""),blocks:un(E.blocks||[]),todoItems:Nt(E.todoItems||[])};return Ne(E.slug,k),Me($n(E),{insertAtStart:!0}),await _t(E.slug,{focusEditor:!0}),n({message:We("taskActions.taskCreated"),type:"success"}),!0}catch(E){return O.value=E.message,!1}finally{P.value=!1}}async function ot(E){const k=String(E||"").trim();!k||k===m.value||!await re()||await _t(k)}async function xt(){if(m.value){ne.value=!0,O.value="";try{const E=m.value;await zi(E),c.value=c.value.filter(ee=>ee.slug!==E);const k={...p.value};delete k[E],p.value=k;const K={...w.value};delete K[E],w.value=K;const ae={...d.value};delete ae[E],d.value=ae,c.value.length?await _t(c.value[0].slug,{focusEditor:!0}):(m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1,await Le())}catch(E){O.value=E.message}finally{ne.value=!1}}}function Et(E={}){const{silent:k=!1}=E;m.value&&(f.value={...f.value,blocks:vr()},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var K,ae;(ae=(K=l.value)==null?void 0:K.focusEditor)==null||ae.call(K)}),k||n({message:We("taskActions.taskCleared"),type:"info"}))}function pt(){if(!m.value)return!1;const E=wa(f.value.blocks);return E.length?(f.value={...f.value,blocks:vr(),todoItems:[{id:Iv(),createdAt:new Date().toISOString(),blocks:E},...Nt(f.value.todoItems)]},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var k,K;(K=(k=l.value)==null?void 0:k.focusEditor)==null||K.call(k)}),n({message:We("taskActions.todoAdded"),type:"success"}),!0):!1}function V(E=""){const k=String(E||"").trim();if(!m.value||!k)return!1;const K=Nt(f.value.todoItems).filter(ae=>ae.id!==k);return K.length===Nt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:K},Ne(m.value,f.value),ye(),z.value=!0,!0)}function X(E=""){const k=String(E||"").trim();if(!m.value||!k)return null;const K=Nt(f.value.todoItems).find(ae=>ae.id===k);return K?(f.value={...f.value,blocks:un(K.blocks),todoItems:Nt(f.value.todoItems).filter(ae=>ae.id!==k)},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var ae,ee;(ee=(ae=l.value)==null?void 0:ae.focusEditor)==null||ee.call(ae)}),K):null}async function de(){var ee;if(await Ye(),!c.value.length){await Le();return}const E=Nv();if(E){const h=await _t(E,{focusEditor:!0,force:!0});if(Ov(),h)return}const k=((ee=c.value.find(h=>!!(h!=null&&h.running)))==null?void 0:ee.slug)||"",K=Rv(),ae=k||(c.value.some(h=>h.slug===K)?K:c.value[0].slug);await _t(ae,{focusEditor:!0,force:!0})}async function he(E){var k,K,ae;L.value=!0,O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Hi(Y);h.push({type:"image",content:xs(D.url),meta:{}})}(ae=l.value)==null||ae.insertUploadedBlocks(h),n({message:We("taskActions.imageInserted",{count:h.length,appended:ee}),type:"success"})}catch(ee){O.value=ee.message}finally{L.value=!1}}async function Ue(E){var k,K,ae;O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Y.text();D.trim()&&h.push({type:"imported_text",content:D,meta:{fileName:Y.name||We("workbench.untitledTask"),collapsed:!0}})}if(!h.length){n({message:We("taskActions.noTextImported"),type:"warning"});return}(ae=l.value)==null||ae.insertImportedBlocks(h),n({message:We("taskActions.importedBlocksInserted",{count:h.length,appended:ee}),type:"success"})}catch{O.value=We("taskActions.textImportFailed")}}async function Tt(E){var k;L.value=!0,O.value="";try{let K=0,ae=0;for(const ee of E){const h=await qi(ee),Y=(h.blocks||[]).map(D=>({...D,content:D.type==="image"?xs(D.content):D.content}));Y.length&&((k=l.value)==null||k.insertBlocks(Y),K+=Y.length,ae+=Number(h.pageCount||0))}if(!K){n({message:We("taskActions.noPdfContent"),type:"warning"});return}n({message:We("taskActions.pdfBlocksInserted",{blockCount:K,pageCount:ae}),type:"success"})}catch(K){O.value=K.message||We("taskActions.pdfImportFailed")}finally{L.value=!1}}function qt(E){const k=E===m.value?f.value:Be(E);return k?Cv({title:String(k.title||""),blocks:J(k.blocks||[])},Ee(E)):""}function At(E){const k=E===m.value?f.value:Be(E);return k?un(J(k.blocks||[])):[]}async function Ot(E){return L.value?(O.value=We("taskActions.fileProcessingBeforeSend"),!1):E!==m.value?!0:y.value&&A?A:z.value?Bt({auto:!1,silent:!0}):!0}async function Qt(E){return await Ot(E)?qt(E):""}function nn(E,k){const K=Sr(k);!K||E!==m.value||(f.value.lastPromptPreview=K,Ne(m.value,f.value),ye())}return $e(f,()=>{if(v.value||!m.value)return;const E=bo(f.value.blocks);!String(f.value.title||"").trim()&&E&&E!==f.value.autoTitle&&(f.value.autoTitle=E),Ne(m.value,f.value),z.value=_e()!==U.value,ye(),z.value&&!y.value&&te()},{deep:!0}),$e(m,E=>{E&&ys(E)}),It(()=>{T(),j()}),$e(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<Q||(lt(r.listSyncTaskSlug.value),st(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:pt,applyTaskSettingsUpdate:Oe,buildPromptForTask:qt,getPromptBlocksForTask:At,buildPromptPreview:Sr,clearCurrentTaskContent:Et,createTaskAndSelect:Le,currentProjectSessionId:H,currentTaskSendState:F,currentTaskAutoTitle:ie,currentTaskDisplayTitle:ve,currentTaskSlug:m,draft:f,editorRef:l,error:O,handleImportPdfFiles:Tt,handleImportTextFiles:Ue,handleTaskSendingChange:ht,handleTaskSessionChange:Ct,handleUpload:he,hasCurrentDraftContent:Fe,hasAnyTaskSending:De,hasUnsavedChanges:z,initializeWorkbench:de,isCurrentTaskSending:He,loadingTask:v,loadingTasks:b,pageTitle:Ke,prepareCodexPromptForTask:Qt,currentTodoItems:je,removeTodoItem:V,removeCurrentTask:xt,reorderTaskList:nt,removingTask:ne,renderedTasks:tt,refreshTaskList:Ye,saveTask:Bt,saving:y,selectTask:ot,selectedSessionMap:w,sendingTaskMap:d,taskDraftMap:p,tasks:c,useTodoItem:X,updateLastPromptPreview:nn,uploading:L,creatingTask:P}}const Fv={class:"flex h-full min-h-0 flex-col overflow-hidden"},Uv={key:0,class:"workbench-desktop-layout grid min-h-0 flex-1 gap-4 lg:grid-cols-[260px_minmax(0,1fr)] lg:grid-rows-1"},Vv={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},zv={class:"min-h-0 min-w-0 overflow-hidden"},Hv={class:"min-h-0 min-w-0 overflow-hidden"},qv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Kv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Wv={class:"flex flex-col gap-2"},Gv={class:"min-h-0 flex-1 overflow-hidden"},Xv={key:1,class:"min-h-0 flex-1 overflow-hidden"},Yv={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Jv={class:"workbench-mobile-tabs-panel shrink-0"},Qv={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Zv={class:"min-h-0 flex-1 overflow-hidden"},ey={class:"h-full min-h-0"},ty={class:"h-full min-h-0"},ny={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},sy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},oy={class:"flex flex-col gap-2"},ry={class:"min-h-0 flex-1 overflow-hidden"},ay={__name:"WorkbenchView",setup(e){const t=q(!1),n=q(!1),o=q(!1),s=q(!1),r=q(!1),l=q(!1),c=q(!1),p=q(!1),w=q(""),d=q(""),m=q(""),f=q(0),b=q("workspace"),v=q(""),{t:P}=St(),{toastMessage:ne,toastType:y,flashToast:L,clearToast:O}=bv(),{sendBehavior:z}=ba(),U=fo(()=>ze(()=>import("./TaskDiffReviewDialog-Bxxkkdld.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),se=fo(()=>ze(()=>import("./WorkbenchSettingsDialog-B046sue0.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),A=q(null),G=q([]),ce=q({});function pe($="",Z=G.value){const we=String($||"").trim();return we&&Z.some(ke=>(ke==null?void 0:ke.engine)===we)?we:""}function I($=G.value){var Z,we;return((Z=$.find(ke=>ke==null?void 0:ke.isDefault))==null?void 0:Z.engine)||((we=$[0])==null?void 0:we.engine)||""}const Q=W({get(){const $=String(je.value||"").trim();return $?pe(ce.value[$])||I():""},set($){const Z=String(je.value||"").trim(),we=pe($);!Z||!we||(ce.value={...ce.value,[Z]:we})}});function le($){return $?A.value:null}function ie(){at(()=>{var $,Z;(Z=($=le(R.value))==null?void 0:$.scrollToBottom)==null||Z.call($)})}const{addCurrentDraftToTodo:ve,applyTaskSettingsUpdate:_,buildPromptForTask:H,getPromptBlocksForTask:F,clearCurrentTaskContent:He,createTaskAndSelect:De,creatingTask:Fe,currentProjectSessionId:je,currentTaskSendState:Ke,currentTaskAutoTitle:tt,currentTaskDisplayTitle:xe,currentTaskSlug:R,draft:J,editorRef:fe,error:_e,handleImportPdfFiles:ge,handleImportTextFiles:Ie,handleTaskSendingChange:Ae,handleTaskSessionChange:Be,handleUpload:Xe,hasCurrentDraftContent:Pe,hasUnsavedChanges:it,initializeWorkbench:Me,isCurrentTaskSending:Ne,loadingTask:Ee,loadingTasks:lt,pageTitle:ht,prepareCodexPromptForTask:dt,currentTodoItems:wt,removeTodoItem:Ct,removeCurrentTask:T,reorderTaskList:j,removingTask:te,renderedTasks:ye,saveTask:Oe,saving:Re,selectTask:Ge,updateLastPromptPreview:Ye,useTodoItem:nt,uploading:yt}=jv({clearToast:O,flashToast:L,scrollCurrentPanelToBottom:ie}),st=W(()=>ye.value.find($=>$.slug===R.value)||null),ft=W(()=>{var $,Z;return!!((Z=($=st.value)==null?void 0:$.workspaceDiffSummary)!=null&&Z.supported)}),_t=W(()=>{const $=st.value;return $?()=>dt($.slug):null}),Bt=W(()=>{const $=st.value;return $?()=>F($.slug):null}),re=W(()=>({creatingTask:Fe.value,currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,draftTitle:J.value.title,editingTaskTitleSlug:m.value,error:_e.value,isCurrentTaskSending:Ne.value,loadingTask:Ee.value,loadingTasks:lt.value,removingTask:te.value,tasks:ye.value,uploading:yt.value})),Le=W(()=>{var $,Z,we,ke;return{buildPromptBlocks:Bt.value,buildPrompt:_t.value,diffSupported:ft.value,selectedAgentEngine:Q.value,selectedSessionId:je.value,sessionSelectionLockReason:(($=st.value)==null?void 0:$.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Z=st.value)!=null&&Z.sessionSelectionLocked),taskSlug:((we=st.value)==null?void 0:we.slug)||"",taskRunning:!!((ke=st.value)!=null&&ke.running)}}),ot=W(()=>({codexSessionId:je.value,sendBehavior:z.value,loading:Ee.value})),xt=W(()=>({currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,editingTaskTitleSlug:m.value,title:xe.value,titleInputValue:J.value.title})),{enterMobileDetail:Et,isMobileLayout:pt,leaveMobileDetail:V,mobileDetailTab:X,mobileView:de}=yv({currentTaskSlug:R});function he($){return $!=null&&$.sending||Number(($==null?void 0:$.codexRunCount)||0)>0?"activity":"input"}wv(ht);function Ue($="workspace",Z=""){b.value=$==="run"?"run":$==="task"?"task":"workspace",v.value=b.value==="run"?String(Z||""):"",o.value=!0,f.value+=1}function Tt(){o.value=!1}function qt(){s.value=!0}function At(){s.value=!1}function Ot(){R.value&&(r.value=!0)}function Qt(){r.value=!1}function nn(){l.value=!0}function E(){l.value=!1,k(),K()}function k(){c.value=!1,w.value=""}function K(){p.value=!1,d.value=""}function ae($){_($)}function ee($){J.value.title=$}async function h(){m.value="",it.value&&await Oe({auto:!1,silent:!0})}function Y($){$===R.value&&(m.value=$,at(()=>{var we,ke;const Z=document.querySelector('[data-task-title-input="current"]');(we=Z==null?void 0:Z.focus)==null||we.call(Z),(ke=Z==null?void 0:Z.select)==null||ke.call(Z)}))}async function D($){if(pt.value){await Un($);return}if($!==R.value){await Un($);return}Y($)}function be(){n.value=!0}function Mt(){te.value||(n.value=!1)}async function jt(){await T(),n.value=!1,pt.value&&V({useHistory:!1})}function Ft(){t.value=!0}function Ut(){t.value=!1}function Pt(){t.value=!1,He()}function mt($){const Z=st.value;Z&&Ae(Z.slug,$)}function Xt($){const Z=st.value;Z&&Be(Z.slug,$)}function Vs($={}){const Z=String(($==null?void 0:$.sessionId)||"").trim(),we=je.value;if(Z&&Z!==we)return;const ke=Array.isArray($==null?void 0:$.bindings)?$.bindings:[];G.value=ke;const u=pe(ce.value[we],ke)||pe($==null?void 0:$.selectedEngine,ke)||I(ke);u&&(Q.value=u)}$e(je,($,Z)=>{String($||"").trim()!==String(Z||"").trim()&&(G.value=[])});function Fn($){Q.value=$}function zs($){L($),!(!pt.value||!R.value)&&(X.value="activity")}async function zt(){var $,Z,we,ke,u,C,B,M;typeof document<"u"&&((Z=($=fe.value)==null?void 0:$.isComposing)!=null&&Z.call($))&&((ke=(we=document.activeElement)==null?void 0:we.blur)==null||ke.call(we)),(C=(u=fe.value)==null?void 0:u.flushPendingInput)==null||C.call(u),await at(),(M=(B=fe.value)==null?void 0:B.flushPendingInput)==null||M.call(B),await at()}async function is(){await zt(),await navigator.clipboard.writeText(H(R.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function Hs(){await De()&&pt.value&&(X.value="input",Et())}async function Un($){const Z=String($||"").trim();Z&&(Z!==R.value&&await Ge(Z),pt.value&&R.value===Z&&(X.value=he(st.value),Et()))}async function ls($=[]){await j($)}async function sn(){await zt(),ve()}function Vn($={}){const Z=String(($==null?void 0:$.rangeLabel)||"").trim();if(Z)return Z;const we=Math.max(0,Number($==null?void 0:$.lineStart)||0),ke=Math.max(0,Number($==null?void 0:$.lineEnd)||0);return we&&ke&&we!==ke?`L${we}-L${ke}`:we||ke?`L${we||ke}`:""}function zn($=""){return`code-context-${String($||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Yt($={}){const Z=String(($==null?void 0:$.filePath)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
|
|
57
|
+
`)}function J(E=[]){return E.map(k=>({id:Number.isInteger(Number(k==null?void 0:k.id))?Number(k.id):null,type:k==null?void 0:k.type,content:(k==null?void 0:k.type)==="image"?xe(k.content):R(k.content),meta:k!=null&&k.meta?{...k.meta}:{}}))}function fe(E=[]){return(E||[]).map(k=>({id:String((k==null?void 0:k.id)||"").trim(),createdAt:String((k==null?void 0:k.createdAt)||""),blocks:J((k==null?void 0:k.blocks)||[])}))}function _e(E=f.value.title,k=f.value.autoTitle,K=f.value.lastPromptPreview,ae=f.value.todoItems,ee=f.value.codexSessionId,h=f.value.blocks){return JSON.stringify({title:String(E||""),autoTitle:String(k||""),lastPromptPreview:String(K||""),todoItems:fe(ae),codexSessionId:String(ee||""),blocks:J(h)})}function ge(){return _e()!==U.value}function Ie(){var E,k;return!!((k=(E=l.value)==null?void 0:E.isEditing)!=null&&k.call(E))}function Ae(E){return c.value.find(k=>k.slug===E)||null}function Be(E){return E&&p.value[E]||null}function Xe(E,k=""){const K=String(E||"").trim();K&&(le={...le,[K]:String(k||"").trim()})}function Pe(E=""){var ee;const k=String(E||"").trim();if(!k)return!1;const K=String(((ee=Ae(k))==null?void 0:ee.updatedAt)||"").trim(),ae=String(le[k]||"").trim();return!!(K&&ae&&K===ae)}function it(E){const k=Be(E.slug),K=E.slug===m.value?f.value.blocks:(k==null?void 0:k.blocks)||[],ae=E.slug===m.value?f.value.title:(k==null?void 0:k.title)??E.title,ee=E.slug===m.value?f.value.autoTitle:(k==null?void 0:k.autoTitle)??E.autoTitle,h=E.slug===m.value?Nt(f.value.todoItems).length:Nt((k==null?void 0:k.todoItems)||[]).length||Number(E.todoCount||0),Y=E.slug===m.value?f.value.lastPromptPreview||E.lastPromptPreview||"":(k==null?void 0:k.lastPromptPreview)||E.lastPromptPreview||"",D=_(E.slug,{summary:E,cachedDraft:k});return{...E,title:ae,autoTitle:ee,todoCount:h,preview:Y,codexSessionId:D,sessionSelectionLocked:!!(D&&Number(E.codexRunCount||0)>0),sessionSelectionLockReason:D&&Number(E.codexRunCount||0)>0?We("taskActions.sessionLocked"):"",displayTitle:yr({title:ae,autoTitle:ee,preview:Y},K),sending:Ns(E)}}function Me(E,k={}){const{insertAtStart:K=!1}=k;if(!(E!=null&&E.slug))return;const ae=[...c.value],ee=ae.findIndex(h=>h.slug===E.slug);if(ee>=0){ae.splice(ee,1,{...ae[ee],...E}),c.value=ae;return}K?ae.unshift(E):ae.push(E),c.value=ae}function Ne(E,k){E&&(p.value={...p.value,[E]:hr(k)})}function Ee(E){return E?`${s}/api/tasks/${E}/raw`:`${s}/api/tasks/`}function lt(E=""){const k=String(E||"").trim();if(!k)return;const K=Ae(k),ae=r.getTaskRunChange(k);if(!K||!(ae!=null&&ae.status))return;const ee=Lv(ae.status);!!K.running!==ee&&Me({...K,running:ee})}function ht(E,k){d.value={...d.value,[E]:!!k}}function dt(E=c.value){const k={};(E||[]).forEach(K=>{K!=null&&K.slug&&(k[K.slug]=!!K.running)}),d.value=k}function wt(E,k){E&&(w.value={...w.value,[E]:String(k||"").trim()})}async function Ct(E,k){const K=String(E||"").trim();if(!K)return;const ae=String(k||"").trim(),ee=Ae(K),h=w.value[K]||(ee==null?void 0:ee.codexSessionId)||"";if(!!(h&&Number((ee==null?void 0:ee.codexRunCount)||0)>0)&&ae!==h){O.value=We("taskActions.sessionLocked");return}wt(K,ae);const D=Be(K);D&&Ne(K,{...D,codexSessionId:ae}),ee&&Me({...ee,codexSessionId:ae,workspaceDiffSummary:ae&&ae===h?ee.workspaceDiffSummary:null}),K===m.value&&(f.value={...f.value,codexSessionId:ae});try{await nl(K,ae)}catch(be){wt(K,h),D&&Ne(K,{...D,codexSessionId:h}),ee&&Me({...ee,codexSessionId:h}),K===m.value&&(f.value={...f.value,codexSessionId:h}),O.value=be.message}}function T(){se&&(window.clearTimeout(se),se=null)}function j(){ce&&(window.clearTimeout(ce),ce=null)}function te(){T(),!(v.value||!m.value)&&(se=window.setTimeout(()=>{Bt({auto:!0,silent:!0})},1500))}function ye(){if(!m.value)return;const E=Ae(m.value)||{slug:m.value,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};Me({...E,title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoCount:Nt(f.value.todoItems).length,codexSessionId:H.value,preview:String(f.value.lastPromptPreview||"")})}function Oe(E={}){const k=String((E==null?void 0:E.slug)||"").trim();if(!k)return;const K=$n(E);Me(K),Xe(k,K.updatedAt||E.updatedAt||""),k===m.value&&(Object.prototype.hasOwnProperty.call(E,"title")&&(f.value.title=String(E.title||"")),Object.prototype.hasOwnProperty.call(E,"autoTitle")&&(f.value.autoTitle=String(E.autoTitle||"")),Ne(k,{...f.value}))}function Re(E=[]){const k=new Map((E||[]).map(K=>{const ae=String((K==null?void 0:K.slug)||"").trim();return ae?[ae,Rs(K.workspaceDiffSummary)]:null}).filter(Boolean));k.size&&(c.value=c.value.map(K=>k.has(K.slug)?{...K,workspaceDiffSummary:k.get(K.slug)}:K))}async function Ge(E=c.value){const k=Array.isArray(E)?E:[],K=k.filter(ee=>String((ee==null?void 0:ee.codexSessionId)||"").trim()),ae=++pe;if(!K.length){c.value=k.map(ee=>Object.prototype.hasOwnProperty.call(ee,"workspaceDiffSummary")?ee:{...ee,workspaceDiffSummary:null});return}try{const ee=await Fi(k.length||30);if(ae!==pe)return;Re(ee.items||[])}catch{}}async function Ye(E={}){const{silent:k=!1}=E;k||(b.value=!0,O.value="");try{const K=c.value,ae=await ji(),ee=wr(K,(ae.items||[]).map($n));c.value=ee,dt(ee),Mv(K,ee)&&Ge(ee)}catch(K){k||(O.value=K.message)}finally{k||(b.value=!1)}}async function nt(E=[]){const k=Bv(c.value,E),K=c.value.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean),ae=k.map(h=>String((h==null?void 0:h.slug)||"").trim()).filter(Boolean);if(!ae.length||ae.join(",")===K.join(","))return!1;const ee=c.value;c.value=k;try{const h=await Vi(ae);Q=Date.now()+Av;const Y=wr(ee,(h.items||[]).map($n));return c.value=Y,dt(Y),!0}catch(h){return c.value=ee,O.value=h.message,!1}}async function yt(E=""){const k=String(m.value||"").trim(),K=String(E||"").trim();if(!k)return;if(!c.value.some(ee=>ee.slug===k)){if(c.value.length){await _t(c.value[0].slug,{force:!0,skipIfDirtyOnApply:!0});return}m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1;return}K&&K!==k||K&&(Ie()||ge()||z.value||y.value||L.value||v.value||await _t(k,{force:!0,skipIfDirtyOnApply:!0,skipIfEditingOnApply:!0}))}function st(E=""){const k=String(E||"").trim();I===null?I=k:I!==k&&(I=""),!ce&&(ce=window.setTimeout(async()=>{const K=I;I=null,ce=null,await Ye({silent:!0}),await yt(K||"")},Ev))}async function ft(E){const k=await Br(E),K=(k.blocks||[]).map(ee=>({...ee,content:ee.type==="image"?xs(ee.content):ee.content}));return{state:{title:String(k.title||""),autoTitle:String(k.autoTitle||""),lastPromptPreview:String(k.lastPromptPreview||""),codexSessionId:String(k.codexSessionId||""),blocks:K,todoItems:Nt(k.todoItems||[])},summary:$n({...k,blocks:K}),updatedAt:String(k.updatedAt||"")}}async function _t(E,k={}){const{focusEditor:K=!1,force:ae=!1,skipIfDirtyOnApply:ee=!1,skipIfEditingOnApply:h=!1,scrollPanelToBottom:Y=!1}=k,D=String(E||"").trim();if(!D)return!1;const be=++G;v.value=!0,O.value="",t();try{const Mt=String(m.value||"").trim(),jt=Be(D),Ft=ae&&jt&&Pe(D);let Ut=ae&&!Ft?null:jt,Pt=null;if(!Ut){const mt=await ft(D);Ut=(mt==null?void 0:mt.state)||null,Pt=(mt==null?void 0:mt.summary)||null,Xe(D,(mt==null?void 0:mt.updatedAt)||(Pt==null?void 0:Pt.updatedAt)||"")}return be!==G||ee&&D===m.value&&(ge()||z.value)||h&&D===m.value&&Ie()?!1:(m.value=D,ys(D),f.value=hr(Ut),Ne(D,Ut),Pt&&Me(Pt),wt(D,Ut.codexSessionId),U.value=_e(f.value.title,f.value.autoTitle,f.value.lastPromptPreview,f.value.todoItems,f.value.codexSessionId,f.value.blocks),z.value=!1,K&&at(()=>{var mt,Xt;return(Xt=(mt=l.value)==null?void 0:mt.focusEditor)==null?void 0:Xt.call(mt)}),(Y||D!==Mt)&&o(),!0)}catch(Mt){return be===G&&(O.value=Mt.message),!1}finally{be===G&&(v.value=!1)}}async function Bt(E={}){const{auto:k=!1,silent:K=!1}=E;return m.value?_e()===U.value?!0:A||(T(),y.value=!0,O.value="",A=(async()=>{try{const ee=await Mr(m.value,{title:String(f.value.title||""),autoTitle:String(f.value.autoTitle||""),lastPromptPreview:String(f.value.lastPromptPreview||""),todoItems:Nt(f.value.todoItems),codexSessionId:H.value,expiry:"none",visibility:"private",blocks:J(f.value.blocks)}),h={title:String(ee.title||""),autoTitle:String(ee.autoTitle||""),lastPromptPreview:String(ee.lastPromptPreview||""),todoItems:Nt(ee.todoItems||f.value.todoItems||[]),codexSessionId:H.value||String(ee.codexSessionId||"").trim(),blocks:un(f.value.blocks)};return Ne(m.value,h),U.value=_e(h.title,h.autoTitle,h.lastPromptPreview,h.todoItems,h.codexSessionId,h.blocks),z.value=!1,Me($n(ee)),Xe(m.value,ee.updatedAt||""),!k&&!K&&n({message:We("taskActions.taskSaved"),type:"success"}),!0}catch(ee){return O.value=ee.message,!1}finally{y.value=!1,A=null,_e()!==U.value&&(z.value=!0,te())}})(),A):!1}async function re(){return L.value?(O.value=We("taskActions.fileProcessing"),!1):A||(z.value?Bt({auto:!1,silent:!0}):!0)}async function Le(){if(!await re()&&m.value)return!1;P.value=!0,O.value="";try{const E=await Ui({title:"",expiry:"none",visibility:"private"}),k={title:String(E.title||""),autoTitle:String(E.autoTitle||""),lastPromptPreview:String(E.lastPromptPreview||""),codexSessionId:String(E.codexSessionId||""),blocks:un(E.blocks||[]),todoItems:Nt(E.todoItems||[])};return Ne(E.slug,k),Me($n(E),{insertAtStart:!0}),await _t(E.slug,{focusEditor:!0}),n({message:We("taskActions.taskCreated"),type:"success"}),!0}catch(E){return O.value=E.message,!1}finally{P.value=!1}}async function ot(E){const k=String(E||"").trim();!k||k===m.value||!await re()||await _t(k)}async function xt(){if(m.value){ne.value=!0,O.value="";try{const E=m.value;await zi(E),c.value=c.value.filter(ee=>ee.slug!==E);const k={...p.value};delete k[E],p.value=k;const K={...w.value};delete K[E],w.value=K;const ae={...d.value};delete ae[E],d.value=ae,c.value.length?await _t(c.value[0].slug,{focusEditor:!0}):(m.value="",ys(""),f.value={title:"",autoTitle:"",lastPromptPreview:"",codexSessionId:"",blocks:[],todoItems:[]},U.value=_e("","","",[],"",[]),z.value=!1,await Le())}catch(E){O.value=E.message}finally{ne.value=!1}}}function Et(E={}){const{silent:k=!1}=E;m.value&&(f.value={...f.value,blocks:vr()},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var K,ae;(ae=(K=l.value)==null?void 0:K.focusEditor)==null||ae.call(K)}),k||n({message:We("taskActions.taskCleared"),type:"info"}))}function pt(){if(!m.value)return!1;const E=wa(f.value.blocks);return E.length?(f.value={...f.value,blocks:vr(),todoItems:[{id:Iv(),createdAt:new Date().toISOString(),blocks:E},...Nt(f.value.todoItems)]},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var k,K;(K=(k=l.value)==null?void 0:k.focusEditor)==null||K.call(k)}),n({message:We("taskActions.todoAdded"),type:"success"}),!0):!1}function V(E=""){const k=String(E||"").trim();if(!m.value||!k)return!1;const K=Nt(f.value.todoItems).filter(ae=>ae.id!==k);return K.length===Nt(f.value.todoItems).length?!1:(f.value={...f.value,todoItems:K},Ne(m.value,f.value),ye(),z.value=!0,!0)}function X(E=""){const k=String(E||"").trim();if(!m.value||!k)return null;const K=Nt(f.value.todoItems).find(ae=>ae.id===k);return K?(f.value={...f.value,blocks:un(K.blocks),todoItems:Nt(f.value.todoItems).filter(ae=>ae.id!==k)},Ne(m.value,f.value),ye(),z.value=!0,at(()=>{var ae,ee;(ee=(ae=l.value)==null?void 0:ae.focusEditor)==null||ee.call(ae)}),K):null}async function de(){var ee;if(await Ye(),!c.value.length){await Le();return}const E=Nv();if(E){const h=await _t(E,{focusEditor:!0,force:!0});if(Ov(),h)return}const k=((ee=c.value.find(h=>!!(h!=null&&h.running)))==null?void 0:ee.slug)||"",K=Rv(),ae=k||(c.value.some(h=>h.slug===K)?K:c.value[0].slug);await _t(ae,{focusEditor:!0,force:!0})}async function he(E){var k,K,ae;L.value=!0,O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Hi(Y);h.push({type:"image",content:xs(D.url),meta:{}})}(ae=l.value)==null||ae.insertUploadedBlocks(h),n({message:We("taskActions.imageInserted",{count:h.length,appended:ee}),type:"success"})}catch(ee){O.value=ee.message}finally{L.value=!1}}async function Ue(E){var k,K,ae;O.value="";try{const ee=((K=(k=l.value)==null?void 0:k.isImportedBlockActive)==null?void 0:K.call(k))||!1,h=[];for(const Y of E){const D=await Y.text();D.trim()&&h.push({type:"imported_text",content:D,meta:{fileName:Y.name||We("workbench.untitledTask"),collapsed:!0}})}if(!h.length){n({message:We("taskActions.noTextImported"),type:"warning"});return}(ae=l.value)==null||ae.insertImportedBlocks(h),n({message:We("taskActions.importedBlocksInserted",{count:h.length,appended:ee}),type:"success"})}catch{O.value=We("taskActions.textImportFailed")}}async function Tt(E){var k;L.value=!0,O.value="";try{let K=0,ae=0;for(const ee of E){const h=await qi(ee),Y=(h.blocks||[]).map(D=>({...D,content:D.type==="image"?xs(D.content):D.content}));Y.length&&((k=l.value)==null||k.insertBlocks(Y),K+=Y.length,ae+=Number(h.pageCount||0))}if(!K){n({message:We("taskActions.noPdfContent"),type:"warning"});return}n({message:We("taskActions.pdfBlocksInserted",{blockCount:K,pageCount:ae}),type:"success"})}catch(K){O.value=K.message||We("taskActions.pdfImportFailed")}finally{L.value=!1}}function qt(E){const k=E===m.value?f.value:Be(E);return k?Cv({title:String(k.title||""),blocks:J(k.blocks||[])},Ee(E)):""}function At(E){const k=E===m.value?f.value:Be(E);return k?un(J(k.blocks||[])):[]}async function Ot(E){return L.value?(O.value=We("taskActions.fileProcessingBeforeSend"),!1):E!==m.value?!0:y.value&&A?A:z.value?Bt({auto:!1,silent:!0}):!0}async function Qt(E){return await Ot(E)?qt(E):""}function nn(E,k){const K=Sr(k);!K||E!==m.value||(f.value.lastPromptPreview=K,Ne(m.value,f.value),ye())}return $e(f,()=>{if(v.value||!m.value)return;const E=bo(f.value.blocks);!String(f.value.title||"").trim()&&E&&E!==f.value.autoTitle&&(f.value.autoTitle=E),Ne(m.value,f.value),z.value=_e()!==U.value,ye(),z.value&&!y.value&&te()},{deep:!0}),$e(m,E=>{E&&ys(E)}),It(()=>{T(),j()}),$e(()=>r.listSyncVersion.value,()=>{r.listSyncReason.value==="reordered"&&Date.now()<Q||(lt(r.listSyncTaskSlug.value),st(r.listSyncTaskSlug.value))}),{addCurrentDraftToTodo:pt,applyTaskSettingsUpdate:Oe,buildPromptForTask:qt,getPromptBlocksForTask:At,buildPromptPreview:Sr,clearCurrentTaskContent:Et,createTaskAndSelect:Le,currentProjectSessionId:H,currentTaskSendState:F,currentTaskAutoTitle:ie,currentTaskDisplayTitle:ve,currentTaskSlug:m,draft:f,editorRef:l,error:O,handleImportPdfFiles:Tt,handleImportTextFiles:Ue,handleTaskSendingChange:ht,handleTaskSessionChange:Ct,handleUpload:he,hasCurrentDraftContent:Fe,hasAnyTaskSending:De,hasUnsavedChanges:z,initializeWorkbench:de,isCurrentTaskSending:He,loadingTask:v,loadingTasks:b,pageTitle:Ke,prepareCodexPromptForTask:Qt,currentTodoItems:je,removeTodoItem:V,removeCurrentTask:xt,reorderTaskList:nt,removingTask:ne,renderedTasks:tt,refreshTaskList:Ye,saveTask:Bt,saving:y,selectTask:ot,selectedSessionMap:w,sendingTaskMap:d,taskDraftMap:p,tasks:c,useTodoItem:X,updateLastPromptPreview:nn,uploading:L,creatingTask:P}}const Fv={class:"flex h-full min-h-0 flex-col overflow-hidden"},Uv={key:0,class:"workbench-desktop-layout grid min-h-0 flex-1 gap-4 lg:grid-cols-[260px_minmax(0,1fr)] lg:grid-rows-1"},Vv={class:"workbench-detail-layout grid min-h-0 gap-4 overflow-hidden lg:grid-cols-2 lg:grid-rows-1"},zv={class:"min-h-0 min-w-0 overflow-hidden"},Hv={class:"min-h-0 min-w-0 overflow-hidden"},qv={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},Kv={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b p-3"},Wv={class:"flex flex-col gap-2"},Gv={class:"min-h-0 flex-1 overflow-hidden"},Xv={key:1,class:"min-h-0 flex-1 overflow-hidden"},Yv={key:1,class:"workbench-mobile-detail-layout flex h-full min-h-0 flex-col gap-1.5 overflow-hidden"},Jv={class:"workbench-mobile-tabs-panel shrink-0"},Qv={class:"workbench-mobile-tabs grid grid-cols-2 gap-2"},Zv={class:"min-h-0 flex-1 overflow-hidden"},ey={class:"h-full min-h-0"},ty={class:"h-full min-h-0"},ny={class:"workbench-input-shell panel flex h-full min-h-0 flex-col overflow-hidden"},sy={class:"workbench-panel-header theme-divider theme-muted-panel shrink-0 border-b px-3 py-3"},oy={class:"flex flex-col gap-2"},ry={class:"min-h-0 flex-1 overflow-hidden"},ay={__name:"WorkbenchView",setup(e){const t=q(!1),n=q(!1),o=q(!1),s=q(!1),r=q(!1),l=q(!1),c=q(!1),p=q(!1),w=q(""),d=q(""),m=q(""),f=q(0),b=q("workspace"),v=q(""),{t:P}=St(),{toastMessage:ne,toastType:y,flashToast:L,clearToast:O}=bv(),{sendBehavior:z}=ba(),U=fo(()=>ze(()=>import("./TaskDiffReviewDialog-VwZmo00b.js"),__vite__mapDeps([41,35,2,3,36,37,38,39,40,42]))),se=fo(()=>ze(()=>import("./WorkbenchSettingsDialog-CThWkZHd.js"),__vite__mapDeps([43,2,3,35,36,37,38,39,40]))),A=q(null),G=q([]),ce=q({});function pe($="",Z=G.value){const we=String($||"").trim();return we&&Z.some(ke=>(ke==null?void 0:ke.engine)===we)?we:""}function I($=G.value){var Z,we;return((Z=$.find(ke=>ke==null?void 0:ke.isDefault))==null?void 0:Z.engine)||((we=$[0])==null?void 0:we.engine)||""}const Q=W({get(){const $=String(je.value||"").trim();return $?pe(ce.value[$])||I():""},set($){const Z=String(je.value||"").trim(),we=pe($);!Z||!we||(ce.value={...ce.value,[Z]:we})}});function le($){return $?A.value:null}function ie(){at(()=>{var $,Z;(Z=($=le(R.value))==null?void 0:$.scrollToBottom)==null||Z.call($)})}const{addCurrentDraftToTodo:ve,applyTaskSettingsUpdate:_,buildPromptForTask:H,getPromptBlocksForTask:F,clearCurrentTaskContent:He,createTaskAndSelect:De,creatingTask:Fe,currentProjectSessionId:je,currentTaskSendState:Ke,currentTaskAutoTitle:tt,currentTaskDisplayTitle:xe,currentTaskSlug:R,draft:J,editorRef:fe,error:_e,handleImportPdfFiles:ge,handleImportTextFiles:Ie,handleTaskSendingChange:Ae,handleTaskSessionChange:Be,handleUpload:Xe,hasCurrentDraftContent:Pe,hasUnsavedChanges:it,initializeWorkbench:Me,isCurrentTaskSending:Ne,loadingTask:Ee,loadingTasks:lt,pageTitle:ht,prepareCodexPromptForTask:dt,currentTodoItems:wt,removeTodoItem:Ct,removeCurrentTask:T,reorderTaskList:j,removingTask:te,renderedTasks:ye,saveTask:Oe,saving:Re,selectTask:Ge,updateLastPromptPreview:Ye,useTodoItem:nt,uploading:yt}=jv({clearToast:O,flashToast:L,scrollCurrentPanelToBottom:ie}),st=W(()=>ye.value.find($=>$.slug===R.value)||null),ft=W(()=>{var $,Z;return!!((Z=($=st.value)==null?void 0:$.workspaceDiffSummary)!=null&&Z.supported)}),_t=W(()=>{const $=st.value;return $?()=>dt($.slug):null}),Bt=W(()=>{const $=st.value;return $?()=>F($.slug):null}),re=W(()=>({creatingTask:Fe.value,currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,draftTitle:J.value.title,editingTaskTitleSlug:m.value,error:_e.value,isCurrentTaskSending:Ne.value,loadingTask:Ee.value,loadingTasks:lt.value,removingTask:te.value,tasks:ye.value,uploading:yt.value})),Le=W(()=>{var $,Z,we,ke;return{buildPromptBlocks:Bt.value,buildPrompt:_t.value,diffSupported:ft.value,selectedAgentEngine:Q.value,selectedSessionId:je.value,sessionSelectionLockReason:(($=st.value)==null?void 0:$.sessionSelectionLockReason)||"",sessionSelectionLocked:!!((Z=st.value)!=null&&Z.sessionSelectionLocked),taskSlug:((we=st.value)==null?void 0:we.slug)||"",taskRunning:!!((ke=st.value)!=null&&ke.running)}}),ot=W(()=>({codexSessionId:je.value,sendBehavior:z.value,loading:Ee.value})),xt=W(()=>({currentTaskAutoTitle:J.value.autoTitle||tt.value,currentTaskSlug:R.value,editingTaskTitleSlug:m.value,title:xe.value,titleInputValue:J.value.title})),{enterMobileDetail:Et,isMobileLayout:pt,leaveMobileDetail:V,mobileDetailTab:X,mobileView:de}=yv({currentTaskSlug:R});function he($){return $!=null&&$.sending||Number(($==null?void 0:$.codexRunCount)||0)>0?"activity":"input"}wv(ht);function Ue($="workspace",Z=""){b.value=$==="run"?"run":$==="task"?"task":"workspace",v.value=b.value==="run"?String(Z||""):"",o.value=!0,f.value+=1}function Tt(){o.value=!1}function qt(){s.value=!0}function At(){s.value=!1}function Ot(){R.value&&(r.value=!0)}function Qt(){r.value=!1}function nn(){l.value=!0}function E(){l.value=!1,k(),K()}function k(){c.value=!1,w.value=""}function K(){p.value=!1,d.value=""}function ae($){_($)}function ee($){J.value.title=$}async function h(){m.value="",it.value&&await Oe({auto:!1,silent:!0})}function Y($){$===R.value&&(m.value=$,at(()=>{var we,ke;const Z=document.querySelector('[data-task-title-input="current"]');(we=Z==null?void 0:Z.focus)==null||we.call(Z),(ke=Z==null?void 0:Z.select)==null||ke.call(Z)}))}async function D($){if(pt.value){await Un($);return}if($!==R.value){await Un($);return}Y($)}function be(){n.value=!0}function Mt(){te.value||(n.value=!1)}async function jt(){await T(),n.value=!1,pt.value&&V({useHistory:!1})}function Ft(){t.value=!0}function Ut(){t.value=!1}function Pt(){t.value=!1,He()}function mt($){const Z=st.value;Z&&Ae(Z.slug,$)}function Xt($){const Z=st.value;Z&&Be(Z.slug,$)}function Vs($={}){const Z=String(($==null?void 0:$.sessionId)||"").trim(),we=je.value;if(Z&&Z!==we)return;const ke=Array.isArray($==null?void 0:$.bindings)?$.bindings:[];G.value=ke;const u=pe(ce.value[we],ke)||pe($==null?void 0:$.selectedEngine,ke)||I(ke);u&&(Q.value=u)}$e(je,($,Z)=>{String($||"").trim()!==String(Z||"").trim()&&(G.value=[])});function Fn($){Q.value=$}function zs($){L($),!(!pt.value||!R.value)&&(X.value="activity")}async function zt(){var $,Z,we,ke,u,C,B,M;typeof document<"u"&&((Z=($=fe.value)==null?void 0:$.isComposing)!=null&&Z.call($))&&((ke=(we=document.activeElement)==null?void 0:we.blur)==null||ke.call(we)),(C=(u=fe.value)==null?void 0:u.flushPendingInput)==null||C.call(u),await at(),(M=(B=fe.value)==null?void 0:B.flushPendingInput)==null||M.call(B),await at()}async function is(){await zt(),await navigator.clipboard.writeText(H(R.value)),L({message:P("workbench.promptCopied"),type:"info"})}async function Hs(){await De()&&pt.value&&(X.value="input",Et())}async function Un($){const Z=String($||"").trim();Z&&(Z!==R.value&&await Ge(Z),pt.value&&R.value===Z&&(X.value=he(st.value),Et()))}async function ls($=[]){await j($)}async function sn(){await zt(),ve()}function Vn($={}){const Z=String(($==null?void 0:$.rangeLabel)||"").trim();if(Z)return Z;const we=Math.max(0,Number($==null?void 0:$.lineStart)||0),ke=Math.max(0,Number($==null?void 0:$.lineEnd)||0);return we&&ke&&we!==ke?`L${we}-L${ke}`:we||ke?`L${we||ke}`:""}function zn($=""){return`code-context-${String($||"").trim().split("/").filter(Boolean).pop()||"code"}.md`}function Yt($={}){const Z=String(($==null?void 0:$.filePath)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
|
|
58
58
|
`).trimEnd();if(!Z||!we.trim())return null;const ke=String(($==null?void 0:$.language)||"").trim(),u=Vn($),C=String(($==null?void 0:$.source)||"").trim()==="diff"?P("workbench.codeContextSourceDiff"):P("workbench.codeContextSourceFile"),B=ke?`\`\`\`${ke}`:"```",M=[P("workbench.codeContextTitle"),P("workbench.codeContextFile",{path:Z}),u?P("workbench.codeContextRange",{range:u}):"",P("workbench.codeContextSource",{source:C}),"",B,we,"```"].filter(oe=>oe!=="");return{type:$t.IMPORTED_TEXT,content:M.join(`
|
|
59
59
|
`),meta:{fileName:zn(Z),collapsed:!1}}}async function us($=[],Z="insertBlocks"){var ke,u,C,B;const we=Array.isArray($)?$.filter(Boolean):[];return we.length?(await zt(),(u=(ke=fe.value)==null?void 0:ke[Z])==null||u.call(ke,we),await at(),(B=(C=fe.value)==null?void 0:C.focusEditor)==null||B.call(C),pt.value&&R.value&&(X.value="input"),L({message:P("taskActions.insertedToEditor"),type:"success"}),!0):!1}async function Hn($={}){const Z=String(($==null?void 0:$.source)||"").trim(),we=String(($==null?void 0:$.content)||"").replace(/\r\n/g,`
|
|
60
60
|
`).trim();if(Z==="response"){if(!we)return;await us([Pn(we)],"insertBlocks");return}const ke=Yt($);ke&&await us([ke],"insertImportedBlocks")}function Tn($){w.value=String($||"").trim(),c.value=!!w.value}function fn(){w.value&&(Ct(w.value),k())}async function cs($=d.value){const Z=String($||"").trim();return!Z||!nt(Z)?!1:(K(),E(),!0)}async function qs($){await zt();const Z=String($||"").trim();if(Z){if(!Pe.value){await cs(Z);return}d.value=Z,p.value=!0}}async function Cn(){var ke,u,C,B;const $=R.value;if(!$)return;const Z=!!((u=(ke=st.value)==null?void 0:ke.automation)!=null&&u.enabled);await zt(),Ye($,H($)),!(!await((B=(C=le($))==null?void 0:C.send)==null?void 0:B.call(C))||$!==R.value)&&(pt.value&&(X.value="activity"),Z||He({silent:!0}),await Oe({auto:!1,silent:!0}))}function Ks(){!pt.value||de.value!=="detail"||X.value!=="input"||!R.value||at(()=>{var $,Z;(Z=($=fe.value)==null?void 0:$.focusEditor)==null||Z.call($)})}function pn($){!it.value&&!yt.value&&!Re.value||($.preventDefault(),$.returnValue="")}function qn(){var $,Z;return p.value?(K(),!0):c.value?(k(),!0):t.value?(Ut(),!0):n.value?(Mt(),!0):r.value?(Qt(),!0):l.value?(E(),!0):o.value?(Tt(),!0):s.value?(At(),!0):!!((Z=($=le(R.value))==null?void 0:$.closeTopDialog)!=null&&Z.call($))}function En($){var u,C,B,M,oe;const Z=String($.key||""),we=Z.toLowerCase(),ke=$.metaKey||$.ctrlKey;if(Z==="Escape"){qn()&&($.preventDefault(),(u=$.stopImmediatePropagation)==null||u.call($));return}if(ke){if(we==="s"){$.preventDefault(),Oe({auto:!1});return}if($.shiftKey&&Z==="Backspace"){$.preventDefault(),Ft();return}if(!$.isComposing){if($.shiftKey&&$.code==="Comma"){$.preventDefault(),qt();return}if($.shiftKey&&we==="k"){$.preventDefault(),(B=(C=le(R.value))==null?void 0:C.openProjectManager)==null||B.call(C);return}if($.shiftKey&&we==="o"){$.preventDefault(),(oe=(M=le(R.value))==null?void 0:M.openSourceBrowser)==null||oe.call(M);return}$.shiftKey&&we==="d"&&($.preventDefault(),ft.value&&Ue("workspace"))}}}dn(()=>{Me(),window.addEventListener("beforeunload",pn),window.addEventListener("keydown",En)}),It(()=>{window.removeEventListener("beforeunload",pn),window.removeEventListener("keydown",En)}),$e([pt,de,X,R],([$,Z,we,ke])=>{!$||Z!=="detail"||we!=="input"||!ke||Ks()});const on={"update:draftTitle":ee,"cancel-title-edit":()=>{m.value=""},"create-task":Hs,"edit-task":Ot,"delete-task":be,"open-settings":qt,"reorder-task":ls,"select-task":Un,"title-blur":h,"title-click":D},ds={"agent-bindings-change":Vs,"insert-code-context":Hn,"open-diff":({scope:$,runId:Z})=>Ue($,Z),"project-created":()=>L({message:P("workbench.projectCreated"),type:"success"}),"selected-session-change":Xt,"update:selectedAgentEngine":Fn,"sending-change":mt,toast:zs},Kn={"clear-request":Ft,"file-feedback":$=>L({message:$,type:"warning"}),"import-pdf-files":ge,"import-text-files":Ie,"send-request":Cn,"upload-files":Xe},mn={"begin-edit":()=>Y(R.value),back:V,"cancel-title-edit":()=>{m.value=""},"title-blur":h,"update:titleInputValue":ee};return($,Z)=>(g(),x("div",Fv,[ue(gv,{message:a(ne),type:a(y)},null,8,["message","type"]),ue(ps,{open:t.value,title:a(P)("workbench.confirmClearTitle"),description:a(P)("workbench.confirmClearDescription"),"confirm-text":a(P)("workbench.confirmClearAction"),"cancel-text":a(P)("workbench.continueEditing"),onCancel:Ut,onConfirm:Pt},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:n.value,title:a(P)("workbench.confirmDeleteTitle"),description:a(P)("workbench.confirmDeleteDescription",{title:a(xe)}),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),loading:a(te),danger:"",onCancel:Mt,onConfirm:jt},null,8,["open","title","description","confirm-text","cancel-text","loading"]),ue(ps,{open:c.value,title:a(P)("workbench.confirmDeleteTodoTitle"),description:a(P)("workbench.confirmDeleteTodoDescription"),"confirm-text":a(P)("workbench.confirmDeleteAction"),"cancel-text":a(P)("workbench.keepForNow"),danger:"",onCancel:k,onConfirm:fn},null,8,["open","title","description","confirm-text","cancel-text"]),ue(ps,{open:p.value,title:a(P)("workbench.replaceEditorTitle"),description:a(P)("workbench.replaceEditorDescription"),"confirm-text":a(P)("workbench.confirmReplaceAction"),"cancel-text":a(P)("workbench.dontReplaceYet"),onCancel:K,onConfirm:Z[0]||(Z[0]=we=>cs())},null,8,["open","title","description","confirm-text","cancel-text"]),ue(pv,{open:l.value,items:a(wt),onClose:E,onDelete:Tn,onUse:qs},null,8,["open","items"]),ue(a(U),{open:o.value,"task-slug":a(R),"task-title":a(xe),"preferred-scope":b.value,"preferred-run-id":v.value,"focus-token":f.value,onInsertCodeContext:Hn,onClose:Tt},null,8,["open","task-slug","task-title","preferred-scope","preferred-run-id","focus-token"]),ue(a(se),{open:s.value,onClose:At},null,8,["open"]),ue(ku,{open:r.value,"task-slug":a(R),"task-title":a(xe),onClose:Qt,onSaved:ae},null,8,["open","task-slug","task-title"]),a(pt)?(g(),x("div",Xv,[a(de)==="tasks"?(g(),Ce(gr,gn({key:0},re.value,{mobile:""},hn(on)),null,16)):(g(),x("div",Yv,[ue(dh,gn(xt.value,hn(mn)),null,16),i("section",Jv,[i("div",Qv,[i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="activity"?"tool-button-accent-subtle":""]),onClick:Z[3]||(Z[3]=we=>X.value="activity")},S(a(P)("workbench.activity")),3),i("button",{type:"button",class:Se(["tool-button px-3 py-1.5 text-sm",a(X)==="input"?"tool-button-accent-subtle":""]),onClick:Z[4]||(Z[4]=we=>X.value="input")},S(a(P)("workbench.input")),3)])]),i("div",Zv,[Wt(i("div",ey,[ue(lr,gn({ref_key:"codexPanelRef",ref:A},Le.value,{"empty-message":a(P)("workbench.selectTask")},hn(ds)),null,16,["empty-message"])],512),[[$s,a(X)==="activity"]]),Wt(i("div",ty,[i("div",ny,[i("div",sy,[i("div",oy,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[5]||(Z[5]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,"onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",ry,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[6]||(Z[6]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])],512),[[$s,a(X)==="input"]])])]))])):(g(),x("div",Uv,[ue(gr,gn(re.value,hn(on)),null,16),i("div",Vv,[i("div",zv,[st.value?(g(),Ce(lr,gn({key:0,ref_key:"codexPanelRef",ref:A},Le.value,hn(ds)),null,16)):me("",!0)]),i("div",Hv,[i("div",qv,[i("div",Kv,[i("div",Wv,[ue(cr,{"can-add-todo":a(Pe),"is-current-task-sending":a(Ne),"send-state":a(Ke),"todo-count":a(wt).length,uploading:a(yt),onAddTodo:sn,onOpenFilePicker:Z[1]||(Z[1]=we=>{var ke,u;return(u=(ke=a(fe))==null?void 0:ke.openFilePicker)==null?void 0:u.call(ke)}),onClearRequest:Ft,onCopyRequest:is,onManageTodo:nn,onSendRequest:Cn},null,8,["can-add-todo","is-current-task-sending","send-state","todo-count","uploading"]),ue(ur,{"agent-bindings":G.value,"selected-agent-engine":Q.value,align:"end","onUpdate:selectedAgentEngine":Fn},null,8,["agent-bindings","selected-agent-engine"])])]),i("div",Gv,[ue(mr,gn({ref_key:"editorRef",ref:fe,modelValue:a(J).blocks,"onUpdate:modelValue":Z[2]||(Z[2]=we=>a(J).blocks=we)},ot.value,hn(Kn)),null,16,["modelValue"])])])])])]))]))}},by=Object.freeze(Object.defineProperty({__proto__:null,default:ay},Symbol.toStringTag,{value:"Module"}));export{Sy as D,bs as W,Gr as _,Yr as a,Ju as b,hv as c,en as d,Gu as e,Fs as f,vy as g,Ze as h,wy as i,Ii as j,py as k,sl as l,Gc as m,Jr as n,gy as o,ct as p,Tu as q,xy as r,hy as s,ps as t,oa as u,yy as v,Ls as w,my as x,fy as y,by as z};
|