@seele00/seele-work 0.1.166 → 0.1.167

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.
Files changed (70) hide show
  1. package/libexec/seele-server +0 -0
  2. package/libexec/seele-worker +0 -0
  3. package/libexec/seele-workspace-observe +0 -0
  4. package/package.json +1 -1
  5. package/release-manifest.json +129 -129
  6. package/web/dist/assets/{abnfDiagram-VRR7QNED-Cmb4B9XM.js → abnfDiagram-VRR7QNED-b-DUXzjd.js} +1 -1
  7. package/web/dist/assets/{arc-CX4xNit8.js → arc-CJmqY7Yh.js} +1 -1
  8. package/web/dist/assets/{architectureDiagram-ZJ3FMSHR-Ch8xUTWk.js → architectureDiagram-ZJ3FMSHR-U-pimDJF.js} +1 -1
  9. package/web/dist/assets/{blockDiagram-677ZJIJ3-C9giuvqR.js → blockDiagram-677ZJIJ3-BpWiwfcj.js} +1 -1
  10. package/web/dist/assets/{c4Diagram-LMCZKHZV-Ah3zGnYY.js → c4Diagram-LMCZKHZV-DNBV4y5Y.js} +1 -1
  11. package/web/dist/assets/channel-CRleKbrN.js +1 -0
  12. package/web/dist/assets/{chunk-2Q5K7J3B-CaY5vtHW.js → chunk-2Q5K7J3B-BffuLo_B.js} +1 -1
  13. package/web/dist/assets/{chunk-32BRIVSS-LFncVjWu.js → chunk-32BRIVSS-BmvnFbG6.js} +1 -1
  14. package/web/dist/assets/{chunk-5VM5RSS4-BQIYcKzt.js → chunk-5VM5RSS4-CN2V3cia.js} +1 -1
  15. package/web/dist/assets/{chunk-EX3LRPZG-PNtB9BhO.js → chunk-EX3LRPZG-Dp0cFWYc.js} +1 -1
  16. package/web/dist/assets/{chunk-JWPE2WC7-CtbYmEYB.js → chunk-JWPE2WC7-C_sofavN.js} +1 -1
  17. package/web/dist/assets/{chunk-MOJQB5TN-Bb_iaYOj.js → chunk-MOJQB5TN-yf5rH-db.js} +1 -1
  18. package/web/dist/assets/{chunk-RYQCIY6F-BxzBspZN.js → chunk-RYQCIY6F-DDHsF9Jh.js} +1 -1
  19. package/web/dist/assets/{chunk-V7JOEXUC-C8sGpXkh.js → chunk-V7JOEXUC-7z77i5-X.js} +1 -1
  20. package/web/dist/assets/{chunk-VR4S4FIN-BW4T48Cc.js → chunk-VR4S4FIN-CEDvyq2A.js} +1 -1
  21. package/web/dist/assets/{chunk-XXDRQBXY-CF046tfg.js → chunk-XXDRQBXY-CkmbfbJF.js} +1 -1
  22. package/web/dist/assets/classDiagram-OUVF2IWQ-iTDfCl6n.js +1 -0
  23. package/web/dist/assets/classDiagram-v2-EOCWNBFH-iTDfCl6n.js +1 -0
  24. package/web/dist/assets/{core-zwIxNY4N.js → core-Cn8g1Lbi.js} +1 -1
  25. package/web/dist/assets/{cose-bilkent-JH36ORCC-bNBFqYO-.js → cose-bilkent-JH36ORCC-CwA_aKqP.js} +1 -1
  26. package/web/dist/assets/{cynefin-VYW2F7L2-Je9U-0Xr.js → cynefin-VYW2F7L2-Ba-P5Gu_.js} +1 -1
  27. package/web/dist/assets/{cynefinDiagram-TSTJHNR4-DJ646RvV.js → cynefinDiagram-TSTJHNR4-CRXpKgjI.js} +1 -1
  28. package/web/dist/assets/{dagre-VKFMJZFB-Eaq98ad4.js → dagre-VKFMJZFB-oa4b2J0n.js} +1 -1
  29. package/web/dist/assets/{diagram-FQU43EPY-C9B_Vbee.js → diagram-FQU43EPY-KK4hL8MV.js} +1 -1
  30. package/web/dist/assets/{diagram-G47NLZAW-C4VB7u3F.js → diagram-G47NLZAW-BAoiVO9n.js} +1 -1
  31. package/web/dist/assets/{diagram-NH7WQ7WH-aIXsPpJ4.js → diagram-NH7WQ7WH-CQvrMkgq.js} +1 -1
  32. package/web/dist/assets/{diagram-OA4YK3LP-1d_J6Ztj.js → diagram-OA4YK3LP-BZM_vS8H.js} +1 -1
  33. package/web/dist/assets/{diagram-WEI45ONY-B_V_uv2r.js → diagram-WEI45ONY-2NNQ6V-T.js} +1 -1
  34. package/web/dist/assets/{ebnfDiagram-CCIWWBDH-DcwesF92.js → ebnfDiagram-CCIWWBDH-BVTKfyKo.js} +1 -1
  35. package/web/dist/assets/{elk.bundled-BP0w9QVX.js → elk.bundled-Bh08ZzYo.js} +1 -1
  36. package/web/dist/assets/{erDiagram-Q63AITRT-BisCdcsq.js → erDiagram-Q63AITRT-CDBb3q8g.js} +1 -1
  37. package/web/dist/assets/{flowDiagram-23GEKE2U-BAw_EBuS.js → flowDiagram-23GEKE2U-CwmKT8IK.js} +1 -1
  38. package/web/dist/assets/{ganttDiagram-NO4QXBWP-SegQ7tyG.js → ganttDiagram-NO4QXBWP-CKroY5q8.js} +1 -1
  39. package/web/dist/assets/{gitGraphDiagram-IHSO6WYX-BsWRzjP-.js → gitGraphDiagram-IHSO6WYX-EoVYFlEk.js} +1 -1
  40. package/web/dist/assets/{index-BT0AwQxX.js → index-CSHLI29L.js} +2 -2
  41. package/web/dist/assets/{index-HPBlKZ1R.css → index-zrDoIOyr.css} +1 -1
  42. package/web/dist/assets/{infoDiagram-FWYZ7A6U-CS-Qraov.js → infoDiagram-FWYZ7A6U-FGFLH7d3.js} +1 -1
  43. package/web/dist/assets/{ishikawaDiagram-FXEZZL3T-7fkMczyw.js → ishikawaDiagram-FXEZZL3T-ScW8G-ZZ.js} +1 -1
  44. package/web/dist/assets/{journeyDiagram-5HDEW3XC-D1r2GqsF.js → journeyDiagram-5HDEW3XC-MwImxKDL.js} +1 -1
  45. package/web/dist/assets/{kanban-definition-HUTT4EX6-C9fjNYHs.js → kanban-definition-HUTT4EX6-v7K2gcGS.js} +1 -1
  46. package/web/dist/assets/{linear-ZeLYF1qT.js → linear-C2xaLGnX.js} +1 -1
  47. package/web/dist/assets/{mermaid.core-u6kdiNZf.js → mermaid.core-kum-uKSk.js} +5 -5
  48. package/web/dist/assets/{mindmap-definition-LN4V7U3C-BA7esxDQ.js → mindmap-definition-LN4V7U3C-BbHJGzmN.js} +1 -1
  49. package/web/dist/assets/{pegDiagram-2B236MQR-Db3493r_.js → pegDiagram-2B236MQR-CyCY7vge.js} +1 -1
  50. package/web/dist/assets/{pieDiagram-ENE6RG2P-sdFTqxRz.js → pieDiagram-ENE6RG2P-B6cm-CVr.js} +1 -1
  51. package/web/dist/assets/{quadrantDiagram-ABIIQ3AL-DY-jB_ym.js → quadrantDiagram-ABIIQ3AL-CYuX1mSf.js} +1 -1
  52. package/web/dist/assets/{railroadDiagram-RFXS5EU6-DrgRQiui.js → railroadDiagram-RFXS5EU6-OivZtwDu.js} +1 -1
  53. package/web/dist/assets/{requirementDiagram-TGXJPOKE-BbIwBt6f.js → requirementDiagram-TGXJPOKE-NilMGO1p.js} +1 -1
  54. package/web/dist/assets/{sankeyDiagram-HTMAVEWB-CNlUs5qI.js → sankeyDiagram-HTMAVEWB-CvGW-7MO.js} +1 -1
  55. package/web/dist/assets/{sequenceDiagram-DBY2YBRQ-r0ipNvRQ.js → sequenceDiagram-DBY2YBRQ-DHF-ITmk.js} +1 -1
  56. package/web/dist/assets/{sizeCapture-X5ZJPWSS-DbakTPrf.js → sizeCapture-X5ZJPWSS-DzttbFuK.js} +1 -1
  57. package/web/dist/assets/{stateDiagram-2N3HPSRC-DvOZm-1l.js → stateDiagram-2N3HPSRC-Ev9u0H67.js} +1 -1
  58. package/web/dist/assets/stateDiagram-v2-6OUMAXLB-CFgmir2v.js +1 -0
  59. package/web/dist/assets/{swimlanes-5IMT3BWC-DMayo9Yu.js → swimlanes-5IMT3BWC-Du7RiMfc.js} +2 -2
  60. package/web/dist/assets/swimlanesDiagram-G3AALYLV-Behm1fLU.js +8 -0
  61. package/web/dist/assets/{timeline-definition-FHXFAJF6-DRrIdo8E.js → timeline-definition-FHXFAJF6-yzGBaGbX.js} +1 -1
  62. package/web/dist/assets/{vennDiagram-L72KCM5P-B4q7wqgw.js → vennDiagram-L72KCM5P-SPO02gLA.js} +1 -1
  63. package/web/dist/assets/{wardleyDiagram-EHGQE667-e8k1wEUp.js → wardleyDiagram-EHGQE667-aWi8ZEHw.js} +1 -1
  64. package/web/dist/assets/{xychartDiagram-FW5EYKEG-HcPBslW6.js → xychartDiagram-FW5EYKEG-B6NChDl8.js} +1 -1
  65. package/web/dist/index.html +2 -2
  66. package/web/dist/assets/channel-B191Oxtt.js +0 -1
  67. package/web/dist/assets/classDiagram-OUVF2IWQ-CKLa38O2.js +0 -1
  68. package/web/dist/assets/classDiagram-v2-EOCWNBFH-CKLa38O2.js +0 -1
  69. package/web/dist/assets/stateDiagram-v2-6OUMAXLB-CZI9uOPV.js +0 -1
  70. package/web/dist/assets/swimlanesDiagram-G3AALYLV-Czpxy_Ud.js +0 -8
@@ -343,7 +343,7 @@ $$
343
343
 
344
344
  `:t)}const Lv=/[#.]/g;function bA(e,t){const n=e||"",a={};let l=0,u,c;for(;l<n.length;){Lv.lastIndex=l;const f=Lv.exec(n),h=n.slice(l,f?f.index:n.length);h&&(u?u==="#"?a.id=h:Array.isArray(a.className)?a.className.push(h):a.className=[h]:c=h,l+=h.length),f&&(u=f[0],l++)}return{type:"element",tagName:c||t||"div",properties:a,children:[]}}function a6(e,t,n){const a=n?jA(n):void 0;function l(u,c,...f){let h;if(u==null){h={type:"root",children:[]};const m=c;f.unshift(m)}else{h=bA(u,t);const m=h.tagName.toLowerCase(),p=a?a.get(m):void 0;if(h.tagName=p||m,wA(c))f.unshift(c);else for(const[y,k]of Object.entries(c))kA(e,h.properties,y,k)}for(const m of f)Zp(h.children,m);return h.type==="element"&&h.tagName==="template"&&(h.content={type:"root",children:h.children},h.children=[]),h}return l}function wA(e){if(e===null||typeof e!="object"||Array.isArray(e))return!0;if(typeof e.type!="string")return!1;const t=e,n=Object.keys(e);for(const a of n){const l=t[a];if(l&&typeof l=="object"){if(!Array.isArray(l))return!0;const u=l;for(const c of u)if(typeof c!="number"&&typeof c!="string")return!0}}return!!("children"in e&&Array.isArray(e.children))}function kA(e,t,n,a){const l=nx(e,n);let u;if(a!=null){if(typeof a=="number"){if(Number.isNaN(a))return;u=a}else typeof a=="boolean"?u=a:typeof a=="string"?l.spaceSeparated?u=f2(a):l.commaSeparated?u=s2(a):l.commaOrSpaceSeparated?u=f2(s2(a).join(" ")):u=Bv(l,l.property,a):Array.isArray(a)?u=[...a]:u=l.property==="style"?SA(a):String(a);if(Array.isArray(u)){const c=[];for(const f of u)c.push(Bv(l,l.property,f));u=c}l.property==="className"&&Array.isArray(t.className)&&(u=t.className.concat(u)),t[l.property]=u}}function Zp(e,t){if(t!=null)if(typeof t=="number"||typeof t=="string")e.push({type:"text",value:String(t)});else if(Array.isArray(t))for(const n of t)Zp(e,n);else if(typeof t=="object"&&"type"in t)t.type==="root"?Zp(e,t.children):e.push(t);else throw new Error("Expected node, nodes, or string, got `"+t+"`")}function Bv(e,t,n){if(typeof n=="string"){if(e.number&&n&&!Number.isNaN(Number(n)))return Number(n);if((e.boolean||e.overloadedBoolean)&&(n===""||Zc(n)===Zc(t)))return!0}return n}function SA(e){const t=[];for(const[n,a]of Object.entries(e))t.push([n,a].join(": "));return t.join("; ")}function jA(e){const t=new Map;for(const n of e)t.set(n.toLowerCase(),n);return t}const CA=["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","solidColor","textArea","textPath"],TA=a6(rx,"div"),AA=a6(kf,"g",CA),ip={html:"http://www.w3.org/1999/xhtml",svg:"http://www.w3.org/2000/svg"};function EA(e,t){return i6(e,{})||{type:"root",children:[]}}function i6(e,t){const n=NA(e,t);return n&&t.afterTransform&&t.afterTransform(e,n),n}function NA(e,t){switch(e.nodeType){case 1:return RA(e,t);case 3:return DA(e);case 8:return zA(e);case 9:return qv(e,t);case 10:return MA();case 11:return qv(e,t);default:return}}function qv(e,t){return{type:"root",children:l6(e,t)}}function MA(){return{type:"doctype"}}function DA(e){return{type:"text",value:e.nodeValue||""}}function zA(e){return{type:"comment",value:e.nodeValue||""}}function RA(e,t){const n=e.namespaceURI,a=n===ip.svg?AA:TA,l=n===ip.html?e.tagName.toLowerCase():e.tagName,u=n===ip.html&&l==="template"?e.content:e,c=e.getAttributeNames(),f={};let h=-1;for(;++h<c.length;)f[c[h]]=e.getAttribute(c[h])||"";return a(l,f,l6(u,t))}function l6(e,t){const n=e.childNodes,a=[];let l=-1;for(;++l<n.length;){const u=i6(n[l],t);u!==void 0&&a.push(u)}return a}new DOMParser;function OA(e,t){const n=IA(e);return EA(n)}function IA(e){const t=document.createElement("template");return t.innerHTML=e,t.content}const Uv=(function(e,t,n){const a=s0(n);if(!e||!e.type||!e.children)throw new Error("Expected parent node");if(typeof t=="number"){if(t<0||t===Number.POSITIVE_INFINITY)throw new Error("Expected positive finite number as index")}else if(t=e.children.indexOf(t),t<0)throw new Error("Expected child node or index");for(;++t<e.children.length;)if(a(e.children[t],t,e))return e.children[t]}),eo=(function(e){if(e==null)return BA;if(typeof e=="string")return LA(e);if(typeof e=="object")return _A(e);if(typeof e=="function")return W1(e);throw new Error("Expected function, string, or array as `test`")});function _A(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=eo(e[n]);return W1(a);function a(...l){let u=-1;for(;++u<t.length;)if(t[u].apply(this,l))return!0;return!1}}function LA(e){return W1(t);function t(n){return n.tagName===e}}function W1(e){return t;function t(n,a,l){return!!(qA(n)&&e.call(this,n,typeof a=="number"?a:void 0,l||void 0))}}function BA(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="element"&&"tagName"in e&&typeof e.tagName=="string")}function qA(e){return e!==null&&typeof e=="object"&&"type"in e&&"tagName"in e}const Hv=/\n/g,$v=/[\t ]+/g,Qp=eo("br"),Fv=eo(YA),UA=eo("p"),Pv=eo("tr"),HA=eo(["datalist","head","noembed","noframes","noscript","rp","script","style","template","title",VA,WA]),s6=eo(["address","article","aside","blockquote","body","caption","center","dd","dialog","dir","dl","dt","div","figure","figcaption","footer","form,","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","legend","li","listing","main","menu","nav","ol","p","plaintext","pre","section","ul","xmp"]);function $A(e,t){const n=t||{},a="children"in e?e.children:[],l=s6(e),u=c6(e,{whitespace:n.whitespace||"normal"}),c=[];(e.type==="text"||e.type==="comment")&&c.push(...u6(e,{breakBefore:!0,breakAfter:!0}));let f=-1;for(;++f<a.length;)c.push(...o6(a[f],e,{whitespace:u,breakBefore:f?void 0:l,breakAfter:f<a.length-1?Qp(a[f+1]):l}));const h=[];let m;for(f=-1;++f<c.length;){const p=c[f];typeof p=="number"?m!==void 0&&p>m&&(m=p):p&&(m!==void 0&&m>-1&&h.push(`
345
345
  `.repeat(m)||" "),m=-1,h.push(p))}return h.join("")}function o6(e,t,n){return e.type==="element"?FA(e,t,n):e.type==="text"?n.whitespace==="normal"?u6(e,n):PA(e):[]}function FA(e,t,n){const a=c6(e,n),l=e.children||[];let u=-1,c=[];if(HA(e))return c;let f,h;for(Qp(e)||Pv(e)&&Uv(t,e,Pv)?h=`
346
- `:UA(e)?(f=2,h=2):s6(e)&&(f=1,h=1);++u<l.length;)c=c.concat(o6(l[u],e,{whitespace:a,breakBefore:u?void 0:f,breakAfter:u<l.length-1?Qp(l[u+1]):h}));return Fv(e)&&Uv(t,e,Fv)&&c.push(" "),f&&c.unshift(f),h&&c.push(h),c}function u6(e,t){const n=String(e.value),a=[],l=[];let u=0;for(;u<=n.length;){Hv.lastIndex=u;const h=Hv.exec(n),m=h&&"index"in h?h.index:n.length;a.push(GA(n.slice(u,m).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),u===0?t.breakBefore:!0,m===n.length?t.breakAfter:!0)),u=m+1}let c=-1,f;for(;++c<a.length;)a[c].charCodeAt(a[c].length-1)===8203||c<a.length-1&&a[c+1].charCodeAt(0)===8203?(l.push(a[c]),f=void 0):a[c]?(typeof f=="number"&&l.push(f),l.push(a[c]),f=0):(c===0||c===a.length-1)&&l.push(0);return l}function PA(e){return[String(e.value)]}function GA(e,t,n){const a=[];let l=0,u;for(;l<e.length;){$v.lastIndex=l;const c=$v.exec(e);u=c?c.index:e.length,!l&&!u&&c&&!t&&a.push(""),l!==u&&a.push(e.slice(l,u)),l=c?u+c[0].length:u}return l!==u&&!n&&a.push(""),a.join(" ")}function c6(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function VA(e){return!!(e.properties||{}).hidden}function YA(e){return e.tagName==="td"||e.tagName==="th"}function WA(e){return e.tagName==="dialog"&&!(e.properties||{}).open}const KA={},XA=[];function ZA(e){const t=e||KA;return function(n,a){T1(n,"element",function(l,u){const c=Array.isArray(l.properties.className)?l.properties.className:XA,f=c.includes("language-math"),h=c.includes("math-display"),m=c.includes("math-inline");let p=h;if(!f&&!h&&!m)return;let y=u[u.length-1],k=l;if(l.tagName==="code"&&f&&y&&y.type==="element"&&y.tagName==="pre"&&(k=y,y=u[u.length-2],p=!0),!y)return;const x=$A(k,{whitespace:"pre"});let C;try{C=Xp.renderToString(x,{...t,displayMode:p,throwOnError:!0})}catch(I){const _=I,N=_.name.toLowerCase();a.message("Could not render math with KaTeX",{ancestors:[...u,l],cause:_,place:l.position,ruleId:N,source:"rehype-katex"});try{C=Xp.renderToString(x,{...t,displayMode:p,strict:"ignore",throwOnError:!1})}catch{C=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(I)},children:[{type:"text",value:x}]}]}}typeof C=="string"&&(C=OA(C).children);const M=y.children.indexOf(k);return y.children.splice(M,1,...C),Mx})}}function QA(e,t,n){return e?t?n==="delta"?e+t:t.startsWith(e)?t:e:e:t}function JA(e,t,n){if(e.kind||e.status!=="pending")return e.status;const a=[...t].reverse().find(l=>l.nodeId===e.id);return a?a.status==="completed"?n.some(l=>l.executionId===a.id&&l.type==="result")?"delivered":"awaiting_review":["accepted","running","failed","cancelled"].includes(a.status)?a.status:e.status:e.status}function eE(e,t){var l;if(!["input:cotask_report","input:cotask_execution"].includes(e.subtype))return null;const n=Date.parse(e.createdAt);return((l=t.filter(u=>(!e.turnId||e.turnId===u.id)&&Date.parse(u.startedAt)<n&&(!u.finishedAt||n<=Date.parse(u.finishedAt))).sort((u,c)=>Date.parse(c.startedAt)-Date.parse(u.startedAt))[0])==null?void 0:l.id)??null}function tE(e){const t=e.phase??e.status,n=e.nodeActivity;if(!n||["draft","finished","completed","cancelled"].includes(t))return[{status:t}];const a=[];return t!=="running"&&a.push({status:t}),n.blocked>0&&a.push({status:"blocked",count:n.blocked}),n.waiting>0&&a.push({status:"waiting",count:n.waiting}),t==="running"&&(n.running>0||a.length===0)&&a.push({status:"running"}),a}const n0=224,Wi=76,Gv=e=>`${e.x},${e.y}`,lp=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),nE=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});function Jp(e,t,n=0){const a=Math.min(...e.map(p=>p.x)),l=Math.max(...e.map(p=>p.x)),u=Math.min(...e.map(p=>p.y)),c=Math.max(...e.map(p=>p.y));if(l<t.x-4||a>t.x+n0+4||c<t.y-4||u>t.y+(t.height??Wi)+4)return!1;if(n>=16||Math.max(l-a,c-u)<.25)return!0;const f=[e[0]],h=[e[e.length-1]];let m=e;for(;m.length>1;)m=m.slice(1).map((p,y)=>nE(m[y],p)),f.push(m[0]),h.unshift(m[m.length-1]);return Jp(f,t,n+1)||Jp(h,t,n+1)}function Vv(e,t){return e.every(n=>t.every(a=>!Jp(n,a)))}function rE(e,t){const n=[];let a=e[0];const l=(u,c,f)=>{const h=f/lp(u,c);return{x:u.x+(c.x-u.x)*h,y:u.y+(c.y-u.y)*h}};for(let u=1;u<e.length-1;u++){const c=e[u],f=e[u-1],h=e[u+1],m=Math.min(t,lp(c,f)/2,lp(c,h)/2);if(m<.001){n.push([a,c]),a=c;continue}const p=l(c,f,m),y=l(c,h,m);n.push([a,p],[p,c,y]),a=y}return n.push([a,e[e.length-1]]),n}function Yv(e){return`M ${Gv(e[0][0])} `+e.map(t=>`${t.length===4?"C":t.length===3?"Q":"L"} ${t.slice(1).map(Gv).join(" ")}`).join(" ")}function d6(e,t){const n=e[0],a=e[e.length-1],l=(n.y+a.y)/2,u=[[n,{x:n.x,y:l},{x:a.x,y:l},a]];if(a.y>n.y&&Vv(u,t))return{path:Yv(u),segments:u};for(const c of[64,40,24,12,6,2,0]){const f=rE(e,c);if(Vv(f,t))return{path:Yv(f),segments:f}}throw new Error("No unobstructed CoTask route")}function aE(e){return JSON.stringify(e.map(t=>({id:t.id,dependencies:[...t.dependencies].sort(),height:t.height??Wi})).sort((t,n)=>t.id.localeCompare(n.id)))}function f6(e){const t=new Map,n=new Map,a=new Map(e.map(x=>[x.id,x])),l=[];for(;a.size;){const x=[...a.values()].filter(M=>M.dependencies.every(I=>n.has(I)||!a.has(I))),C=x.length?x:[...a.values()];l.push(C);for(const M of C)a.delete(M.id),n.set(M.id,l.length-1)}const u=Math.max(1,...l.map(x=>x.length))*296-24,c=[];let f=24;l.forEach(x=>{x.forEach((M,I)=>t.set(M.id,{x:(u-(x.length*296-72))/2+I*296,y:f}));const C=f+Math.max(Wi,...x.map(M=>M.height??Wi));c.push(C),f=C+80});const h=new Map(e.map(x=>[x.id,x.height??Wi])),m=[...t].map(([x,C])=>({id:x,...C,height:h.get(x)})),p=[],y=[];let k=u;for(const x of e)for(const C of x.dependencies){const M=t.get(C),I=t.get(x.id);if(!M||!I)continue;const _={x:M.x+n0/2,y:M.y+(h.get(C)??Wi)},N={x:I.x+n0/2,y:I.y};k+=18;const q=c[n.get(C)]+25,R=[_,{x:_.x,y:q},{x:k,y:q},{x:k,y:N.y-25},{x:N.x,y:N.y-25},N],X=m.filter(P=>P.id!==C&&P.id!==x.id);try{p.push({source:C,target:x.id,path:d6(R,X).path})}catch{y.push({source:C,target:x.id})}}return{positions:t,edges:p,failedEdges:y,width:k+48,height:Math.max(124,f-80+24)}}async function iE(e){var m;if(!e.length)return f6(e);const{default:t}=await ln(async()=>{const{default:p}=await import("./elk.bundled-BP0w9QVX.js").then(y=>y.e);return{default:p}},[],import.meta.url),n=new Set(e.map(p=>p.id)),a=e.flatMap(p=>p.dependencies.filter(y=>n.has(y)).map(y=>({source:y,target:p.id}))),u=await new t().layout({id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.layered.spacing.edgeNodeBetweenLayers":"18","elk.padding":"[top=24,left=24,bottom=24,right=24]","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX"},children:e.map(p=>({id:p.id,width:n0,height:p.height??Wi})),edges:a.map((p,y)=>({id:`edge-${y}`,sources:[p.source],targets:[p.target]}))}),c=(u.children??[]).map(p=>({id:p.id,x:p.x??0,y:p.y??0,height:p.height})),f=new Map((m=u.edges)==null?void 0:m.map(p=>[p.id,p])),h=a.map((p,y)=>{var C,M;const k=(M=(C=f.get(`edge-${y}`))==null?void 0:C.sections)==null?void 0:M[0];if(!k)throw new Error("Missing CoTask dependency route");const x=[k.startPoint,...k.bendPoints??[],k.endPoint];return{...p,path:d6(x,c.filter(I=>I.id!==p.source&&I.id!==p.target)).path}});return{positions:new Map(c.map(p=>[p.id,p])),edges:h,width:u.width??320,height:u.height??196}}const Wv={pending:"待开始",completed:"已确认完成",blocked:"已阻塞",cancelled:"已取消",running:"执行中",accepted:"等待执行",failed:"执行失败",delivered:"已交付,待确认",awaiting_review:"执行已结束,待确认"};function lE({nodes:e,members:t,executions:n,reports:a,selectedId:l,onSelect:u,onDismiss:c,detail:f,finalCheckpointId:h}){var Ce,U;const m=e.some(E=>E.kind!==void 0),p=(E,Y)=>E.kind==="checkpoint"?{pending:"等待前置完成",waiting:"等待 Owner 继续",completed:"已继续"}[Y]??Wv[Y]??Y:E.kind&&Y==="completed"?"已完成":Wv[Y]??Y,[y,k]=A.useState({}),x=A.useRef(new Map);A.useEffect(()=>{const E=new ResizeObserver(()=>{k(Y=>{const O=Object.fromEntries([...x.current].map(([ee,ke])=>[ee,ke.offsetHeight]));return Object.keys(O).length===Object.keys(Y).length&&Object.entries(O).every(([ee,ke])=>Y[ee]===ke)?Y:O})});return x.current.forEach(Y=>E.observe(Y)),()=>E.disconnect()},[e.map(E=>E.id).join("\0")]);const C=aE(e.map(E=>({...E,height:y[E.id]??Wi}))),M=A.useMemo(()=>f6(JSON.parse(C)),[C]),[I,_]=A.useState(null),[N,q]=A.useState(!1),R=(I==null?void 0:I.topology)===C?I.graph:M;A.useEffect(()=>{let E=!0;return q(!1),iE(JSON.parse(C)).then(Y=>{E&&_({topology:C,graph:Y})}).catch(()=>{E&&q(!0)}),()=>{E=!1}},[C]);const X=A.useRef(null),[P,H]=A.useState({width:900,height:560}),[J,ne]=A.useState(1),[F,te]=A.useState(!1),se=A.useRef(!1),ve=A.useRef(null),be=A.useId().replace(/:/g,"");A.useEffect(()=>{if(!X.current)return;const E=new ResizeObserver(([Y])=>H({width:Y.contentRect.width,height:Y.contentRect.height}));return E.observe(X.current),()=>E.disconnect()},[]);const he=Math.min(1,Math.max(.15,Math.min((P.width-32)/R.width,(P.height-32)/R.height))),Z=J??he,me=new Map(e.map(E=>[E.id,JA(E,n,a)])),V=e.find(E=>E.id===l);return s.jsxs("section",{className:"cotask-graph","aria-label":"Task dependency graph",children:[s.jsxs("div",{className:"cotask-graph-toolbar",children:[s.jsxs("span",{children:["Arrows show dependencies ",s.jsxs("span",{className:"cotask-graph-count",children:["· ",e.length," nodes / ",R.edges.length+(((Ce=R.failedEdges)==null?void 0:Ce.length)??0)," dependencies"]}),N&&s.jsx("small",{role:"status",children:" · 自动布局暂不可用,已显示基础布局"})]}),s.jsxs("div",{children:[s.jsx("button",{"aria-label":"Zoom out",onClick:()=>ne(Math.max(.15,Z-.15)),children:"−"}),s.jsxs("span",{children:[Math.round(Z*100),"%"]}),s.jsx("button",{"aria-label":"Zoom in",onClick:()=>ne(Math.min(2,Z+.15)),children:"+"}),s.jsx("button",{onClick:()=>ne(1),children:"100%"}),s.jsx("button",{onClick:()=>ne(null),children:"Fit to view"})]})]}),!!((U=R.failedEdges)!=null&&U.length)&&s.jsxs("details",{className:"cotask-warning",role:"status",children:[s.jsxs("summary",{children:[R.failedEdges.length," 条依赖连线暂未能绘制,节点仍可查看"]}),s.jsx("ul",{children:R.failedEdges.map(E=>{var Y,O;return s.jsxs("li",{children:[((Y=e.find(ee=>ee.id===E.source))==null?void 0:Y.name)??E.source," → ",((O=e.find(ee=>ee.id===E.target))==null?void 0:O.name)??E.target]},`${E.source}:${E.target}`)})})]}),s.jsxs("div",{className:"cotask-graph-stage",children:[s.jsx("div",{className:`cotask-graph-viewport${F?" dragging":""}`,ref:X,"data-layout":(I==null?void 0:I.topology)===C?"adaptive":"fallback",onClickCapture:E=>{se.current&&(E.preventDefault(),E.stopPropagation())},onClick:E=>{E.target.closest("button")||c()},onPointerDown:E=>{if(E.button!==0||E.target.closest(".cotask-node-text"))return;se.current=!1;const Y=E.currentTarget;ve.current={id:E.pointerId,x:E.clientX,y:E.clientY,left:Y.scrollLeft,top:Y.scrollTop,moved:!1}},onPointerMove:E=>{if(!ve.current||ve.current.id!==E.pointerId)return;const Y=E.clientX-ve.current.x,O=E.clientY-ve.current.y;Math.abs(Y)+Math.abs(O)>4&&(ve.current.moved=!0,te(!0),E.currentTarget.setPointerCapture(E.pointerId),E.preventDefault()),ve.current.moved&&(E.currentTarget.scrollLeft=ve.current.left-Y,E.currentTarget.scrollTop=ve.current.top-O)},onPointerUp:E=>{ve.current&&(se.current=ve.current.moved,ve.current=null,te(!1),E.currentTarget.hasPointerCapture(E.pointerId)&&E.currentTarget.releasePointerCapture(E.pointerId),window.setTimeout(()=>{se.current=!1},0))},onPointerCancel:()=>{ve.current=null,te(!1)},onLostPointerCapture:()=>{ve.current=null,te(!1)},children:s.jsx("div",{className:"cotask-graph-scroll",style:{width:Math.max(P.width,R.width*Z),height:Math.max(P.height,R.height*Z)},children:s.jsxs("div",{className:"cotask-graph-canvas",style:{width:R.width,height:R.height,transform:`scale(${Z})`,left:0,top:0},children:[s.jsxs("svg",{width:R.width,height:R.height,className:"cotask-graph-edges","aria-hidden":"true",children:[s.jsx("defs",{children:["default","complete","selected"].map(E=>s.jsx("marker",{id:`${be}-${E}`,markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"userSpaceOnUse",children:s.jsx("path",{d:"M 1 1 L 7 4 L 1 7 Z",className:`cotask-arrow-${E}`})},E))}),R.edges.map(E=>{const Y=l&&[E.source,E.target].includes(l)?"selected":me.get(E.source)==="completed"?"complete":"default";return s.jsx("path",{"data-source":E.source,"data-target":E.target,d:E.path,className:`cotask-edge ${Y}`,markerEnd:`url(#${be}-${Y})`},`${E.source}:${E.target}`)})]}),e.map(E=>{var ee;const Y=R.positions.get(E.id),O=me.get(E.id);return s.jsxs("button",{ref:ke=>{ke?x.current.set(E.id,ke):x.current.delete(E.id)},className:`cotask-graph-node ${O}${E.kind==="checkpoint"?" checkpoint":""}${l===E.id?" selected":""}`,style:{left:Y.x,top:Y.y,width:n0,minHeight:Wi},"aria-pressed":l===E.id,onClick:()=>u(E),title:E.dependencies.length?`Depends on: ${E.dependencies.map(ke=>{var Ae;return((Ae=e.find(He=>He.id===ke))==null?void 0:Ae.name)??ke}).join(", ")}`:"No dependencies",children:[E.dependencies.length>0&&s.jsx("i",{className:"cotask-node-port input"}),s.jsx("strong",{className:"cotask-node-text",children:E.name}),s.jsxs("span",{className:"cotask-graph-node-footer",children:[s.jsx("span",{className:"cotask-graph-node-member cotask-node-text",children:E.kind==="checkpoint"?s.jsx(s.Fragment,{children:s.jsxs("span",{className:"cotask-checkpoint-type",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:s.jsx("path",{d:"M6 1 11 6 6 11 1 6Z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})}),E.id===h?"最终检查点":"检查点"]})}):((ee=t.find(ke=>ke.id===E.memberId))==null?void 0:ee.name)??E.memberId}),s.jsxs("span",{className:"cotask-graph-node-status",children:[s.jsx("i",{}),s.jsx("span",{className:"cotask-node-text",children:p(E,O)})]})]}),R.edges.some(ke=>ke.source===E.id)&&s.jsx("i",{className:"cotask-node-port output"})]},E.id)})]})})}),V&&s.jsxs("aside",{className:"cotask-node-drawer","aria-label":`Node details: ${V.name}`,onKeyDown:E=>{E.key==="Escape"&&(E.stopPropagation(),c())},children:[s.jsxs("header",{children:[s.jsx("strong",{children:V.name}),s.jsx("button",{onClick:c,"aria-label":"Close node details",children:"关闭"})]}),s.jsx("div",{className:"cotask-node-drawer-content",children:f},V.id)]})]}),s.jsxs("div",{className:"cotask-graph-legend",children:[s.jsxs("span",{children:[s.jsx("i",{className:"running"}),"执行中"]}),s.jsxs("span",{children:[s.jsx("i",{className:"delivered"}),m?"检查点等待继续":"待 Owner 确认"]}),s.jsxs("span",{children:[s.jsx("i",{className:"completed"}),m?"已完成 / 已继续":"已确认完成"]}),s.jsxs("span",{children:[s.jsx("i",{className:"pending"}),"待开始"]}),s.jsx("span",{children:m?"执行节点报告结果并正常结束后自动完成;检查点由 Owner 检查后继续":"点击节点查看上下文与报告;成员执行结束不等于节点已确认完成"})]})]})}const h6=e=>({draft:"草稿",running:"运行中",pausing:"正在暂停",paused:"已暂停",waiting:"等待继续",finished:"已结束",pending:"Pending",completed:"Completed",blocked:"Blocked",cancelled:"Cancelled",accepted:"Accepted",failed:"Failed"})[e]??e;function sp({task:e}){const t=tE(e),n={running:["active","进行中","M8 5l10 7-10 7Z"],finished:["done","已结束","m6 12 4 4 8-8"],completed:["done","已结束","m6 12 4 4 8-8"],paused:["attention","已暂停","M9 7v10M15 7v10"],pausing:["attention","正在暂停","M9 7v10M15 7v10"],waiting:["attention","等待检查","M12 6v6l4 2"],blocked:["danger","存在阻塞","M12 6v7m0 3v1"],failed:["danger","失败","M12 6v7m0 3v1"],cancelled:["neutral","已取消","m8 8 8 8m0-8-8 8"],draft:["neutral","草稿","M8 8h8M8 12h8M8 16h5"]};return s.jsx("span",{className:"cotask-task-statuses",children:t.map(({status:a,count:l})=>{const[u,c,f]=n[a]??["neutral",h6(a),"M12 6v6l4 2"];return s.jsxs("span",{className:`cotask-task-status ${u}`,children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:f})]}),c,l!=null&&` · ${l}`]},a)})})}function sE({ownerId:e,ownerName:t,request:n,onExpanded:a,renderMember:l,renderMarkdown:u}){const[c,f]=A.useState([]),[h,m]=A.useState(null),[p,y]=A.useState(null),[k,x]=A.useState("graph"),[C,M]=A.useState(null),[I,_]=A.useState(null),[N,q]=A.useState(null),[R,X]=A.useState([]),[P,H]=A.useState(null),[J,ne]=A.useState(null),[F,te]=A.useState([]),[se,ve]=A.useState(""),[be,he]=A.useState(!1),Z=A.useRef(null),me=A.useRef(0),V=A.useRef("");V.current=`${h}:${p==null?void 0:p.task.revision}`;const Ce=A.useRef(C);Ce.current=C;const U=`conversations/${encodeURIComponent(e)}/cotasks`;A.useEffect(()=>{let oe=!0;const Me=async()=>{try{const Ze=await n(U);oe&&f(Ze.tasks)}catch(Ze){oe&&ve(String(Ze))}};Me();const ze=window.setInterval(()=>void Me(),5e3);return()=>{oe=!1,window.clearInterval(ze)}},[U,n]),A.useEffect(()=>(a(h!==null),()=>a(!1)),[h,a]),A.useEffect(()=>{if(!h)return;let oe=!0;const Me=async()=>{try{const Ze=await n(`${U}/${encodeURIComponent(h)}`);if(oe&&(y(Ze),ve("")),k==="operations"){const Ut=await n(`${U}/${encodeURIComponent(h)}`,{operations:!0});oe&&te(Ut.operations)}}catch(Ze){oe&&ve(String(Ze))}};Me();const ze=window.setInterval(()=>void Me(),3e3);return()=>{oe=!1,window.clearInterval(ze)}},[h,U,n,k]),A.useEffect(()=>{var oe;h&&((oe=Z.current)==null||oe.focus())},[h]),A.useEffect(()=>{me.current++,H(null),ne(null),X([])},[p==null?void 0:p.task.revision]);const E=JSON.stringify(p==null?void 0:p.reports.map(oe=>oe.id)),Y=JSON.stringify(p==null?void 0:p.nodes.map(oe=>[oe.id,oe.status,oe.reason]));A.useEffect(()=>{if(!h||!I||!p)return;let oe=!0;if(!p.nodes.some(Me=>Me.id===I)){_(null),q(null);return}return n(`${U}/${encodeURIComponent(h)}`,{nodeIds:[I]}).then(Me=>{oe&&q(Me.nodes[0]??null)}).catch(Me=>{oe&&ve(String(Me))}),()=>{oe=!1}},[h,I,p==null?void 0:p.task.revision,E,Y,U,n]);const O=oe=>{_(null),me.current++,H(null),ne(null),te([]),ve(""),y(null),m(oe),x("graph"),M(null),q(null),X([])},ee=()=>{me.current++,_(null),q(null),X([])},ke=()=>{me.current++,m(null)},Ae=c.find(oe=>oe.status==="running")??c.find(oe=>oe.status==="draft")??c[0];if(!h)return Ae?s.jsxs("div",{className:"cotask-launcher",children:[s.jsxs("button",{className:"cotask-launch-primary",onClick:()=>O(Ae.id),children:[s.jsxs("span",{className:"cotask-launch-heading",children:[s.jsx("span",{children:"CoTask"}),s.jsx(sp,{task:Ae})]}),s.jsx("strong",{children:Ae.name}),s.jsxs("small",{children:["已完成 ",Ae.completedNodeCount??0," / ",Ae.nodeCount," 节点 ↗"]})]}),c.length>1&&s.jsxs("details",{className:"cotask-task-list",children:[s.jsxs("summary",{children:["其他任务(",c.length-1,")"]}),c.filter(oe=>oe.id!==Ae.id).map(oe=>s.jsxs("button",{onClick:()=>O(oe.id),children:[s.jsx("strong",{children:oe.name}),s.jsx(sp,{task:oe})]},oe.id))]})]}):null;const He=oe=>{I!==oe.id&&(me.current++,ve(""),q(null),X([]),_(oe.id))},it=async oe=>{const Me=++me.current;try{const ze=await n(`${U}/${h}`,{reportIds:[oe.id]});Me===me.current&&X(ze.reports)}catch(ze){ve(String(ze))}},pe=p==null?void 0:p.bindings.find(oe=>oe.memberId===C),Pe=p==null?void 0:p.members.find(oe=>oe.id===C),Ke=(oe,Me=e)=>s.jsx("div",{className:"cotask-markdown",children:u(oe??"",Me)});return s.jsx("div",{className:"context-panel-overlay settings-overlay cotask-overlay",children:s.jsxs("section",{className:"context-panel settings-panel cotask-frame",role:"dialog","aria-modal":"true","aria-label":"CoTask",tabIndex:-1,ref:Z,onKeyDown:oe=>{var Me;if(oe.stopPropagation(),oe.key==="Escape"&&(oe.preventDefault(),k==="graph"&&I?ee():ke()),oe.key==="Tab"){const ze=(Me=Z.current)==null?void 0:Me.querySelectorAll('button:not(:disabled),select,input,a[href],textarea,[tabindex="0"]');if(!(ze!=null&&ze.length))return;const Ze=ze[0],Ut=ze[ze.length-1];oe.shiftKey&&(document.activeElement===Ze||document.activeElement===Z.current)?(oe.preventDefault(),Ut.focus()):!oe.shiftKey&&document.activeElement===Ut&&(oe.preventDefault(),Ze.focus())}},children:[s.jsxs("header",{className:"cotask-header settings-panel-header",children:[s.jsxs("div",{children:[s.jsxs("p",{children:["CoTask · ",t]}),s.jsx("h1",{children:(p==null?void 0:p.task.name)??"Loading task…"})]}),p&&s.jsx(sp,{task:p.task}),s.jsxs("button",{className:"cotask-back",onClick:ke,title:`返回 ${t}`,children:[s.jsx("span",{"aria-hidden":"true",children:"← "}),"返回"]}),(p==null?void 0:p.task.status)==="draft"&&s.jsx("button",{className:"cotask-close-draft cotask-back",disabled:be,onClick:async()=>{if(!window.confirm(`Close draft “${p.task.name}”? It will not run. The task history will be retained.`))return;const oe=h,Me=V.current;he(!0),ve("");try{const ze=await n(`${U}/${encodeURIComponent(oe)}/close-draft`,{expectedRevision:p.task.revision},"POST");f(Ze=>Ze.map(Ut=>Ut.id===oe?ze.task:Ut)),V.current===Me&&y(Ze=>Ze&&{...Ze,task:ze.task})}catch(ze){V.current===Me&&ve(String(ze))}finally{he(!1)}},children:be?"Closing…":"Close draft"})]}),s.jsxs("aside",{className:"cotask-nav",children:[s.jsxs("section",{className:"workspace-group","aria-label":"Task navigation",children:[s.jsx("h2",{className:"cotask-nav-group-title",children:"Task"}),s.jsx("nav",{className:"workspace-group-items",children:[["graph","Task graph"],["operations","Activity"],["settings","Settings"]].map(([oe,Me])=>s.jsx("button",{className:`session-item${k===oe?" active":""}`,"aria-current":k===oe?"page":void 0,onClick:()=>{x(oe),M(null)},children:s.jsx("span",{className:"session-title",children:Me})},oe))})]}),s.jsxs("section",{className:"workspace-group","aria-label":"Task members",children:[s.jsx("h2",{className:"cotask-nav-group-title",children:"Members"}),s.jsx("div",{className:"workspace-group-items cotask-member-list",children:p==null?void 0:p.members.map(oe=>{const Me=p.executions.some(Ze=>Ze.memberId===oe.id&&["accepted","running"].includes(Ze.status)),ze=Me?"Running":p.bindings.some(Ze=>Ze.memberId===oe.id&&Ze.workspaceId)?"Idle":"Not created";return s.jsx("button",{className:`session-item${k==="member"&&C===oe.id?" active":""}`,title:`${oe.name} · ${ze}`,"aria-label":`${oe.name} · ${ze}`,"aria-current":k==="member"&&C===oe.id?"page":void 0,onClick:()=>{M(oe.id),x("member")},children:s.jsxs("span",{className:"session-heading",children:[s.jsx("span",{className:`session-status${Me?" running":""}`,"aria-hidden":"true"}),s.jsx("span",{className:"session-title",children:oe.name})]})},oe.id)})})]}),s.jsxs("button",{className:"cotask-return",onClick:ke,children:["← Back to ",t]})]}),s.jsxs("section",{className:"cotask-main",children:[se&&s.jsx("div",{className:"cotask-error",role:"alert",children:se}),s.jsx("div",{className:`cotask-body${k==="graph"?" cotask-graph-body":k==="member"?" cotask-member-body":""}`,children:p?s.jsxs(s.Fragment,{children:[p.warnings.length>0&&s.jsx("div",{className:"cotask-warning",children:p.warnings.map((oe,Me)=>s.jsxs("p",{children:[oe.id?`${oe.id}: `:"Common context: ","Context may exceed the injection limit. (estimated ",oe.estimatedTokens," tokens)"]},Me))}),k==="graph"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"cotask-section-heading",children:[s.jsx("h2",{children:"Task graph"}),s.jsxs("span",{children:[p.nodes.filter(oe=>oe.status==="completed").length," / ",p.nodes.length," Completed"]})]}),!p.nodes.length&&s.jsx("p",{children:"No nodes yet. Discuss the plan with the initiating agent to define the graph."}),s.jsxs("details",{className:"cotask-context",onToggle:oe=>{if(oe.currentTarget.open&&P===null){const Me=V.current;n(`${U}/${h}`,{view:"definition"}).then(ze=>{V.current===Me&&H(ze.definition.commonContext)}).catch(ze=>{V.current===Me&&ve(String(ze))})}},children:[s.jsx("summary",{children:"Common context"}),P===null?s.jsx("p",{children:"Loading…"}):Ke(P)]},p.task.revision),p.nodes.length>0&&s.jsx(lE,{finalCheckpointId:p.finalCheckpointId,nodes:p.nodes,members:p.members,executions:p.executions,reports:p.reports,selectedId:I??void 0,onSelect:oe=>void He(oe),onDismiss:ee,detail:(N==null?void 0:N.definition.id)===I?s.jsxs("div",{className:"cotask-node-detail",children:[N.runtime&&s.jsxs("p",{children:[h6(N.runtime.status),N.runtime.reason&&s.jsxs(s.Fragment,{children:[" · ",N.runtime.reason]})]}),Ke(N.definition.context),s.jsx("h4",{children:N.definition.kind==="checkpoint"?"检查点":"Reports"}),N.reports.length?N.reports.map(oe=>s.jsxs("button",{onClick:()=>void it(oe),children:[oe.type," · ",oe.summary]},oe.id)):s.jsx("p",{children:N.definition.kind==="checkpoint"?"此节点不启动成员执行,也不生成成员报告。Owner 按上下文检查交付内容后继续。":"No reports yet."}),R.map(oe=>{var Me;return s.jsxs("article",{children:[s.jsx("h4",{children:oe.summary}),Ke(oe.content,((Me=p.executions.find(ze=>ze.id===oe.executionId))==null?void 0:Me.workspaceId)??"")]},oe.id)})]}):s.jsx("p",{children:"Loading node…"})}),p.task.conclusion&&s.jsxs("details",{className:"cotask-conclusion",children:[s.jsx("summary",{children:"Conclusion"}),Ke(p.task.conclusion)]})]}),k==="operations"&&s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:"Activity"}),s.jsx("p",{children:"Changes are saved immediately and retained if a turn fails."}),F.length?F.map((oe,Me)=>s.jsxs("details",{className:"cotask-operation",children:[s.jsxs("summary",{children:[String(oe.action)," · ",String(oe.status)," · Turn ",String(oe.turnStatus)]}),s.jsx("pre",{children:JSON.stringify(oe,null,2)})]},Me)):s.jsx("p",{children:"No activity yet."})]}),k==="settings"&&s.jsx(oE,{task:p.task,path:`${U}/${h}/settings`,request:n,onSaved:oe=>y({...p,task:oe})},h),k==="member"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"cotask-section-heading",children:[s.jsx("h2",{children:Pe==null?void 0:Pe.name}),s.jsx("span",{children:"CoTask member"})]}),s.jsxs("details",{className:"cotask-context",onToggle:oe=>{if(oe.currentTarget.open&&C&&(J==null?void 0:J.id)!==C){const Me=C,ze=V.current;n(`${U}/${h}`,{memberIds:[Me]}).then(Ze=>{var Ut;V.current===ze&&Ce.current===Me&&ne({id:Me,context:((Ut=Ze.members[0])==null?void 0:Ut.context)??""})}).catch(Ze=>{V.current===ze&&Ce.current===Me&&ve(String(Ze))})}},children:[s.jsx("summary",{children:"Member context"}),(J==null?void 0:J.id)===C?Ke(J.context):s.jsx("p",{children:"Loading…"})]},`${C}:${p.task.revision}`),pe!=null&&pe.workspaceId?l(pe.workspaceId):s.jsx("p",{children:p.executions.some(oe=>oe.memberId===C)?"This member instance was removed. Execution history is retained.":p.task.executionMode==="self_driving"?"首次符合执行条件时,平台自动创建此成员实例。":"This member will be created when its first node is driven."})]})]}):s.jsx("p",{children:"Loading task…"})})]})]})})}function oE({task:e,path:t,request:n,onSaved:a}){var N,q;const[l,u]=A.useState({...e.runtimeSettings,mode:e.runtimeSettings.mode??"custom",fastMode:e.runtimeSettings.fastMode??!1}),[c,f]=A.useState(e.revision),[h,m]=A.useState([]),[p,y]=A.useState([]),[k,x]=A.useState(!1),[C,M]=A.useState("");A.useEffect(()=>{let R=!0;return Promise.all([n("settings/runtime/models?refresh=0"),n("settings/model-providers/options")]).then(([X,P])=>{R&&(m(X.models),y(P.channels))}).catch(X=>{R&&M(String(X))}),()=>{R=!1}},[n]);const I=h.find(R=>R.model===l.model||R.id===l.model),_=((N=I==null?void 0:I.supportedReasoningEfforts)==null?void 0:N.map(R=>R.reasoningEffort))??["none","minimal","low","medium","high","xhigh","max"];return s.jsxs("section",{className:"cotask-settings",children:[s.jsx("h2",{children:"Settings"}),s.jsx("p",{children:"Settings apply to the whole CoTask and take effect on each member’s next turn."}),s.jsxs("label",{children:["配置模式",s.jsxs("select",{value:l.mode,onChange:R=>u({...l,mode:R.target.value}),children:[s.jsx("option",{value:"global",children:"沿用 CoTask 默认配置"}),s.jsx("option",{value:"custom",children:"CoTask 自定义配置"})]})]}),l.mode==="global"?s.jsx("p",{children:"每个成员在下一次 turn 读取最新 CoTask 默认模型、推理强度和倍速设置;正在运行的 turn 不受影响。"}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:["Model source",s.jsxs("select",{value:l.modelSource.type==="codex"?"codex":l.modelSource.channelId,onChange:R=>u({...l,modelSource:R.target.value==="codex"?{type:"codex"}:{type:"custom",channelId:R.target.value}}),children:[s.jsx("option",{value:"codex",children:"Codex"}),l.modelSource.type==="custom"&&!p.some(R=>R.id===l.modelSource.channelId)&&s.jsx("option",{value:l.modelSource.channelId,children:"Current channel unavailable"}),p.map(R=>s.jsx("option",{value:R.id,children:R.name},R.id))]})]}),l.modelSource.type==="codex"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"1.5 倍速(Fast mode)"}),s.jsx("input",{type:"checkbox",checked:l.fastMode,onChange:R=>u({...l,fastMode:R.target.checked})})]}),s.jsxs("label",{children:["Model",s.jsxs("select",{value:l.model,onChange:R=>u({...l,model:R.target.value}),children:[s.jsx("option",{value:"",children:"Default model"}),l.model&&!h.some(R=>R.model===l.model)&&s.jsx("option",{children:l.model}),h.map(R=>s.jsx("option",{value:R.model,children:R.displayName},R.id))]})]}),s.jsxs("label",{children:["Reasoning effort",s.jsxs("select",{value:l.reasoningEffort,onChange:R=>u({...l,reasoningEffort:R.target.value}),children:[s.jsx("option",{value:"",children:"Default"}),l.reasoningEffort&&!_.includes(l.reasoningEffort)&&s.jsx("option",{children:l.reasoningEffort}),_.map(R=>s.jsx("option",{children:R},R))]})]})]}):s.jsxs("p",{children:["Channel model: ",((q=p.find(R=>R.id===l.modelSource.channelId))==null?void 0:q.model)??"Channel unavailable",". Codex reasoning effort does not apply to custom channels."]})]}),s.jsx("button",{disabled:k,onClick:async()=>{x(!0),M("");try{const R=await n(t,{expectedRevision:c,runtimeSettings:l},"PUT");f(R.task.revision),a(R.task),M("Saved. Changes take effect on the next turn.")}catch(R){M(`${String(R)}. If the task changed, reopen Settings before saving.`)}finally{x(!1)}},children:k?"Saving…":"Save settings"}),C&&s.jsx("p",{role:"status",children:C})]})}function uE(e,t=new Date){if(e==null||!Number.isInteger(e)||e<1||e>31)return null;const n=new Date(t.getTime()+480*60*1e3),a=n.getUTCFullYear(),l=n.getUTCMonth(),u=Date.UTC(a,l,n.getUTCDate()),c=h=>Date.UTC(a,l+h,Math.min(e,new Date(Date.UTC(a,l+h+1,0)).getUTCDate()));let f=c(0);return f<u&&(f=c(1)),{date:new Date(f).toISOString().slice(0,10),days:(f-u)/864e5}}function cE({content:e,streaming:t}){const[n,a]=A.useState(!1),l=A.useId();return s.jsxs("section",{className:`message reasoning${t?" is-streaming":""}${n?" is-expanded":""}`,children:[s.jsxs("button",{className:"reasoning-toggle",type:"button","aria-expanded":n,"aria-controls":l,onClick:()=>a(u=>!u),children:[s.jsx("span",{className:"reasoning-indicator","aria-hidden":"true"}),s.jsx("span",{children:t?"思考中":"思考过程"}),s.jsx("span",{className:"reasoning-action",children:n?"收起":"展开"}),s.jsx("svg",{className:"reasoning-chevron",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:s.jsx("path",{d:"m4 2 4 4-4 4",fill:"none",stroke:"currentColor",strokeWidth:"1.4"})})]}),s.jsx("div",{id:l,hidden:!n&&!t,className:`reasoning-content${n?"":" reasoning-preview"}`,children:s.jsx("div",{className:"message-body",children:n?e:e.slice(-600)})})]})}function dE(e,t){if(!t||typeof t!="object")return null;const{method:n,params:a}=t;if(!a)return null;if(n==="item/completed"){const m=a.item;if((m==null?void 0:m.type)!=="reasoning"||typeof m.id!="string")return null;const p=e.get(m.id)??{itemId:m.id,text:new Map,summary:new Map,completed:!1};for(const y of["text","summary"]){const k=m[y];Array.isArray(k)&&k.forEach((x,C)=>{typeof x=="string"&&x&&p[y].set(C,x)})}return p.completed=!0,e.set(m.id,p),p}const l=/^item\/reasoning\/(text|summaryText)(Delta|Snapshot)$/.exec(n??"");if(!l||typeof a.itemId!="string")return null;const u=l[1]==="text"?"text":"summary",c=a[u==="text"?"contentIndex":"summaryIndex"],f=a[l[2]==="Delta"?"delta":"text"];if(typeof c!="number"||!Number.isSafeInteger(c)||c<0||typeof f!="string")return null;const h=e.get(a.itemId)??{itemId:a.itemId,text:new Map,summary:new Map,completed:!1};return h[u].set(c,l[2]==="Snapshot"?f:(h[u].get(c)??"")+f),e.set(a.itemId,h),h}function fE(e){return[...e.text.size?e.text:e.summary].sort(([n],[a])=>n-a).map(([,n])=>n).join(`
346
+ `:UA(e)?(f=2,h=2):s6(e)&&(f=1,h=1);++u<l.length;)c=c.concat(o6(l[u],e,{whitespace:a,breakBefore:u?void 0:f,breakAfter:u<l.length-1?Qp(l[u+1]):h}));return Fv(e)&&Uv(t,e,Fv)&&c.push(" "),f&&c.unshift(f),h&&c.push(h),c}function u6(e,t){const n=String(e.value),a=[],l=[];let u=0;for(;u<=n.length;){Hv.lastIndex=u;const h=Hv.exec(n),m=h&&"index"in h?h.index:n.length;a.push(GA(n.slice(u,m).replace(/[\u061C\u200E\u200F\u202A-\u202E\u2066-\u2069]/g,""),u===0?t.breakBefore:!0,m===n.length?t.breakAfter:!0)),u=m+1}let c=-1,f;for(;++c<a.length;)a[c].charCodeAt(a[c].length-1)===8203||c<a.length-1&&a[c+1].charCodeAt(0)===8203?(l.push(a[c]),f=void 0):a[c]?(typeof f=="number"&&l.push(f),l.push(a[c]),f=0):(c===0||c===a.length-1)&&l.push(0);return l}function PA(e){return[String(e.value)]}function GA(e,t,n){const a=[];let l=0,u;for(;l<e.length;){$v.lastIndex=l;const c=$v.exec(e);u=c?c.index:e.length,!l&&!u&&c&&!t&&a.push(""),l!==u&&a.push(e.slice(l,u)),l=c?u+c[0].length:u}return l!==u&&!n&&a.push(""),a.join(" ")}function c6(e,t){if(e.type==="element"){const n=e.properties||{};switch(e.tagName){case"listing":case"plaintext":case"xmp":return"pre";case"nobr":return"nowrap";case"pre":return n.wrap?"pre-wrap":"pre";case"td":case"th":return n.noWrap?"nowrap":t.whitespace;case"textarea":return"pre-wrap"}}return t.whitespace}function VA(e){return!!(e.properties||{}).hidden}function YA(e){return e.tagName==="td"||e.tagName==="th"}function WA(e){return e.tagName==="dialog"&&!(e.properties||{}).open}const KA={},XA=[];function ZA(e){const t=e||KA;return function(n,a){T1(n,"element",function(l,u){const c=Array.isArray(l.properties.className)?l.properties.className:XA,f=c.includes("language-math"),h=c.includes("math-display"),m=c.includes("math-inline");let p=h;if(!f&&!h&&!m)return;let y=u[u.length-1],k=l;if(l.tagName==="code"&&f&&y&&y.type==="element"&&y.tagName==="pre"&&(k=y,y=u[u.length-2],p=!0),!y)return;const x=$A(k,{whitespace:"pre"});let C;try{C=Xp.renderToString(x,{...t,displayMode:p,throwOnError:!0})}catch(I){const _=I,N=_.name.toLowerCase();a.message("Could not render math with KaTeX",{ancestors:[...u,l],cause:_,place:l.position,ruleId:N,source:"rehype-katex"});try{C=Xp.renderToString(x,{...t,displayMode:p,strict:"ignore",throwOnError:!1})}catch{C=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(I)},children:[{type:"text",value:x}]}]}}typeof C=="string"&&(C=OA(C).children);const M=y.children.indexOf(k);return y.children.splice(M,1,...C),Mx})}}function QA(e,t,n){return e?t?n==="delta"?e+t:t.startsWith(e)?t:e:e:t}function JA(e,t,n){if(e.kind||e.status!=="pending")return e.status;const a=[...t].reverse().find(l=>l.nodeId===e.id);return a?a.status==="completed"?n.some(l=>l.executionId===a.id&&l.type==="result")?"delivered":"awaiting_review":["accepted","running","failed","cancelled"].includes(a.status)?a.status:e.status:e.status}function eE(e,t){var l;if(!["input:cotask_report","input:cotask_execution"].includes(e.subtype))return null;const n=Date.parse(e.createdAt);return((l=t.filter(u=>(!e.turnId||e.turnId===u.id)&&Date.parse(u.startedAt)<n&&(!u.finishedAt||n<=Date.parse(u.finishedAt))).sort((u,c)=>Date.parse(c.startedAt)-Date.parse(u.startedAt))[0])==null?void 0:l.id)??null}function tE(e){const t=e.phase??e.status,n=e.nodeActivity;if(!n||["draft","finished","completed","cancelled"].includes(t))return[{status:t}];const a=[];return t!=="running"&&a.push({status:t}),n.blocked>0&&a.push({status:"blocked",count:n.blocked}),n.waiting>0&&a.push({status:"waiting",count:n.waiting}),t==="running"&&(n.running>0||a.length===0)&&a.push({status:"running"}),a}const n0=224,Wi=76,Gv=e=>`${e.x},${e.y}`,lp=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),nE=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2});function Jp(e,t,n=0){const a=Math.min(...e.map(p=>p.x)),l=Math.max(...e.map(p=>p.x)),u=Math.min(...e.map(p=>p.y)),c=Math.max(...e.map(p=>p.y));if(l<t.x-4||a>t.x+n0+4||c<t.y-4||u>t.y+(t.height??Wi)+4)return!1;if(n>=16||Math.max(l-a,c-u)<.25)return!0;const f=[e[0]],h=[e[e.length-1]];let m=e;for(;m.length>1;)m=m.slice(1).map((p,y)=>nE(m[y],p)),f.push(m[0]),h.unshift(m[m.length-1]);return Jp(f,t,n+1)||Jp(h,t,n+1)}function Vv(e,t){return e.every(n=>t.every(a=>!Jp(n,a)))}function rE(e,t){const n=[];let a=e[0];const l=(u,c,f)=>{const h=f/lp(u,c);return{x:u.x+(c.x-u.x)*h,y:u.y+(c.y-u.y)*h}};for(let u=1;u<e.length-1;u++){const c=e[u],f=e[u-1],h=e[u+1],m=Math.min(t,lp(c,f)/2,lp(c,h)/2);if(m<.001){n.push([a,c]),a=c;continue}const p=l(c,f,m),y=l(c,h,m);n.push([a,p],[p,c,y]),a=y}return n.push([a,e[e.length-1]]),n}function Yv(e){return`M ${Gv(e[0][0])} `+e.map(t=>`${t.length===4?"C":t.length===3?"Q":"L"} ${t.slice(1).map(Gv).join(" ")}`).join(" ")}function d6(e,t){const n=e[0],a=e[e.length-1],l=(n.y+a.y)/2,u=[[n,{x:n.x,y:l},{x:a.x,y:l},a]];if(a.y>n.y&&Vv(u,t))return{path:Yv(u),segments:u};for(const c of[64,40,24,12,6,2,0]){const f=rE(e,c);if(Vv(f,t))return{path:Yv(f),segments:f}}throw new Error("No unobstructed CoTask route")}function aE(e){return JSON.stringify(e.map(t=>({id:t.id,dependencies:[...t.dependencies].sort(),height:t.height??Wi})).sort((t,n)=>t.id.localeCompare(n.id)))}function f6(e){const t=new Map,n=new Map,a=new Map(e.map(x=>[x.id,x])),l=[];for(;a.size;){const x=[...a.values()].filter(M=>M.dependencies.every(I=>n.has(I)||!a.has(I))),C=x.length?x:[...a.values()];l.push(C);for(const M of C)a.delete(M.id),n.set(M.id,l.length-1)}const u=Math.max(1,...l.map(x=>x.length))*296-24,c=[];let f=24;l.forEach(x=>{x.forEach((M,I)=>t.set(M.id,{x:(u-(x.length*296-72))/2+I*296,y:f}));const C=f+Math.max(Wi,...x.map(M=>M.height??Wi));c.push(C),f=C+80});const h=new Map(e.map(x=>[x.id,x.height??Wi])),m=[...t].map(([x,C])=>({id:x,...C,height:h.get(x)})),p=[],y=[];let k=u;for(const x of e)for(const C of x.dependencies){const M=t.get(C),I=t.get(x.id);if(!M||!I)continue;const _={x:M.x+n0/2,y:M.y+(h.get(C)??Wi)},N={x:I.x+n0/2,y:I.y};k+=18;const q=c[n.get(C)]+25,R=[_,{x:_.x,y:q},{x:k,y:q},{x:k,y:N.y-25},{x:N.x,y:N.y-25},N],X=m.filter(P=>P.id!==C&&P.id!==x.id);try{p.push({source:C,target:x.id,path:d6(R,X).path})}catch{y.push({source:C,target:x.id})}}return{positions:t,edges:p,failedEdges:y,width:k+48,height:Math.max(124,f-80+24)}}async function iE(e){var m;if(!e.length)return f6(e);const{default:t}=await ln(async()=>{const{default:p}=await import("./elk.bundled-Bh08ZzYo.js").then(y=>y.e);return{default:p}},[],import.meta.url),n=new Set(e.map(p=>p.id)),a=e.flatMap(p=>p.dependencies.filter(y=>n.has(y)).map(y=>({source:y,target:p.id}))),u=await new t().layout({id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":"DOWN","elk.edgeRouting":"ORTHOGONAL","elk.spacing.nodeNode":"40","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.layered.spacing.edgeNodeBetweenLayers":"18","elk.padding":"[top=24,left=24,bottom=24,right=24]","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX"},children:e.map(p=>({id:p.id,width:n0,height:p.height??Wi})),edges:a.map((p,y)=>({id:`edge-${y}`,sources:[p.source],targets:[p.target]}))}),c=(u.children??[]).map(p=>({id:p.id,x:p.x??0,y:p.y??0,height:p.height})),f=new Map((m=u.edges)==null?void 0:m.map(p=>[p.id,p])),h=a.map((p,y)=>{var C,M;const k=(M=(C=f.get(`edge-${y}`))==null?void 0:C.sections)==null?void 0:M[0];if(!k)throw new Error("Missing CoTask dependency route");const x=[k.startPoint,...k.bendPoints??[],k.endPoint];return{...p,path:d6(x,c.filter(I=>I.id!==p.source&&I.id!==p.target)).path}});return{positions:new Map(c.map(p=>[p.id,p])),edges:h,width:u.width??320,height:u.height??196}}const Wv={pending:"待开始",completed:"已确认完成",blocked:"已阻塞",cancelled:"已取消",running:"执行中",accepted:"等待执行",failed:"执行失败",delivered:"已交付,待确认",awaiting_review:"执行已结束,待确认"};function lE({nodes:e,members:t,executions:n,reports:a,selectedId:l,onSelect:u,onDismiss:c,detail:f,finalCheckpointId:h}){var Ce,U;const m=e.some(E=>E.kind!==void 0),p=(E,Y)=>E.kind==="checkpoint"?{pending:"等待前置完成",waiting:"等待 Owner 继续",completed:"已继续"}[Y]??Wv[Y]??Y:E.kind&&Y==="completed"?"已完成":Wv[Y]??Y,[y,k]=A.useState({}),x=A.useRef(new Map);A.useEffect(()=>{const E=new ResizeObserver(()=>{k(Y=>{const O=Object.fromEntries([...x.current].map(([ee,ke])=>[ee,ke.offsetHeight]));return Object.keys(O).length===Object.keys(Y).length&&Object.entries(O).every(([ee,ke])=>Y[ee]===ke)?Y:O})});return x.current.forEach(Y=>E.observe(Y)),()=>E.disconnect()},[e.map(E=>E.id).join("\0")]);const C=aE(e.map(E=>({...E,height:y[E.id]??Wi}))),M=A.useMemo(()=>f6(JSON.parse(C)),[C]),[I,_]=A.useState(null),[N,q]=A.useState(!1),R=(I==null?void 0:I.topology)===C?I.graph:M;A.useEffect(()=>{let E=!0;return q(!1),iE(JSON.parse(C)).then(Y=>{E&&_({topology:C,graph:Y})}).catch(()=>{E&&q(!0)}),()=>{E=!1}},[C]);const X=A.useRef(null),[P,H]=A.useState({width:900,height:560}),[J,ne]=A.useState(1),[F,te]=A.useState(!1),se=A.useRef(!1),ve=A.useRef(null),be=A.useId().replace(/:/g,"");A.useEffect(()=>{if(!X.current)return;const E=new ResizeObserver(([Y])=>H({width:Y.contentRect.width,height:Y.contentRect.height}));return E.observe(X.current),()=>E.disconnect()},[]);const he=Math.min(1,Math.max(.15,Math.min((P.width-32)/R.width,(P.height-32)/R.height))),Z=J??he,me=new Map(e.map(E=>[E.id,JA(E,n,a)])),V=e.find(E=>E.id===l);return s.jsxs("section",{className:"cotask-graph","aria-label":"Task dependency graph",children:[s.jsxs("div",{className:"cotask-graph-toolbar",children:[s.jsxs("span",{children:["Arrows show dependencies ",s.jsxs("span",{className:"cotask-graph-count",children:["· ",e.length," nodes / ",R.edges.length+(((Ce=R.failedEdges)==null?void 0:Ce.length)??0)," dependencies"]}),N&&s.jsx("small",{role:"status",children:" · 自动布局暂不可用,已显示基础布局"})]}),s.jsxs("div",{children:[s.jsx("button",{"aria-label":"Zoom out",onClick:()=>ne(Math.max(.15,Z-.15)),children:"−"}),s.jsxs("span",{children:[Math.round(Z*100),"%"]}),s.jsx("button",{"aria-label":"Zoom in",onClick:()=>ne(Math.min(2,Z+.15)),children:"+"}),s.jsx("button",{onClick:()=>ne(1),children:"100%"}),s.jsx("button",{onClick:()=>ne(null),children:"Fit to view"})]})]}),!!((U=R.failedEdges)!=null&&U.length)&&s.jsxs("details",{className:"cotask-warning",role:"status",children:[s.jsxs("summary",{children:[R.failedEdges.length," 条依赖连线暂未能绘制,节点仍可查看"]}),s.jsx("ul",{children:R.failedEdges.map(E=>{var Y,O;return s.jsxs("li",{children:[((Y=e.find(ee=>ee.id===E.source))==null?void 0:Y.name)??E.source," → ",((O=e.find(ee=>ee.id===E.target))==null?void 0:O.name)??E.target]},`${E.source}:${E.target}`)})})]}),s.jsxs("div",{className:"cotask-graph-stage",children:[s.jsx("div",{className:`cotask-graph-viewport${F?" dragging":""}`,ref:X,"data-layout":(I==null?void 0:I.topology)===C?"adaptive":"fallback",onClickCapture:E=>{se.current&&(E.preventDefault(),E.stopPropagation())},onClick:E=>{E.target.closest("button")||c()},onPointerDown:E=>{if(E.button!==0||E.target.closest(".cotask-node-text"))return;se.current=!1;const Y=E.currentTarget;ve.current={id:E.pointerId,x:E.clientX,y:E.clientY,left:Y.scrollLeft,top:Y.scrollTop,moved:!1}},onPointerMove:E=>{if(!ve.current||ve.current.id!==E.pointerId)return;const Y=E.clientX-ve.current.x,O=E.clientY-ve.current.y;Math.abs(Y)+Math.abs(O)>4&&(ve.current.moved=!0,te(!0),E.currentTarget.setPointerCapture(E.pointerId),E.preventDefault()),ve.current.moved&&(E.currentTarget.scrollLeft=ve.current.left-Y,E.currentTarget.scrollTop=ve.current.top-O)},onPointerUp:E=>{ve.current&&(se.current=ve.current.moved,ve.current=null,te(!1),E.currentTarget.hasPointerCapture(E.pointerId)&&E.currentTarget.releasePointerCapture(E.pointerId),window.setTimeout(()=>{se.current=!1},0))},onPointerCancel:()=>{ve.current=null,te(!1)},onLostPointerCapture:()=>{ve.current=null,te(!1)},children:s.jsx("div",{className:"cotask-graph-scroll",style:{width:Math.max(P.width,R.width*Z),height:Math.max(P.height,R.height*Z)},children:s.jsxs("div",{className:"cotask-graph-canvas",style:{width:R.width,height:R.height,transform:`scale(${Z})`,left:0,top:0},children:[s.jsxs("svg",{width:R.width,height:R.height,className:"cotask-graph-edges","aria-hidden":"true",children:[s.jsx("defs",{children:["default","complete","selected"].map(E=>s.jsx("marker",{id:`${be}-${E}`,markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"userSpaceOnUse",children:s.jsx("path",{d:"M 1 1 L 7 4 L 1 7 Z",className:`cotask-arrow-${E}`})},E))}),R.edges.map(E=>{const Y=l&&[E.source,E.target].includes(l)?"selected":me.get(E.source)==="completed"?"complete":"default";return s.jsx("path",{"data-source":E.source,"data-target":E.target,d:E.path,className:`cotask-edge ${Y}`,markerEnd:`url(#${be}-${Y})`},`${E.source}:${E.target}`)})]}),e.map(E=>{var ee;const Y=R.positions.get(E.id),O=me.get(E.id);return s.jsxs("button",{ref:ke=>{ke?x.current.set(E.id,ke):x.current.delete(E.id)},className:`cotask-graph-node ${O}${E.kind==="checkpoint"?" checkpoint":""}${l===E.id?" selected":""}`,style:{left:Y.x,top:Y.y,width:n0,minHeight:Wi},"aria-pressed":l===E.id,onClick:()=>u(E),title:E.dependencies.length?`Depends on: ${E.dependencies.map(ke=>{var Ae;return((Ae=e.find(He=>He.id===ke))==null?void 0:Ae.name)??ke}).join(", ")}`:"No dependencies",children:[E.dependencies.length>0&&s.jsx("i",{className:"cotask-node-port input"}),s.jsx("strong",{className:"cotask-node-text",children:E.name}),s.jsxs("span",{className:"cotask-graph-node-footer",children:[s.jsx("span",{className:"cotask-graph-node-member cotask-node-text",children:E.kind==="checkpoint"?s.jsx(s.Fragment,{children:s.jsxs("span",{className:"cotask-checkpoint-type",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:s.jsx("path",{d:"M6 1 11 6 6 11 1 6Z",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})}),E.id===h?"最终检查点":"检查点"]})}):((ee=t.find(ke=>ke.id===E.memberId))==null?void 0:ee.name)??E.memberId}),s.jsxs("span",{className:"cotask-graph-node-status",children:[s.jsx("i",{}),s.jsx("span",{className:"cotask-node-text",children:p(E,O)})]})]}),R.edges.some(ke=>ke.source===E.id)&&s.jsx("i",{className:"cotask-node-port output"})]},E.id)})]})})}),V&&s.jsxs("aside",{className:"cotask-node-drawer","aria-label":`Node details: ${V.name}`,onKeyDown:E=>{E.key==="Escape"&&(E.stopPropagation(),c())},children:[s.jsxs("header",{children:[s.jsx("strong",{children:V.name}),s.jsx("button",{onClick:c,"aria-label":"Close node details",children:"关闭"})]}),s.jsx("div",{className:"cotask-node-drawer-content",children:f},V.id)]})]}),s.jsxs("div",{className:"cotask-graph-legend",children:[s.jsxs("span",{children:[s.jsx("i",{className:"running"}),"执行中"]}),s.jsxs("span",{children:[s.jsx("i",{className:"delivered"}),m?"检查点等待继续":"待 Owner 确认"]}),s.jsxs("span",{children:[s.jsx("i",{className:"completed"}),m?"已完成 / 已继续":"已确认完成"]}),s.jsxs("span",{children:[s.jsx("i",{className:"pending"}),"待开始"]}),s.jsx("span",{children:m?"执行节点报告结果并正常结束后自动完成;检查点由 Owner 检查后继续":"点击节点查看上下文与报告;成员执行结束不等于节点已确认完成"})]})]})}const h6=e=>({draft:"草稿",running:"运行中",pausing:"正在暂停",paused:"已暂停",waiting:"等待继续",finished:"已结束",pending:"Pending",completed:"Completed",blocked:"Blocked",cancelled:"Cancelled",accepted:"Accepted",failed:"Failed"})[e]??e;function sp({task:e}){const t=tE(e),n={running:["active","进行中","M8 5l10 7-10 7Z"],finished:["done","已结束","m6 12 4 4 8-8"],completed:["done","已结束","m6 12 4 4 8-8"],paused:["attention","已暂停","M9 7v10M15 7v10"],pausing:["attention","正在暂停","M9 7v10M15 7v10"],waiting:["attention","等待检查","M12 6v6l4 2"],blocked:["danger","存在阻塞","M12 6v7m0 3v1"],failed:["danger","失败","M12 6v7m0 3v1"],cancelled:["neutral","已取消","m8 8 8 8m0-8-8 8"],draft:["neutral","草稿","M8 8h8M8 12h8M8 16h5"]};return s.jsx("span",{className:"cotask-task-statuses",children:t.map(({status:a,count:l})=>{const[u,c,f]=n[a]??["neutral",h6(a),"M12 6v6l4 2"];return s.jsxs("span",{className:`cotask-task-status ${u}`,children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:f})]}),c,l!=null&&` · ${l}`]},a)})})}function sE({ownerId:e,ownerName:t,request:n,onExpanded:a,renderMember:l,renderMarkdown:u}){const[c,f]=A.useState([]),[h,m]=A.useState(null),[p,y]=A.useState(null),[k,x]=A.useState("graph"),[C,M]=A.useState(null),[I,_]=A.useState(null),[N,q]=A.useState(null),[R,X]=A.useState([]),[P,H]=A.useState(null),[J,ne]=A.useState(null),[F,te]=A.useState([]),[se,ve]=A.useState(""),[be,he]=A.useState(!1),Z=A.useRef(null),me=A.useRef(0),V=A.useRef("");V.current=`${h}:${p==null?void 0:p.task.revision}`;const Ce=A.useRef(C);Ce.current=C;const U=`conversations/${encodeURIComponent(e)}/cotasks`;A.useEffect(()=>{let oe=!0;const Me=async()=>{try{const Ze=await n(U);oe&&f(Ze.tasks)}catch(Ze){oe&&ve(String(Ze))}};Me();const ze=window.setInterval(()=>void Me(),5e3);return()=>{oe=!1,window.clearInterval(ze)}},[U,n]),A.useEffect(()=>(a(h!==null),()=>a(!1)),[h,a]),A.useEffect(()=>{if(!h)return;let oe=!0;const Me=async()=>{try{const Ze=await n(`${U}/${encodeURIComponent(h)}`);if(oe&&(y(Ze),ve("")),k==="operations"){const Ut=await n(`${U}/${encodeURIComponent(h)}`,{operations:!0});oe&&te(Ut.operations)}}catch(Ze){oe&&ve(String(Ze))}};Me();const ze=window.setInterval(()=>void Me(),3e3);return()=>{oe=!1,window.clearInterval(ze)}},[h,U,n,k]),A.useEffect(()=>{var oe;h&&((oe=Z.current)==null||oe.focus())},[h]),A.useEffect(()=>{me.current++,H(null),ne(null),X([])},[p==null?void 0:p.task.revision]);const E=JSON.stringify(p==null?void 0:p.reports.map(oe=>oe.id)),Y=JSON.stringify(p==null?void 0:p.nodes.map(oe=>[oe.id,oe.status,oe.reason]));A.useEffect(()=>{if(!h||!I||!p)return;let oe=!0;if(!p.nodes.some(Me=>Me.id===I)){_(null),q(null);return}return n(`${U}/${encodeURIComponent(h)}`,{nodeIds:[I]}).then(Me=>{oe&&q(Me.nodes[0]??null)}).catch(Me=>{oe&&ve(String(Me))}),()=>{oe=!1}},[h,I,p==null?void 0:p.task.revision,E,Y,U,n]);const O=oe=>{_(null),me.current++,H(null),ne(null),te([]),ve(""),y(null),m(oe),x("graph"),M(null),q(null),X([])},ee=()=>{me.current++,_(null),q(null),X([])},ke=()=>{me.current++,m(null)},Ae=c.find(oe=>oe.status==="running")??c.find(oe=>oe.status==="draft")??c[0];if(!h)return Ae?s.jsxs("div",{className:"cotask-launcher",children:[s.jsxs("button",{className:"cotask-launch-primary",onClick:()=>O(Ae.id),children:[s.jsxs("span",{className:"cotask-launch-heading",children:[s.jsx("span",{children:"CoTask"}),s.jsx(sp,{task:Ae})]}),s.jsx("strong",{children:Ae.name}),s.jsxs("small",{children:["已完成 ",Ae.completedNodeCount??0," / ",Ae.nodeCount," 节点 ↗"]})]}),c.length>1&&s.jsxs("details",{className:"cotask-task-list",children:[s.jsxs("summary",{children:["其他任务(",c.length-1,")"]}),c.filter(oe=>oe.id!==Ae.id).map(oe=>s.jsxs("button",{onClick:()=>O(oe.id),children:[s.jsx("strong",{children:oe.name}),s.jsx(sp,{task:oe})]},oe.id))]})]}):null;const He=oe=>{I!==oe.id&&(me.current++,ve(""),q(null),X([]),_(oe.id))},it=async oe=>{const Me=++me.current;try{const ze=await n(`${U}/${h}`,{reportIds:[oe.id]});Me===me.current&&X(ze.reports)}catch(ze){ve(String(ze))}},pe=p==null?void 0:p.bindings.find(oe=>oe.memberId===C),Pe=p==null?void 0:p.members.find(oe=>oe.id===C),Ke=(oe,Me=e)=>s.jsx("div",{className:"cotask-markdown",children:u(oe??"",Me)});return s.jsx("div",{className:"context-panel-overlay settings-overlay cotask-overlay",children:s.jsxs("section",{className:"context-panel settings-panel cotask-frame",role:"dialog","aria-modal":"true","aria-label":"CoTask",tabIndex:-1,ref:Z,onKeyDown:oe=>{var Me;if(oe.stopPropagation(),oe.key==="Escape"&&(oe.preventDefault(),k==="graph"&&I?ee():ke()),oe.key==="Tab"){const ze=(Me=Z.current)==null?void 0:Me.querySelectorAll('button:not(:disabled),select,input,a[href],textarea,[tabindex="0"]');if(!(ze!=null&&ze.length))return;const Ze=ze[0],Ut=ze[ze.length-1];oe.shiftKey&&(document.activeElement===Ze||document.activeElement===Z.current)?(oe.preventDefault(),Ut.focus()):!oe.shiftKey&&document.activeElement===Ut&&(oe.preventDefault(),Ze.focus())}},children:[s.jsxs("header",{className:"cotask-header settings-panel-header",children:[s.jsxs("div",{children:[s.jsxs("p",{children:["CoTask · ",t]}),s.jsx("h1",{children:(p==null?void 0:p.task.name)??"Loading task…"})]}),p&&s.jsx(sp,{task:p.task}),s.jsxs("button",{className:"cotask-back",onClick:ke,title:`返回 ${t}`,children:[s.jsx("span",{"aria-hidden":"true",children:"← "}),"返回"]}),(p==null?void 0:p.task.status)==="draft"&&s.jsx("button",{className:"cotask-close-draft cotask-back",disabled:be,onClick:async()=>{if(!window.confirm(`Close draft “${p.task.name}”? It will not run. The task history will be retained.`))return;const oe=h,Me=V.current;he(!0),ve("");try{const ze=await n(`${U}/${encodeURIComponent(oe)}/close-draft`,{expectedRevision:p.task.revision},"POST");f(Ze=>Ze.map(Ut=>Ut.id===oe?ze.task:Ut)),V.current===Me&&y(Ze=>Ze&&{...Ze,task:ze.task})}catch(ze){V.current===Me&&ve(String(ze))}finally{he(!1)}},children:be?"Closing…":"Close draft"})]}),s.jsxs("aside",{className:"cotask-nav",children:[s.jsxs("section",{className:"workspace-group","aria-label":"Task navigation",children:[s.jsx("h2",{className:"cotask-nav-group-title",children:"Task"}),s.jsx("nav",{className:"workspace-group-items",children:[["graph","Task graph"],["operations","Activity"],["settings","Settings"]].map(([oe,Me])=>s.jsx("button",{className:`session-item${k===oe?" active":""}`,"aria-current":k===oe?"page":void 0,onClick:()=>{x(oe),M(null)},children:s.jsx("span",{className:"session-title",children:Me})},oe))})]}),s.jsxs("section",{className:"workspace-group","aria-label":"Task members",children:[s.jsx("h2",{className:"cotask-nav-group-title",children:"Members"}),s.jsx("div",{className:"workspace-group-items cotask-member-list",children:p==null?void 0:p.members.map(oe=>{const Me=p.executions.some(Ze=>Ze.memberId===oe.id&&["accepted","running"].includes(Ze.status)),ze=Me?"Running":p.bindings.some(Ze=>Ze.memberId===oe.id&&Ze.workspaceId)?"Idle":"Not created";return s.jsx("button",{className:`session-item${k==="member"&&C===oe.id?" active":""}`,title:`${oe.name} · ${ze}`,"aria-label":`${oe.name} · ${ze}`,"aria-current":k==="member"&&C===oe.id?"page":void 0,onClick:()=>{M(oe.id),x("member")},children:s.jsxs("span",{className:"session-heading",children:[s.jsx("span",{className:`session-status${Me?" running":""}`,"aria-hidden":"true"}),s.jsx("span",{className:"session-title",children:oe.name})]})},oe.id)})})]}),s.jsxs("button",{className:"cotask-return",onClick:ke,children:["← Back to ",t]})]}),s.jsxs("section",{className:"cotask-main",children:[se&&s.jsx("div",{className:"cotask-error",role:"alert",children:se}),s.jsx("div",{className:`cotask-body${k==="graph"?" cotask-graph-body":k==="member"?" cotask-member-body":""}`,children:p?s.jsxs(s.Fragment,{children:[p.warnings.length>0&&s.jsx("div",{className:"cotask-warning",children:p.warnings.map((oe,Me)=>s.jsxs("p",{children:[oe.id?`${oe.id}: `:"Common context: ","Context may exceed the injection limit. (estimated ",oe.estimatedTokens," tokens)"]},Me))}),k==="graph"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"cotask-section-heading",children:[s.jsx("h2",{children:"Task graph"}),s.jsxs("span",{children:[p.nodes.filter(oe=>oe.status==="completed").length," / ",p.nodes.length," Completed"]})]}),!p.nodes.length&&s.jsx("p",{children:"No nodes yet. Discuss the plan with the initiating agent to define the graph."}),s.jsxs("details",{className:"cotask-context",onToggle:oe=>{if(oe.currentTarget.open&&P===null){const Me=V.current;n(`${U}/${h}`,{view:"definition"}).then(ze=>{V.current===Me&&H(ze.definition.commonContext)}).catch(ze=>{V.current===Me&&ve(String(ze))})}},children:[s.jsx("summary",{children:"Common context"}),P===null?s.jsx("p",{children:"Loading…"}):Ke(P)]},p.task.revision),p.nodes.length>0&&s.jsx(lE,{finalCheckpointId:p.finalCheckpointId,nodes:p.nodes,members:p.members,executions:p.executions,reports:p.reports,selectedId:I??void 0,onSelect:oe=>void He(oe),onDismiss:ee,detail:(N==null?void 0:N.definition.id)===I?s.jsxs("div",{className:"cotask-node-detail",children:[N.runtime&&s.jsxs("p",{children:[h6(N.runtime.status),N.runtime.reason&&s.jsxs(s.Fragment,{children:[" · ",N.runtime.reason]})]}),Ke(N.definition.context),s.jsx("h4",{children:N.definition.kind==="checkpoint"?"检查点":"Reports"}),N.reports.length?N.reports.map(oe=>s.jsxs("button",{onClick:()=>void it(oe),children:[oe.type," · ",oe.summary]},oe.id)):s.jsx("p",{children:N.definition.kind==="checkpoint"?"此节点不启动成员执行,也不生成成员报告。Owner 按上下文检查交付内容后继续。":"No reports yet."}),R.map(oe=>{var Me;return s.jsxs("article",{children:[s.jsx("h4",{children:oe.summary}),Ke(oe.content,((Me=p.executions.find(ze=>ze.id===oe.executionId))==null?void 0:Me.workspaceId)??"")]},oe.id)})]}):s.jsx("p",{children:"Loading node…"})}),p.task.conclusion&&s.jsxs("details",{className:"cotask-conclusion",children:[s.jsx("summary",{children:"Conclusion"}),Ke(p.task.conclusion)]})]}),k==="operations"&&s.jsxs(s.Fragment,{children:[s.jsx("h2",{children:"Activity"}),s.jsx("p",{children:"Changes are saved immediately and retained if a turn fails."}),F.length?F.map((oe,Me)=>s.jsxs("details",{className:"cotask-operation",children:[s.jsxs("summary",{children:[String(oe.action)," · ",String(oe.status)," · Turn ",String(oe.turnStatus)]}),s.jsx("pre",{children:JSON.stringify(oe,null,2)})]},Me)):s.jsx("p",{children:"No activity yet."})]}),k==="settings"&&s.jsx(oE,{task:p.task,path:`${U}/${h}/settings`,request:n,onSaved:oe=>y({...p,task:oe})},h),k==="member"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"cotask-section-heading",children:[s.jsx("h2",{children:Pe==null?void 0:Pe.name}),s.jsx("span",{children:"CoTask member"})]}),s.jsxs("details",{className:"cotask-context",onToggle:oe=>{if(oe.currentTarget.open&&C&&(J==null?void 0:J.id)!==C){const Me=C,ze=V.current;n(`${U}/${h}`,{memberIds:[Me]}).then(Ze=>{var Ut;V.current===ze&&Ce.current===Me&&ne({id:Me,context:((Ut=Ze.members[0])==null?void 0:Ut.context)??""})}).catch(Ze=>{V.current===ze&&Ce.current===Me&&ve(String(Ze))})}},children:[s.jsx("summary",{children:"Member context"}),(J==null?void 0:J.id)===C?Ke(J.context):s.jsx("p",{children:"Loading…"})]},`${C}:${p.task.revision}`),pe!=null&&pe.workspaceId?l(pe.workspaceId):s.jsx("p",{children:p.executions.some(oe=>oe.memberId===C)?"This member instance was removed. Execution history is retained.":p.task.executionMode==="self_driving"?"首次符合执行条件时,平台自动创建此成员实例。":"This member will be created when its first node is driven."})]})]}):s.jsx("p",{children:"Loading task…"})})]})]})})}function oE({task:e,path:t,request:n,onSaved:a}){var N,q;const[l,u]=A.useState({...e.runtimeSettings,mode:e.runtimeSettings.mode??"custom",fastMode:e.runtimeSettings.fastMode??!1}),[c,f]=A.useState(e.revision),[h,m]=A.useState([]),[p,y]=A.useState([]),[k,x]=A.useState(!1),[C,M]=A.useState("");A.useEffect(()=>{let R=!0;return Promise.all([n("settings/runtime/models?refresh=0"),n("settings/model-providers/options")]).then(([X,P])=>{R&&(m(X.models),y(P.channels))}).catch(X=>{R&&M(String(X))}),()=>{R=!1}},[n]);const I=h.find(R=>R.model===l.model||R.id===l.model),_=((N=I==null?void 0:I.supportedReasoningEfforts)==null?void 0:N.map(R=>R.reasoningEffort))??["none","minimal","low","medium","high","xhigh","max"];return s.jsxs("section",{className:"cotask-settings",children:[s.jsx("h2",{children:"Settings"}),s.jsx("p",{children:"Settings apply to the whole CoTask and take effect on each member’s next turn."}),s.jsxs("label",{children:["配置模式",s.jsxs("select",{value:l.mode,onChange:R=>u({...l,mode:R.target.value}),children:[s.jsx("option",{value:"global",children:"沿用 CoTask 默认配置"}),s.jsx("option",{value:"custom",children:"CoTask 自定义配置"})]})]}),l.mode==="global"?s.jsx("p",{children:"每个成员在下一次 turn 读取最新 CoTask 默认模型、推理强度和倍速设置;正在运行的 turn 不受影响。"}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:["Model source",s.jsxs("select",{value:l.modelSource.type==="codex"?"codex":l.modelSource.channelId,onChange:R=>u({...l,modelSource:R.target.value==="codex"?{type:"codex"}:{type:"custom",channelId:R.target.value}}),children:[s.jsx("option",{value:"codex",children:"Codex"}),l.modelSource.type==="custom"&&!p.some(R=>R.id===l.modelSource.channelId)&&s.jsx("option",{value:l.modelSource.channelId,children:"Current channel unavailable"}),p.map(R=>s.jsx("option",{value:R.id,children:R.name},R.id))]})]}),l.modelSource.type==="codex"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{children:[s.jsx("span",{children:"1.5 倍速(Fast mode)"}),s.jsx("input",{type:"checkbox",checked:l.fastMode,onChange:R=>u({...l,fastMode:R.target.checked})})]}),s.jsxs("label",{children:["Model",s.jsxs("select",{value:l.model,onChange:R=>u({...l,model:R.target.value}),children:[s.jsx("option",{value:"",children:"Default model"}),l.model&&!h.some(R=>R.model===l.model)&&s.jsx("option",{children:l.model}),h.map(R=>s.jsx("option",{value:R.model,children:R.displayName},R.id))]})]}),s.jsxs("label",{children:["Reasoning effort",s.jsxs("select",{value:l.reasoningEffort,onChange:R=>u({...l,reasoningEffort:R.target.value}),children:[s.jsx("option",{value:"",children:"Default"}),l.reasoningEffort&&!_.includes(l.reasoningEffort)&&s.jsx("option",{children:l.reasoningEffort}),_.map(R=>s.jsx("option",{children:R},R))]})]})]}):s.jsxs("p",{children:["Channel model: ",((q=p.find(R=>R.id===l.modelSource.channelId))==null?void 0:q.model)??"Channel unavailable",". Codex reasoning effort does not apply to custom channels."]})]}),s.jsx("button",{disabled:k,onClick:async()=>{x(!0),M("");try{const R=await n(t,{expectedRevision:c,runtimeSettings:l},"PUT");f(R.task.revision),a(R.task),M("Saved. Changes take effect on the next turn.")}catch(R){M(`${String(R)}. If the task changed, reopen Settings before saving.`)}finally{x(!1)}},children:k?"Saving…":"Save settings"}),C&&s.jsx("p",{role:"status",children:C})]})}function uE(e,t=new Date){if(e==null||!Number.isInteger(e)||e<1||e>31)return null;const n=new Date(t.getTime()+480*60*1e3),a=n.getUTCFullYear(),l=n.getUTCMonth(),u=Date.UTC(a,l,n.getUTCDate()),c=h=>Date.UTC(a,l+h,Math.min(e,new Date(Date.UTC(a,l+h+1,0)).getUTCDate()));let f=c(0);return f<u&&(f=c(1)),{date:new Date(f).toISOString().slice(0,10),days:(f-u)/864e5}}function cE({content:e,streaming:t}){const[n,a]=A.useState(!1),l=A.useId();return s.jsxs("section",{className:`message reasoning${t?" is-streaming":""}${n?" is-expanded":""}`,children:[s.jsxs("button",{className:"reasoning-toggle",type:"button","aria-expanded":n,"aria-controls":l,onClick:()=>a(u=>!u),children:[s.jsx("span",{className:"reasoning-indicator","aria-hidden":"true"}),s.jsx("span",{children:t?"思考中":"思考过程"}),s.jsx("span",{className:"reasoning-action",children:n?"收起":"展开"}),s.jsx("svg",{className:"reasoning-chevron",width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:s.jsx("path",{d:"m4 2 4 4-4 4",fill:"none",stroke:"currentColor",strokeWidth:"1.4"})})]}),s.jsx("div",{id:l,hidden:!n&&!t,className:`reasoning-content${n?"":" reasoning-preview"}`,children:s.jsx("div",{className:"message-body",children:n?e:e.slice(-600)})})]})}function dE(e,t){if(!t||typeof t!="object")return null;const{method:n,params:a}=t;if(!a)return null;if(n==="item/completed"){const m=a.item;if((m==null?void 0:m.type)!=="reasoning"||typeof m.id!="string")return null;const p=e.get(m.id)??{itemId:m.id,text:new Map,summary:new Map,completed:!1};for(const y of["text","summary"]){const k=m[y];Array.isArray(k)&&k.forEach((x,C)=>{typeof x=="string"&&x&&p[y].set(C,x)})}return p.completed=!0,e.set(m.id,p),p}const l=/^item\/reasoning\/(text|summaryText)(Delta|Snapshot)$/.exec(n??"");if(!l||typeof a.itemId!="string")return null;const u=l[1]==="text"?"text":"summary",c=a[u==="text"?"contentIndex":"summaryIndex"],f=a[l[2]==="Delta"?"delta":"text"];if(typeof c!="number"||!Number.isSafeInteger(c)||c<0||typeof f!="string")return null;const h=e.get(a.itemId)??{itemId:a.itemId,text:new Map,summary:new Map,completed:!1};return h[u].set(c,l[2]==="Snapshot"?f:(h[u].get(c)??"")+f),e.set(a.itemId,h),h}function fE(e){return[...e.text.size?e.text:e.summary].sort(([n],[a])=>n-a).map(([,n])=>n).join(`
347
347
 
348
348
  `)}function hE({id:e,baseUrl:t,query:n}){var p;const[a,l]=A.useState(null),[u,c]=A.useState(!1),[f,h]=A.useState(!1),m=async()=>{c(!0),h(!1);try{const y=await n(e);y.status==="ok"||y.status==="unsupported"?l(y):(h(!0),l(k=>(k==null?void 0:k.status)==="ok"?k:y))}catch{h(!0)}finally{c(!1)}};return A.useEffect(()=>{let y=!1;return c(!0),n(e).then(k=>{y||l(k)}).catch(()=>{y||h(!0)}).finally(()=>{y||c(!1)}),()=>{y=!0}},[e,n]),s.jsxs("div",{className:"channel-balance-inline",children:[s.jsx("span",{className:"channel-balance-total",title:"Available balance",children:(a==null?void 0:a.status)==="ok"&&a.balance?a.balance.balance_infos.map(y=>`${y.currency} ${y.total_balance}`).join(" / "):u?"Checking…":(a==null?void 0:a.status)==="unsupported"?"Balance —":"Balance unavailable"}),f?s.jsx("span",{className:"channel-balance-warning",title:"Refresh failed; the displayed amount may be stale",role:"status",children:"Stale"}):null,a!=null&&a.balance&&!a.balance.is_available?s.jsx("span",{className:"channel-balance-warning",children:"Insufficient"}):null,s.jsx("button",{type:"button","aria-label":"Refresh balance",title:"Refresh balance",disabled:u,onClick:()=>void m(),children:"↻"}),s.jsxs("details",{className:"channel-balance-details",children:[s.jsx("summary",{children:"Details"}),s.jsxs("div",{children:[s.jsxs("p",{className:"channel-endpoint",children:[t," · Responses API"]}),(p=a==null?void 0:a.balance)==null?void 0:p.balance_infos.map(y=>s.jsxs("p",{children:[y.currency," · Granted ",y.granted_balance," · Topped up ",y.topped_up_balance]},y.currency)),a?s.jsxs("small",{children:["Checked ",new Date(a.checkedAt).toLocaleString()]}):null,f?s.jsx("small",{children:"Refresh failed. Any amount shown is the last successful result."}):null,(a==null?void 0:a.status)==="unsupported"?s.jsx("small",{children:"This channel does not support balance queries."}):null,s.jsx("small",{children:"Uses saved credentials; unsaved edits are not queried."})]})]})]})}function m6(e,t){const n=e??{type:"codex"},a=t??{type:"codex"};return n.type===a.type&&(n.type!=="custom"||a.type==="custom"&&n.channelId===a.channelId)}function mE({load:e,save:t,queryBalance:n}){const[a,l]=A.useState(null),[u,c]=A.useState([]),[f,h]=A.useState(!1),[m,p]=A.useState(""),[y,k]=A.useState(!1),[x,C]=A.useState(null),M=JSON.stringify(u)!==JSON.stringify((a==null?void 0:a.channels.map(N=>({channel:N})))??[]);A.useEffect(()=>{let N=!1;return e().then(q=>{N||(l(q),c(q.channels.map(R=>({channel:R}))))}).catch(()=>{N||p("Unable to load channels. Reopen this panel to retry.")}),()=>{N=!0}},[e]);const I=(N,q)=>{k(!1),c(R=>R.map((X,P)=>P===N?{...X,channel:{...X.channel,...q}}:X))},_=async N=>{if(N.preventDefault(),!(!a||f)){h(!0),p(""),k(!1);try{const q=await t({expectedRevision:a.revision,channels:u.map(R=>({channel:R.channel,...R.apiKey?{apiKey:R.apiKey}:{}}))});l(q),c(q.channels.map(R=>({channel:R}))),k(!0),C(null)}catch{p("Channels were not saved. Check the fields. If another administrator changed them, reopen this panel to load the latest version.")}finally{h(!1)}}};return s.jsxs("section",{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Custom model channels"}),s.jsx("p",{children:"Select a configured channel in Runtime."})]})}),s.jsxs("form",{className:"settings-form",onSubmit:N=>void _(N),children:[!a&&!m?s.jsx("p",{children:"Loading channels…"}):null,s.jsxs("div",{className:"settings-field-wide channel-summary-list",children:[u.map(N=>s.jsxs("article",{className:"channel-summary-card",children:[s.jsxs("div",{className:"channel-summary-identity",children:[s.jsx("h4",{children:N.channel.name||"New channel"}),s.jsx("p",{children:N.channel.model||"Model not configured"})]}),n&&(a!=null&&a.channels.some(q=>q.id===N.channel.id))?s.jsx(hE,{id:N.channel.id,baseUrl:a.channels.find(q=>q.id===N.channel.id).baseUrl,query:n},`${N.channel.id}:${a.revision}`):s.jsx("small",{children:"Not saved"}),s.jsx("button",{type:"button",disabled:f||x!==null&&x!==N.channel.id,onClick:()=>{C(N.channel.id),k(!1)},children:"Edit channel"})]},N.channel.id)),a&&u.length===0?s.jsx("p",{children:"No custom channels yet. Add a channel to get started."}):null]}),u.map((N,q)=>x===N.channel.id?s.jsxs("fieldset",{disabled:f,className:"settings-field-wide model-channel-card",children:[s.jsx("legend",{children:a!=null&&a.channels.some(R=>R.id===N.channel.id)?"Edit channel":"Add channel"}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Name"}),s.jsx("input",{"aria-label":`Channel ${q+1} name`,required:!0,maxLength:128,value:N.channel.name,onChange:R=>I(q,{name:R.target.value})})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Type"}),s.jsx("select",{"aria-label":`Channel ${q+1} type`,value:N.channel.kind,onChange:()=>{},children:s.jsx("option",{value:"responses",children:"Responses API"})})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{"aria-label":`Channel ${q+1} URL`,type:"url",required:!0,placeholder:"https://api.example.com/v1",value:N.channel.baseUrl,onChange:R=>I(q,{baseUrl:R.target.value})})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Model ID"}),s.jsx("input",{"aria-label":`Channel ${q+1} model`,required:!0,maxLength:256,placeholder:"Model ID from your service",value:N.channel.model,onChange:R=>I(q,{model:R.target.value})})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"API key"}),s.jsx("input",{"aria-label":`Channel ${q+1} API key`,type:"password",autoComplete:"new-password",required:!(a!=null&&a.channels.some(R=>R.id===N.channel.id)),value:N.apiKey??"",placeholder:a!=null&&a.channels.some(R=>R.id===N.channel.id)?"Configured · leave blank to keep":"Enter API key",onChange:R=>{const X=R.target.value;k(!1),c(P=>P.map((H,J)=>J===q?{...H,apiKey:X}:H))}})]}),s.jsx("button",{type:"button",onClick:()=>{c(R=>R.filter((X,P)=>P!==q)),k(!1),C(null)},children:"Remove channel on save"}),s.jsx("small",{children:"Changes take effect only after Save channels. Leave the API key blank to keep the saved key."})]},N.channel.id):null),m?s.jsx("p",{role:"alert",children:m}):null,y?s.jsx("p",{role:"status",children:"Channels saved. New executions use the updated configuration."}):null,s.jsxs("div",{className:"settings-form-actions",children:[s.jsx("button",{type:"button",disabled:!a||f||x!==null||u.length>=100,onClick:()=>{const N=crypto.randomUUID().replaceAll("-","");C(N),k(!1),c(q=>[...q,{channel:{id:N,name:"",kind:"responses",baseUrl:"",model:""}}])},children:"Add channel"}),x||JSON.stringify(u)!==JSON.stringify(a==null?void 0:a.channels.map(N=>({channel:N})))?s.jsx("button",{type:"button",disabled:f,onClick:()=>{c((a==null?void 0:a.channels.map(N=>({channel:N})))??[]),C(null),p("")},children:"Discard changes"}):null,x||M?s.jsx("button",{type:"submit",disabled:!a||f,children:f?"Saving…":"Save channels"}):null]})]})]})}function pE(e){const t=new Map;for(const n of e){if(!n.turnId)continue;if(n.event==="server.wakeup.started"){t.set(n.turnId,"wakeup");continue}if(n.event!=="server.turn")continue;const a=yE(n.data);t.set(n.turnId,typeof a.source=="string"?a.source:"web")}return t}function Vc(e,t){return!!(t&&e.includes(t))}function gE(e){var n;if((e==null?void 0:e.status)!=="failed")return null;const t=(n=e.error)==null?void 0:n.trim();return t?{turnId:e.id,content:t,createdAt:e.finishedAt??e.startedAt}:null}function yE(e){return e&&typeof e=="object"?e:{}}const vE=["summary","message","status","instruction","description","reason","error","text"],Kv=96,xE=new Set(["codex.dynamic_tool_request","codex.process_exited","codex.protocol_error"]),bE=new Set(["server.item.snapshot","server.status","runtime.worker_stderr","codex.dynamic_tool_request"]),wE=new Set(["agentMessage","commandExecution","contextCompaction","fileChange","mcpToolCall","reasoning","userMessage","webSearch"]),p6=new Set(["item/commandExecution/terminalInteraction"]),kE=new Map([["server.wakeup.retry_scheduled","Wakeup retry scheduled"],["runtime.worker_exit","Runtime worker exited"]]);function SE(e){if(e.event!=="codex.notification")return!1;const t=si(e.data);return typeof t.method=="string"&&p6.has(t.method)}function jE(e){if(bE.has(e.event))return null;if(e.event.startsWith("server.")||e.event.startsWith("runtime.")||xE.has(e.event))return e.event;if(e.event!=="codex.notification")return null;const t=si(e.data),n=typeof t.method=="string"?t.method:"",a=si(t.params),l=si(a.item),u=typeof l.type=="string"?l.type:"";return!n.startsWith("item/")||p6.has(n)||/(?:\/delta|Delta)$/.test(n)||wE.has(u)?null:n}function g6(e,t){const n=t.replace(/^input:/,""),a=(e==null?void 0:e.trim())??"";return!a||a===t||a===n?kE.get(n)??y6(n):a}function Xs(e,t=[]){const n=si(e),l=[...t,...vE.map(u=>Yc(n[u]))].map(u=>(u==null?void 0:u.replace(/\s+/g," ").trim())??"").find(Boolean);return l?l.length<=Kv?l:`${l.slice(0,Kv-3)}...`:"查看详情"}function e1(e,t=new Map){const n=si(e),a=typeof n.unreadCount=="number"&&n.unreadCount>0?Math.floor(n.unreadCount):0,u=(Array.isArray(n.senderWorkspaceIds)?Array.from(new Set(n.senderWorkspaceIds.filter(h=>typeof h=="string").map(h=>h.trim()).filter(Boolean))):[]).map(h=>t.get(h)??h),c="Messages",f=[a>0?String(a):"",u.length>0?`from ${u.join(", ")}`:""].filter(Boolean).join(" ");return{title:c,detail:Xs({},[f])}}function CE(e){const t=si(e),n=Array.isArray(t.offers)?t.offers.map(si).filter(u=>Object.keys(u).length>0):[],a=n.map(u=>{var c;return(c=Yc(u.previewText))==null?void 0:c.trim()}).filter(u=>!!u),l=n.length;return{title:l===1?"New input available":`${l} new inputs available`,detail:Xs({},a.slice(0,2)),meta:l===1?"preview":`${l} previews`}}function TE(e){const t=si(e),n=Yc(t.actionType)??"",a=si(t.payload);return n==="seele_wakeup"||n==="seele_workspace_schedule_wakeup"?{title:(Yc(a.action)??"schedule")==="cancel"?"Wakeup cancellation requested":"Wakeup requested",detail:Xs(a,[Yc(a.instruction)]),meta:"after turn"}:{title:"Action requested",detail:Xs(a,[y6(n||"agent action")]),meta:"after turn"}}function y6(e){const n=(e.split(/[./]/).filter(Boolean).pop()??e).replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim();return n?n.charAt(0).toUpperCase()+n.slice(1):"System event"}function Yc(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e)}function si(e){return e&&typeof e=="object"?e:{}}function t1(e){const t=n1(e);return(Array.isArray(t.changes)?t.changes:[]).flatMap(a=>{const l=n1(a);if(typeof l.path!="string"||!l.path.trim())return[];const u=ME(l.kind),c=typeof l.diff=="string"?l.diff:"",f=NE(c,u);return[{path:l.path,kind:u,additions:f.additions,deletions:f.deletions}]})}function v6(e,t){const n=Zv(e),a=Zv(t??"").replace(/\/+$/,"");return a&&(n===a||n.startsWith(`${a}/`))?n.slice(a.length+1)||".":n}function AE(e,t){if(e.length===0)return"File changed";const n=v6(e[0].path,t);return e.length===1?n:`${n} +${e.length-1}`}function EE(e){return e.reduce((t,n)=>({additions:t.additions+n.additions,deletions:t.deletions+n.deletions}),{additions:0,deletions:0})}function NE(e,t){if(!e)return{additions:0,deletions:0};if(t==="add")return{additions:Xv(e),deletions:0};if(t==="delete")return{additions:0,deletions:Xv(e)};let n=0,a=0;for(const l of e.split(`
349
349
  `))l.startsWith("+")&&!l.startsWith("+++")?n+=1:l.startsWith("-")&&!l.startsWith("---")&&(a+=1);return{additions:n,deletions:a}}function Xv(e){const t=e.split(`
@@ -381,7 +381,7 @@ ${e.content}`:e.type==="system"?[e.title,e.fullDetail??e.detail].filter(t=>!!(t!
381
381
  `);if(t<0)return 0;const n=[0];for(let l=0;l<e.length;l+=1)e[l]===`
382
382
  `&&l+1<e.length&&n.push(l+1);let a=-1;for(const l of n){const u=e.indexOf(`
383
383
  `,l),c=e.slice(l,u===-1?e.length:u);/^\s*(```|~~~)/.test(c)&&(a=a===-1?l:-1)}return a>=0?a:t+1}function JM({artifact:e,onPreview:t,onCopyUrl:n,copied:a}){return e?s.jsxs("figure",{className:"artifact-preview",children:[s.jsx("button",{className:"artifact-preview-media",onClick:()=>t(e),type:"button",children:s.jsx("img",{alt:e.name,src:e.url})}),s.jsxs("figcaption",{children:[s.jsx("span",{children:e.name}),s.jsxs("div",{className:"artifact-preview-actions",children:[s.jsx("button",{onClick:()=>t(e),type:"button",children:"Preview"}),s.jsx("a",{href:e.url,rel:"noreferrer",target:"_blank",children:"Open"}),s.jsx("button",{onClick:()=>n(e),type:"button",children:a?"Copied":"Copy"})]})]})]}):null}function eD(e,t){const n=new Map;for(const a of tD(e)){const l=P6(a);if(l){const u=G6(l).toLowerCase(),c=n.get(u);(!c||aD(l,c))&&n.set(u,l)}}return Array.from(n.values()).map(a=>nD(a,t)).filter(a=>a!==null)}function tD(e){const t=[],n=/!\[[^\]]*]\(([^)]+)\)/g,a=/\[[^\]]+]\(([^)]+)\)/g,l=/(?:artifact|preview|image|file)\s*:\s*(`?[^`\n]+?\.(?:svg|png|jpe?g|webp|gif)`?)/gim;for(const u of[n,a,l]){let c;for(;(c=u.exec(e))!==null;)t.push(c[1])}return t}function nD(e,t){const n=P6(e);if(!n||!rD(n))return null;const a=w6(n,t.workspacePath);return{id:`${t.id}:${a}`,path:a,name:G6(a),url:Ne(`conversations/${t.id}/files?path=${encodeURIComponent(a)}`)}}function P6(e){const t=e.trim().replace(/^`+|`+$/g,"").replace(/[),.;:,。;:]+$/g,"");return t||null}function rD(e){return/\.(?:svg|png|jpe?g|webp|gif)$/i.test(e)}function G6(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).pop()??e}function aD(e,t){return e.startsWith("/")&&!t.startsWith("/")?!0:e.length>t.length}function a0(e){return e.trim()}function V6(e){return e.trim()}function T3(e){return e instanceof DOMException&&e.name==="AbortError"||e instanceof Error&&e.name==="AbortError"}function iD(e){return{a({children:t,href:n}){if(!n)return s.jsx(s.Fragment,{children:t});const a=/^[a-z][a-z\d+.-]*:/i.test(n),l=b6(n);if(n.startsWith("seele-public:")&&!l)return s.jsxs("span",{title:"无效的 Seele Public URL 地址",children:[t,"(地址格式无效)"]});const u=!a&&e?lD(n,e):null,c=l?Ne(`deployment/public-link?path=${encodeURIComponent(l)}`):u??n,f=a||!!u;return s.jsx("a",{className:"markdown-link",href:c,rel:f?"noreferrer":void 0,target:f?"_blank":void 0,children:t})},img(){return null},pre({children:t}){const n=oD(t);return n?ng(n.language)==="mermaid"?s.jsx(uD,{code:n.code}):s.jsx(fD,{code:n.code,language:n.language}):s.jsx("pre",{children:t})},table({children:t}){return s.jsx("div",{className:"markdown-table-wrap",children:s.jsx("table",{className:"markdown-table",children:t})})},td({align:t,children:n}){return s.jsx("td",{style:A3(t),children:n})},th({align:t,children:n}){return s.jsx("th",{style:A3(t),children:n})}}}function lD(e,t){if(!e||e.startsWith("#")||e.startsWith("/api/")||e.startsWith("?"))return null;const n=XE(e,t.workspacePath);if(!n)return null;const a=n.line?`#L${n.line}${n.column?`C${n.column}`:""}`:"";return`${Ne(`conversations/${t.id}/files?path=${encodeURIComponent(n.path)}`)}${a}`}function A3(e){return e&&e!=="char"?{textAlign:e}:void 0}function es(e,t){const n=xA(sD(e));return s.jsx(iS,{urlTransform:a=>b6(a)?a:zx(a),components:iD(t),remarkPlugins:[gC,vA],rehypePlugins:[[ZA,{trust:!1,strict:"ignore"}]],skipHtml:!0,children:n})}function sD(e){return e.replace(/([^\n])(```[^\n`]*(?:\r?\n|$))/g,`$1
384
- $2`)}function oD(e){var u;const t=A.Children.toArray(e),n=t.length===1&&A.isValidElement(t[0])?t[0]:null;if(!n||n.type!=="code")return null;const l=((u=(n.props.className??"").match(/(?:^|\s)language-([^\s]+)/))==null?void 0:u[1])??"";return{code:o1(n.props.children).replace(/\n$/,""),language:l}}function o1(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(o1).join(""):A.isValidElement(e)?o1(e.props.children):""}const Y6="github-light",gp=new Map,yp=new Map;let vp=null,xp=null;const W6=new Set(["bash","css","diff","dockerfile","html","java","javascript","json","jsonc","jsx","markdown","python","shellscript","sql","toml","tsx","typescript","xml","yaml"]);function ng(e){const t=e.trim().toLowerCase().replace(/^\./,"");return{bash:"bash",cjs:"javascript",console:"shellscript",htm:"html",js:"javascript",jsx:"jsx",md:"markdown",mjs:"javascript",py:"python",rb:"ruby",shell:"bash",ts:"typescript",tsx:"tsx",yml:"yaml",zsh:"bash"}[t]??t}function K6(e){const t=ng(e);return!t||t==="text"||t==="txt"?"text":W6.has(t)?t:"text"}function uD({code:e}){const n=`seele-mermaid-${A.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,[a,l]=A.useState(!1),[u,c]=A.useState(()=>yp.get(e)??null),[f,h]=A.useState(null);A.useEffect(()=>{let p=!1,y;const k=yp.get(e);return k?(c(k),h(null),()=>{p=!0}):(h(null),c(null),cD(n,e).then(x=>{p||(y!==void 0&&window.clearTimeout(y),yp.set(e,x),c(x),h(null))},x=>{if(!p){const C=x instanceof Error?x.message:String(x);y=window.setTimeout(()=>{p||h(C)},iN)}}),()=>{p=!0,y!==void 0&&window.clearTimeout(y)})},[e,n]);async function m(){await navigator.clipboard.writeText(e),l(!0),window.setTimeout(()=>l(!1),1200)}return s.jsxs("figure",{className:`mermaid-block${f?" error":""}`,children:[s.jsx("span",{className:"code-block-kind",children:"mermaid"}),s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":a?"Copied Mermaid source":"Copy Mermaid source",className:a?"copied":"",onClick:()=>void m(),title:a?"Copied":"Copy",type:"button",children:s.jsx(rg,{})})}),u?s.jsx("div",{className:"mermaid-diagram",dangerouslySetInnerHTML:{__html:u}}):f?s.jsxs("div",{className:"mermaid-error",children:[s.jsx("strong",{children:"Mermaid render failed"}),s.jsx("pre",{children:f}),s.jsx("code",{children:e})]}):s.jsx("div",{className:"mermaid-loading",children:"Rendering diagram..."})]})}async function cD(e,t){return(await(await dD()).render(e,t)).svg}function dD(){return xp||(xp=ln(()=>import("./mermaid.core-u6kdiNZf.js").then(e=>e.bp),[],import.meta.url).then(e=>{const t=e.default;return t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#f9fafa",primaryBorderColor:"#d8d9e8",primaryTextColor:"#0b0f16",lineColor:"#7a8294",secondaryColor:"#f5f5fb",tertiaryColor:"#ffffff",fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}}),t})),xp}function fD({code:e,language:t,reserveHeight:n=!1}){const[a,l]=A.useState(!1),[u,c]=A.useState(()=>{if(!M3(t))return null;const m=N3(e,t);return gp.get(m)??null}),f=n?{"--code-block-min-height":`${pN(e)}px`}:void 0;A.useEffect(()=>{let m=!1;if(!M3(t))return c(null),()=>{m=!0};const p=N3(e,t),y=gp.get(p);return y?(c(y),()=>{m=!0}):(c(null),xD(e,t).then(k=>{gp.set(p,k),m||c(k)}).catch(k=>{console.warn("Failed to highlight code block",k),m||c(null)}),()=>{m=!0})},[e,t]);async function h(){await navigator.clipboard.writeText(e),l(!0),window.setTimeout(()=>l(!1),1200)}return s.jsxs("figure",{className:"code-block",style:f,children:[t?s.jsx("span",{className:"code-block-kind",children:t}):null,s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":a?"Copied code block":"Copy code block",className:a?"copied":"",onClick:()=>void h(),title:a?"Copied":"Copy",type:"button",children:s.jsx(rg,{})})}),u?s.jsx("div",{className:"code-block-shiki",dangerouslySetInnerHTML:{__html:u}}):s.jsx("pre",{children:s.jsx("code",{children:e})})]})}function rg(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"13",viewBox:"0 0 24 24",width:"13",children:[s.jsx("rect",{height:"14",rx:"2",stroke:"currentColor",strokeWidth:"2",width:"14",x:"8",y:"8"}),s.jsx("path",{d:"M4 16V6a2 2 0 0 1 2-2h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})]})}function X6(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"16",viewBox:"0 0 24 24",width:"16",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("circle",{cx:"18",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M6 7v1a6 6 0 0 0 6 6v3M18 7v1a6 6 0 0 1-6 6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})]})}function ag(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"12",viewBox:"0 0 24 24",width:"12",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M12 7v6",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2.4"}),s.jsx("circle",{cx:"12",cy:"17",fill:"currentColor",r:"1.25"})]})}function hD(){return s.jsx("svg",{"aria-hidden":"true",fill:"none",height:"18",viewBox:"0 0 24 24",width:"18",children:s.jsx("path",{d:"M4 7h16M4 12h16M4 17h16",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})})}function mD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M7 7h10M7 12h10M7 17h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"}),s.jsx("circle",{cx:"4",cy:"7",fill:"currentColor",r:"1.4"}),s.jsx("circle",{cx:"4",cy:"12",fill:"currentColor",r:"1.4"}),s.jsx("circle",{cx:"4",cy:"17",fill:"currentColor",r:"1.4"})]})}function E3(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M19 12a7.8 7.8 0 0 0-.1-1l2-1.5-2-3.4-2.4 1a8 8 0 0 0-1.8-1l-.3-2.6h-4l-.3 2.6a8 8 0 0 0-1.8 1l-2.4-1-2 3.4 2 1.5a7.8 7.8 0 0 0 0 2l-2 1.5 2 3.4 2.4-1a8 8 0 0 0 1.8 1l.3 2.6h4l.3-2.6a8 8 0 0 0 1.8-1l2.4 1 2-3.4-2-1.5c.1-.3.1-.7.1-1Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"1.7"})]})}function pD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("rect",{height:"16",rx:"2.6",stroke:"currentColor",strokeWidth:"1.8",width:"18",x:"3",y:"4"}),s.jsx("path",{d:"m7 9 3 3-3 3M12.5 15h4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.9"})]})}function ef(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"17",viewBox:"0 0 24 24",width:"17",children:[s.jsx("circle",{cx:"7",cy:"12",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("circle",{cx:"17",cy:"7",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("circle",{cx:"17",cy:"17",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"m9.2 10.9 5.6-2.8M9.2 13.1l5.6 2.8",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.8"})]})}function Hf(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"13",viewBox:"0 0 24 24",width:"13",children:[s.jsx("path",{d:"m4 16-.8 4 4-.8L18.4 8 15.2 4.8 4 16Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"2"}),s.jsx("path",{d:"m13.8 6.2 3.2 3.2",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})]})}function gD(){return s.jsx("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:s.jsx("path",{d:"M5 8v11h14V8M4 4h16v4H4zM9 12h6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function yD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"2"})]})}function vD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"}),s.jsx("path",{d:"M9.9 5.4A9.8 9.8 0 0 1 12 5c6 0 9.5 7 9.5 7a15.5 15.5 0 0 1-3 3.8M6.2 6.8C3.8 8.4 2.5 12 2.5 12s3.5 7 9.5 7a9.7 9.7 0 0 0 4-.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})]})}function N3(e,t){return`${Y6}:${K6(t)}:${e}`}function M3(e){const t=ng(e);return!!t&&W6.has(t)}async function xD(e,t){return(await bD()).codeToHtml(e,{lang:K6(t),theme:Y6})}function bD(){return vp||(vp=wD()),vp}async function wD(){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t},{default:n},{default:a},{default:l},{default:u},{default:c},{default:f},{default:h},{default:m},{default:p},{default:y},{default:k},{default:x},{default:C},{default:M},{default:I},{default:_},{default:N},{default:q},{default:R},{default:X}]=await Promise.all([ln(()=>import("./core-zwIxNY4N.js"),[],import.meta.url),ln(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),ln(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),ln(()=>import("./bash-BELqPA7S.js").then(P=>P.b),[],import.meta.url),ln(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),ln(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),ln(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),ln(()=>import("./html-pp8916En.js"),__vite__mapDeps([0,1,2]),import.meta.url),ln(()=>import("./java-CylS5w8V.js"),[],import.meta.url),ln(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),ln(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),ln(()=>import("./jsonc-Des-eS-w.js"),[],import.meta.url),ln(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),ln(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),ln(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),ln(()=>import("./bash-BELqPA7S.js").then(P=>P.s),[],import.meta.url),ln(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),ln(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ln(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),ln(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),ln(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([3,4]),import.meta.url),ln(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url)]);return e({engine:t(),themes:[n],langs:[a,l,u,c,f,h,m,p,y,k,x,C,M,I,_,N,q,R,X]})}async function D3(){const e=Ne("conversations"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).conversations}async function kD(){const e=Ne("workspace-states"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).workspaces}async function z3(){const e=Ne("collaboration/topics"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).topics}async function Pd(e){const t=Ne(`collaboration/topics/${e}/messages?limit=100`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).messages}async function SD(e){const t=Ne("collaboration/topics"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"POST",url:t}),(await n.json()).topic}async function jD(e,t){const n=Ne(`collaboration/topics/${e}`),a=await fetch(n,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PATCH",url:n}),(await a.json()).topic}async function CD(e,t){const n=Ne(`collaboration/topics/${e}/archive`),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedVersion:t})});return await Ve(a,{method:"POST",url:n}),(await a.json()).topic}async function TD(e){const t=Ne(`conversations/${e}/read`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t})}async function R3(){const e=Ne("workspace-groups"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).groups}async function AD(e){const t=Ne("workspace-groups"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});return await Ve(n,{method:"POST",url:t}),(await n.json()).group}async function ED(e,t){const n=Ne(`workspace-groups/${e}`),a=await fetch(n,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PATCH",url:n}),(await a.json()).group}async function ND(e){const t=Ne(`workspace-groups/${e}`),n=await fetch(t,{method:"DELETE"});return await Ve(n,{method:"DELETE",url:t}),await n.json()}async function MD(){const e=Ne("settings/environment"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).variables}async function DD(e){const t=Ne(`conversations/${e}/settings/environment`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).variables}async function zD(e){const t=Ne(`conversations/${e}/knowledge`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).items}async function RD(){const e=Ne("settings/model-providers"),t=await fetch(e);return await Ve(t,{url:e}),t.json()}async function OD(){const e=Ne("settings/model-providers/options"),t=await fetch(e);return await Ve(t,{url:e}),t.json()}async function ID(e){const t=Ne(`settings/model-providers/${encodeURIComponent(e)}/balance`),n=await fetch(t);return await Ve(n,{url:t}),n.json()}async function _D(e){const t=Ne("settings/model-providers"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{url:t,method:"PUT"}),n.json()}async function LD(){const e=Ne("settings/runtime"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).settings}async function BD(){const e=Ne("settings/deployment"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).settings}async function qD(){const e=Ne("diagnostics"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function UD(){const e=Ne("settings/runtime/codex"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function tf(){const e=Ne("settings/runtime/accounts"),t=await fetch(e);await Ve(t,{url:e});const n=await t.json();return to(),n}async function O3(e=!1){const t=Ne(`settings/runtime/accounts/refresh${e?"?force=1":""}`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t});const a=await n.json();return to(),a}async function HD(e){const t=Ne("settings/runtime/accounts"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});await Ve(n,{method:"POST",url:t});const a=await n.json();return a.login.status==="succeeded"&&to(),a.login}async function $D(e){const t=Ne(`settings/runtime/accounts/login/${e}`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).login}async function FD(e){const t=Ne(`settings/runtime/accounts/login/${e}/cancel`),n=await fetch(t,{method:"POST"});return await Ve(n,{method:"POST",url:t}),(await n.json()).login}async function PD(e,t,n){const a=Ne(`settings/runtime/accounts/${e}`),l=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,renewalDay:n})});await Ve(l,{method:"PATCH",url:a});const u=await l.json();return to(),u.account}async function GD(e){const t=Ne(`settings/runtime/accounts/${e}`),n=await fetch(t,{method:"DELETE"});await Ve(n,{method:"DELETE",url:t}),to()}async function VD(e){const t=Ne(`settings/runtime/accounts/${e}/switch`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t});const a=await n.json();return to(),a}async function YD(e=!0){const t=Ne(`settings/runtime/models?refresh=${e?"1":"0"}`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function WD(e=!1){const t=Ne(`settings/runtime/codex/update${e?"?refreshLatest=1":""}`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function KD(){const e=Ne("settings/runtime/codex/update"),t=await fetch(e,{method:"POST"});return await Ve(t,{method:"POST",url:e}),(await t.json()).job}async function XD(e){const t=Ne(`conversations/${e}/settings/runtime`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).settings}async function ZD(){const e=Ne("settings/memory"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function QD(e){const t=Ne("settings/runtime"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"PUT",url:t}),(await n.json()).settings}async function JD(e){const t=Ne("settings/deployment"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"PUT",url:t}),(await n.json()).settings}async function I3(e,t){const n=Ne(`conversations/${e}/settings/runtime`),a=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PUT",url:n}),await a.json()}async function _3(e,t){const n=Ne(`conversations/${e}/runtime/reset`),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"POST",url:n}),(await a.json()).job}async function L3(e){const t=Ne(`conversations/${e}/runtime/reset-preview`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function ez(e,t){const n=Ne(`conversations/${e}/runtime/reset-selection`),a=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});await Ve(a,{method:"PUT",url:n})}async function tz(e){const t=Ne(`conversations/${e}/runtime/thread-read`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).result}async function nz(e){const t=Ne(`conversations/${e}/runtime/token-usage`),n=await fetch(t);await Ve(n,{url:t});const a=await n.json();return a.event?ub(a.event):null}async function rz(e){const t=Ne(`conversations/${e}/runtime/additional-context`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function az(e){const t=Ne(`conversations/${e}/runtime/compactions`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).compactions}function iz(e,t,n){return{modelSource:m6(e.modelSource,t.modelSource)&&(n==null?void 0:n.sources.modelSource)!=="workspace"?null:e.modelSource??{type:"codex"},model:e.model===t.model?null:e.model,reasoningEffort:OE(e.reasoningEffort,t.reasoningEffort,(n==null?void 0:n.sources.reasoningEffort)==="workspace"),fastMode:e.fastMode===t.fastMode?null:e.fastMode,sandbox:e.sandbox===t.sandbox?null:e.sandbox}}function lz(e){return{kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceClues:oz(e.sourceCluesText),requiredEnv:uz(e.requiredEnvText)}}function sz(e){return{id:e.id,kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceCluesText:e.sourceClues.map(t=>`${t.type}: ${t.value}`).join(`
384
+ $2`)}function oD(e){var u;const t=A.Children.toArray(e),n=t.length===1&&A.isValidElement(t[0])?t[0]:null;if(!n||n.type!=="code")return null;const l=((u=(n.props.className??"").match(/(?:^|\s)language-([^\s]+)/))==null?void 0:u[1])??"";return{code:o1(n.props.children).replace(/\n$/,""),language:l}}function o1(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(o1).join(""):A.isValidElement(e)?o1(e.props.children):""}const Y6="github-light",gp=new Map,yp=new Map;let vp=null,xp=null;const W6=new Set(["bash","css","diff","dockerfile","html","java","javascript","json","jsonc","jsx","markdown","python","shellscript","sql","toml","tsx","typescript","xml","yaml"]);function ng(e){const t=e.trim().toLowerCase().replace(/^\./,"");return{bash:"bash",cjs:"javascript",console:"shellscript",htm:"html",js:"javascript",jsx:"jsx",md:"markdown",mjs:"javascript",py:"python",rb:"ruby",shell:"bash",ts:"typescript",tsx:"tsx",yml:"yaml",zsh:"bash"}[t]??t}function K6(e){const t=ng(e);return!t||t==="text"||t==="txt"?"text":W6.has(t)?t:"text"}function uD({code:e}){const n=`seele-mermaid-${A.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,[a,l]=A.useState(!1),[u,c]=A.useState(()=>yp.get(e)??null),[f,h]=A.useState(null);A.useEffect(()=>{let p=!1,y;const k=yp.get(e);return k?(c(k),h(null),()=>{p=!0}):(h(null),c(null),cD(n,e).then(x=>{p||(y!==void 0&&window.clearTimeout(y),yp.set(e,x),c(x),h(null))},x=>{if(!p){const C=x instanceof Error?x.message:String(x);y=window.setTimeout(()=>{p||h(C)},iN)}}),()=>{p=!0,y!==void 0&&window.clearTimeout(y)})},[e,n]);async function m(){await navigator.clipboard.writeText(e),l(!0),window.setTimeout(()=>l(!1),1200)}return s.jsxs("figure",{className:`mermaid-block${f?" error":""}`,children:[s.jsx("span",{className:"code-block-kind",children:"mermaid"}),s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":a?"Copied Mermaid source":"Copy Mermaid source",className:a?"copied":"",onClick:()=>void m(),title:a?"Copied":"Copy",type:"button",children:s.jsx(rg,{})})}),u?s.jsx("div",{className:"mermaid-diagram",dangerouslySetInnerHTML:{__html:u}}):f?s.jsxs("div",{className:"mermaid-error",children:[s.jsx("strong",{children:"Mermaid render failed"}),s.jsx("pre",{children:f}),s.jsx("code",{children:e})]}):s.jsx("div",{className:"mermaid-loading",children:"Rendering diagram..."})]})}async function cD(e,t){return(await(await dD()).render(e,t)).svg}function dD(){return xp||(xp=ln(()=>import("./mermaid.core-kum-uKSk.js").then(e=>e.bp),[],import.meta.url).then(e=>{const t=e.default;return t.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#f9fafa",primaryBorderColor:"#d8d9e8",primaryTextColor:"#0b0f16",lineColor:"#7a8294",secondaryColor:"#f5f5fb",tertiaryColor:"#ffffff",fontFamily:'Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}}),t})),xp}function fD({code:e,language:t,reserveHeight:n=!1}){const[a,l]=A.useState(!1),[u,c]=A.useState(()=>{if(!M3(t))return null;const m=N3(e,t);return gp.get(m)??null}),f=n?{"--code-block-min-height":`${pN(e)}px`}:void 0;A.useEffect(()=>{let m=!1;if(!M3(t))return c(null),()=>{m=!0};const p=N3(e,t),y=gp.get(p);return y?(c(y),()=>{m=!0}):(c(null),xD(e,t).then(k=>{gp.set(p,k),m||c(k)}).catch(k=>{console.warn("Failed to highlight code block",k),m||c(null)}),()=>{m=!0})},[e,t]);async function h(){await navigator.clipboard.writeText(e),l(!0),window.setTimeout(()=>l(!1),1200)}return s.jsxs("figure",{className:"code-block",style:f,children:[t?s.jsx("span",{className:"code-block-kind",children:t}):null,s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":a?"Copied code block":"Copy code block",className:a?"copied":"",onClick:()=>void h(),title:a?"Copied":"Copy",type:"button",children:s.jsx(rg,{})})}),u?s.jsx("div",{className:"code-block-shiki",dangerouslySetInnerHTML:{__html:u}}):s.jsx("pre",{children:s.jsx("code",{children:e})})]})}function rg(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"13",viewBox:"0 0 24 24",width:"13",children:[s.jsx("rect",{height:"14",rx:"2",stroke:"currentColor",strokeWidth:"2",width:"14",x:"8",y:"8"}),s.jsx("path",{d:"M4 16V6a2 2 0 0 1 2-2h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})]})}function X6(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"16",viewBox:"0 0 24 24",width:"16",children:[s.jsx("circle",{cx:"6",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("circle",{cx:"18",cy:"5",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M6 7v1a6 6 0 0 0 6 6v3M18 7v1a6 6 0 0 1-6 6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})]})}function ag(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"12",viewBox:"0 0 24 24",width:"12",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.2"}),s.jsx("path",{d:"M12 7v6",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2.4"}),s.jsx("circle",{cx:"12",cy:"17",fill:"currentColor",r:"1.25"})]})}function hD(){return s.jsx("svg",{"aria-hidden":"true",fill:"none",height:"18",viewBox:"0 0 24 24",width:"18",children:s.jsx("path",{d:"M4 7h16M4 12h16M4 17h16",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})})}function mD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M7 7h10M7 12h10M7 17h10",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"}),s.jsx("circle",{cx:"4",cy:"7",fill:"currentColor",r:"1.4"}),s.jsx("circle",{cx:"4",cy:"12",fill:"currentColor",r:"1.4"}),s.jsx("circle",{cx:"4",cy:"17",fill:"currentColor",r:"1.4"})]})}function E3(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"2"}),s.jsx("path",{d:"M19 12a7.8 7.8 0 0 0-.1-1l2-1.5-2-3.4-2.4 1a8 8 0 0 0-1.8-1l-.3-2.6h-4l-.3 2.6a8 8 0 0 0-1.8 1l-2.4-1-2 3.4 2 1.5a7.8 7.8 0 0 0 0 2l-2 1.5 2 3.4 2.4-1a8 8 0 0 0 1.8 1l.3 2.6h4l.3-2.6a8 8 0 0 0 1.8-1l2.4 1 2-3.4-2-1.5c.1-.3.1-.7.1-1Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"1.7"})]})}function pD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("rect",{height:"16",rx:"2.6",stroke:"currentColor",strokeWidth:"1.8",width:"18",x:"3",y:"4"}),s.jsx("path",{d:"m7 9 3 3-3 3M12.5 15h4.5",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.9"})]})}function ef(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"17",viewBox:"0 0 24 24",width:"17",children:[s.jsx("circle",{cx:"7",cy:"12",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("circle",{cx:"17",cy:"7",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("circle",{cx:"17",cy:"17",r:"2.4",stroke:"currentColor",strokeWidth:"1.8"}),s.jsx("path",{d:"m9.2 10.9 5.6-2.8M9.2 13.1l5.6 2.8",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.8"})]})}function Hf(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"13",viewBox:"0 0 24 24",width:"13",children:[s.jsx("path",{d:"m4 16-.8 4 4-.8L18.4 8 15.2 4.8 4 16Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"2"}),s.jsx("path",{d:"m13.8 6.2 3.2 3.2",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})]})}function gD(){return s.jsx("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:s.jsx("path",{d:"M5 8v11h14V8M4 4h16v4H4zM9 12h6",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function yD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M2.5 12s3.5-6 9.5-6 9.5 6 9.5 6-3.5 6-9.5 6-9.5-6-9.5-6Z",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"3",stroke:"currentColor",strokeWidth:"2"})]})}function vD(){return s.jsxs("svg",{"aria-hidden":"true",fill:"none",height:"14",viewBox:"0 0 24 24",width:"14",children:[s.jsx("path",{d:"M3 3l18 18",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"}),s.jsx("path",{d:"M9.9 5.4A9.8 9.8 0 0 1 12 5c6 0 9.5 7 9.5 7a15.5 15.5 0 0 1-3 3.8M6.2 6.8C3.8 8.4 2.5 12 2.5 12s3.5 7 9.5 7a9.7 9.7 0 0 0 4-.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})]})}function N3(e,t){return`${Y6}:${K6(t)}:${e}`}function M3(e){const t=ng(e);return!!t&&W6.has(t)}async function xD(e,t){return(await bD()).codeToHtml(e,{lang:K6(t),theme:Y6})}function bD(){return vp||(vp=wD()),vp}async function wD(){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t},{default:n},{default:a},{default:l},{default:u},{default:c},{default:f},{default:h},{default:m},{default:p},{default:y},{default:k},{default:x},{default:C},{default:M},{default:I},{default:_},{default:N},{default:q},{default:R},{default:X}]=await Promise.all([ln(()=>import("./core-Cn8g1Lbi.js"),[],import.meta.url),ln(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),ln(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),ln(()=>import("./bash-BELqPA7S.js").then(P=>P.b),[],import.meta.url),ln(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),ln(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),ln(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),ln(()=>import("./html-pp8916En.js"),__vite__mapDeps([0,1,2]),import.meta.url),ln(()=>import("./java-CylS5w8V.js"),[],import.meta.url),ln(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),ln(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),ln(()=>import("./jsonc-Des-eS-w.js"),[],import.meta.url),ln(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),ln(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),ln(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),ln(()=>import("./bash-BELqPA7S.js").then(P=>P.s),[],import.meta.url),ln(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),ln(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),ln(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),ln(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),ln(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([3,4]),import.meta.url),ln(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url)]);return e({engine:t(),themes:[n],langs:[a,l,u,c,f,h,m,p,y,k,x,C,M,I,_,N,q,R,X]})}async function D3(){const e=Ne("conversations"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).conversations}async function kD(){const e=Ne("workspace-states"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).workspaces}async function z3(){const e=Ne("collaboration/topics"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).topics}async function Pd(e){const t=Ne(`collaboration/topics/${e}/messages?limit=100`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).messages}async function SD(e){const t=Ne("collaboration/topics"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"POST",url:t}),(await n.json()).topic}async function jD(e,t){const n=Ne(`collaboration/topics/${e}`),a=await fetch(n,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PATCH",url:n}),(await a.json()).topic}async function CD(e,t){const n=Ne(`collaboration/topics/${e}/archive`),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedVersion:t})});return await Ve(a,{method:"POST",url:n}),(await a.json()).topic}async function TD(e){const t=Ne(`conversations/${e}/read`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t})}async function R3(){const e=Ne("workspace-groups"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).groups}async function AD(e){const t=Ne("workspace-groups"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});return await Ve(n,{method:"POST",url:t}),(await n.json()).group}async function ED(e,t){const n=Ne(`workspace-groups/${e}`),a=await fetch(n,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PATCH",url:n}),(await a.json()).group}async function ND(e){const t=Ne(`workspace-groups/${e}`),n=await fetch(t,{method:"DELETE"});return await Ve(n,{method:"DELETE",url:t}),await n.json()}async function MD(){const e=Ne("settings/environment"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).variables}async function DD(e){const t=Ne(`conversations/${e}/settings/environment`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).variables}async function zD(e){const t=Ne(`conversations/${e}/knowledge`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).items}async function RD(){const e=Ne("settings/model-providers"),t=await fetch(e);return await Ve(t,{url:e}),t.json()}async function OD(){const e=Ne("settings/model-providers/options"),t=await fetch(e);return await Ve(t,{url:e}),t.json()}async function ID(e){const t=Ne(`settings/model-providers/${encodeURIComponent(e)}/balance`),n=await fetch(t);return await Ve(n,{url:t}),n.json()}async function _D(e){const t=Ne("settings/model-providers"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{url:t,method:"PUT"}),n.json()}async function LD(){const e=Ne("settings/runtime"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).settings}async function BD(){const e=Ne("settings/deployment"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).settings}async function qD(){const e=Ne("diagnostics"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function UD(){const e=Ne("settings/runtime/codex"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function tf(){const e=Ne("settings/runtime/accounts"),t=await fetch(e);await Ve(t,{url:e});const n=await t.json();return to(),n}async function O3(e=!1){const t=Ne(`settings/runtime/accounts/refresh${e?"?force=1":""}`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t});const a=await n.json();return to(),a}async function HD(e){const t=Ne("settings/runtime/accounts"),n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});await Ve(n,{method:"POST",url:t});const a=await n.json();return a.login.status==="succeeded"&&to(),a.login}async function $D(e){const t=Ne(`settings/runtime/accounts/login/${e}`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).login}async function FD(e){const t=Ne(`settings/runtime/accounts/login/${e}/cancel`),n=await fetch(t,{method:"POST"});return await Ve(n,{method:"POST",url:t}),(await n.json()).login}async function PD(e,t,n){const a=Ne(`settings/runtime/accounts/${e}`),l=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,renewalDay:n})});await Ve(l,{method:"PATCH",url:a});const u=await l.json();return to(),u.account}async function GD(e){const t=Ne(`settings/runtime/accounts/${e}`),n=await fetch(t,{method:"DELETE"});await Ve(n,{method:"DELETE",url:t}),to()}async function VD(e){const t=Ne(`settings/runtime/accounts/${e}/switch`),n=await fetch(t,{method:"POST"});await Ve(n,{method:"POST",url:t});const a=await n.json();return to(),a}async function YD(e=!0){const t=Ne(`settings/runtime/models?refresh=${e?"1":"0"}`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function WD(e=!1){const t=Ne(`settings/runtime/codex/update${e?"?refreshLatest=1":""}`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function KD(){const e=Ne("settings/runtime/codex/update"),t=await fetch(e,{method:"POST"});return await Ve(t,{method:"POST",url:e}),(await t.json()).job}async function XD(e){const t=Ne(`conversations/${e}/settings/runtime`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).settings}async function ZD(){const e=Ne("settings/memory"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function QD(e){const t=Ne("settings/runtime"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"PUT",url:t}),(await n.json()).settings}async function JD(e){const t=Ne("settings/deployment"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"PUT",url:t}),(await n.json()).settings}async function I3(e,t){const n=Ne(`conversations/${e}/settings/runtime`),a=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PUT",url:n}),await a.json()}async function _3(e,t){const n=Ne(`conversations/${e}/runtime/reset`),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"POST",url:n}),(await a.json()).job}async function L3(e){const t=Ne(`conversations/${e}/runtime/reset-preview`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function ez(e,t){const n=Ne(`conversations/${e}/runtime/reset-selection`),a=await fetch(n,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});await Ve(a,{method:"PUT",url:n})}async function tz(e){const t=Ne(`conversations/${e}/runtime/thread-read`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).result}async function nz(e){const t=Ne(`conversations/${e}/runtime/token-usage`),n=await fetch(t);await Ve(n,{url:t});const a=await n.json();return a.event?ub(a.event):null}async function rz(e){const t=Ne(`conversations/${e}/runtime/additional-context`),n=await fetch(t);return await Ve(n,{url:t}),await n.json()}async function az(e){const t=Ne(`conversations/${e}/runtime/compactions`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).compactions}function iz(e,t,n){return{modelSource:m6(e.modelSource,t.modelSource)&&(n==null?void 0:n.sources.modelSource)!=="workspace"?null:e.modelSource??{type:"codex"},model:e.model===t.model?null:e.model,reasoningEffort:OE(e.reasoningEffort,t.reasoningEffort,(n==null?void 0:n.sources.reasoningEffort)==="workspace"),fastMode:e.fastMode===t.fastMode?null:e.fastMode,sandbox:e.sandbox===t.sandbox?null:e.sandbox}}function lz(e){return{kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceClues:oz(e.sourceCluesText),requiredEnv:uz(e.requiredEnvText)}}function sz(e){return{id:e.id,kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceCluesText:e.sourceClues.map(t=>`${t.type}: ${t.value}`).join(`
385
385
  `),requiredEnvText:e.fetch.requiredEnv.map(t=>t.description?`${t.key} - ${t.description}`:t.key).join(`
386
386
  `)}}function oz(e){const t=new Date().toISOString();return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).map(n=>{const a=n.match(/^([a-zA-Z][\w-]{0,31})\s*:\s*(.+)$/);return{type:a?a[1].toLowerCase():"text",value:a?a[2].trim():n,providedBy:"user",providedAt:t}})}function uz(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(Boolean).map(t=>{const[n,...a]=t.split(/\s+-\s+/);return{key:n.trim().toUpperCase(),description:a.join(" - ").trim()}}).filter(t=>/^[A-Z_][A-Z0-9_]*$/.test(t.key))}function B3(e,t){const n=q3(t.attention)-q3(e.attention);return n!==0?n:t.updatedAt.localeCompare(e.updatedAt)}function q3(e){return e==="watch"?2:e==="tracked"?1:0}function Kc(e){return e.map(t=>({key:t.key??"",value:t.value??"",updatedAt:t.updatedAt}))}function cz(e){return e?/^[a-z_][a-z0-9_.-]*$/.test(e)?null:"Key must start with a lowercase English letter or underscore, and may contain lowercase letters, numbers, dots, underscores, and hyphens.":"Key is required."}function dz(e){return Kc(e).filter(t=>t.key.trim()&&t.value.trim()).map(t=>`${t.key.trim()}: ${t.value.trim()}`).join(`
387
387
  `)}async function fz(e){const t=Ne("settings/memory"),n=await fetch(t,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Ve(n,{method:"PUT",url:t}),await n.json()}async function hz(e,t,n){const a=Ne("settings/environment"),l=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:n,key:e,value:t})});return await Ve(l,{method:"PUT",url:a}),(await l.json()).variable}async function mz(e,t,n,a){const l=Ne(`conversations/${e}/settings/environment`),u=await fetch(l,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:a,key:t,value:n})});return await Ve(u,{method:"PUT",url:l}),await u.json()}async function pz(e){const t=Ne(`settings/environment/${encodeURIComponent(e)}/reveal`),n=await fetch(t);return await Ve(n,{url:t}),(await n.json()).variable.value}async function gz(e,t){const n=Ne(`conversations/${e}/settings/environment/${encodeURIComponent(t)}/reveal`),a=await fetch(n);return await Ve(a,{url:n}),(await a.json()).variable.value}async function yz(e){const t=Ne(`settings/environment/${encodeURIComponent(e)}`),n=await fetch(t,{method:"DELETE"});await Ve(n,{method:"DELETE",url:t})}async function vz(e,t){const n=Ne(`conversations/${e}/settings/environment/${encodeURIComponent(t)}`),a=await fetch(n,{method:"DELETE"});return await Ve(a,{method:"DELETE",url:n}),(await a.json()).conversation}async function xz(e,t){const n=Ne(`conversations/${e}/knowledge`),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"POST",url:n}),(await a.json()).item}async function bz(e,t,n){const a=Ne(`conversations/${e}/knowledge/${encodeURIComponent(t)}`),l=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return await Ve(l,{method:"PATCH",url:a}),(await l.json()).item}async function wz(e,t){const n=Ne(`conversations/${e}/knowledge/${encodeURIComponent(t)}`),a=await fetch(n,{method:"DELETE"});await Ve(a,{method:"DELETE",url:n})}async function kz(){const e=Ne("meta"),t=await fetch(e);return await Ve(t,{url:e}),await t.json()}async function Sz(){const e=Ne("settings/runtime/rate-limits"),t=await fetch(e);return await Ve(t,{url:e}),(await t.json()).usage??null}async function jz(e,t){const n=Ne("conversations"),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,groupId:t})});return await Ve(a,{method:"POST",url:n}),(await a.json()).conversation}function Cz(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;const t=Array.from(e,n=>n.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}async function Tz(e,t,n,a,l){const u=Ne(`conversations/${e}/clone`),c=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,groupId:n,excludeTopicHistory:a,requestId:l})});return await Ve(c,{method:"POST",url:u}),await c.json()}async function Az(e){const t=Ne(`conversations/${e}/clone/retry`),n=await fetch(t,{method:"POST"});return await Ve(n,{method:"POST",url:t}),await n.json()}async function Xc(e,t={}){const n=new URLSearchParams;n.set("limit",String(t.limit??k6)),t.before&&n.set("before",t.before);const a=Ne(`conversations/${e}?${n}`),l=await fetch(a);return await Ve(l,{url:a}),(await l.json()).conversation}async function Z6(e,t){const n=Ne(`conversations/${e}/turns/${t}/history-events`),a=await fetch(n);return await Ve(a,{url:n}),(await a.json()).events}async function Gd(e,t){const n=Ne(`conversations/${e}`),a=await fetch(n,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});return await Ve(a,{method:"PATCH",url:n}),(await a.json()).conversation}async function Ez(e){const t=Ne(`conversations/${e}`),n=await fetch(t,{method:"DELETE"});await Ve(n,{method:"DELETE",url:t})}function Nz(e){return e.title==="Phase boundary recommended"||e.title==="Long run in progress"}function Q6(e){return e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")} +${e.length-3}`}function Mz(e,t){if(e.event==="server.error"||e.event==="client.error")return{id:e.id,kind:"error",title:"Error",body:Wz(e.data),createdAt:e.createdAt??new Date().toISOString()};if(e.event==="server.collaboration.message_staged"||e.event==="server.collaboration.message_sent"||e.event==="server.collaboration.message_rejected"){const u=Fe(e.data),c=et(u.toolCallId),f=typeof u.controlIndex=="number"?u.controlIndex:null;if(c||f!==null){const h=e.event==="server.collaboration.message_staged",m=e.event==="server.collaboration.message_sent",p=et(u.audience),y=et(u.recipientWorkspaceId),k=y?[y]:Array.isArray(u.recipientWorkspaceIds)?u.recipientWorkspaceIds.filter(I=>typeof I=="string"):Array.isArray(u.recipients)?u.recipients.filter(I=>typeof I=="string"):[],x=k.filter(I=>I!=="ALL").map(I=>t.get(I)).filter(I=>!!I);let C="Topic";x.length>0?C=Q6(x):k.length===1?C=k[0]==="ALL"?"Topic participants":ns(k[0]):k.length>1?C=`${k.length} workspaces`:p==="public"||p==="all"?C="Topic participants":p==="owner"&&(C="Topic owner");const M=et(u.topicId);return{id:e.id,kind:"collaboration",title:`Send to ${C}`,body:M?`Topic ${ns(M)}`:"Topic",createdAt:e.createdAt??new Date().toISOString(),itemId:c||`legacy-topic-message:${f}`,meta:h?"pending send":m?"done":"failed",output:h||m?et(u.contentMarkdown)||void 0:et(u.reason)||void 0,topicAction:"send",topicRecipientLabel:C,topicMessageContent:(h||m)&&et(u.contentMarkdown)||void 0}}}if(e.event==="codex.input_request"||e.event==="codex.input_or_approval_request"){const u=Fe(e.data);if(e.event==="codex.input_request"||u.method==="item/tool/requestUserInput"){const c=Fe(u.params),h=(Array.isArray(c.questions)?c.questions:[]).map(m=>{const p=Fe(m),y=typeof p.question=="string"?p.question:"Please provide the missing information.",k=Array.isArray(p.options)?p.options.map(x=>{const C=Fe(x);return typeof C.label=="string"?`- ${C.label}${typeof C.description=="string"?`: ${C.description}`:""}`:""}).filter(Boolean).join(`