@seele00/seele-work 0.1.112 → 0.1.113

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 (68) hide show
  1. package/libexec/seele-server +0 -0
  2. package/libexec/seele-worker +0 -0
  3. package/package.json +1 -1
  4. package/release-manifest.json +127 -127
  5. package/web/dist/assets/{abnfDiagram-VRR7QNED-C7h-iXm2.js → abnfDiagram-VRR7QNED-CTFNTHtM.js} +1 -1
  6. package/web/dist/assets/{arc-DXQ6J1b4.js → arc-DS3EJOfQ.js} +1 -1
  7. package/web/dist/assets/{architectureDiagram-ZJ3FMSHR-BR4W6WuE.js → architectureDiagram-ZJ3FMSHR-9BTL3Ju3.js} +1 -1
  8. package/web/dist/assets/{blockDiagram-677ZJIJ3-BkVwm53d.js → blockDiagram-677ZJIJ3-CxNwI3Xj.js} +1 -1
  9. package/web/dist/assets/{c4Diagram-LMCZKHZV-CSPw-zXM.js → c4Diagram-LMCZKHZV-C5g2eUlL.js} +1 -1
  10. package/web/dist/assets/channel-C6DgvyR9.js +1 -0
  11. package/web/dist/assets/{chunk-2Q5K7J3B-CWGjwR5B.js → chunk-2Q5K7J3B-DLiVoZwr.js} +1 -1
  12. package/web/dist/assets/{chunk-32BRIVSS-YKt5SJpe.js → chunk-32BRIVSS-BaP4nKH_.js} +1 -1
  13. package/web/dist/assets/{chunk-5VM5RSS4-DWkFuE3C.js → chunk-5VM5RSS4-CvQNZGgw.js} +1 -1
  14. package/web/dist/assets/{chunk-EX3LRPZG-DhY30PMW.js → chunk-EX3LRPZG-DtrgZU5v.js} +1 -1
  15. package/web/dist/assets/{chunk-JWPE2WC7-Dd9mAjbo.js → chunk-JWPE2WC7-D4nWpDMu.js} +1 -1
  16. package/web/dist/assets/{chunk-MOJQB5TN-Hn5r5aBe.js → chunk-MOJQB5TN-BWEHq24P.js} +1 -1
  17. package/web/dist/assets/{chunk-RYQCIY6F-D4pWNzmL.js → chunk-RYQCIY6F-vtxLm7z0.js} +1 -1
  18. package/web/dist/assets/{chunk-V7JOEXUC-DUAcJBKc.js → chunk-V7JOEXUC-llCgx7fN.js} +1 -1
  19. package/web/dist/assets/{chunk-VR4S4FIN-MPdT1U6q.js → chunk-VR4S4FIN-6uhuz7-D.js} +1 -1
  20. package/web/dist/assets/{chunk-XXDRQBXY-CtOpraHU.js → chunk-XXDRQBXY-CsMCPwks.js} +1 -1
  21. package/web/dist/assets/classDiagram-OUVF2IWQ-DgAdMh5n.js +1 -0
  22. package/web/dist/assets/classDiagram-v2-EOCWNBFH-DgAdMh5n.js +1 -0
  23. package/web/dist/assets/{core-pJEyggQv.js → core-bqmd5bjk.js} +1 -1
  24. package/web/dist/assets/{cose-bilkent-JH36ORCC-e2Ygfaks.js → cose-bilkent-JH36ORCC-CeuPKvzZ.js} +1 -1
  25. package/web/dist/assets/{cynefin-VYW2F7L2-BqRhGR2A.js → cynefin-VYW2F7L2-Fo6bLIsl.js} +1 -1
  26. package/web/dist/assets/{cynefinDiagram-TSTJHNR4-BZZt2EvR.js → cynefinDiagram-TSTJHNR4-CSawoxKX.js} +1 -1
  27. package/web/dist/assets/{dagre-VKFMJZFB-aVTRxrXw.js → dagre-VKFMJZFB-D9Xhs7On.js} +1 -1
  28. package/web/dist/assets/{diagram-FQU43EPY-BDC6T3hK.js → diagram-FQU43EPY-DB6cN00s.js} +1 -1
  29. package/web/dist/assets/{diagram-G47NLZAW-B21qThL_.js → diagram-G47NLZAW-DNjwGU89.js} +1 -1
  30. package/web/dist/assets/{diagram-NH7WQ7WH-EpQa0MSs.js → diagram-NH7WQ7WH-C3vQfyZ-.js} +1 -1
  31. package/web/dist/assets/{diagram-OA4YK3LP-BxBeLQzb.js → diagram-OA4YK3LP-D0hZJ12O.js} +1 -1
  32. package/web/dist/assets/{diagram-WEI45ONY-ClBT3QKx.js → diagram-WEI45ONY-C0WVplc9.js} +1 -1
  33. package/web/dist/assets/{ebnfDiagram-CCIWWBDH-C9ekJuVs.js → ebnfDiagram-CCIWWBDH-Cn3Px4hL.js} +1 -1
  34. package/web/dist/assets/{erDiagram-Q63AITRT-ff1Dz1-y.js → erDiagram-Q63AITRT-BepZUHQn.js} +1 -1
  35. package/web/dist/assets/{flowDiagram-23GEKE2U-c3ecXPkY.js → flowDiagram-23GEKE2U-V3omTqUp.js} +1 -1
  36. package/web/dist/assets/{ganttDiagram-NO4QXBWP-CpPWXix5.js → ganttDiagram-NO4QXBWP-Cy_CoUKz.js} +1 -1
  37. package/web/dist/assets/{gitGraphDiagram-IHSO6WYX-jR0L9b0V.js → gitGraphDiagram-IHSO6WYX-WhcXyRXe.js} +1 -1
  38. package/web/dist/assets/{index-BCuI0kOw.js → index-CwPe0GUY.js} +2 -2
  39. package/web/dist/assets/{index-BAAV84l8.css → index-DxOW60R2.css} +1 -1
  40. package/web/dist/assets/{infoDiagram-FWYZ7A6U-DHblvYNj.js → infoDiagram-FWYZ7A6U-gZwwoFtB.js} +1 -1
  41. package/web/dist/assets/{ishikawaDiagram-FXEZZL3T-D2l5mXjm.js → ishikawaDiagram-FXEZZL3T-J8gxmrVV.js} +1 -1
  42. package/web/dist/assets/{journeyDiagram-5HDEW3XC-CONf-vax.js → journeyDiagram-5HDEW3XC-PAvt63QU.js} +1 -1
  43. package/web/dist/assets/{kanban-definition-HUTT4EX6-CbnYjXlH.js → kanban-definition-HUTT4EX6-BYxCMhgE.js} +1 -1
  44. package/web/dist/assets/{linear-DTiqDBnD.js → linear-AosVMPOw.js} +1 -1
  45. package/web/dist/assets/{mermaid.core-BOqAG-mK.js → mermaid.core-Ci_ONQ9q.js} +4 -4
  46. package/web/dist/assets/{mindmap-definition-LN4V7U3C-DoWsEXJa.js → mindmap-definition-LN4V7U3C-Cz93df7q.js} +1 -1
  47. package/web/dist/assets/{pegDiagram-2B236MQR-B5IL4X3k.js → pegDiagram-2B236MQR-BYDLv35r.js} +1 -1
  48. package/web/dist/assets/{pieDiagram-ENE6RG2P-BzzkxA-b.js → pieDiagram-ENE6RG2P-DWhhF7Hn.js} +1 -1
  49. package/web/dist/assets/{quadrantDiagram-ABIIQ3AL-C-PEn4Ug.js → quadrantDiagram-ABIIQ3AL-MMJJt6nx.js} +1 -1
  50. package/web/dist/assets/{railroadDiagram-RFXS5EU6-CRGUTI40.js → railroadDiagram-RFXS5EU6-DPlzTzo3.js} +1 -1
  51. package/web/dist/assets/{requirementDiagram-TGXJPOKE-DHO3LobU.js → requirementDiagram-TGXJPOKE-CQyfc0-y.js} +1 -1
  52. package/web/dist/assets/{sankeyDiagram-HTMAVEWB-mUxV6fXw.js → sankeyDiagram-HTMAVEWB-BcHtyC1S.js} +1 -1
  53. package/web/dist/assets/{sequenceDiagram-DBY2YBRQ-CWir2Ru9.js → sequenceDiagram-DBY2YBRQ-DNYEIkZM.js} +1 -1
  54. package/web/dist/assets/{sizeCapture-X5ZJPWSS-MLFnO9To.js → sizeCapture-X5ZJPWSS-CKIvFl0J.js} +1 -1
  55. package/web/dist/assets/{stateDiagram-2N3HPSRC-D56HPKf3.js → stateDiagram-2N3HPSRC-Bj_EvZzb.js} +1 -1
  56. package/web/dist/assets/stateDiagram-v2-6OUMAXLB-DEtbmzxr.js +1 -0
  57. package/web/dist/assets/{swimlanes-5IMT3BWC-mpl26K7n.js → swimlanes-5IMT3BWC-DcyNtdoo.js} +2 -2
  58. package/web/dist/assets/swimlanesDiagram-G3AALYLV-DvBxqz5a.js +8 -0
  59. package/web/dist/assets/{timeline-definition-FHXFAJF6-BL05xd2h.js → timeline-definition-FHXFAJF6-BPciKKRW.js} +1 -1
  60. package/web/dist/assets/{vennDiagram-L72KCM5P-PW4aqfb8.js → vennDiagram-L72KCM5P-DLI8MwWc.js} +1 -1
  61. package/web/dist/assets/{wardleyDiagram-EHGQE667-Jv8fW4K-.js → wardleyDiagram-EHGQE667-CCQNQxnJ.js} +1 -1
  62. package/web/dist/assets/{xychartDiagram-FW5EYKEG-DTtLXxZ2.js → xychartDiagram-FW5EYKEG-BAiR6SbB.js} +1 -1
  63. package/web/dist/index.html +2 -2
  64. package/web/dist/assets/channel-Bfwe-6s5.js +0 -1
  65. package/web/dist/assets/classDiagram-OUVF2IWQ-C4_4_z1-.js +0 -1
  66. package/web/dist/assets/classDiagram-v2-EOCWNBFH-C4_4_z1-.js +0 -1
  67. package/web/dist/assets/stateDiagram-v2-6OUMAXLB-DdZPKSvY.js +0 -1
  68. package/web/dist/assets/swimlanesDiagram-G3AALYLV-CaSxO9Mr.js +0 -8
@@ -90,7 +90,7 @@ ${W.detail}`:W.message)}).finally(()=>H(!1))},A=()=>{N(!0),L(null),sD(e.id).then
90
90
  ${W.detail}`:W.message)}).finally(()=>N(!1))},z=()=>{de(!0),F(null),oD(e.id).then(C=>ye(C)).catch(C=>{const W=Ge(C);F(W.detail?`${W.message}
91
91
  ${W.detail}`:W.message)}).finally(()=>de(!1))};return s.jsx("div",{className:"context-panel-overlay workspace-context-overlay",onClick:b,role:"presentation",children:s.jsxs("section",{"aria-label":"Workspace context",className:"context-panel workspace-context-panel",onClick:C=>C.stopPropagation(),children:[s.jsxs("header",{className:"context-panel-header workspace-context-header",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Workspace Context"}),s.jsx("p",{children:"Long-lived context assets and observable state for this workspace."})]}),s.jsx("button",{"aria-label":"Close context panel",onClick:b,type:"button",children:"×"})]}),s.jsxs("div",{className:"workspace-context-body",children:[s.jsxs("nav",{className:"settings-nav workspace-context-nav","aria-label":"Workspace context sections",children:[s.jsxs("button",{className:x==="overview"?"active":void 0,onClick:()=>S("overview"),type:"button",children:[s.jsx("span",{children:"Overview"}),s.jsx("small",{children:"Identity + state"})]}),s.jsxs("button",{className:x==="responsibility"?"active":void 0,onClick:()=>S("responsibility"),type:"button",children:[s.jsx("span",{children:"Responsibility"}),s.jsx("small",{children:"Long-lived role"})]}),s.jsxs("button",{className:x==="knowledge"?"active":void 0,onClick:()=>S("knowledge"),type:"button",children:[s.jsx("span",{children:"Knowledge"}),s.jsx("small",{children:"Sources + skills"})]}),s.jsxs("button",{className:x==="runtime"?"active":void 0,onClick:()=>S("runtime"),type:"button",children:[s.jsx("span",{children:"Runtime View"}),s.jsx("small",{children:"Thread + tokens"})]}),s.jsxs("button",{className:x==="compactions"?"active":void 0,onClick:()=>S("compactions"),type:"button",children:[s.jsx("span",{children:"Compactions"}),s.jsx("small",{children:"Context history"})]}),s.jsxs("button",{className:x==="additionalContext"?"active":void 0,onClick:()=>S("additionalContext"),type:"button",children:[s.jsx("span",{children:"Additional Context"}),s.jsx("small",{children:"Injected keys"})]})]}),s.jsx("div",{className:"workspace-context-content",children:x==="overview"?s.jsxs("div",{className:"workspace-context-grid",children:[s.jsxs("section",{className:`context-card wide workspace-status-detail ${be}`,children:[s.jsx("h3",{children:"Current Status"}),s.jsx(et,{label:"Status",value:Xc(be,e.nextWakeup,i)}),e.nextWakeup?s.jsxs(s.Fragment,{children:[s.jsx(et,{label:"Wakeup state",value:e.nextWakeup.status}),s.jsx(et,{label:"Wake at",value:su(e.nextWakeup.wakeAt)}),e.nextWakeup.status==="scheduled"?s.jsx(et,{label:"Remaining",value:ad(e.nextWakeup,i)}):null,s.jsx(et,{label:"Created by",value:e.nextWakeup.createdBy}),s.jsx(et,{label:"Attempts",value:`${e.nextWakeup.attemptCount} / ${e.nextWakeup.maxAttempts}`,mono:!0}),s.jsxs("div",{className:"workspace-status-detail-text",children:[s.jsx("span",{children:"Wakeup instruction"}),s.jsx("pre",{children:e.nextWakeup.instruction})]}),e.nextWakeup.error?s.jsxs("div",{className:"workspace-status-detail-text error",children:[s.jsx("span",{children:"Wakeup error"}),s.jsx("pre",{children:e.nextWakeup.error})]}):null]}):null,e.statusError?s.jsxs("div",{className:"workspace-status-detail-text error",children:[s.jsx("span",{children:"Error"}),s.jsx("pre",{children:e.statusError})]}):e.status==="error"||e.status==="initialization_failed"?s.jsx("p",{className:"context-muted",children:"No persisted error detail is available for this status."}):null]}),s.jsxs("section",{className:"context-card",children:[s.jsx("h3",{children:"Workspace"}),s.jsx(et,{label:"Name",value:e.title}),s.jsx(et,{label:"ID",value:`workspaces/${Ns(e.id)}`,mono:!0}),s.jsx(et,{label:"Path",value:e.workspacePath,mono:!0})]}),s.jsxs("section",{className:"context-card",children:[s.jsx("h3",{children:"Context Assets"}),s.jsx(et,{label:"Responsibility",value:e.responsibility.trim()?"configured":"missing"}),s.jsx(et,{label:"Memory",value:e.memory.trim()?"configured":"empty"}),s.jsx(et,{label:"Knowledge",value:`${r.length} item${r.length===1?"":"s"}`})]}),s.jsxs("section",{className:"context-card wide",children:[s.jsx("h3",{children:"Current Responsibility"}),e.responsibility.trim()?s.jsx("div",{className:"context-markdown-preview",children:El(e.responsibility,e)}):s.jsx("p",{className:"context-muted",children:"No approved responsibility is configured yet."})]}),s.jsxs("section",{className:"context-card wide",children:[s.jsx("h3",{children:"Knowledge Index"}),s.jsx(Gv,{items:r,onDelete:d,onEdit:C=>{p(C),S("knowledge")}})]})]}):x==="responsibility"?s.jsxs("section",{className:"context-tab-surface",children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Workspace Responsibility"}),s.jsx("p",{children:"User-approved long-lived role for this workspace. Edit it from Settings in workspace scope."})]})}),e.responsibility.trim()?s.jsx("div",{className:"context-card context-markdown-preview",children:El(e.responsibility,e)}):s.jsx("p",{className:"context-card context-muted",children:"No approved responsibility is configured yet."})]}):x==="knowledge"?s.jsx(tN,{draft:a,items:r,scope:"workspace",workspaceName:e.title,onCancel:c,onDelete:d,onDraftChange:g,onEdit:p,onSubmit:m}):x==="runtime"?s.jsxs("div",{className:"workspace-context-grid",children:[s.jsxs("section",{className:"context-card",children:[s.jsx("h3",{children:"Runtime"}),s.jsx(et,{label:"Runtime thread",value:e.codexThreadId??"not started",mono:!0}),s.jsxs("div",{className:"thread-read-actions",children:[s.jsx("button",{disabled:M,onClick:O,type:"button",children:M?"Reading...":"Read Codex thread"}),w?s.jsx("button",{disabled:M,onClick:()=>E(!1),type:"button",children:"Hide"}):null]})]}),s.jsxs("section",{className:"context-card",children:[s.jsx("h3",{children:"Token Window"}),u?s.jsxs(s.Fragment,{children:[s.jsx(et,{label:"Used",value:oe===null?"unknown":`${Math.round(oe)}%`,mono:!0}),s.jsx(et,{label:"Latest usage",value:u.modelContextWindow?`${In(u.totalTokens)} / ${In(u.modelContextWindow)}`:In(u.totalTokens),mono:!0}),oe!==null?s.jsx("div",{className:`context-token-bar ${Lh(oe)}`,children:s.jsx("span",{style:{width:`${dd(oe)}%`}})}):null,s.jsx(et,{label:"Input / output",value:`${Kc(u.inputTokens)} / ${Kc(u.outputTokens)}`,mono:!0}),s.jsx(et,{label:"Reasoning",value:Kc(u.reasoningOutputTokens),mono:!0}),s.jsxs("p",{className:"context-muted",children:["Updated ",He(u.createdAt),"."]})]}):s.jsx("p",{className:"context-muted",children:"No token usage event has been observed in the loaded event window yet."})]}),w?s.jsxs("section",{className:"context-card wide thread-read-panel",children:[s.jsx("h3",{children:"Runtime thread profile"}),s.jsx("p",{className:"context-muted",children:"One-time live thread/read response from Codex app-server. Seele does not persist this profile result."}),M?s.jsx("p",{className:"context-muted",children:"Reading Codex thread..."}):$?s.jsx("pre",{className:"thread-read-error",children:$}):R?s.jsxs(s.Fragment,{children:[_e?s.jsx(oN,{summary:_e}):null,s.jsxs("details",{className:"thread-read-raw",open:!0,children:[s.jsx("summary",{children:"Raw thread/read JSON"}),s.jsx("pre",{className:"thread-read-dump",children:JSON.stringify(R,null,2)})]})]}):s.jsx("p",{className:"context-muted",children:"No thread/read result loaded yet."})]}):null]}):x==="compactions"?s.jsxs("section",{className:"context-tab-surface",children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Context Compactions"}),s.jsx("p",{children:"Compaction history recorded for the current runtime thread."})]}),s.jsx("button",{className:"context-refresh-button",disabled:te,onClick:z,type:"button",children:te?"Refreshing...":"Refresh"})]}),ue?s.jsx("pre",{className:"thread-read-error",children:ue}):te&&!Ne?s.jsx("p",{className:"context-card context-muted",children:"Loading compaction history..."}):Ne!=null&&Ne.length?s.jsx("div",{className:"context-compaction-list",children:Ne.map(C=>s.jsxs("article",{className:"context-compaction-item",children:[s.jsxs("div",{className:"context-compaction-heading",children:[s.jsx("time",{children:He(C.completedAt??C.usageObservedAt??C.startedAt??"")}),s.jsx("span",{className:`context-compaction-status ${C.status}`,children:C.status==="completed"?"Completed":"Running"})]}),s.jsx("dl",{className:"context-compaction-facts",children:PD(C).map(W=>s.jsxs("div",{children:[s.jsx("dt",{children:W.label}),s.jsx("dd",{children:W.value})]},W.label))}),s.jsxs("small",{children:[Nl(C.id),C.turnId?` · turn ${Nl(C.turnId)}`:""]})]},C.id))}):s.jsx("p",{className:"context-card context-muted",children:"No compaction records yet."})]}):s.jsxs("section",{className:"context-tab-surface thread-read-panel",children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Additional Context"}),s.jsx("p",{children:"One-time live render of the application additionalContext for this workspace. Seele does not persist this preview result."})]})}),ie?s.jsx("p",{className:"context-card context-muted",children:"Rendering additionalContext..."}):ee?s.jsx("pre",{className:"thread-read-error",children:ee}):Q?s.jsx(rN,{preview:Q,refreshing:ie,onRefresh:A}):s.jsx("p",{className:"context-card context-muted",children:"No additionalContext preview loaded yet."})]})})]})]})})}function zA({conversations:e,onClose:i,workspaceGroups:a}){var O;const[r,u]=D.useState([]),[c,d]=D.useState("active"),[p,g]=D.useState(null),[m,b]=D.useState([]),[x,S]=D.useState(!0),[w,E]=D.useState(null),[M,H]=D.useState(null),[R,q]=D.useState(!1),[$,V]=D.useState(!1),[ie,N]=D.useState(new Set),[Q,re]=D.useState({title:"",publicDescription:"",ownerWorkspaceId:((O=e[0])==null?void 0:O.id)??"",participantWorkspaceIds:[]}),ee=r.find(A=>A.id===p)??null,L=D.useMemo(()=>new Map(e.map(A=>[A.id,A.title])),[e]),te=r.filter(A=>c==="archived"?A.status==="archived":A.status!=="archived"),de=a.map(A=>({...A,conversations:A.conversations.filter(z=>z.id!==Q.ownerWorkspaceId)})).filter(A=>A.conversations.length>0),Ne=()=>{var A;re({title:"",publicDescription:"",ownerWorkspaceId:((A=e[0])==null?void 0:A.id)??"",participantWorkspaceIds:[]}),N(new Set),H("create")},ye=()=>{!ee||ee.status!=="active"||(re({title:ee.title,publicDescription:ee.publicDescription,ownerWorkspaceId:ee.ownerWorkspaceId,participantWorkspaceIds:ee.members.filter(A=>A.role==="participant"&&A.status==="active").map(A=>A.workspaceId)}),N(new Set),H("edit"))},ue=async(A,z=c)=>{var C;S(!0),E(null);try{const W=await nb();u(W);const fe=W.filter(xe=>z==="archived"?xe.status==="archived":xe.status!=="archived"),X=(A&&fe.some(xe=>xe.id===A)?A:null)??(p&&fe.some(xe=>xe.id===p)?p:((C=fe[0])==null?void 0:C.id)??null);g(X),b(X?await $c(X):[])}catch(W){E(W instanceof Ji?W.detail:W instanceof Error?W.message:String(W))}finally{S(!1)}};D.useEffect(()=>{ue()},[]),D.useEffect(()=>{const A=window.setInterval(()=>{(async()=>{try{const z=await nb();u(z),p&&z.some(C=>C.id===p)&&b(await $c(p))}catch{}})()},1e4);return()=>window.clearInterval(A)},[p]);const F=async A=>{g(A),E(null);try{b(await $c(A))}catch(z){E(z instanceof Ji?z.detail:z instanceof Error?z.message:String(z))}},oe=async A=>{var C;if(A===c)return;d(A),E(null);const z=((C=r.find(W=>A==="archived"?W.status==="archived":W.status!=="archived"))==null?void 0:C.id)??null;if(g(z),!z){b([]);return}try{b(await $c(z))}catch(W){E(W instanceof Ji?W.detail:W instanceof Error?W.message:String(W))}},be=async A=>{var z;if(A.preventDefault(),!(!Q.title.trim()||!Q.ownerWorkspaceId)){V(!0),E(null);try{const C=M==="edit"&&ee?await _2(ee.id,{expectedVersion:ee.version,title:Q.title.trim(),publicDescription:Q.publicDescription.trim(),participantWorkspaceIds:Q.participantWorkspaceIds}):await R2({...Q,title:Q.title.trim(),publicDescription:Q.publicDescription.trim()});d("active"),H(null),re({title:"",publicDescription:"",ownerWorkspaceId:((z=e[0])==null?void 0:z.id)??"",participantWorkspaceIds:[]}),await ue(C.id,"active")}catch(C){E(C instanceof Ji?C.detail:C instanceof Error?C.message:String(C))}finally{V(!1)}}},_e=async()=>{if(!(!ee||ee.status!=="active")){V(!0),E(null);try{const A=await M2(ee.id,ee.version);q(!1),d("active"),await ue(void 0,"active")}catch(A){E(A instanceof Ji?A.detail:A instanceof Error?A.message:String(A))}finally{V(!1)}}};return s.jsx("div",{className:"context-panel-overlay settings-overlay",onClick:i,role:"presentation",children:s.jsxs("section",{"aria-label":"工作空间协作",className:"context-panel collaboration-panel",onClick:A=>A.stopPropagation(),children:[s.jsxs("header",{className:"context-panel-header collaboration-panel-header",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"协作"}),s.jsx("p",{children:"在明确选择的工作空间之间建立持久、定向的 Topic 通信。"})]}),s.jsxs("div",{className:"collaboration-header-actions",children:[s.jsx("button",{"aria-label":"新建 Topic",className:"memory-icon-button collaboration-new-topic",onClick:Ne,title:"新建 Topic",type:"button",children:"+"}),s.jsx("button",{"aria-label":"关闭协作",className:"icon-button",onClick:i,type:"button",children:"×"})]})]}),w?s.jsx("div",{className:"collaboration-error",children:w}):null,s.jsxs("div",{className:"collaboration-body",children:[s.jsxs("nav",{className:"collaboration-topic-list","aria-label":"协作 Topics",children:[s.jsxs("div",{className:"collaboration-topic-tabs",role:"tablist","aria-label":"Topic 列表范围",children:[s.jsx("button",{"aria-selected":c==="active",className:c==="active"?"active":void 0,onClick:()=>void oe("active"),role:"tab",type:"button",children:"当前"}),s.jsx("button",{"aria-selected":c==="archived",className:c==="archived"?"active":void 0,onClick:()=>void oe("archived"),role:"tab",type:"button",children:"已归档"})]}),x?s.jsx("p",{children:"正在加载..."}):te.length===0?s.jsx("p",{children:c==="archived"?"还没有已归档 Topic。":"还没有当前 Topic。"}):te.map(A=>s.jsxs("button",{className:`collaboration-topic-entry${A.id===p?" active":""}`,onClick:()=>void F(A.id),type:"button",children:[s.jsx("span",{children:A.title}),s.jsxs("small",{children:[A.members.length," 个工作空间 · ",A.status]})]},A.id))]}),s.jsx("main",{className:"collaboration-topic-detail",children:ee?s.jsxs(s.Fragment,{children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h3",{children:ee.title}),s.jsx("p",{children:ee.publicDescription||"没有公开描述。"})]}),s.jsxs("div",{className:"collaboration-topic-actions",children:[s.jsx("span",{children:ee.status}),ee.status==="active"?s.jsxs(s.Fragment,{children:[s.jsx("button",{"aria-label":`编辑 Topic ${ee.title}`,className:"memory-icon-button",onClick:ye,title:"编辑",type:"button",children:s.jsx(cd,{})}),s.jsx("button",{"aria-label":`归档 Topic ${ee.title}`,className:"memory-icon-button",onClick:()=>q(!0),title:"归档",type:"button",children:s.jsx(j2,{})})]}):null]})]}),s.jsx("div",{className:"collaboration-members",children:ee.members.filter(A=>A.status==="active").map(A=>s.jsxs("span",{children:[A.workspaceTitleSnapshot,s.jsx("small",{children:A.role})]},`${A.workspaceId}-${A.membershipVersion}`))}),s.jsx("div",{className:"collaboration-message-list",children:m.length===0?s.jsx("p",{children:"还没有消息。"}):m.map(A=>s.jsxs("article",{children:[s.jsxs("header",{children:[s.jsx("strong",{children:A.senderTitleSnapshot}),s.jsx("span",{children:A.recipientWorkspaceIds.includes("ALL")?"发给全部参与者":`发给 ${uw(A.recipientWorkspaceIds.map(z=>L.get(z)??Nl(z)))}`}),s.jsx("time",{children:He(A.createdAt)})]}),s.jsx("div",{className:"markdown-body",children:El(A.contentMarkdown,void 0)})]},A.id))})]}):s.jsx("div",{className:"collaboration-empty",children:"选择或新建一个 Topic。"})})]}),M?s.jsx("div",{className:"collaboration-create-overlay",role:"presentation",onClick:()=>!$&&H(null),children:s.jsxs("form",{className:"dialog-card collaboration-create-dialog",onClick:A=>A.stopPropagation(),onSubmit:be,children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h3",{children:M==="edit"?"编辑 Topic":"新建 Topic"}),s.jsx("p",{children:M==="edit"?"调整公开信息与参与工作空间。":"明确选择本次通信的 owner 与参与者。"})]}),s.jsx("button",{"aria-label":"关闭 Topic 编辑",className:"icon-button",onClick:()=>H(null),type:"button",children:"×"})]}),s.jsxs("label",{children:["标题",s.jsx("input",{autoFocus:!0,placeholder:"填写 Topic 标题",value:Q.title,onChange:A=>re(z=>({...z,title:A.target.value}))})]}),s.jsxs("label",{children:["公开描述",s.jsx("textarea",{placeholder:"填写所有参与工作空间可见的共享背景",value:Q.publicDescription,onChange:A=>re(z=>({...z,publicDescription:A.target.value}))})]}),s.jsxs("label",{children:["Owner 工作空间",s.jsx("select",{disabled:M==="edit",value:Q.ownerWorkspaceId,onChange:A=>re(z=>({...z,ownerWorkspaceId:A.target.value,participantWorkspaceIds:z.participantWorkspaceIds.filter(C=>C!==A.target.value)})),children:a.map(A=>s.jsx("optgroup",{label:A.title,children:A.conversations.map(z=>s.jsx("option",{value:z.id,children:z.title},z.id))},A.id))})]}),s.jsxs("fieldset",{className:"collaboration-participant-groups",children:[s.jsx("legend",{children:"参与工作空间"}),s.jsxs("div",{className:"collaboration-participant-toolbar",children:[s.jsxs("span",{children:[Q.participantWorkspaceIds.length," 个已选择"]}),s.jsxs("div",{children:[s.jsx("button",{onClick:()=>N(new Set),type:"button",children:"全部展开"}),s.jsx("button",{onClick:()=>N(new Set(de.map(A=>A.id))),type:"button",children:"全部收起"})]})]}),de.map(A=>{const z=A.conversations,C=z.filter(fe=>Q.participantWorkspaceIds.includes(fe.id)).length,W=ie.has(A.id);return s.jsxs("section",{className:"collaboration-participant-group",children:[s.jsxs("header",{children:[s.jsxs("button",{"aria-expanded":!W,className:"collaboration-group-toggle",onClick:()=>N(fe=>{const X=new Set(fe);return X.has(A.id)?X.delete(A.id):X.add(A.id),X}),type:"button",children:[s.jsx("span",{"aria-hidden":"true",className:W?void 0:"expanded",children:"›"}),s.jsx("strong",{children:A.title}),s.jsxs("small",{children:[C,"/",z.length]})]}),s.jsxs("label",{title:`选择 ${A.title} 全部工作空间`,children:[s.jsx("input",{checked:C===z.length,onChange:()=>re(fe=>{const X=z.map(Me=>Me.id),xe=new Set(fe.participantWorkspaceIds);return X.every(Me=>xe.has(Me))?X.forEach(Me=>xe.delete(Me)):X.forEach(Me=>xe.add(Me)),{...fe,participantWorkspaceIds:Array.from(xe)}}),type:"checkbox"}),s.jsx("span",{children:"全选"})]})]}),W?null:s.jsx("div",{children:z.map(fe=>s.jsxs("label",{className:"collaboration-participant-option",children:[s.jsx("input",{checked:Q.participantWorkspaceIds.includes(fe.id),onChange:X=>re(xe=>({...xe,participantWorkspaceIds:X.target.checked?[...xe.participantWorkspaceIds,fe.id]:xe.participantWorkspaceIds.filter(Me=>Me!==fe.id)})),type:"checkbox"}),s.jsx("span",{children:fe.title})]},fe.id))})]},A.id)})]}),s.jsxs("footer",{children:[s.jsx("button",{className:"secondary",disabled:$,onClick:()=>H(null),type:"button",children:"取消"}),s.jsx("button",{disabled:$||!Q.title.trim()||!Q.ownerWorkspaceId,type:"submit",children:$?"正在保存...":M==="edit"?"保存":"创建 Topic"})]})]})}):null,R&&ee?s.jsx("div",{className:"collaboration-create-overlay",onClick:()=>!$&&q(!1),role:"presentation",children:s.jsxs("section",{"aria-label":"归档 Topic",className:"dialog-card collaboration-archive-dialog",onClick:A=>A.stopPropagation(),children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h3",{children:"归档 Topic"}),s.jsx("p",{children:"归档后保留历史消息,但工作空间不能再向此 Topic 发送新消息。"})]}),s.jsx("button",{"aria-label":"关闭归档确认",className:"icon-button",onClick:()=>q(!1),type:"button",children:"×"})]}),s.jsx("strong",{children:ee.title}),s.jsxs("footer",{children:[s.jsx("button",{className:"secondary",disabled:$,onClick:()=>q(!1),type:"button",children:"取消"}),s.jsx("button",{className:"danger",disabled:$,onClick:()=>void _e(),type:"button",children:$?"正在归档...":"归档"})]})]})}):null]})})}function LA({busy:e,conversation:i,conversationId:a,forceStopBusy:r,preview:u,previewLoading:c,result:d,status:p,warmup:g,workspaceGroups:m,onCancelResetPreview:b,onClose:x,onForceStop:S,onPreviewReset:w,onStartBlankContext:E,onResetRuntime:M,onSaveResetSelection:H,onWorkspaceChange:R,onWarmupChange:q}){const $=!i||e||p==="running"||p==="initializing";return s.jsx("div",{className:"context-panel-overlay settings-overlay",onClick:x,role:"presentation",children:s.jsxs("section",{"aria-label":"Seele console",className:"context-panel console-panel",onClick:V=>V.stopPropagation(),children:[s.jsxs("header",{className:"context-panel-header console-panel-header",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Console"}),s.jsx("p",{children:"Control actions for the selected workspace runtime."})]}),s.jsxs("div",{className:"console-header-actions",children:[s.jsxs("label",{className:"console-workspace-picker",children:[s.jsx("span",{children:"Workspace"}),s.jsx("select",{disabled:e,onChange:V=>R(V.target.value),value:a??"",children:m.map(V=>s.jsx("optgroup",{label:V.title,children:V.conversations.map(ie=>s.jsxs("option",{value:ie.id,children:[ie.title," · workspaces/",Ns(ie.id)]},ie.id))},V.id))})]}),s.jsx("button",{"aria-label":"Close console",onClick:x,type:"button",children:"×"})]})]}),s.jsx("div",{className:"console-body",children:s.jsxs("section",{className:"console-card",children:[s.jsxs("div",{className:"console-card-heading",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Workspace Runtime"}),s.jsx("p",{children:"Reset only replaces the Codex runtime thread. Seele workspace history, metadata, and files remain intact."})]}),s.jsx("span",{className:`console-status ${p}`,children:p})]}),s.jsxs("dl",{className:"console-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Workspace"}),s.jsx("dd",{children:(i==null?void 0:i.title)??"No workspace selected"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"ID"}),s.jsx("dd",{children:i?`workspaces/${Ns(i.id)}`:"-"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Thread"}),s.jsx("dd",{children:(i==null?void 0:i.codexThreadId)??"Not created"})]})]}),s.jsxs("label",{className:"console-toggle",children:[s.jsx("input",{checked:g,onChange:V=>q(V.target.checked),type:"checkbox"}),s.jsxs("span",{children:["Run a warmup turn after reset",s.jsx("small",{children:"The workspace will receive a system wakeup to re-orient itself after the thread is rebuilt."})]})]}),s.jsxs("div",{className:"console-actions",children:[s.jsx("button",{className:"danger",disabled:!i||r,onClick:S,title:"Kill the workspace runtime and repair every non-terminal scheduler state",type:"button",children:r?"Stopping & repairing...":"Force stop & repair"}),s.jsx("button",{className:"danger",disabled:$||c,onClick:w,type:"button",children:c?"Preparing preview...":"Preview runtime reset"}),s.jsx("button",{disabled:$||c,onClick:E,type:"button",children:"Clear memory & start blank"}),p==="running"||p==="initializing"?s.jsx("span",{children:"Force stop the active workspace operation before resetting."}):null]}),d?s.jsxs("div",{className:"console-result",children:[s.jsx("strong",{children:d.workspaceMemoryCleared?"Blank workspace context ready":"Runtime reset completed"}),s.jsxs("span",{children:[d.injectedItemCount," visible history items injected"]}),d.historyCompactionCount>0?s.jsxs("span",{children:["Full history processed in ",d.historyBatchCount," chronological batches with ",d.historyCompactionCount," native compactions"]}):null,d.workspaceMemoryCleared?s.jsx("span",{children:"Workspace Memory cleared; Base Memory retained"}):null,s.jsxs("span",{children:["New thread: ",d.newThreadId]}),d.warmupTurnId?s.jsxs("span",{children:["Warmup turn: ",d.warmupTurnId]}):null]}):null]})}),u?s.jsx(IA,{busy:e,preview:u,warmup:g,onCancel:b,onConfirm:M,onSaveSelection:H}):null]})})}function IA({busy:e,preview:i,warmup:a,onCancel:r,onConfirm:u,onSaveSelection:c}){const[d,p]=D.useState(()=>new Set(i.entries.filter(L=>L.includedByDefault).map(L=>L.id))),[g,m]=D.useState(!1),[b,x]=D.useState(!1),[S,w]=D.useState(null),E=D.useRef(null),M=i.entries.filter(L=>d.has(L.id)),H=M.filter(L=>L.role==="user").length,R=M.length-H,q=i.entries.filter(L=>L.topicRelation!==null).map(L=>L.id),$=q.filter(L=>d.has(L)).length,V=i.entries.length>0&&d.size===i.entries.length;D.useEffect(()=>{E.current&&(E.current.indeterminate=d.size>0&&d.size<i.entries.length)},[i.entries.length,d.size]);const ie=e||b;async function N(L){x(!0),w(null);try{await c(i.entries.filter(te=>L.has(te.id)).map(te=>te.id)),p(L)}catch(te){w(Ge(te).message)}finally{x(!1)}}function Q(L,te){const de=new Set(d);te?de.add(L):de.delete(L),N(de)}function re(){const L=new Set(d);q.forEach(te=>L.add(te)),N(L)}function ee(){const L=new Set(d);q.forEach(te=>{L.has(te)?L.delete(te):L.add(te)}),N(L)}return s.jsx("div",{className:`reset-preview-overlay ${g?"expanded":""}`,onClick:ie?void 0:r,role:"presentation",children:s.jsxs("section",{"aria-label":"Runtime reset preview","aria-modal":"true",className:`reset-preview-dialog ${g?"expanded":""}`,onClick:L=>L.stopPropagation(),role:"dialog",children:[s.jsxs("header",{className:"reset-preview-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Confirm runtime reset"}),s.jsx("p",{children:"The new thread will process the selected original messages in chronological batches. Each batch is compacted natively before the next batch is injected; the old thread context is never reused."})]}),s.jsxs("div",{className:"reset-preview-header-actions",children:[s.jsx("button",{"aria-label":g?"Restore reset preview size":"Expand reset preview",onClick:()=>m(L=>!L),title:g?"Restore size":"Expand",type:"button",children:g?"⊡":"⛶"}),s.jsx("button",{"aria-label":"Close reset preview",disabled:ie,onClick:r,type:"button",children:"×"})]})]}),s.jsxs("div",{className:"reset-preview-summary",children:[s.jsxs("label",{className:"reset-preview-select-all",children:[s.jsx("input",{checked:V,disabled:ie||i.entries.length===0,onChange:L=>void N(L.target.checked?new Set(i.entries.map(te=>te.id)):new Set),ref:E,type:"checkbox"}),s.jsxs("span",{children:[d.size," of ",i.entries.length," selected"]})]}),s.jsxs("span",{children:[H," user"]}),s.jsxs("span",{children:[R," assistant"]}),q.length>0?s.jsxs("div",{className:"reset-preview-topic-actions",children:[s.jsxs("span",{children:[$," of ",q.length," Topic input + response"]}),s.jsx("button",{disabled:ie||$===q.length,onClick:re,type:"button",children:"Select Topic turns"}),s.jsx("button",{disabled:ie,onClick:ee,type:"button",children:"Invert Topic turns"})]}):null,s.jsxs("span",{children:[i.historyBatchCount," planned batch",i.historyBatchCount===1?"":"es"]}),s.jsxs("span",{children:["~",i.estimatedTokenCount.toLocaleString()," source tokens"]}),s.jsx("span",{children:a?"Warmup enabled":"No warmup"}),b?s.jsx("span",{children:"Saving defaults..."}):null,S?s.jsx("span",{className:"reset-preview-selection-error",children:S}):null]}),s.jsx("div",{className:"reset-preview-list",children:i.entries.length>0?i.entries.map((L,te)=>s.jsxs("article",{className:`reset-preview-item ${L.role} ${d.has(L.id)?"":"excluded"}`,children:[s.jsxs("header",{children:[s.jsxs("label",{children:[s.jsx("input",{"aria-label":`Include ${L.role} message ${te+1}`,checked:d.has(L.id),disabled:ie,onChange:de=>Q(L.id,de.target.checked),type:"checkbox"}),s.jsx("span",{children:te+1})]}),s.jsx("strong",{children:L.role}),L.topicRelation?s.jsxs("span",{className:"reset-preview-topic-badge",children:["Topic ",L.topicRelation]}):null,s.jsx("time",{dateTime:L.createdAt,children:He(L.createdAt)})]}),s.jsx("pre",{children:L.content})]},L.id)):s.jsx("p",{className:"reset-preview-empty",children:"No visible history will be injected."})}),s.jsxs("footer",{className:"reset-preview-actions",children:[s.jsxs("small",{children:["Preview fingerprint: ",i.fingerprint.slice(0,12)]}),s.jsxs("div",{children:[s.jsx("button",{disabled:ie,onClick:r,type:"button",children:"Cancel"}),s.jsx("button",{className:"danger",disabled:ie,onClick:()=>u(i.entries.filter(L=>d.has(L.id)).map(L=>L.id)),type:"button",children:e?"Rebuilding and compacting...":"Confirm full-history reset"})]})]})]})})}function UA({currentReleasedAt:e,currentVersion:i,job:a,latest:r,latestChecking:u,starting:c,onClose:d,onRefresh:p,onStart:g}){const m=(a==null?void 0:a.currentVersion)??i,b=r!=null&&r.version&&sR(r.version,m)?rR(r.version):null;return D.useEffect(()=>{const x=S=>{S.key==="Escape"&&d()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[d]),s.jsx("div",{className:"codex-update-overlay",onClick:d,role:"presentation",children:s.jsxs("section",{"aria-label":"Codex CLI update",className:"codex-update-panel",onClick:x=>x.stopPropagation(),children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Codex CLI update"}),s.jsx("p",{children:"Managed by Seele in the instance runtime directory."})]}),s.jsx("button",{"aria-label":"Close Codex CLI update",onClick:d,type:"button",children:"×"})]}),s.jsxs("dl",{className:"codex-update-summary",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Status"}),s.jsx("dd",{className:a?`status-${a.status}`:void 0,children:(a==null?void 0:a.status)??"Not started"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Current"}),s.jsx("dd",{children:lh(m,(a==null?void 0:a.codexReleasedAt)??e)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Latest"}),s.jsxs("dd",{title:(r==null?void 0:r.error)??void 0,children:[u?"Checking...":r!=null&&r.version?lh(r.version,r.releasedAt):r!=null&&r.error?"Check failed":"Not checked",b?s.jsx("a",{className:"codex-release-notes-link",href:b,rel:"noreferrer",target:"_blank",children:"Release notes"}):null]})]}),a?s.jsxs("div",{children:[s.jsx("dt",{children:"Started"}),s.jsx("dd",{children:He(a.startedAt)})]}):null]}),r!=null&&r.error?s.jsxs("p",{className:"codex-latest-error",children:["Latest version check: ",r.error]}):null,s.jsx("div",{className:"codex-update-log",role:"log","aria-live":"polite",children:a!=null&&a.logs.length?a.logs.map((x,S)=>s.jsxs("div",{className:`log-${x.stream}`,children:[s.jsx("time",{children:lR(x.at)}),s.jsx("span",{children:x.text})]},`${x.at}-${S}`)):s.jsx("p",{children:"No update logs yet."})}),s.jsxs("footer",{children:[s.jsx("button",{className:"secondary",onClick:p,type:"button",children:"Refresh"}),s.jsx("button",{disabled:c||(a==null?void 0:a.status)==="running",onClick:g,type:"button",children:c?"Starting...":(a==null?void 0:a.status)==="running"?"Updating...":a?"Run again":"Start update"})]})]})})}function BA({currentUser:e,conversations:i,deploymentSettings:a,editingEnvironmentKey:r,environmentDraft:u,globalEnvironment:c,workspaceEnvironment:d,memorySettings:p,memorySettingsDraft:g,managedUsers:m,workspaceMemoryDraft:b,runtimeSettings:x,runtimeModels:S,runtimeCodexVersion:w,runtimeCodexReleasedAt:E,runtimeCodexUpdating:M,runtimeSettingsDraft:H,runtimeSettingsScope:R,settingsWorkspace:q,settingsWorkspaceId:$,systemDiagnostics:V,systemDiagnosticsLoading:ie,workspaceGroups:N,workspaceRuntimeSettings:Q,workspaceRuntimeSettingsDraft:re,onCancelEnvironmentEdit:ee,onClose:L,onCreateUser:te,onDeleteUser:de,onDeleteEnvironment:Ne,onDraftChange:ye,onEditEnvironment:ue,onSaveBaseMemoryItems:F,onSaveDeploymentSettings:oe,onSaveResponsibility:be,onSaveWorkspaceMemoryItems:_e,onRevealEnvironmentValue:O,onRuntimeDraftChange:A,onCodexAccountSwitched:z,onUpdateCodexCli:C,onRuntimeScopeChange:W,onSettingsWorkspaceChange:fe,onSubmitRuntimeSettings:X,onSubmitEnvironment:xe,onRefreshSystemDiagnostics:Me,onUpdateUser:Ve,onWorkspaceRuntimeDraftChange:Ct,onWorkspaceRuntimeReset:vt,revealedEnvironmentKeys:rn}){const[Ye,St]=D.useState("model"),[It,sn]=D.useState(!1),[Le,Ut]=D.useState(null),[mn,Xt]=D.useState(!1),[Ti,Qn]=D.useState((q==null?void 0:q.responsibility)??""),[La,_t]=D.useState(!1),Ia=D.useRef(null),ae=R==="workspace"?Object.values((Q==null?void 0:Q.sources)??{}).filter(ce=>ce==="workspace").length:0;return D.useEffect(()=>{R==="global"&&Xt(!1)},[R]),D.useEffect(()=>{Qn((q==null?void 0:q.responsibility)??"")},[q==null?void 0:q.id,q==null?void 0:q.responsibility]),D.useEffect(()=>{if(!mn)return;const ce=Ue=>{var Vt;const Qe=Ue.target;Qe instanceof Node&&((Vt=Ia.current)!=null&&Vt.contains(Qe))||Xt(!1)},Ee=Ue=>{Ue.key==="Escape"&&Xt(!1)};return document.addEventListener("pointerdown",ce,!0),document.addEventListener("keydown",Ee,!0),()=>{document.removeEventListener("pointerdown",ce,!0),document.removeEventListener("keydown",Ee,!0)}},[mn]),s.jsx("div",{className:"context-panel-overlay settings-overlay",onClick:L,role:"presentation",children:s.jsxs("section",{"aria-label":"Seele settings",className:"context-panel settings-panel",onClick:ce=>ce.stopPropagation(),children:[s.jsxs("header",{className:"context-panel-header settings-panel-header",children:[s.jsxs("div",{className:"settings-panel-title",children:[s.jsx("h2",{children:"Settings"}),Ye!=="system"&&Ye!=="users"&&Ye!=="accounts"&&Ye!=="deployment"?s.jsxs("div",{"aria-label":"Configuration scope",className:"settings-scope-segments",role:"radiogroup",children:[e.role==="admin"?s.jsx("button",{"aria-checked":R==="global",className:R==="global"?"active":void 0,onClick:()=>W("global"),role:"radio",type:"button",children:"Global"}):null,s.jsxs("div",{className:"settings-workspace-picker",ref:Ia,children:[s.jsx("button",{"aria-checked":R==="workspace","aria-expanded":R==="workspace"?mn:void 0,"aria-label":R==="workspace"?"Settings workspace target":void 0,className:R==="workspace"?"active settings-scope-workspace-trigger":void 0,disabled:i.length===0,onClick:()=>{if(R!=="workspace"){W("workspace");return}Xt(ce=>!ce)},role:"radio",type:"button",children:R==="workspace"?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Workspace: ",(q==null?void 0:q.title)??"Select workspace"]}),s.jsx("span",{"aria-hidden":"true",children:"⌄"})]}):"Workspace"}),R==="workspace"&&mn?s.jsx("div",{className:"settings-workspace-menu",role:"listbox",children:N.map(ce=>s.jsxs("div",{className:"settings-workspace-menu-group",children:[s.jsx("div",{className:"settings-workspace-menu-heading",children:ce.title}),ce.conversations.map(Ee=>s.jsxs("button",{"aria-selected":Ee.id===$,className:Ee.id===$?"selected":void 0,onClick:()=>{fe(Ee.id),Xt(!1)},role:"option",type:"button",children:[s.jsx("span",{children:Ee.title}),s.jsxs("small",{children:["workspaces/",Ee.id]})]},Ee.id))]},ce.id))}):null]})]}):null]}),s.jsx("div",{className:"settings-header-actions",children:s.jsx("button",{"aria-label":"Close settings panel",onClick:L,type:"button",children:"×"})})]}),s.jsxs("div",{className:"settings-body",children:[s.jsxs("nav",{className:"settings-nav","aria-label":"Settings sections",children:[s.jsxs("button",{className:Ye==="model"?"active":void 0,onClick:()=>St("model"),type:"button",children:[s.jsx("span",{children:"Runtime"}),s.jsx("small",{children:"Effective settings"})]}),s.jsxs("button",{className:Ye==="responsibility"?"active":void 0,onClick:()=>St("responsibility"),type:"button",children:[s.jsx("span",{children:"Responsibility"}),s.jsx("small",{children:"Workspace role"})]}),s.jsxs("button",{className:Ye==="memory"?"active":void 0,onClick:()=>St("memory"),type:"button",children:[s.jsx("span",{children:"Memory"}),s.jsx("small",{children:"Base + workspace context"})]}),s.jsxs("button",{className:Ye==="environment"?"active":void 0,onClick:()=>St("environment"),type:"button",children:[s.jsx("span",{children:"Environment"}),s.jsx("small",{children:"Base + workspace variables"})]}),e.role==="admin"?s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:Ye==="accounts"?"active":void 0,onClick:()=>St("accounts"),type:"button",children:[s.jsx("span",{children:"Codex Accounts"}),s.jsx("small",{children:"Cloud login + active account"})]}),s.jsxs("button",{className:Ye==="deployment"?"active":void 0,onClick:()=>St("deployment"),type:"button",children:[s.jsx("span",{children:"Deployment"}),s.jsx("small",{children:"Local integrations"})]}),s.jsxs("button",{onClick:()=>{window.location.assign(`${Eh()}admin/host`)},type:"button",children:[s.jsx("span",{children:"Work Operations"}),s.jsx("small",{children:"Versions, restart, logs"})]}),s.jsxs("button",{className:Ye==="system"?"active":void 0,onClick:()=>St("system"),type:"button",children:[s.jsx("span",{children:"System"}),s.jsx("small",{children:"Runtime + resources"})]}),s.jsxs("button",{className:Ye==="users"?"active":void 0,onClick:()=>St("users"),type:"button",children:[s.jsx("span",{children:"Users"}),s.jsx("small",{children:"Access + roles"})]})]}):null]}),s.jsxs("section",{className:"settings-content",children:[Ye!=="system"&&Ye!=="users"&&Ye!=="accounts"&&Ye!=="deployment"?s.jsxs("div",{className:`settings-scope-banner ${R==="workspace"?"workspace":"global"}`,children:[s.jsx("strong",{children:R==="workspace"?"Editing workspace custom settings":"Editing global settings"}),s.jsx("span",{children:R==="workspace"?`${(q==null?void 0:q.title)??"Selected workspace"} overrides global defaults.`:"These defaults apply to every workspace unless that workspace overrides them."})]}):null,Ye==="system"?s.jsx(qA,{conversations:i,diagnostics:V,loading:ie,onRefresh:Me}):Ye==="users"?s.jsx(WA,{currentUser:e,users:m,onCreate:te,onDelete:de,onUpdate:Ve}):Ye==="accounts"?s.jsx(PA,{onSwitched:z}):Ye==="deployment"?s.jsx(KA,{settings:a,onSave:oe}):Ye==="model"?s.jsx(XA,{draft:R==="workspace"?re:H,globalSettings:x,models:S,codexVersion:w,codexReleasedAt:E,codexUpdating:M,scope:R,workspaceOverrideCount:ae,settings:R==="workspace"?(Q==null?void 0:Q.effective)??re:x,workspaceSettings:Q,onDraftChange:R==="workspace"?Ct:A,onResetWorkspaceSetting:vt,onSubmit:X,onUpdateCodexCli:C}):Ye==="responsibility"?s.jsx(GA,{draft:Ti,saving:La,scope:R,workspace:q,onDraftChange:Qn,onSubmit:ce=>{ce.preventDefault(),ce.stopPropagation(),!(R!=="workspace"||!q)&&(_t(!0),be(q.id,Ti).then(Ee=>Qn(Ee)).finally(()=>_t(!1)))}}):Ye==="memory"?s.jsx(QA,{baseSettings:p,scope:R,workspaceSettings:b,workspaceName:q==null?void 0:q.title,onSaveBaseItems:F,onSaveWorkspaceItems:_e}):s.jsx(eN,{deleteConfirmKey:Le,editingEnvironmentKey:r,environmentDraft:u,globalEnvironment:c,scope:R,workspaceEnvironment:d,valueVisible:It,onCancelEnvironmentEdit:ee,onDeleteConfirmChange:Ut,onDeleteEnvironment:Ne,onDraftChange:ye,onEditEnvironment:ue,onRevealEnvironmentValue:O,onSubmitEnvironment:xe,onValueVisibleChange:sn,revealedEnvironmentKeys:rn})]})]})]})})}function qA({conversations:e,diagnostics:i,loading:a,onRefresh:r}){const u=(i==null?void 0:i.runtime.pool)??null,c=D.useMemo(()=>(i==null?void 0:i.systemLogs)??[],[i]),[d,p]=D.useState(!1),g=D.useMemo(()=>new Map(e.map(w=>[w.id,w.title])),[e]),m=D.useMemo(()=>i?JSON.stringify({generatedAt:i.generatedAt,app:i.app,systemLogs:c},null,2):"",[i,c]),b=async()=>{m&&(await navigator.clipboard.writeText(m),p(!0),window.setTimeout(()=>p(!1),1800))},x=()=>{if(!m||!i)return;const w=URL.createObjectURL(new Blob([m],{type:"application/json"})),E=document.createElement("a");E.href=w,E.download=`seele-system-log-${i.generatedAt.replaceAll(":","-").replaceAll(".","-")}.json`,E.click(),URL.revokeObjectURL(w)},S=()=>{if(!i||!c.length)return;const w=c[0],E=c.slice(0,5).map($=>`- ${su($.createdAt)} · ${$.level.toUpperCase()} · ${$.event} · ${$.summary}`).join(`
92
92
  `),M=JSON.stringify(w,null,2),H=["## Environment","",`- Seele: ${i.app.version}`,`- Runtime: ${i.app.runtime}`,`- Report generated: ${su(i.generatedAt)}`,"","## Latest incident","","```json",M.slice(0,2500),"```","","## Recent system log","",E,"","_Generated by Seele System Log. Attach the downloaded JSON report when more history is needed._"].join(`
93
- `),R=`[System Log] ${w.summary}`.slice(0,180),q=new URL("https://github.com/seele-labs/seele-work/issues/new");q.searchParams.set("title",R),q.searchParams.set("body",H),window.open(q.toString(),"_blank","noopener,noreferrer")};return s.jsxs("section",{className:"system-information-section",children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"System"}),s.jsx("p",{children:"Read-only runtime and resource information managed by Seele."})]}),s.jsx("button",{className:"system-information-refresh",disabled:a,onClick:r,type:"button",children:a?"Refreshing...":"Refresh"})]}),u?s.jsxs(s.Fragment,{children:[s.jsxs("dl",{className:"system-information-summary",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"LRU pool target"}),s.jsxs("dd",{children:[In(u.maxRetainedRuntimes)," runtimes"]}),s.jsx("small",{children:u.capacitySource==="system_memory"?"Idle runtimes are released by least recent use":"Fallback target because system memory was unavailable"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Retention policy"}),s.jsxs("dd",{children:["LRU · ",Op(u.maxIdleSeconds*1e3)," max idle"]}),s.jsx("small",{children:"Only idle runtimes are eligible for eviction"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Current pool"}),s.jsxs("dd",{children:[u.activeRuntimeCount," active · ",u.idleRuntimeCount," idle"]}),s.jsxs("small",{children:[u.retainedRuntimeCount," retained runtimes"]})]})]}),s.jsxs("section",{className:"system-runtime-list",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h4",{children:"Workspace runtimes"}),s.jsx("p",{children:"Active workspaces and idle runtimes currently retained for reuse."})]}),s.jsx("time",{dateTime:i==null?void 0:i.generatedAt,children:i?He(i.generatedAt):""})]}),u.workspaces.length>0?s.jsxs("div",{className:"system-runtime-table",children:[s.jsxs("div",{className:"system-runtime-table-header",children:[s.jsx("span",{children:"Workspace"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"Runtime"}),s.jsx("span",{children:"Age"})]}),u.workspaces.map(w=>s.jsxs("div",{className:"system-runtime-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:g.get(w.workspaceId)??w.workspaceId}),s.jsx("small",{children:w.workspaceId})]}),s.jsx("span",{className:`system-runtime-state ${w.turnId?"active":"idle"}`,children:w.lifecycle==="shutting_down"?"Shutting down":w.turnId?"Active":"Idle"}),s.jsxs("div",{children:[s.jsx("span",{children:w.turnId?w.state:"Retained"}),s.jsx("small",{children:w.pid===null?"PID unavailable":`PID ${w.pid}`})]}),s.jsx("span",{children:w.idleMs===null?Op(w.uptimeMs):`${Op(w.idleMs)} idle`})]},w.workspaceId))]}):s.jsx("div",{className:"system-runtime-empty",children:"No workspace runtimes are currently retained."})]}),s.jsxs("section",{className:"system-runtime-list system-log-list",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h4",{children:"System log"}),s.jsx("p",{children:"Recent persistent warnings and errors for external diagnostics."})]}),s.jsxs("div",{className:"system-log-actions",children:[s.jsx("button",{"aria-label":"Copy system log report",className:"icon-button",disabled:!c.length,onClick:()=>void b(),title:"Copy system log report",type:"button",children:s.jsx(Mh,{})}),s.jsx("button",{"aria-label":"Download system log report",className:"icon-button",disabled:!c.length,onClick:x,title:"Download system log report",type:"button",children:s.jsx(HA,{})}),s.jsx("button",{"aria-label":"Report system log issue",className:"icon-button",disabled:!c.length,onClick:S,title:"Report issue to seele-labs/seele-work",type:"button",children:s.jsx($A,{})}),d?s.jsx("small",{children:"Copied"}):null]})]}),c.length?s.jsx("div",{className:"system-log-entries",children:c.map(w=>s.jsxs("details",{className:`system-log-entry ${w.level}`,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"system-log-level",children:w.level}),s.jsxs("span",{children:[s.jsx("strong",{children:w.summary}),s.jsxs("small",{children:[w.component," · ",su(w.createdAt)]})]})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Event"}),s.jsx("dd",{children:w.event})]}),w.workspaceId?s.jsxs("div",{children:[s.jsx("dt",{children:"Workspace"}),s.jsxs("dd",{children:[g.get(w.workspaceId)??w.workspaceId," · ",w.workspaceId]})]}):null,w.turnId?s.jsxs("div",{children:[s.jsx("dt",{children:"Turn"}),s.jsx("dd",{children:w.turnId})]}):null,w.runtimeId?s.jsxs("div",{children:[s.jsx("dt",{children:"Runtime"}),s.jsx("dd",{children:w.runtimeId})]}):null]}),s.jsx("pre",{children:JSON.stringify(w.detail,null,2)})]},w.id))}):s.jsx("div",{className:"system-runtime-empty",children:"No warnings or errors have been recorded."})]})]}):s.jsx("div",{className:"system-runtime-empty",children:a?"Loading system information...":"System information is unavailable."})]})}function HA(){return s.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"})})}function $A(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 7v6m0 4h.01"})]})}function GA({draft:e,saving:i,scope:a,workspace:r,onDraftChange:u,onSubmit:c}){const d=a==="workspace";return s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Responsibility"}),s.jsx("p",{children:"Workspace-specific long-lived role. This is content context, so it is only editable in workspace scope."})]})}),d&&r?s.jsxs("form",{className:"settings-responsibility-form",onSubmit:c,children:[s.jsxs("label",{children:[s.jsx("span",{children:r.title}),s.jsx("textarea",{"aria-label":"Workspace responsibility",onChange:p=>u(p.target.value),placeholder:"Describe this workspace's durable role, scope, and long-term responsibilities.",rows:14,value:e})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{disabled:i,type:"submit",children:i?"Saving...":"Save responsibility"})})]}):s.jsx("section",{className:"settings-readonly-block",children:s.jsxs("div",{children:[s.jsx("strong",{children:"Workspace-only setting"}),s.jsx("span",{children:"Switch the header scope to Workspace and choose a workspace to edit its responsibility."})]})})]})}function VA({usage:e}){return s.jsx("div",{"aria-label":"Codex account usage",className:"codex-account-usage",children:[...e.windows].sort((i,a)=>i.windowDurationMins-a.windowDurationMins).map(i=>{const a=dd(i.usedPercent),r=Yv(i.windowDurationMins);return s.jsxs("div",{className:"codex-account-usage-window",children:[s.jsxs("div",{children:[s.jsxs("span",{children:[r," used"]}),s.jsx("strong",{children:jw(a)})]}),s.jsx("span",{"aria-hidden":"true",className:"codex-account-usage-track",children:s.jsx("span",{style:{width:`${a}%`}})}),s.jsxs("small",{children:["Resets ",Cw(i.resetsAt)]})]},`${i.windowDurationMins}:${i.resetsAt}`)})})}function FA(e){if(!e)return null;const i=e.toLowerCase();return i==="chatgpt"?"ChatGPT":i==="apikey"||i==="api_key"?"API key":e}function YA(e){return e?e.split(/[_-]/).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "):null}function PA({onSwitched:e}){var A;const[i,a]=D.useState(null),[r,u]=D.useState(!0),[c,d]=D.useState(!1),[p,g]=D.useState(!1),[m,b]=D.useState(""),[x,S]=D.useState(!1),[w,E]=D.useState(""),[M,H]=D.useState(null),[R,q]=D.useState(null),[$,V]=D.useState(""),[ie,N]=D.useState(null),[Q,re]=D.useState(null),[ee,L]=D.useState(!1);async function te(){var C;const z=await ab();a(z),((C=z.login)==null?void 0:C.status)==="pending"&&(H(z.login),S(!0))}async function de(z){d(!0),b("");try{a(await lb(z))}catch(C){b(Ge(C).message)}finally{d(!1)}}D.useEffect(()=>{let z=!1;return ab().then(C=>{var W;z||(a(C),((W=C.login)==null?void 0:W.status)==="pending"&&(H(C.login),S(!0)),C.accounts.length>0&&(d(!0),lb(!1).then(fe=>{z||a(fe)}).catch(fe=>{z||b(Ge(fe).message)}).finally(()=>{z||d(!1)})))}).catch(C=>{z||b(Ge(C).message)}).finally(()=>{z||u(!1)}),()=>{z=!0}},[]),D.useEffect(()=>{if(!M||M.status!=="pending")return;let z=!1;const C=window.setInterval(()=>{Y2(M.id).then(async W=>{z||(H(W),W.status!=="pending"&&(window.clearInterval(C),W.status==="succeeded"&&a(fe=>{if(!fe||!W.account)return fe;const X=fe.accounts.some(xe=>{var Me;return xe.id===((Me=W.account)==null?void 0:Me.id)})?fe.accounts.map(xe=>{var Me;return xe.id===((Me=W.account)==null?void 0:Me.id)?W.account:xe}):[...fe.accounts,W.account];return{...fe,accounts:X}})))}).catch(W=>{z||b(Ge(W).message)})},1e3);return()=>{z=!0,window.clearInterval(C)}},[M==null?void 0:M.id,M==null?void 0:M.status]);function Ne(){E(""),H(null),b(""),L(!1),S(!0)}async function ye(z){z.preventDefault(),g(!0),b("");try{H(await F2(w.trim()))}catch(C){b(Ge(C).message)}finally{g(!1)}}async function ue(){if(!M||M.status!=="pending"){S(!1);return}g(!0),b("");try{const z=await P2(M.id);H(z),S(!1)}catch(z){b(Ge(z).message)}finally{g(!1)}}function F(z){q(z),V(z.name),b("")}async function oe(z){if(z.preventDefault(),!R)return;const C=$.trim();if(!C||C===R.name){q(null);return}g(!0),b("");try{await W2(R.id,C),await te(),q(null)}catch(W){b(Ge(W).message)}finally{g(!1)}}async function be(){var z;if(ie){g(!0),b("");try{const C=await X2(ie.id);a(C),N(null),await e()}catch(C){const W=Ge(C);b((z=W.detail)!=null&&z.includes('"runtime_busy"')?"Codex runtime is busy. Stop all active work before switching accounts.":W.detail??W.message)}finally{g(!1)}}}async function _e(){if(Q){g(!0),b("");try{await K2(Q.id),await te(),re(null)}catch(z){b(Ge(z).detail??Ge(z).message)}finally{g(!1)}}}const O=(i==null?void 0:i.accounts)??[];return s.jsxs("section",{className:"settings-section codex-accounts-section",children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Codex Accounts"}),s.jsx("p",{children:"Manage the cloud-owned Codex logins. Every deployment uses the same globally active account; workspaces do not bind to accounts."})]}),s.jsxs("div",{className:"codex-account-toolbar",children:[s.jsx("button",{className:"codex-account-add",disabled:p||c||O.length===0,onClick:()=>void de(!0),type:"button",children:c?"Refreshing...":"Refresh details"}),s.jsx("button",{className:"codex-account-add",disabled:p||c||(M==null?void 0:M.status)==="pending",onClick:Ne,type:"button",children:"Add account"})]})]}),s.jsxs("div",{className:"codex-account-policy",children:[s.jsx("strong",{children:"Cloud-wide active account"}),s.jsx("span",{children:"Switching requires the cloud runtime to be idle. The cloud publishes the selected credential; members pause new work and apply it after any active turn finishes. There is no per-deployment selection."})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,r?s.jsx("p",{className:"settings-note",children:"Loading Codex accounts..."}):null,!r&&O.length===0?s.jsx("p",{className:"settings-note",children:"No persisted Codex account. Add one with the official device login flow."}):null,s.jsx("div",{className:"codex-account-list",children:O.map(z=>{var Ve,Ct;const C=(i==null?void 0:i.activeAccountId)===z.id,W=(Ve=i==null?void 0:i.accountDetails)==null?void 0:Ve[z.id],fe=((Ct=i==null?void 0:i.accountIssues)==null?void 0:Ct[z.id])??[],X=fe.length>0,xe=fe.some(vt=>["missing_credential","invalid_credential","credential_unreadable"].includes(vt.code)),Me=[z.email,FA(z.accountType),YA(z.planType)].filter(vt=>!!vt);return s.jsxs("article",{className:`codex-account-card${C?" active":""}${X?" issue":""}`,children:[s.jsxs("div",{className:"codex-account-main",children:[s.jsxs("div",{className:"codex-account-title",children:[s.jsx("strong",{children:z.name}),C?s.jsx("span",{className:"codex-account-active",children:"Active"}):null,X?s.jsx("span",{className:"codex-account-warning",children:"Needs attention"}):null]}),s.jsx("small",{children:Me.join(" · ")||`Added ${He(z.createdAt)}`}),X?s.jsx("div",{className:"codex-account-issues",role:"status",children:fe.map(vt=>s.jsx("span",{children:vt.message},vt.code))}):null,W!=null&&W.usage?s.jsx(VA,{usage:W.usage}):s.jsx("span",{className:"codex-account-usage-empty",children:c?"Reading account usage...":"Usage unavailable"}),W?s.jsx("small",{className:W.error?"codex-account-detail-error":"codex-account-refreshed",children:W.error?`Refresh issue: ${W.error}`:`Updated ${He(W.refreshedAt)}`}):null]}),s.jsxs("div",{className:"codex-account-actions",children:[s.jsx("button",{disabled:p||c||xe,onClick:()=>F(z),title:xe?"Sign in again or delete this account to replace its credential.":void 0,type:"button",children:X?"Repair & rename":"Rename"}),s.jsx("button",{disabled:p||c||C||X,onClick:()=>{b(""),N(z)},type:"button",children:C?"In use":X?"Unavailable":"Switch"}),s.jsx("button",{className:"danger",disabled:p||c||C,onClick:()=>{b(""),re(z)},type:"button",children:"Delete"})]})]},z.id)})}),R?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&q(null),role:"presentation",children:s.jsxs("form",{"aria-label":"Rename Codex account",className:"memory-editor-popover codex-account-login-dialog",onClick:z=>z.stopPropagation(),onSubmit:z=>void oe(z),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Rename Codex Account"}),s.jsx("button",{"aria-label":"Close account rename",className:"memory-icon-button",disabled:p,onClick:()=>q(null),type:"button",children:"×"})]}),s.jsx("p",{className:"settings-note",children:"This name is only a Seele label. It does not change the Codex login or credential."}),s.jsxs("label",{children:[s.jsx("span",{children:"Account name"}),s.jsx("input",{"aria-label":"Codex account name",autoFocus:!0,maxLength:80,onChange:z=>V(z.target.value),value:$})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>q(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p||!$.trim(),type:"submit",children:p?"Saving...":"Save"})]})]})}):null,x?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&!M&&S(!1),role:"presentation",children:M?s.jsxs("section",{"aria-label":"Complete Codex account login",className:"memory-delete-dialog codex-account-login-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:M.status==="succeeded"?"Account Added":"Complete Codex Login"}),s.jsx("button",{"aria-label":"Close account login",className:"memory-icon-button",disabled:p,onClick:()=>void ue(),type:"button",children:"×"})]}),M.status==="pending"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Open the official Codex device page and enter this one-time code."}),s.jsxs("div",{className:"codex-device-code",children:[s.jsx("strong",{children:M.userCode}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(M.userCode),L(!0),window.setTimeout(()=>L(!1),1500)},type:"button",children:ee?"Copied":"Copy code"})]}),s.jsx("a",{href:M.verificationUrl,rel:"noreferrer",target:"_blank",children:"Open Codex device login"}),s.jsx("small",{className:"codex-login-waiting",children:"Waiting for Codex to confirm the login..."})]}):M.status==="succeeded"?s.jsxs("p",{children:[s.jsx("strong",{children:((A=M.account)==null?void 0:A.name)??M.accountName})," is persisted on the cloud and ready to synchronize. It was not activated automatically."]}):s.jsx("p",{className:"memory-editor-error",children:M.error??"Codex login was cancelled."}),s.jsx("div",{className:"memory-delete-actions",children:s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>void ue(),type:"button",children:M.status==="pending"?"Cancel login":"Close"})})]}):s.jsxs("form",{"aria-label":"Add Codex account",className:"memory-editor-popover codex-account-login-dialog",onClick:z=>z.stopPropagation(),onSubmit:z=>void ye(z),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Add Codex Account"}),s.jsx("button",{"aria-label":"Close account login",className:"memory-icon-button",onClick:()=>S(!1),type:"button",children:"×"})]}),s.jsx("p",{className:"settings-note",children:"Seele creates the login profile on the cloud. Completing login shares it with every deployment but does not make it active."}),s.jsxs("label",{children:[s.jsx("span",{children:"Account name"}),s.jsx("input",{autoFocus:!0,maxLength:80,onChange:z=>E(z.target.value),placeholder:"For example: Codex backup",value:w})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:()=>S(!1),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p||!w.trim(),type:"submit",children:p?"Starting...":"Continue"})]})]})}):null,ie?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&N(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Switch Codex account",className:"memory-delete-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Switch Codex Account"}),s.jsx("button",{"aria-label":"Close account switch",className:"memory-icon-button",disabled:p,onClick:()=>N(null),type:"button",children:"×"})]}),s.jsxs("p",{children:["Switch cloud-wide execution to ",s.jsx("strong",{children:ie.name}),"? The cloud runtime must be idle. Member deployments finish active turns, pause new work, and then install this credential; workspace threads and memory stay unchanged."]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>N(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p,onClick:()=>void be(),type:"button",children:p?"Switching...":"Stop and switch"})]})]})}):null,Q?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&re(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Delete Codex account",className:"memory-delete-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Delete Codex Account"}),s.jsx("button",{"aria-label":"Close account deletion",className:"memory-icon-button",disabled:p,onClick:()=>re(null),type:"button",children:"×"})]}),s.jsxs("p",{children:["Delete ",s.jsx("strong",{children:Q.name})," and its persisted Codex credential from the cloud and every member mirror? This cannot be undone."]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>re(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button danger",disabled:p,onClick:()=>void _e(),type:"button",children:p?"Deleting...":"Delete"})]})]})}):null]})}function WA({currentUser:e,users:i,onCreate:a,onDelete:r,onUpdate:u}){const c={username:"",password:"",role:"user",active:!0},[d,p]=D.useState(null),[g,m]=D.useState(c),[b,x]=D.useState(!1),[S,w]=D.useState(null),[E,M]=D.useState("");function H(){m(c),M(""),p("new")}function R(V){m({username:V.username,password:"",role:V.role,active:V.active}),M(""),p(V)}function q(){b||(p(null),M(""))}async function $(V){if(V.preventDefault(),!!d){x(!0),M("");try{d==="new"?await a({username:g.username.trim(),password:g.password,role:g.role}):await u(d.id,{username:g.username.trim(),password:g.password||void 0,role:g.role,active:g.active}),p(null)}catch(ie){M(Ge(ie).message)}finally{x(!1)}}}return s.jsxs("section",{className:"settings-section user-management-section",children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Users"}),s.jsx("p",{children:"Manage sign-in access and Seele roles."})]})}),s.jsx("div",{className:"memory-items-editor-header actions-only",children:s.jsx("button",{"aria-label":"Add user",className:"memory-icon-button",onClick:H,title:"Add user",type:"button",children:"+"})}),s.jsxs("div",{className:"user-list",children:[i.map(V=>s.jsxs("div",{className:"user-list-item",children:[s.jsxs("div",{className:"user-list-main",children:[s.jsxs("div",{children:[s.jsx("strong",{children:V.username}),V.id===e.id?s.jsx("span",{className:"user-current-badge",children:"Current"}):null]}),s.jsxs("small",{children:["Created ",He(V.createdAt)]})]}),s.jsx("span",{className:`user-role-badge role-${V.role}`,children:V.role}),s.jsx("span",{className:`user-status ${V.active?"active":"disabled"}`,children:V.active?"Active":"Disabled"}),s.jsxs("div",{className:"user-row-actions",children:[s.jsx("button",{"aria-label":`Edit user ${V.username}`,className:"memory-icon-button",onClick:()=>R(V),title:"Edit",type:"button",children:s.jsx(cd,{})}),s.jsx("button",{"aria-label":`Delete user ${V.username}`,className:"memory-icon-button memory-item-delete",disabled:V.id===e.id,onClick:()=>{M(""),w(V)},title:"Delete",type:"button",children:"×"})]})]},V.id)),i.length===0?s.jsx("p",{className:"settings-note",children:"No users are configured."}):null]}),d?s.jsx("div",{className:"memory-editor-overlay",onClick:q,role:"presentation",children:s.jsxs("form",{"aria-label":d==="new"?"Add user":"Edit user",className:"memory-editor-popover user-editor-popover",onClick:V=>V.stopPropagation(),onSubmit:V=>void $(V),children:[s.jsxs("header",{children:[s.jsx("strong",{children:d==="new"?"Add User":"Edit User"}),s.jsx("button",{"aria-label":"Close user editor",className:"memory-icon-button",onClick:q,title:"Close",type:"button",children:"×"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Username"}),s.jsx("input",{autoComplete:"off",autoFocus:!0,onChange:V=>m(ie=>({...ie,username:V.target.value})),placeholder:"Sign-in username",value:g.username})]}),s.jsxs("label",{children:[s.jsx("span",{children:d==="new"?"Initial password":"New password"}),s.jsx("input",{autoComplete:"new-password",minLength:8,onChange:V=>m(ie=>({...ie,password:V.target.value})),placeholder:d==="new"?"At least 8 characters":"Leave blank to keep the current password",type:"password",value:g.password})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Role"}),s.jsxs("select",{disabled:d!=="new"&&d.id===e.id,onChange:V=>m(ie=>({...ie,role:V.target.value==="admin"?"admin":"user"})),value:g.role,children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]}),d!=="new"?s.jsxs("label",{className:"user-editor-active",children:[s.jsx("input",{checked:g.active,disabled:d.id===e.id,onChange:V=>m(ie=>({...ie,active:V.target.checked})),type:"checkbox"}),s.jsx("span",{children:"Account active"})]}):null,E?s.jsx("p",{className:"memory-editor-error",children:E}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:q,type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:b||!g.username.trim()||d==="new"&&g.password.length<8||d!=="new"&&g.password.length>0&&g.password.length<8,type:"submit",children:b?"Saving...":"Save"})]})]})}):null,S?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>w(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Delete user",className:"memory-delete-dialog",onClick:V=>V.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Delete User"}),s.jsx("button",{"aria-label":"Close delete user confirmation",className:"memory-icon-button",onClick:()=>w(null),title:"Close",type:"button",children:"×"})]}),s.jsxs("p",{children:["Delete ",s.jsx("strong",{children:S.username}),". Users that own workspaces must be disabled instead."]}),E?s.jsx("p",{className:"memory-editor-error",children:E}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:()=>w(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button danger",onClick:()=>{r(S.id).then(()=>w(null)).catch(V=>M(Ge(V).message))},type:"button",children:"Delete"})]})]})}):null]})}function KA({settings:e,onSave:i}){const[a,r]=D.useState(e),[u,c]=D.useState(!1);return D.useEffect(()=>r(e),[e]),s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Deployment"}),s.jsx("p",{children:"Settings stored only on this Seele instance. Cloud synchronization does not copy or overwrite them."})]})}),s.jsxs("form",{className:"settings-form",onSubmit:d=>{d.preventDefault(),c(!0),i(a).finally(()=>c(!1))},children:[s.jsxs("label",{className:"settings-field",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Public URL"}),s.jsx("small",{children:"The externally reachable main URL of this deployment. Seele uses it when publishing callback links to external systems."})]}),s.jsx("input",{"aria-label":"Public URL of this deployment",onChange:d=>r({...a,publicUrl:d.target.value||null}),placeholder:"https://profuse.antgroup-inc.cn/codex/yishao-0/",type:"url",value:a.publicUrl||""})]}),s.jsxs("label",{className:"settings-toggle-field",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Profuse notification"}),s.jsx("small",{children:"Send DingTalk notifications from this deployment when a turn finishes or fails. Keep this off where the Profuse endpoint is unreachable."})]}),s.jsx("input",{"aria-label":"Enable Profuse notification on this deployment",checked:a.profuseNotificationEnabled,onChange:d=>r({...a,profuseNotificationEnabled:d.target.checked}),type:"checkbox"})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{disabled:u,type:"submit",children:u?"Saving...":"Save deployment settings"})})]})]})}function XA({codexReleasedAt:e,codexVersion:i,codexUpdating:a,draft:r,globalSettings:u,models:c,scope:d,settings:p,workspaceOverrideCount:g,workspaceSettings:m,onDraftChange:b,onResetWorkspaceSetting:x,onSubmit:S,onUpdateCodexCli:w}){var V;const E=d==="workspace",M=Jo(r.model,c),H=Jo(u.model,c),R=Jo(p.model,c),q=Cx(r.reasoningEffort,M),$=HE(M,r.reasoningEffort);return D.useEffect(()=>{M&&q!==r.reasoningEffort&&b({...r,reasoningEffort:q})},[r,M,q,b]),s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Runtime"}),s.jsx("p",{children:"Configure global defaults or override them for the selected workspace. Running turns keep the settings they started with."})]}),E?s.jsx("span",{className:g>0?"section-override-count active":"section-override-count",children:g>0?`${g} custom`:"No custom runtime"}):null]}),s.jsxs("form",{className:"settings-form runtime-form",onSubmit:S,children:[s.jsxs("label",{className:Bc(E,Tl(r.model,u.model,m==null?void 0:m.sources.model)),children:[s.jsx(Uc,{globalValue:pb(u.model,c),isWorkspaceScope:E,label:"Model",settingKey:"model",source:Tl(r.model,u.model,m==null?void 0:m.sources.model),onReset:x}),s.jsx(jp,{"aria-label":"Runtime model",onChange:ie=>{const N=Jo(ie,c);b({...r,model:ie,reasoningEffort:Cx(r.reasoningEffort,N)})},options:oR(c,r.model),value:r.model||((V=c.find(ie=>ie.isDefault))==null?void 0:V.model)||""})]}),s.jsxs("label",{className:Bc(E,Tl(r.reasoningEffort,u.reasoningEffort,m==null?void 0:m.sources.reasoningEffort)),children:[s.jsx(Uc,{globalValue:jx(u.reasoningEffort,H),isWorkspaceScope:E,label:"Reasoning effort",settingKey:"reasoningEffort",source:Tl(r.reasoningEffort,u.reasoningEffort,m==null?void 0:m.sources.reasoningEffort),onReset:x}),s.jsx(jp,{"aria-label":"Runtime reasoning effort",onChange:ie=>b({...r,reasoningEffort:ie}),options:$,value:q})]}),s.jsxs("label",{className:Bc(E,Tl(r.sandbox,u.sandbox,m==null?void 0:m.sources.sandbox)),children:[s.jsx(Uc,{globalValue:gb(u.sandbox),isWorkspaceScope:E,label:"Permission mode",settingKey:"sandbox",source:Tl(r.sandbox,u.sandbox,m==null?void 0:m.sources.sandbox),onReset:x}),s.jsx(jp,{"aria-label":"Permission mode",onChange:ie=>b({...r,sandbox:ie}),options:pA,value:r.sandbox})]}),s.jsxs("label",{className:Bc(E,Tl(r.fastMode,u.fastMode,m==null?void 0:m.sources.fastMode),"settings-toggle-field"),children:[s.jsxs("span",{children:[s.jsx(Uc,{globalValue:u.fastMode?"On":"Off",isWorkspaceScope:E,label:"Fast mode",settingKey:"fastMode",source:Tl(r.fastMode,u.fastMode,m==null?void 0:m.sources.fastMode),onReset:x}),s.jsx("small",{children:"1.5x speed with higher Codex credit consumption"})]}),s.jsx("input",{"aria-label":"Enable Fast mode",checked:r.fastMode,onChange:ie=>b({...r,fastMode:ie.target.checked}),type:"checkbox"})]}),s.jsxs("dl",{className:"runtime-summary",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Current"}),s.jsxs("dd",{children:["Model ",pb(p.model,c),", reasoning"," ",jx(p.reasoningEffort,R),", Fast mode"," ",p.fastMode?"on":"off",", permission"," ",gb(p.sandbox),"."]})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Codex CLI"}),s.jsxs("dd",{className:"runtime-version-value",children:[s.jsx("span",{children:lh(i,e)}),s.jsx("button",{className:"runtime-update-button",disabled:a,onClick:w,type:"button",children:a?"Updating...":"Check update"})]})]})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{type:"submit",children:E?"Save workspace overrides":"Save global runtime"})})]})]})}function Uc({globalValue:e,isWorkspaceScope:i,label:a,settingKey:r,source:u,onReset:c}){const d=i&&u==="workspace";return s.jsxs("span",{className:"runtime-field-label",children:[s.jsx("span",{children:a}),i?s.jsxs("span",{className:"runtime-field-meta",children:[s.jsx("span",{className:d?"override":"inherited",children:d?"Workspace override":`Inherited: ${e}`}),d?s.jsx("button",{type:"button",onClick:()=>c(r),children:"Reset"}):null]}):null]})}function jp({"aria-label":e,onChange:i,options:a,value:r}){const[u,c]=D.useState(!1),d=D.useRef(null),p=a.find(g=>g.value===r)??a[0]??null;return D.useEffect(()=>{if(!u)return;function g(b){var x;(x=d.current)!=null&&x.contains(b.target)||c(!1)}function m(b){b.key==="Escape"&&c(!1)}return document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",m,!0),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",m,!0)}},[u]),s.jsxs("div",{className:"runtime-select",ref:d,children:[s.jsxs("button",{"aria-expanded":u,"aria-label":e,className:"runtime-select-trigger",onClick:()=>c(g=>!g),type:"button",children:[s.jsx("span",{children:(p==null?void 0:p.label)??r}),s.jsx("span",{"aria-hidden":"true",children:"⌄"})]}),u?s.jsx("div",{className:"runtime-select-menu",role:"listbox",children:a.map(g=>s.jsx("button",{"aria-selected":g.value===r,className:g.value===r?"selected":void 0,onClick:()=>{i(g.value),c(!1)},role:"option",type:"button",children:g.label},g.value||"default"))}):null]})}function Tl(e,i,a){return e!==i?"workspace":a}function Bc(e,i,a="settings-wide-field"){return[a,e?"workspace-scoped":"",e&&i==="workspace"?"workspace-overridden":""].filter(Boolean).join(" ")}function QA({baseSettings:e,scope:i,workspaceSettings:a,workspaceName:r,onSaveBaseItems:u,onSaveWorkspaceItems:c}){const d=i==="workspace",p=d?a.items:e.items,g=d?c:u;return s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:d?"Workspace Memory":"Base Memory"}),s.jsx("p",{children:d?"Workspace memory applies only to the selected workspace. Use stable English keys; values may be Chinese, plain text, or Markdown.":"Base memory applies to every workspace. Use stable English keys; values may be Chinese, plain text, or Markdown."})]})}),d?s.jsxs("section",{className:"settings-readonly-block",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Base Memory"}),s.jsx("span",{children:"Read-only in workspace scope"})]}),s.jsx(JA,{emptyText:"No base memory is configured.",items:e.items,readonly:!0})]}):null,s.jsx("div",{className:"memory-manager-shell",children:s.jsx(ZA,{ariaLabel:d?"Workspace memory":"Base memory",emptyText:"No memory items are configured.",items:p,onSaveItems:g,title:""})})]})}function ZA({ariaLabel:e,emptyText:i,items:a,onSaveItems:r,title:u}){var Q;const[c,d]=D.useState(ru(a)),[p,g]=D.useState(null),[m,b]=D.useState({key:"",value:""}),[x,S]=D.useState(null),[w,E]=D.useState(null),[M,H]=D.useState(null);D.useEffect(()=>{d(ru(a))},[a]),D.useEffect(()=>{if(p===null)return;const re=ee=>{ee.key==="Escape"&&(V(),E(null))};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[p]);async function R(re,ee){H(ee);try{const L=await r(re);return d(ru(L)),L}finally{H(null)}}function q(){E(null),S(null),b({key:"",value:""}),g("new")}function $(re){const ee=c[re];ee&&(E(null),S(null),b({...ee}),g(re))}function V(){g(null),S(null),b({key:"",value:""})}async function ie(re){const ee=c[re],L=(ee==null?void 0:ee.key)||`${re}`;await R(c.filter((te,de)=>de!==re),`delete:${L}`),E(null)}async function N(re){re.preventDefault(),re.stopPropagation();const ee=m.key.trim(),L=hD(ee);if(L){S(L);return}const te=m.value.trim();if(!te){S("Value is required.");return}const de=p==="new"?-1:p;if(c.some((ye,ue)=>ue!==de&&ye.key.trim()===ee)){S(`Key "${ee}" already exists. Each memory key must be unique.`);return}const Ne={...m,key:ee,value:te};p==="new"?await R([...c,Ne],"add"):typeof p=="number"&&await R(c.map((ye,ue)=>ue===p?Ne:ye),`save:${p}`),V()}return s.jsxs("section",{className:"memory-items-manager","aria-label":e,children:[s.jsxs("div",{className:u?"memory-items-editor-header":"memory-items-editor-header actions-only",children:[u?s.jsx("span",{children:u}):null,s.jsx("button",{"aria-label":"Add memory item",className:"memory-icon-button",title:"Add",type:"button",onClick:q,children:"+"})]}),c.length?s.jsx("div",{className:"memory-items-grid",children:c.map((re,ee)=>s.jsxs("div",{className:"memory-item-display",children:[s.jsxs("pre",{"aria-label":`Memory item ${re.key}`,children:[s.jsx("span",{className:"memory-tag",children:`<${re.key}>`}),`
93
+ `),R=`[System Log] ${w.summary}`.slice(0,180),q=new URL("https://github.com/seele-labs/seele-work/issues/new");q.searchParams.set("title",R),q.searchParams.set("body",H),window.open(q.toString(),"_blank","noopener,noreferrer")};return s.jsxs("section",{className:"system-information-section",children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"System"}),s.jsx("p",{children:"Read-only runtime and resource information managed by Seele."})]}),s.jsx("button",{className:"system-information-refresh",disabled:a,onClick:r,type:"button",children:a?"Refreshing...":"Refresh"})]}),u?s.jsxs(s.Fragment,{children:[s.jsxs("dl",{className:"system-information-summary",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"LRU pool target"}),s.jsxs("dd",{children:[In(u.maxRetainedRuntimes)," runtimes"]}),s.jsx("small",{children:u.capacitySource==="system_memory"?"Idle runtimes are released by least recent use":"Fallback target because system memory was unavailable"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Retention policy"}),s.jsxs("dd",{children:["LRU · ",Op(u.maxIdleSeconds*1e3)," max idle"]}),s.jsx("small",{children:"Only idle runtimes are eligible for eviction"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Current pool"}),s.jsxs("dd",{children:[u.activeRuntimeCount," active · ",u.idleRuntimeCount," idle"]}),s.jsxs("small",{children:[u.retainedRuntimeCount," retained runtimes"]})]})]}),s.jsxs("section",{className:"system-runtime-list",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h4",{children:"Workspace runtimes"}),s.jsx("p",{children:"Active workspaces and idle runtimes currently retained for reuse."})]}),s.jsx("time",{dateTime:i==null?void 0:i.generatedAt,children:i?He(i.generatedAt):""})]}),u.workspaces.length>0?s.jsxs("div",{className:"system-runtime-table",children:[s.jsxs("div",{className:"system-runtime-table-header",children:[s.jsx("span",{children:"Workspace"}),s.jsx("span",{children:"Status"}),s.jsx("span",{children:"Runtime"}),s.jsx("span",{children:"Age"})]}),u.workspaces.map(w=>s.jsxs("div",{className:"system-runtime-row",children:[s.jsxs("div",{children:[s.jsx("strong",{children:g.get(w.workspaceId)??w.workspaceId}),s.jsx("small",{children:w.workspaceId})]}),s.jsx("span",{className:`system-runtime-state ${w.turnId?"active":"idle"}`,children:w.lifecycle==="shutting_down"?"Shutting down":w.turnId?"Active":"Idle"}),s.jsxs("div",{children:[s.jsx("span",{children:w.turnId?w.state:"Retained"}),s.jsx("small",{children:w.pid===null?"PID unavailable":`PID ${w.pid}`})]}),s.jsx("span",{children:w.idleMs===null?Op(w.uptimeMs):`${Op(w.idleMs)} idle`})]},w.workspaceId))]}):s.jsx("div",{className:"system-runtime-empty",children:"No workspace runtimes are currently retained."})]}),s.jsxs("section",{className:"system-runtime-list system-log-list",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("h4",{children:"System log"}),s.jsx("p",{children:"Recent persistent warnings and errors for external diagnostics."})]}),s.jsxs("div",{className:"system-log-actions",children:[s.jsx("button",{"aria-label":"Copy system log report",className:"icon-button",disabled:!c.length,onClick:()=>void b(),title:"Copy system log report",type:"button",children:s.jsx(Mh,{})}),s.jsx("button",{"aria-label":"Download system log report",className:"icon-button",disabled:!c.length,onClick:x,title:"Download system log report",type:"button",children:s.jsx(HA,{})}),s.jsx("button",{"aria-label":"Report system log issue",className:"icon-button",disabled:!c.length,onClick:S,title:"Report issue to seele-labs/seele-work",type:"button",children:s.jsx($A,{})}),d?s.jsx("small",{children:"Copied"}):null]})]}),c.length?s.jsx("div",{className:"system-log-entries",children:c.map(w=>s.jsxs("details",{className:`system-log-entry ${w.level}`,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"system-log-level",children:w.level}),s.jsxs("span",{children:[s.jsx("strong",{children:w.summary}),s.jsxs("small",{children:[w.component," · ",su(w.createdAt)]})]})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Event"}),s.jsx("dd",{children:w.event})]}),w.workspaceId?s.jsxs("div",{children:[s.jsx("dt",{children:"Workspace"}),s.jsxs("dd",{children:[g.get(w.workspaceId)??w.workspaceId," · ",w.workspaceId]})]}):null,w.turnId?s.jsxs("div",{children:[s.jsx("dt",{children:"Turn"}),s.jsx("dd",{children:w.turnId})]}):null,w.runtimeId?s.jsxs("div",{children:[s.jsx("dt",{children:"Runtime"}),s.jsx("dd",{children:w.runtimeId})]}):null]}),s.jsx("pre",{children:JSON.stringify(w.detail,null,2)})]},w.id))}):s.jsx("div",{className:"system-runtime-empty",children:"No warnings or errors have been recorded."})]})]}):s.jsx("div",{className:"system-runtime-empty",children:a?"Loading system information...":"System information is unavailable."})]})}function HA(){return s.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M12 3v12m0 0 4-4m-4 4-4-4M5 20h14"})})}function $A(){return s.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"12",r:"9"}),s.jsx("path",{d:"M12 7v6m0 4h.01"})]})}function GA({draft:e,saving:i,scope:a,workspace:r,onDraftChange:u,onSubmit:c}){const d=a==="workspace";return s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Responsibility"}),s.jsx("p",{children:"Workspace-specific long-lived role. This is content context, so it is only editable in workspace scope."})]})}),d&&r?s.jsxs("form",{className:"settings-responsibility-form",onSubmit:c,children:[s.jsxs("label",{children:[s.jsx("span",{children:r.title}),s.jsx("textarea",{"aria-label":"Workspace responsibility",onChange:p=>u(p.target.value),placeholder:"Describe this workspace's durable role, scope, and long-term responsibilities.",rows:14,value:e})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{disabled:i,type:"submit",children:i?"Saving...":"Save responsibility"})})]}):s.jsx("section",{className:"settings-readonly-block",children:s.jsxs("div",{children:[s.jsx("strong",{children:"Workspace-only setting"}),s.jsx("span",{children:"Switch the header scope to Workspace and choose a workspace to edit its responsibility."})]})})]})}function VA({usage:e}){return s.jsx("div",{"aria-label":"Codex account usage",className:"codex-account-usage",children:[...e.windows].sort((i,a)=>i.windowDurationMins-a.windowDurationMins).map(i=>{const a=dd(i.usedPercent),r=Yv(i.windowDurationMins);return s.jsxs("div",{className:"codex-account-usage-window",children:[s.jsxs("div",{children:[s.jsxs("span",{children:[r," used"]}),s.jsx("strong",{children:jw(a)})]}),s.jsx("span",{"aria-hidden":"true",className:"codex-account-usage-track",children:s.jsx("span",{style:{width:`${a}%`}})}),s.jsxs("small",{children:["Resets ",Cw(i.resetsAt)]})]},`${i.windowDurationMins}:${i.resetsAt}`)})})}function FA(e){if(!e)return null;const i=e.toLowerCase();return i==="chatgpt"?"ChatGPT":i==="apikey"||i==="api_key"?"API key":e}function YA(e){return e?e.split(/[_-]/).filter(Boolean).map(i=>i.charAt(0).toUpperCase()+i.slice(1)).join(" "):null}function PA({onSwitched:e}){var A;const[i,a]=D.useState(null),[r,u]=D.useState(!0),[c,d]=D.useState(!1),[p,g]=D.useState(!1),[m,b]=D.useState(""),[x,S]=D.useState(!1),[w,E]=D.useState(""),[M,H]=D.useState(null),[R,q]=D.useState(null),[$,V]=D.useState(""),[ie,N]=D.useState(null),[Q,re]=D.useState(null),[ee,L]=D.useState(!1);async function te(){var C;const z=await ab();a(z),((C=z.login)==null?void 0:C.status)==="pending"&&(H(z.login),S(!0))}async function de(z){d(!0),b("");try{a(await lb(z))}catch(C){b(Ge(C).message)}finally{d(!1)}}D.useEffect(()=>{let z=!1;return ab().then(C=>{var W;z||(a(C),((W=C.login)==null?void 0:W.status)==="pending"&&(H(C.login),S(!0)),C.accounts.length>0&&(d(!0),lb(!1).then(fe=>{z||a(fe)}).catch(fe=>{z||b(Ge(fe).message)}).finally(()=>{z||d(!1)})))}).catch(C=>{z||b(Ge(C).message)}).finally(()=>{z||u(!1)}),()=>{z=!0}},[]),D.useEffect(()=>{if(!M||M.status!=="pending")return;let z=!1;const C=window.setInterval(()=>{Y2(M.id).then(async W=>{z||(H(W),W.status!=="pending"&&(window.clearInterval(C),W.status==="succeeded"&&a(fe=>{if(!fe||!W.account)return fe;const X=fe.accounts.some(xe=>{var Me;return xe.id===((Me=W.account)==null?void 0:Me.id)})?fe.accounts.map(xe=>{var Me;return xe.id===((Me=W.account)==null?void 0:Me.id)?W.account:xe}):[...fe.accounts,W.account];return{...fe,accounts:X}})))}).catch(W=>{z||b(Ge(W).message)})},1e3);return()=>{z=!0,window.clearInterval(C)}},[M==null?void 0:M.id,M==null?void 0:M.status]);function Ne(){E(""),H(null),b(""),L(!1),S(!0)}async function ye(z){z.preventDefault(),g(!0),b("");try{H(await F2(w.trim()))}catch(C){b(Ge(C).message)}finally{g(!1)}}async function ue(){if(!M||M.status!=="pending"){S(!1);return}g(!0),b("");try{const z=await P2(M.id);H(z),S(!1)}catch(z){b(Ge(z).message)}finally{g(!1)}}function F(z){q(z),V(z.name),b("")}async function oe(z){if(z.preventDefault(),!R)return;const C=$.trim();if(!C||C===R.name){q(null);return}g(!0),b("");try{await W2(R.id,C),await te(),q(null)}catch(W){b(Ge(W).message)}finally{g(!1)}}async function be(){var z;if(ie){g(!0),b("");try{const C=await X2(ie.id);a(C),N(null),await e()}catch(C){const W=Ge(C);b((z=W.detail)!=null&&z.includes('"runtime_busy"')?"Codex runtime is busy. Stop all active work before switching accounts.":W.detail??W.message)}finally{g(!1)}}}async function _e(){if(Q){g(!0),b("");try{await K2(Q.id),await te(),re(null)}catch(z){b(Ge(z).detail??Ge(z).message)}finally{g(!1)}}}const O=(i==null?void 0:i.accounts)??[];return s.jsxs("section",{className:"settings-section codex-accounts-section",children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Codex Accounts"}),s.jsx("p",{children:"Manage the cloud-owned Codex logins. Every deployment uses the same globally active account; workspaces do not bind to accounts."})]}),s.jsxs("div",{className:"codex-account-toolbar",children:[s.jsx("button",{className:"codex-account-add",disabled:p||c||O.length===0,onClick:()=>void de(!0),type:"button",children:c?"Refreshing...":"Refresh details"}),s.jsx("button",{className:"codex-account-add",disabled:p||c||(M==null?void 0:M.status)==="pending",onClick:Ne,type:"button",children:"Add account"})]})]}),s.jsxs("div",{className:"codex-account-policy",children:[s.jsx("strong",{children:"Cloud-wide active account"}),s.jsx("span",{children:"Switching requires the cloud runtime to be idle. The cloud publishes the selected credential; members pause new work and apply it after any active turn finishes. There is no per-deployment selection."})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,r?s.jsx("p",{className:"settings-note",children:"Loading Codex accounts..."}):null,!r&&O.length===0?s.jsx("p",{className:"settings-note",children:"No persisted Codex account. Add one with the official device login flow."}):null,s.jsx("div",{className:"codex-account-list",children:O.map(z=>{var Ve,Ct;const C=(i==null?void 0:i.activeAccountId)===z.id,W=(Ve=i==null?void 0:i.accountDetails)==null?void 0:Ve[z.id],fe=((Ct=i==null?void 0:i.accountIssues)==null?void 0:Ct[z.id])??[],X=fe.length>0,xe=fe.some(vt=>["missing_credential","invalid_credential","credential_unreadable"].includes(vt.code)),Me=[z.email,FA(z.accountType),YA(z.planType)].filter(vt=>!!vt);return s.jsxs("article",{className:`codex-account-card${C?" active":""}${X?" issue":""}`,children:[s.jsxs("div",{className:"codex-account-main",children:[s.jsxs("div",{className:"codex-account-title",children:[s.jsx("strong",{children:z.name}),C?s.jsx("span",{className:"codex-account-active",children:"Active"}):null,X?s.jsx("span",{className:"codex-account-warning",children:"Needs attention"}):null]}),s.jsx("small",{children:Me.join(" · ")||`Added ${He(z.createdAt)}`}),X?s.jsx("div",{className:"codex-account-issues",role:"status",children:fe.map(vt=>s.jsx("span",{children:vt.message},vt.code))}):null,W!=null&&W.usage?s.jsx(VA,{usage:W.usage}):s.jsx("span",{className:"codex-account-usage-empty",children:c?"Reading account usage...":"Usage unavailable"}),W?s.jsx("small",{className:W.error?"codex-account-detail-error":"codex-account-refreshed",children:W.error?`Refresh issue: ${W.error}`:`Updated ${He(W.refreshedAt)}`}):null]}),s.jsxs("div",{className:"codex-account-actions",children:[s.jsx("button",{disabled:p||c||xe,onClick:()=>F(z),title:xe?"Sign in again or delete this account to replace its credential.":void 0,type:"button",children:X?"Repair & rename":"Rename"}),s.jsx("button",{disabled:p||c||C||X,onClick:()=>{b(""),N(z)},type:"button",children:C?"In use":X?"Unavailable":"Switch"}),s.jsx("button",{className:"danger",disabled:p||c||C,onClick:()=>{b(""),re(z)},type:"button",children:"Delete"})]})]},z.id)})}),R?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&q(null),role:"presentation",children:s.jsxs("form",{"aria-label":"Rename Codex account",className:"memory-editor-popover codex-account-login-dialog",onClick:z=>z.stopPropagation(),onSubmit:z=>void oe(z),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Rename Codex Account"}),s.jsx("button",{"aria-label":"Close account rename",className:"memory-icon-button",disabled:p,onClick:()=>q(null),type:"button",children:"×"})]}),s.jsx("p",{className:"settings-note",children:"This name is only a Seele label. It does not change the Codex login or credential."}),s.jsxs("label",{children:[s.jsx("span",{children:"Account name"}),s.jsx("input",{"aria-label":"Codex account name",autoFocus:!0,maxLength:80,onChange:z=>V(z.target.value),value:$})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>q(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p||!$.trim(),type:"submit",children:p?"Saving...":"Save"})]})]})}):null,x?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&!M&&S(!1),role:"presentation",children:M?s.jsxs("section",{"aria-label":"Complete Codex account login",className:"memory-delete-dialog codex-account-login-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:M.status==="succeeded"?"Account Added":"Complete Codex Login"}),s.jsx("button",{"aria-label":"Close account login",className:"memory-icon-button",disabled:p,onClick:()=>void ue(),type:"button",children:"×"})]}),M.status==="pending"?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:"Open the official Codex device page and enter this one-time code."}),s.jsxs("div",{className:"codex-device-code",children:[s.jsx("strong",{children:M.userCode}),s.jsx("button",{onClick:()=>{navigator.clipboard.writeText(M.userCode),L(!0),window.setTimeout(()=>L(!1),1500)},type:"button",children:ee?"Copied":"Copy code"})]}),s.jsx("a",{href:M.verificationUrl,rel:"noreferrer",target:"_blank",children:"Open Codex device login"}),s.jsx("small",{className:"codex-login-waiting",children:"Waiting for Codex to confirm the login..."})]}):M.status==="succeeded"?s.jsxs("p",{children:[s.jsx("strong",{children:((A=M.account)==null?void 0:A.name)??M.accountName})," is persisted on the cloud and ready to synchronize. It was not activated automatically."]}):s.jsx("p",{className:"memory-editor-error",children:M.error??"Codex login was cancelled."}),s.jsx("div",{className:"memory-delete-actions",children:s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>void ue(),type:"button",children:M.status==="pending"?"Cancel login":"Close"})})]}):s.jsxs("form",{"aria-label":"Add Codex account",className:"memory-editor-popover codex-account-login-dialog",onClick:z=>z.stopPropagation(),onSubmit:z=>void ye(z),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Add Codex Account"}),s.jsx("button",{"aria-label":"Close account login",className:"memory-icon-button",onClick:()=>S(!1),type:"button",children:"×"})]}),s.jsx("p",{className:"settings-note",children:"Seele creates the login profile on the cloud. Completing login shares it with every deployment but does not make it active."}),s.jsxs("label",{children:[s.jsx("span",{children:"Account name"}),s.jsx("input",{autoFocus:!0,maxLength:80,onChange:z=>E(z.target.value),placeholder:"For example: Codex backup",value:w})]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:()=>S(!1),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p||!w.trim(),type:"submit",children:p?"Starting...":"Continue"})]})]})}):null,ie?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&N(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Switch Codex account",className:"memory-delete-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Switch Codex Account"}),s.jsx("button",{"aria-label":"Close account switch",className:"memory-icon-button",disabled:p,onClick:()=>N(null),type:"button",children:"×"})]}),s.jsxs("p",{children:["Switch cloud-wide execution to ",s.jsx("strong",{children:ie.name}),"? The cloud runtime must be idle. Member deployments finish active turns, pause new work, and then install this credential; workspace threads and memory stay unchanged."]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>N(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:p,onClick:()=>void be(),type:"button",children:p?"Switching...":"Stop and switch"})]})]})}):null,Q?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>!p&&re(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Delete Codex account",className:"memory-delete-dialog",onClick:z=>z.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Delete Codex Account"}),s.jsx("button",{"aria-label":"Close account deletion",className:"memory-icon-button",disabled:p,onClick:()=>re(null),type:"button",children:"×"})]}),s.jsxs("p",{children:["Delete ",s.jsx("strong",{children:Q.name})," and its persisted Codex credential from the cloud and every member mirror? This cannot be undone."]}),m?s.jsx("p",{className:"memory-editor-error",children:m}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",disabled:p,onClick:()=>re(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button danger",disabled:p,onClick:()=>void _e(),type:"button",children:p?"Deleting...":"Delete"})]})]})}):null]})}function WA({currentUser:e,users:i,onCreate:a,onDelete:r,onUpdate:u}){const c={username:"",password:"",role:"user",active:!0},[d,p]=D.useState(null),[g,m]=D.useState(c),[b,x]=D.useState(!1),[S,w]=D.useState(null),[E,M]=D.useState("");function H(){m(c),M(""),p("new")}function R(V){m({username:V.username,password:"",role:V.role,active:V.active}),M(""),p(V)}function q(){b||(p(null),M(""))}async function $(V){if(V.preventDefault(),!!d){x(!0),M("");try{d==="new"?await a({username:g.username.trim(),password:g.password,role:g.role}):await u(d.id,{username:g.username.trim(),password:g.password||void 0,role:g.role,active:g.active}),p(null)}catch(ie){M(Ge(ie).message)}finally{x(!1)}}}return s.jsxs("section",{className:"settings-section user-management-section",children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Users"}),s.jsx("p",{children:"Manage sign-in access and Seele roles."})]})}),s.jsx("div",{className:"memory-items-editor-header actions-only",children:s.jsx("button",{"aria-label":"Add user",className:"memory-icon-button",onClick:H,title:"Add user",type:"button",children:"+"})}),s.jsxs("div",{className:"user-list",children:[i.map(V=>s.jsxs("div",{className:"user-list-item",children:[s.jsxs("div",{className:"user-list-main",children:[s.jsxs("div",{children:[s.jsx("strong",{children:V.username}),V.id===e.id?s.jsx("span",{className:"user-current-badge",children:"Current"}):null]}),s.jsxs("small",{children:["Created ",He(V.createdAt)]})]}),s.jsx("span",{className:`user-role-badge role-${V.role}`,children:V.role}),s.jsx("span",{className:`user-status ${V.active?"active":"disabled"}`,children:V.active?"Active":"Disabled"}),s.jsxs("div",{className:"user-row-actions",children:[s.jsx("button",{"aria-label":`Edit user ${V.username}`,className:"memory-icon-button",onClick:()=>R(V),title:"Edit",type:"button",children:s.jsx(cd,{})}),s.jsx("button",{"aria-label":`Delete user ${V.username}`,className:"memory-icon-button memory-item-delete",disabled:V.id===e.id,onClick:()=>{M(""),w(V)},title:"Delete",type:"button",children:"×"})]})]},V.id)),i.length===0?s.jsx("p",{className:"settings-note",children:"No users are configured."}):null]}),d?s.jsx("div",{className:"memory-editor-overlay",onClick:q,role:"presentation",children:s.jsxs("form",{"aria-label":d==="new"?"Add user":"Edit user",className:"memory-editor-popover user-editor-popover",onClick:V=>V.stopPropagation(),onSubmit:V=>void $(V),children:[s.jsxs("header",{children:[s.jsx("strong",{children:d==="new"?"Add User":"Edit User"}),s.jsx("button",{"aria-label":"Close user editor",className:"memory-icon-button",onClick:q,title:"Close",type:"button",children:"×"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Username"}),s.jsx("input",{autoComplete:"off",autoFocus:!0,onChange:V=>m(ie=>({...ie,username:V.target.value})),placeholder:"Sign-in username",value:g.username})]}),s.jsxs("label",{children:[s.jsx("span",{children:d==="new"?"Initial password":"New password"}),s.jsx("input",{autoComplete:"new-password",minLength:8,onChange:V=>m(ie=>({...ie,password:V.target.value})),placeholder:d==="new"?"At least 8 characters":"Leave blank to keep the current password",type:"password",value:g.password})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Role"}),s.jsxs("select",{disabled:d!=="new"&&d.id===e.id,onChange:V=>m(ie=>({...ie,role:V.target.value==="admin"?"admin":"user"})),value:g.role,children:[s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"admin",children:"Admin"})]})]}),d!=="new"?s.jsxs("label",{className:"user-editor-active",children:[s.jsx("input",{checked:g.active,disabled:d.id===e.id,onChange:V=>m(ie=>({...ie,active:V.target.checked})),type:"checkbox"}),s.jsx("span",{children:"Account active"})]}):null,E?s.jsx("p",{className:"memory-editor-error",children:E}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:q,type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button primary",disabled:b||!g.username.trim()||d==="new"&&g.password.length<8||d!=="new"&&g.password.length>0&&g.password.length<8,type:"submit",children:b?"Saving...":"Save"})]})]})}):null,S?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>w(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Delete user",className:"memory-delete-dialog",onClick:V=>V.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Delete User"}),s.jsx("button",{"aria-label":"Close delete user confirmation",className:"memory-icon-button",onClick:()=>w(null),title:"Close",type:"button",children:"×"})]}),s.jsxs("p",{children:["Delete ",s.jsx("strong",{children:S.username}),". Users that own workspaces must be disabled instead."]}),E?s.jsx("p",{className:"memory-editor-error",children:E}):null,s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{className:"memory-dialog-button",onClick:()=>w(null),type:"button",children:"Cancel"}),s.jsx("button",{className:"memory-dialog-button danger",onClick:()=>{r(S.id).then(()=>w(null)).catch(V=>M(Ge(V).message))},type:"button",children:"Delete"})]})]})}):null]})}function KA({settings:e,onSave:i}){const[a,r]=D.useState(e),[u,c]=D.useState(!1);return D.useEffect(()=>r(e),[e]),s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:"Deployment"}),s.jsx("p",{children:"Settings stored only on this Seele instance. Cloud synchronization does not copy or overwrite them."})]})}),s.jsxs("form",{className:"settings-form",onSubmit:d=>{d.preventDefault(),c(!0),i(a).finally(()=>c(!1))},children:[s.jsxs("label",{className:"settings-field settings-field-wide",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Public URL"}),s.jsx("small",{children:"The externally reachable main URL of this deployment. Seele uses it when publishing callback links to external systems."})]}),s.jsx("input",{"aria-label":"Public URL of this deployment",onChange:d=>r({...a,publicUrl:d.target.value||null}),placeholder:"https://profuse.antgroup-inc.cn/codex/yishao-0/",type:"url",value:a.publicUrl||""})]}),s.jsxs("label",{className:"settings-toggle-field",children:[s.jsxs("span",{children:[s.jsx("strong",{children:"Profuse notification"}),s.jsx("small",{children:"Send DingTalk notifications from this deployment when a turn finishes or fails. Keep this off where the Profuse endpoint is unreachable."})]}),s.jsx("input",{"aria-label":"Enable Profuse notification on this deployment",checked:a.profuseNotificationEnabled,onChange:d=>r({...a,profuseNotificationEnabled:d.target.checked}),type:"checkbox"})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{disabled:u,type:"submit",children:u?"Saving...":"Save deployment settings"})})]})]})}function XA({codexReleasedAt:e,codexVersion:i,codexUpdating:a,draft:r,globalSettings:u,models:c,scope:d,settings:p,workspaceOverrideCount:g,workspaceSettings:m,onDraftChange:b,onResetWorkspaceSetting:x,onSubmit:S,onUpdateCodexCli:w}){var V;const E=d==="workspace",M=Jo(r.model,c),H=Jo(u.model,c),R=Jo(p.model,c),q=Cx(r.reasoningEffort,M),$=HE(M,r.reasoningEffort);return D.useEffect(()=>{M&&q!==r.reasoningEffort&&b({...r,reasoningEffort:q})},[r,M,q,b]),s.jsxs(s.Fragment,{children:[s.jsxs("header",{className:"settings-section-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"Runtime"}),s.jsx("p",{children:"Configure global defaults or override them for the selected workspace. Running turns keep the settings they started with."})]}),E?s.jsx("span",{className:g>0?"section-override-count active":"section-override-count",children:g>0?`${g} custom`:"No custom runtime"}):null]}),s.jsxs("form",{className:"settings-form runtime-form",onSubmit:S,children:[s.jsxs("label",{className:Bc(E,Tl(r.model,u.model,m==null?void 0:m.sources.model)),children:[s.jsx(Uc,{globalValue:pb(u.model,c),isWorkspaceScope:E,label:"Model",settingKey:"model",source:Tl(r.model,u.model,m==null?void 0:m.sources.model),onReset:x}),s.jsx(jp,{"aria-label":"Runtime model",onChange:ie=>{const N=Jo(ie,c);b({...r,model:ie,reasoningEffort:Cx(r.reasoningEffort,N)})},options:oR(c,r.model),value:r.model||((V=c.find(ie=>ie.isDefault))==null?void 0:V.model)||""})]}),s.jsxs("label",{className:Bc(E,Tl(r.reasoningEffort,u.reasoningEffort,m==null?void 0:m.sources.reasoningEffort)),children:[s.jsx(Uc,{globalValue:jx(u.reasoningEffort,H),isWorkspaceScope:E,label:"Reasoning effort",settingKey:"reasoningEffort",source:Tl(r.reasoningEffort,u.reasoningEffort,m==null?void 0:m.sources.reasoningEffort),onReset:x}),s.jsx(jp,{"aria-label":"Runtime reasoning effort",onChange:ie=>b({...r,reasoningEffort:ie}),options:$,value:q})]}),s.jsxs("label",{className:Bc(E,Tl(r.sandbox,u.sandbox,m==null?void 0:m.sources.sandbox)),children:[s.jsx(Uc,{globalValue:gb(u.sandbox),isWorkspaceScope:E,label:"Permission mode",settingKey:"sandbox",source:Tl(r.sandbox,u.sandbox,m==null?void 0:m.sources.sandbox),onReset:x}),s.jsx(jp,{"aria-label":"Permission mode",onChange:ie=>b({...r,sandbox:ie}),options:pA,value:r.sandbox})]}),s.jsxs("label",{className:Bc(E,Tl(r.fastMode,u.fastMode,m==null?void 0:m.sources.fastMode),"settings-toggle-field"),children:[s.jsxs("span",{children:[s.jsx(Uc,{globalValue:u.fastMode?"On":"Off",isWorkspaceScope:E,label:"Fast mode",settingKey:"fastMode",source:Tl(r.fastMode,u.fastMode,m==null?void 0:m.sources.fastMode),onReset:x}),s.jsx("small",{children:"1.5x speed with higher Codex credit consumption"})]}),s.jsx("input",{"aria-label":"Enable Fast mode",checked:r.fastMode,onChange:ie=>b({...r,fastMode:ie.target.checked}),type:"checkbox"})]}),s.jsxs("dl",{className:"runtime-summary",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Current"}),s.jsxs("dd",{children:["Model ",pb(p.model,c),", reasoning"," ",jx(p.reasoningEffort,R),", Fast mode"," ",p.fastMode?"on":"off",", permission"," ",gb(p.sandbox),"."]})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Codex CLI"}),s.jsxs("dd",{className:"runtime-version-value",children:[s.jsx("span",{children:lh(i,e)}),s.jsx("button",{className:"runtime-update-button",disabled:a,onClick:w,type:"button",children:a?"Updating...":"Check update"})]})]})]}),s.jsx("div",{className:"settings-form-actions",children:s.jsx("button",{type:"submit",children:E?"Save workspace overrides":"Save global runtime"})})]})]})}function Uc({globalValue:e,isWorkspaceScope:i,label:a,settingKey:r,source:u,onReset:c}){const d=i&&u==="workspace";return s.jsxs("span",{className:"runtime-field-label",children:[s.jsx("span",{children:a}),i?s.jsxs("span",{className:"runtime-field-meta",children:[s.jsx("span",{className:d?"override":"inherited",children:d?"Workspace override":`Inherited: ${e}`}),d?s.jsx("button",{type:"button",onClick:()=>c(r),children:"Reset"}):null]}):null]})}function jp({"aria-label":e,onChange:i,options:a,value:r}){const[u,c]=D.useState(!1),d=D.useRef(null),p=a.find(g=>g.value===r)??a[0]??null;return D.useEffect(()=>{if(!u)return;function g(b){var x;(x=d.current)!=null&&x.contains(b.target)||c(!1)}function m(b){b.key==="Escape"&&c(!1)}return document.addEventListener("pointerdown",g,!0),document.addEventListener("keydown",m,!0),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("keydown",m,!0)}},[u]),s.jsxs("div",{className:"runtime-select",ref:d,children:[s.jsxs("button",{"aria-expanded":u,"aria-label":e,className:"runtime-select-trigger",onClick:()=>c(g=>!g),type:"button",children:[s.jsx("span",{children:(p==null?void 0:p.label)??r}),s.jsx("span",{"aria-hidden":"true",children:"⌄"})]}),u?s.jsx("div",{className:"runtime-select-menu",role:"listbox",children:a.map(g=>s.jsx("button",{"aria-selected":g.value===r,className:g.value===r?"selected":void 0,onClick:()=>{i(g.value),c(!1)},role:"option",type:"button",children:g.label},g.value||"default"))}):null]})}function Tl(e,i,a){return e!==i?"workspace":a}function Bc(e,i,a="settings-wide-field"){return[a,e?"workspace-scoped":"",e&&i==="workspace"?"workspace-overridden":""].filter(Boolean).join(" ")}function QA({baseSettings:e,scope:i,workspaceSettings:a,workspaceName:r,onSaveBaseItems:u,onSaveWorkspaceItems:c}){const d=i==="workspace",p=d?a.items:e.items,g=d?c:u;return s.jsxs(s.Fragment,{children:[s.jsx("header",{className:"settings-section-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:d?"Workspace Memory":"Base Memory"}),s.jsx("p",{children:d?"Workspace memory applies only to the selected workspace. Use stable English keys; values may be Chinese, plain text, or Markdown.":"Base memory applies to every workspace. Use stable English keys; values may be Chinese, plain text, or Markdown."})]})}),d?s.jsxs("section",{className:"settings-readonly-block",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"Base Memory"}),s.jsx("span",{children:"Read-only in workspace scope"})]}),s.jsx(JA,{emptyText:"No base memory is configured.",items:e.items,readonly:!0})]}):null,s.jsx("div",{className:"memory-manager-shell",children:s.jsx(ZA,{ariaLabel:d?"Workspace memory":"Base memory",emptyText:"No memory items are configured.",items:p,onSaveItems:g,title:""})})]})}function ZA({ariaLabel:e,emptyText:i,items:a,onSaveItems:r,title:u}){var Q;const[c,d]=D.useState(ru(a)),[p,g]=D.useState(null),[m,b]=D.useState({key:"",value:""}),[x,S]=D.useState(null),[w,E]=D.useState(null),[M,H]=D.useState(null);D.useEffect(()=>{d(ru(a))},[a]),D.useEffect(()=>{if(p===null)return;const re=ee=>{ee.key==="Escape"&&(V(),E(null))};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[p]);async function R(re,ee){H(ee);try{const L=await r(re);return d(ru(L)),L}finally{H(null)}}function q(){E(null),S(null),b({key:"",value:""}),g("new")}function $(re){const ee=c[re];ee&&(E(null),S(null),b({...ee}),g(re))}function V(){g(null),S(null),b({key:"",value:""})}async function ie(re){const ee=c[re],L=(ee==null?void 0:ee.key)||`${re}`;await R(c.filter((te,de)=>de!==re),`delete:${L}`),E(null)}async function N(re){re.preventDefault(),re.stopPropagation();const ee=m.key.trim(),L=hD(ee);if(L){S(L);return}const te=m.value.trim();if(!te){S("Value is required.");return}const de=p==="new"?-1:p;if(c.some((ye,ue)=>ue!==de&&ye.key.trim()===ee)){S(`Key "${ee}" already exists. Each memory key must be unique.`);return}const Ne={...m,key:ee,value:te};p==="new"?await R([...c,Ne],"add"):typeof p=="number"&&await R(c.map((ye,ue)=>ue===p?Ne:ye),`save:${p}`),V()}return s.jsxs("section",{className:"memory-items-manager","aria-label":e,children:[s.jsxs("div",{className:u?"memory-items-editor-header":"memory-items-editor-header actions-only",children:[u?s.jsx("span",{children:u}):null,s.jsx("button",{"aria-label":"Add memory item",className:"memory-icon-button",title:"Add",type:"button",onClick:q,children:"+"})]}),c.length?s.jsx("div",{className:"memory-items-grid",children:c.map((re,ee)=>s.jsxs("div",{className:"memory-item-display",children:[s.jsxs("pre",{"aria-label":`Memory item ${re.key}`,children:[s.jsx("span",{className:"memory-tag",children:`<${re.key}>`}),`
94
94
  `,s.jsx("span",{children:re.value}),`
95
95
  `,s.jsx("span",{className:"memory-tag",children:`</${re.key}>`})]}),s.jsxs("div",{className:"memory-item-actions",children:[s.jsx("button",{"aria-label":`Edit memory item ${re.key||ee+1}`,className:"memory-icon-button memory-item-edit",disabled:M!==null,title:"Edit",type:"button",onClick:()=>$(ee),children:"✎"}),s.jsx("button",{"aria-label":`Delete memory item ${re.key||ee+1}`,className:"memory-icon-button memory-item-delete",disabled:M!==null,title:"Delete",type:"button",onClick:()=>E(ee),children:"×"})]})]},`${ee}-${re.key}`))}):s.jsx("p",{className:"settings-note",children:i}),p!==null?s.jsx("div",{className:"memory-editor-overlay",onClick:V,role:"presentation",children:s.jsxs("form",{"aria-label":p==="new"?"Add memory item":"Edit memory item",className:"memory-editor-popover",onClick:re=>re.stopPropagation(),onSubmit:re=>void N(re),children:[s.jsxs("header",{children:[s.jsx("strong",{children:p==="new"?"Add Memory":"Edit Memory"}),s.jsx("button",{"aria-label":"Close memory editor",className:"memory-icon-button",title:"Close",type:"button",onClick:V,children:"×"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Key"}),s.jsx("input",{autoComplete:"off",autoFocus:!0,onChange:re=>b(ee=>({...ee,key:re.target.value})),placeholder:"Stable technical key used as the injected tag name",value:m.key})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Value · up to 1000 tokens"}),s.jsx("textarea",{onChange:re=>b(ee=>({...ee,value:re.target.value})),placeholder:"Memory content injected under this key",rows:10,value:m.value})]}),x?s.jsx("p",{className:"memory-editor-error",children:x}):null,s.jsxs("div",{className:"memory-editor-actions",children:[s.jsx("button",{"aria-label":"Cancel memory edit",className:"memory-dialog-button",type:"button",onClick:V,children:"Cancel"}),s.jsx("button",{"aria-label":"Save memory item",className:"memory-dialog-button primary",disabled:M!==null,type:"submit",children:M==="add"||M!=null&&M.startsWith("save:")?"Saving...":"Save"})]})]})}):null,w!==null?s.jsx("div",{className:"memory-editor-overlay",onClick:()=>E(null),role:"presentation",children:s.jsxs("section",{"aria-label":"Confirm delete memory item",className:"memory-delete-dialog",onClick:re=>re.stopPropagation(),children:[s.jsxs("header",{children:[s.jsx("strong",{children:"Delete Memory"}),s.jsx("button",{"aria-label":"Close delete confirmation",className:"memory-icon-button",title:"Close",type:"button",onClick:()=>E(null),children:"×"})]}),s.jsxs("p",{children:["Delete"," ",s.jsx("code",{children:((Q=c[w])==null?void 0:Q.key)||`item ${w+1}`}),"?"]}),s.jsxs("div",{className:"memory-delete-actions",children:[s.jsx("button",{"aria-label":"Cancel delete",className:"memory-dialog-button",disabled:M!==null,type:"button",onClick:()=>E(null),children:"Cancel"}),s.jsx("button",{"aria-label":"Confirm delete",className:"memory-dialog-button danger",disabled:M!==null,type:"button",onClick:()=>void ie(w),children:"Delete"})]})]})}):null]})}function JA({emptyText:e,items:i}){const a=ru(i);return a.length?s.jsx("div",{className:"memory-items-list",children:a.map(r=>s.jsx("div",{className:"memory-item-display memory-item-readonly",children:s.jsxs("pre",{"aria-label":`Memory item ${r.key}`,children:[s.jsx("span",{className:"memory-tag",children:`<${r.key}>`}),`
96
96
  `,s.jsx("span",{children:r.value}),`
@@ -109,7 +109,7 @@ ${e.content}`:e.type==="system"?[e.title,e.fullDetail??e.detail].filter(i=>!!(i!
109
109
  `);if(i<0)return 0;const a=[0];for(let u=0;u<e.length;u+=1)e[u]===`
110
110
  `&&u+1<e.length&&a.push(u+1);let r=-1;for(const u of a){const c=e.indexOf(`
111
111
  `,u),d=e.slice(u,c===-1?e.length:c);/^\s*(```|~~~)/.test(d)&&(r=r===-1?u:-1)}return r>=0?r:i+1}function r2({artifact:e,onPreview:i,onCopyUrl:a,copied:r}){return e?s.jsxs("figure",{className:"artifact-preview",children:[s.jsx("button",{className:"artifact-preview-media",onClick:()=>i(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:()=>i(e),type:"button",children:"Preview"}),s.jsx("a",{href:e.url,rel:"noreferrer",target:"_blank",children:"Open"}),s.jsx("button",{onClick:()=>a(e),type:"button",children:r?"Copied":"Copy"})]})]})]}):null}function s2(e,i){const a=new Map;for(const r of o2(e)){const u=ew(r);if(u){const c=tw(u).toLowerCase(),d=a.get(c);(!d||d2(u,d))&&a.set(c,u)}}return Array.from(a.values()).map(r=>u2(r,i)).filter(r=>r!==null)}function o2(e){const i=[],a=/!\[[^\]]*]\(([^)]+)\)/g,r=/\[[^\]]+]\(([^)]+)\)/g,u=/(?:artifact|preview|image|file)\s*:\s*(`?[^`\n]+?\.(?:svg|png|jpe?g|webp|gif)`?)/gim;for(const c of[a,r,u]){let d;for(;(d=c.exec(e))!==null;)i.push(d[1])}return i}function u2(e,i){const a=ew(e);if(!a||!c2(a))return null;const r=Rv(a,i.workspacePath);return{id:`${i.id}:${r}`,path:r,name:tw(r),url:ge(`conversations/${i.id}/files?path=${encodeURIComponent(r)}`)}}function ew(e){const i=e.trim().replace(/^`+|`+$/g,"").replace(/[),.;:,。;:]+$/g,"");return i||null}function c2(e){return/\.(?:svg|png|jpe?g|webp|gif)$/i.test(e)}function tw(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).pop()??e}function d2(e,i){return e.startsWith("/")&&!i.startsWith("/")?!0:e.length>i.length}function wr(e){return e.trim()}function nw(e){return e.trim()}function Xx(e){return e instanceof DOMException&&e.name==="AbortError"||e instanceof Error&&e.name==="AbortError"}function f2(e){return{a({children:i,href:a}){if(!a)return s.jsx(s.Fragment,{children:i});const r=/^[a-z][a-z\d+.-]*:/i.test(a),u=!r&&e?p2(a,e):null,c=u??a,d=r||!!u;return s.jsx("a",{className:"markdown-link",href:c,rel:d?"noreferrer":void 0,target:d?"_blank":void 0,children:i})},img(){return null},pre({children:i}){const a=m2(i);return a?_h(a.language)==="mermaid"?s.jsx(g2,{code:a.code}):s.jsx(b2,{code:a.code,language:a.language}):s.jsx("pre",{children:i})},table({children:i}){return s.jsx("div",{className:"markdown-table-wrap",children:s.jsx("table",{className:"markdown-table",children:i})})},td({align:i,children:a}){return s.jsx("td",{style:Qx(i),children:a})},th({align:i,children:a}){return s.jsx("th",{style:Qx(i),children:a})}}}function p2(e,i){if(!e||e.startsWith("#")||e.startsWith("/api/")||e.startsWith("?"))return null;const a=tA(e,i.workspacePath);if(!a)return null;const r=a.line?`#L${a.line}${a.column?`C${a.column}`:""}`:"";return`${ge(`conversations/${i.id}/files?path=${encodeURIComponent(a.path)}`)}${r}`}function Qx(e){return e&&e!=="char"?{textAlign:e}:void 0}function El(e,i){const a=h2(e);return s.jsx(cC,{components:f2(i),remarkPlugins:[SE],skipHtml:!0,children:a})}function h2(e){return e.replace(/([^\n])(```[^\n`]*(?:\r?\n|$))/g,`$1
112
- $2`)}function m2(e){var c;const i=D.Children.toArray(e),a=i.length===1&&D.isValidElement(i[0])?i[0]:null;if(!a||a.type!=="code")return null;const u=((c=(a.props.className??"").match(/(?:^|\s)language-([^\s]+)/))==null?void 0:c[1])??"";return{code:nh(a.props.children).replace(/\n$/,""),language:u}}function nh(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(nh).join(""):D.isValidElement(e)?nh(e.props.children):""}const iw="github-light",Np=new Map,Dp=new Map;let Rp=null,_p=null;const aw=new Set(["bash","css","diff","dockerfile","html","java","javascript","json","jsonc","jsx","markdown","python","shellscript","sql","toml","tsx","typescript","xml","yaml"]);function _h(e){const i=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"}[i]??i}function lw(e){const i=_h(e);return!i||i==="text"||i==="txt"?"text":aw.has(i)?i:"text"}function g2({code:e}){const a=`seele-mermaid-${D.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,[r,u]=D.useState(!1),[c,d]=D.useState(()=>Dp.get(e)??null),[p,g]=D.useState(null);D.useEffect(()=>{let b=!1,x;const S=Dp.get(e);return S?(d(S),g(null),()=>{b=!0}):(g(null),d(null),y2(a,e).then(w=>{b||(x!==void 0&&window.clearTimeout(x),Dp.set(e,w),d(w),g(null))},w=>{if(!b){const E=w instanceof Error?w.message:String(w);x=window.setTimeout(()=>{b||g(E)},fA)}}),()=>{b=!0,x!==void 0&&window.clearTimeout(x)})},[e,a]);async function m(){await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}return s.jsxs("figure",{className:`mermaid-block${p?" error":""}`,children:[s.jsx("span",{className:"code-block-kind",children:"mermaid"}),s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":r?"Copied Mermaid source":"Copy Mermaid source",className:r?"copied":"",onClick:()=>void m(),title:r?"Copied":"Copy",type:"button",children:s.jsx(Mh,{})})}),c?s.jsx("div",{className:"mermaid-diagram",dangerouslySetInnerHTML:{__html:c}}):p?s.jsxs("div",{className:"mermaid-error",children:[s.jsx("strong",{children:"Mermaid render failed"}),s.jsx("pre",{children:p}),s.jsx("code",{children:e})]}):s.jsx("div",{className:"mermaid-loading",children:"Rendering diagram..."})]})}async function y2(e,i){return(await(await x2()).render(e,i)).svg}function x2(){return _p||(_p=Tt(()=>import("./mermaid.core-BOqAG-mK.js").then(e=>e.bp),[],import.meta.url).then(e=>{const i=e.default;return i.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'}}),i})),_p}function b2({code:e,language:i,reserveHeight:a=!1}){const[r,u]=D.useState(!1),[c,d]=D.useState(()=>{if(!eb(i))return null;const m=Jx(e,i);return Np.get(m)??null}),p=a?{"--code-block-min-height":`${SA(e)}px`}:void 0;D.useEffect(()=>{let m=!1;if(!eb(i))return d(null),()=>{m=!0};const b=Jx(e,i),x=Np.get(b);return x?(d(x),()=>{m=!0}):(d(null),E2(e,i).then(S=>{Np.set(b,S),m||d(S)}).catch(S=>{console.warn("Failed to highlight code block",S),m||d(null)}),()=>{m=!0})},[e,i]);async function g(){await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}return s.jsxs("figure",{className:"code-block",style:p,children:[i?s.jsx("span",{className:"code-block-kind",children:i}):null,s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":r?"Copied code block":"Copy code block",className:r?"copied":"",onClick:()=>void g(),title:r?"Copied":"Copy",type:"button",children:s.jsx(Mh,{})})}),c?s.jsx("div",{className:"code-block-shiki",dangerouslySetInnerHTML:{__html:c}}):s.jsx("pre",{children:s.jsx("code",{children:e})})]})}function Mh(){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 v2(){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 rw(){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 w2(){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 k2(){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 Zx(){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 S2(){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 Pc(){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 cd(){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 j2(){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 C2(){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 T2(){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 Jx(e,i){return`${iw}:${lw(i)}:${e}`}function eb(e){const i=_h(e);return!!i&&aw.has(i)}async function E2(e,i){return(await A2()).codeToHtml(e,{lang:lw(i),theme:iw})}function A2(){return Rp||(Rp=N2()),Rp}async function N2(){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:i},{default:a},{default:r},{default:u},{default:c},{default:d},{default:p},{default:g},{default:m},{default:b},{default:x},{default:S},{default:w},{default:E},{default:M},{default:H},{default:R},{default:q},{default:$},{default:V},{default:ie}]=await Promise.all([Tt(()=>import("./core-pJEyggQv.js"),[],import.meta.url),Tt(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),Tt(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),Tt(()=>import("./bash-BELqPA7S.js").then(N=>N.b),[],import.meta.url),Tt(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),Tt(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),Tt(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),Tt(()=>import("./html-pp8916En.js"),__vite__mapDeps([0,1,2]),import.meta.url),Tt(()=>import("./java-CylS5w8V.js"),[],import.meta.url),Tt(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),Tt(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),Tt(()=>import("./jsonc-Des-eS-w.js"),[],import.meta.url),Tt(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),Tt(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),Tt(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),Tt(()=>import("./bash-BELqPA7S.js").then(N=>N.s),[],import.meta.url),Tt(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),Tt(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),Tt(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),Tt(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),Tt(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([3,4]),import.meta.url),Tt(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url)]);return e({engine:i(),themes:[a],langs:[r,u,c,d,p,g,m,b,x,S,w,E,M,H,R,q,$,V,ie]})}async function tb(){const e=ge("conversations"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).conversations}async function D2(){const e=ge("workspace-states"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).workspaces}async function nb(){const e=ge("collaboration/topics"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).topics}async function $c(e){const i=ge(`collaboration/topics/${e}/messages?limit=100`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).messages}async function R2(e){const i=ge("collaboration/topics"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"POST",url:i}),(await a.json()).topic}async function _2(e,i){const a=ge(`collaboration/topics/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PATCH",url:a}),(await r.json()).topic}async function M2(e,i){const a=ge(`collaboration/topics/${e}/archive`),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedVersion:i})});return await Te(r,{method:"POST",url:a}),(await r.json()).topic}async function O2(e){const i=ge(`conversations/${e}/read`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i})}async function ib(){const e=ge("workspace-groups"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).groups}async function z2(e){const i=ge("workspace-groups"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});return await Te(a,{method:"POST",url:i}),(await a.json()).group}async function L2(e,i){const a=ge(`workspace-groups/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PATCH",url:a}),(await r.json()).group}async function I2(e){const i=ge(`workspace-groups/${e}`),a=await fetch(i,{method:"DELETE"});return await Te(a,{method:"DELETE",url:i}),await a.json()}async function U2(){const e=ge("settings/environment"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).variables}async function B2(e){const i=ge(`conversations/${e}/settings/environment`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).variables}async function q2(e){const i=ge(`conversations/${e}/knowledge`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).items}async function H2(){const e=ge("settings/runtime"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).settings}async function $2(){const e=ge("settings/deployment"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).settings}async function G2(){const e=ge("diagnostics"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function V2(){const e=ge("settings/runtime/codex"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function ab(){const e=ge("settings/runtime/accounts"),i=await fetch(e);await Te(i,{url:e});const a=await i.json();return Sr(),a}async function lb(e=!1){const i=ge(`settings/runtime/accounts/refresh${e?"?force=1":""}`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i});const r=await a.json();return Sr(),r}async function F2(e){const i=ge("settings/runtime/accounts"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});await Te(a,{method:"POST",url:i});const r=await a.json();return r.login.status==="succeeded"&&Sr(),r.login}async function Y2(e){const i=ge(`settings/runtime/accounts/login/${e}`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).login}async function P2(e){const i=ge(`settings/runtime/accounts/login/${e}/cancel`),a=await fetch(i,{method:"POST"});return await Te(a,{method:"POST",url:i}),(await a.json()).login}async function W2(e,i){const a=ge(`settings/runtime/accounts/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i})});await Te(r,{method:"PATCH",url:a});const u=await r.json();return Sr(),u.account}async function K2(e){const i=ge(`settings/runtime/accounts/${e}`),a=await fetch(i,{method:"DELETE"});await Te(a,{method:"DELETE",url:i}),Sr()}async function X2(e){const i=ge(`settings/runtime/accounts/${e}/switch`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i});const r=await a.json();return Sr(),r}async function Q2(e=!0){const i=ge(`settings/runtime/models?refresh=${e?"1":"0"}`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function Z2(e=!1){const i=ge(`settings/runtime/codex/update${e?"?refreshLatest=1":""}`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function J2(){const e=ge("settings/runtime/codex/update"),i=await fetch(e,{method:"POST"});return await Te(i,{method:"POST",url:e}),(await i.json()).job}async function eD(e){const i=ge(`conversations/${e}/settings/runtime`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).settings}async function tD(){const e=ge("settings/memory"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function nD(e){const i=ge("settings/runtime"),a=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"PUT",url:i}),(await a.json()).settings}async function iD(e){const i=ge("settings/deployment"),a=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"PUT",url:i}),(await a.json()).settings}async function rb(e,i){const a=ge(`conversations/${e}/settings/runtime`),r=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PUT",url:a}),await r.json()}async function sb(e,i){const a=ge(`conversations/${e}/runtime/reset`),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});await Te(r,{method:"POST",url:a});const u=(await r.json()).job;return ow(e,u)}async function sw(e){const i=ge(`conversations/${e}/runtime/reset`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).job}async function ow(e,i){let a=i;const r=Date.now()+1800*1e3;for(;a.status==="running";){if(Date.now()>=r)throw new Error("Full-history reset is still running after 30 minutes. Reopen Console to check the workspace before retrying.");await new Promise(c=>window.setTimeout(c,1e3));const u=await sw(e);if(!u||u.id!==a.id)throw new Error("The runtime reset job is no longer available.");a=u}if(a.status==="failed"||a.status==="cancelled"||!a.result)throw new Error(a.error??"Full-history reset failed.");return a.result}async function ob(e){const i=ge(`conversations/${e}/runtime/reset-preview`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function aD(e,i){const a=ge(`conversations/${e}/runtime/reset-selection`),r=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});await Te(r,{method:"PUT",url:a})}async function lD(e){const i=ge(`conversations/${e}/runtime/thread-read`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).result}async function rD(e){const i=ge(`conversations/${e}/runtime/token-usage`),a=await fetch(i);await Te(a,{url:i});const r=await a.json();return r.event?vw(r.event):null}async function sD(e){const i=ge(`conversations/${e}/runtime/additional-context`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function oD(e){const i=ge(`conversations/${e}/runtime/compactions`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).compactions}function uD(e,i,a){return{model:e.model===i.model?null:e.model,reasoningEffort:$E(e.reasoningEffort,i.reasoningEffort,(a==null?void 0:a.sources.reasoningEffort)==="workspace"),fastMode:e.fastMode===i.fastMode?null:e.fastMode,sandbox:e.sandbox===i.sandbox?null:e.sandbox}}function cD(e){return{kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceClues:fD(e.sourceCluesText),requiredEnv:pD(e.requiredEnvText)}}function dD(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(i=>`${i.type}: ${i.value}`).join(`
112
+ $2`)}function m2(e){var c;const i=D.Children.toArray(e),a=i.length===1&&D.isValidElement(i[0])?i[0]:null;if(!a||a.type!=="code")return null;const u=((c=(a.props.className??"").match(/(?:^|\s)language-([^\s]+)/))==null?void 0:c[1])??"";return{code:nh(a.props.children).replace(/\n$/,""),language:u}}function nh(e){return e==null||typeof e=="boolean"?"":typeof e=="string"||typeof e=="number"||typeof e=="bigint"?String(e):Array.isArray(e)?e.map(nh).join(""):D.isValidElement(e)?nh(e.props.children):""}const iw="github-light",Np=new Map,Dp=new Map;let Rp=null,_p=null;const aw=new Set(["bash","css","diff","dockerfile","html","java","javascript","json","jsonc","jsx","markdown","python","shellscript","sql","toml","tsx","typescript","xml","yaml"]);function _h(e){const i=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"}[i]??i}function lw(e){const i=_h(e);return!i||i==="text"||i==="txt"?"text":aw.has(i)?i:"text"}function g2({code:e}){const a=`seele-mermaid-${D.useId().replace(/[^a-zA-Z0-9_-]/g,"")}`,[r,u]=D.useState(!1),[c,d]=D.useState(()=>Dp.get(e)??null),[p,g]=D.useState(null);D.useEffect(()=>{let b=!1,x;const S=Dp.get(e);return S?(d(S),g(null),()=>{b=!0}):(g(null),d(null),y2(a,e).then(w=>{b||(x!==void 0&&window.clearTimeout(x),Dp.set(e,w),d(w),g(null))},w=>{if(!b){const E=w instanceof Error?w.message:String(w);x=window.setTimeout(()=>{b||g(E)},fA)}}),()=>{b=!0,x!==void 0&&window.clearTimeout(x)})},[e,a]);async function m(){await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}return s.jsxs("figure",{className:`mermaid-block${p?" error":""}`,children:[s.jsx("span",{className:"code-block-kind",children:"mermaid"}),s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":r?"Copied Mermaid source":"Copy Mermaid source",className:r?"copied":"",onClick:()=>void m(),title:r?"Copied":"Copy",type:"button",children:s.jsx(Mh,{})})}),c?s.jsx("div",{className:"mermaid-diagram",dangerouslySetInnerHTML:{__html:c}}):p?s.jsxs("div",{className:"mermaid-error",children:[s.jsx("strong",{children:"Mermaid render failed"}),s.jsx("pre",{children:p}),s.jsx("code",{children:e})]}):s.jsx("div",{className:"mermaid-loading",children:"Rendering diagram..."})]})}async function y2(e,i){return(await(await x2()).render(e,i)).svg}function x2(){return _p||(_p=Tt(()=>import("./mermaid.core-Ci_ONQ9q.js").then(e=>e.bp),[],import.meta.url).then(e=>{const i=e.default;return i.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'}}),i})),_p}function b2({code:e,language:i,reserveHeight:a=!1}){const[r,u]=D.useState(!1),[c,d]=D.useState(()=>{if(!eb(i))return null;const m=Jx(e,i);return Np.get(m)??null}),p=a?{"--code-block-min-height":`${SA(e)}px`}:void 0;D.useEffect(()=>{let m=!1;if(!eb(i))return d(null),()=>{m=!0};const b=Jx(e,i),x=Np.get(b);return x?(d(x),()=>{m=!0}):(d(null),E2(e,i).then(S=>{Np.set(b,S),m||d(S)}).catch(S=>{console.warn("Failed to highlight code block",S),m||d(null)}),()=>{m=!0})},[e,i]);async function g(){await navigator.clipboard.writeText(e),u(!0),window.setTimeout(()=>u(!1),1200)}return s.jsxs("figure",{className:"code-block",style:p,children:[i?s.jsx("span",{className:"code-block-kind",children:i}):null,s.jsx("div",{className:"code-block-tools",children:s.jsx("button",{"aria-label":r?"Copied code block":"Copy code block",className:r?"copied":"",onClick:()=>void g(),title:r?"Copied":"Copy",type:"button",children:s.jsx(Mh,{})})}),c?s.jsx("div",{className:"code-block-shiki",dangerouslySetInnerHTML:{__html:c}}):s.jsx("pre",{children:s.jsx("code",{children:e})})]})}function Mh(){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 v2(){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 rw(){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 w2(){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 k2(){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 Zx(){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 S2(){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 Pc(){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 cd(){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 j2(){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 C2(){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 T2(){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 Jx(e,i){return`${iw}:${lw(i)}:${e}`}function eb(e){const i=_h(e);return!!i&&aw.has(i)}async function E2(e,i){return(await A2()).codeToHtml(e,{lang:lw(i),theme:iw})}function A2(){return Rp||(Rp=N2()),Rp}async function N2(){const[{createHighlighterCore:e},{createJavaScriptRegexEngine:i},{default:a},{default:r},{default:u},{default:c},{default:d},{default:p},{default:g},{default:m},{default:b},{default:x},{default:S},{default:w},{default:E},{default:M},{default:H},{default:R},{default:q},{default:$},{default:V},{default:ie}]=await Promise.all([Tt(()=>import("./core-bqmd5bjk.js"),[],import.meta.url),Tt(()=>import("./engine-javascript-DBd1bXLz.js"),[],import.meta.url),Tt(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),Tt(()=>import("./bash-BELqPA7S.js").then(N=>N.b),[],import.meta.url),Tt(()=>import("./css-CLj8gQPS.js"),[],import.meta.url),Tt(()=>import("./diff-D97Zzqfu.js"),[],import.meta.url),Tt(()=>import("./dockerfile-BcOcwvcX.js"),[],import.meta.url),Tt(()=>import("./html-pp8916En.js"),__vite__mapDeps([0,1,2]),import.meta.url),Tt(()=>import("./java-CylS5w8V.js"),[],import.meta.url),Tt(()=>import("./javascript-wDzz0qaB.js"),[],import.meta.url),Tt(()=>import("./json-Cp-IABpG.js"),[],import.meta.url),Tt(()=>import("./jsonc-Des-eS-w.js"),[],import.meta.url),Tt(()=>import("./jsx-g9-lgVsj.js"),[],import.meta.url),Tt(()=>import("./markdown-Cvjx9yec.js"),[],import.meta.url),Tt(()=>import("./python-B6aJPvgy.js"),[],import.meta.url),Tt(()=>import("./bash-BELqPA7S.js").then(N=>N.s),[],import.meta.url),Tt(()=>import("./sql-CRqJ_cUM.js"),[],import.meta.url),Tt(()=>import("./toml-vGWfd6FD.js"),[],import.meta.url),Tt(()=>import("./tsx-COt5Ahok.js"),[],import.meta.url),Tt(()=>import("./typescript-BPQ3VLAy.js"),[],import.meta.url),Tt(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([3,4]),import.meta.url),Tt(()=>import("./yaml-Buea-lGh.js"),[],import.meta.url)]);return e({engine:i(),themes:[a],langs:[r,u,c,d,p,g,m,b,x,S,w,E,M,H,R,q,$,V,ie]})}async function tb(){const e=ge("conversations"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).conversations}async function D2(){const e=ge("workspace-states"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).workspaces}async function nb(){const e=ge("collaboration/topics"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).topics}async function $c(e){const i=ge(`collaboration/topics/${e}/messages?limit=100`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).messages}async function R2(e){const i=ge("collaboration/topics"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"POST",url:i}),(await a.json()).topic}async function _2(e,i){const a=ge(`collaboration/topics/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PATCH",url:a}),(await r.json()).topic}async function M2(e,i){const a=ge(`collaboration/topics/${e}/archive`),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({expectedVersion:i})});return await Te(r,{method:"POST",url:a}),(await r.json()).topic}async function O2(e){const i=ge(`conversations/${e}/read`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i})}async function ib(){const e=ge("workspace-groups"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).groups}async function z2(e){const i=ge("workspace-groups"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e})});return await Te(a,{method:"POST",url:i}),(await a.json()).group}async function L2(e,i){const a=ge(`workspace-groups/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PATCH",url:a}),(await r.json()).group}async function I2(e){const i=ge(`workspace-groups/${e}`),a=await fetch(i,{method:"DELETE"});return await Te(a,{method:"DELETE",url:i}),await a.json()}async function U2(){const e=ge("settings/environment"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).variables}async function B2(e){const i=ge(`conversations/${e}/settings/environment`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).variables}async function q2(e){const i=ge(`conversations/${e}/knowledge`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).items}async function H2(){const e=ge("settings/runtime"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).settings}async function $2(){const e=ge("settings/deployment"),i=await fetch(e);return await Te(i,{url:e}),(await i.json()).settings}async function G2(){const e=ge("diagnostics"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function V2(){const e=ge("settings/runtime/codex"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function ab(){const e=ge("settings/runtime/accounts"),i=await fetch(e);await Te(i,{url:e});const a=await i.json();return Sr(),a}async function lb(e=!1){const i=ge(`settings/runtime/accounts/refresh${e?"?force=1":""}`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i});const r=await a.json();return Sr(),r}async function F2(e){const i=ge("settings/runtime/accounts"),a=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e})});await Te(a,{method:"POST",url:i});const r=await a.json();return r.login.status==="succeeded"&&Sr(),r.login}async function Y2(e){const i=ge(`settings/runtime/accounts/login/${e}`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).login}async function P2(e){const i=ge(`settings/runtime/accounts/login/${e}/cancel`),a=await fetch(i,{method:"POST"});return await Te(a,{method:"POST",url:i}),(await a.json()).login}async function W2(e,i){const a=ge(`settings/runtime/accounts/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i})});await Te(r,{method:"PATCH",url:a});const u=await r.json();return Sr(),u.account}async function K2(e){const i=ge(`settings/runtime/accounts/${e}`),a=await fetch(i,{method:"DELETE"});await Te(a,{method:"DELETE",url:i}),Sr()}async function X2(e){const i=ge(`settings/runtime/accounts/${e}/switch`),a=await fetch(i,{method:"POST"});await Te(a,{method:"POST",url:i});const r=await a.json();return Sr(),r}async function Q2(e=!0){const i=ge(`settings/runtime/models?refresh=${e?"1":"0"}`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function Z2(e=!1){const i=ge(`settings/runtime/codex/update${e?"?refreshLatest=1":""}`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function J2(){const e=ge("settings/runtime/codex/update"),i=await fetch(e,{method:"POST"});return await Te(i,{method:"POST",url:e}),(await i.json()).job}async function eD(e){const i=ge(`conversations/${e}/settings/runtime`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).settings}async function tD(){const e=ge("settings/memory"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function nD(e){const i=ge("settings/runtime"),a=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"PUT",url:i}),(await a.json()).settings}async function iD(e){const i=ge("settings/deployment"),a=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"PUT",url:i}),(await a.json()).settings}async function rb(e,i){const a=ge(`conversations/${e}/settings/runtime`),r=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PUT",url:a}),await r.json()}async function sb(e,i){const a=ge(`conversations/${e}/runtime/reset`),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});await Te(r,{method:"POST",url:a});const u=(await r.json()).job;return ow(e,u)}async function sw(e){const i=ge(`conversations/${e}/runtime/reset`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).job}async function ow(e,i){let a=i;const r=Date.now()+1800*1e3;for(;a.status==="running";){if(Date.now()>=r)throw new Error("Full-history reset is still running after 30 minutes. Reopen Console to check the workspace before retrying.");await new Promise(c=>window.setTimeout(c,1e3));const u=await sw(e);if(!u||u.id!==a.id)throw new Error("The runtime reset job is no longer available.");a=u}if(a.status==="failed"||a.status==="cancelled"||!a.result)throw new Error(a.error??"Full-history reset failed.");return a.result}async function ob(e){const i=ge(`conversations/${e}/runtime/reset-preview`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function aD(e,i){const a=ge(`conversations/${e}/runtime/reset-selection`),r=await fetch(a,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});await Te(r,{method:"PUT",url:a})}async function lD(e){const i=ge(`conversations/${e}/runtime/thread-read`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).result}async function rD(e){const i=ge(`conversations/${e}/runtime/token-usage`),a=await fetch(i);await Te(a,{url:i});const r=await a.json();return r.event?vw(r.event):null}async function sD(e){const i=ge(`conversations/${e}/runtime/additional-context`),a=await fetch(i);return await Te(a,{url:i}),await a.json()}async function oD(e){const i=ge(`conversations/${e}/runtime/compactions`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).compactions}function uD(e,i,a){return{model:e.model===i.model?null:e.model,reasoningEffort:$E(e.reasoningEffort,i.reasoningEffort,(a==null?void 0:a.sources.reasoningEffort)==="workspace"),fastMode:e.fastMode===i.fastMode?null:e.fastMode,sandbox:e.sandbox===i.sandbox?null:e.sandbox}}function cD(e){return{kind:e.kind,name:e.name,description:e.description,purpose:e.purpose,attention:e.attention,refreshPolicy:e.refreshPolicy,status:e.status,sourceClues:fD(e.sourceCluesText),requiredEnv:pD(e.requiredEnvText)}}function dD(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(i=>`${i.type}: ${i.value}`).join(`
113
113
  `),requiredEnvText:e.fetch.requiredEnv.map(i=>i.description?`${i.key} - ${i.description}`:i.key).join(`
114
114
  `)}}function fD(e){const i=new Date().toISOString();return e.split(/\r?\n/).map(a=>a.trim()).filter(Boolean).map(a=>{const r=a.match(/^([a-zA-Z][\w-]{0,31})\s*:\s*(.+)$/);return{type:r?r[1].toLowerCase():"text",value:r?r[2].trim():a,providedBy:"user",providedAt:i}})}function pD(e){return e.split(/\r?\n/).map(i=>i.trim()).filter(Boolean).map(i=>{const[a,...r]=i.split(/\s+-\s+/);return{key:a.trim().toUpperCase(),description:r.join(" - ").trim()}}).filter(i=>/^[A-Z_][A-Z0-9_]*$/.test(i.key))}function ub(e,i){const a=cb(i.attention)-cb(e.attention);return a!==0?a:i.updatedAt.localeCompare(e.updatedAt)}function cb(e){return e==="watch"?2:e==="tracked"?1:0}function ru(e){return e.map(i=>({key:i.key??"",value:i.value??"",updatedAt:i.updatedAt}))}function hD(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 mD(e){return ru(e).filter(i=>i.key.trim()&&i.value.trim()).map(i=>`${i.key.trim()}: ${i.value.trim()}`).join(`
115
115
  `)}async function gD(e){const i=ge("settings/memory"),a=await fetch(i,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});return await Te(a,{method:"PUT",url:i}),await a.json()}async function yD(e,i,a){const r=ge("settings/environment"),u=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:a,key:e,value:i})});return await Te(u,{method:"PUT",url:r}),(await u.json()).variable}async function xD(e,i,a,r){const u=ge(`conversations/${e}/settings/environment`),c=await fetch(u,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:r,key:i,value:a})});return await Te(c,{method:"PUT",url:u}),await c.json()}async function bD(e){const i=ge(`settings/environment/${encodeURIComponent(e)}/reveal`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).variable.value}async function vD(e,i){const a=ge(`conversations/${e}/settings/environment/${encodeURIComponent(i)}/reveal`),r=await fetch(a);return await Te(r,{url:a}),(await r.json()).variable.value}async function wD(e){const i=ge(`settings/environment/${encodeURIComponent(e)}`),a=await fetch(i,{method:"DELETE"});await Te(a,{method:"DELETE",url:i})}async function kD(e,i){const a=ge(`conversations/${e}/settings/environment/${encodeURIComponent(i)}`),r=await fetch(a,{method:"DELETE"});return await Te(r,{method:"DELETE",url:a}),(await r.json()).conversation}async function SD(e,i){const a=ge(`conversations/${e}/knowledge`),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"POST",url:a}),(await r.json()).item}async function jD(e,i,a){const r=ge(`conversations/${e}/knowledge/${encodeURIComponent(i)}`),u=await fetch(r,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});return await Te(u,{method:"PATCH",url:r}),(await u.json()).item}async function CD(e,i){const a=ge(`conversations/${e}/knowledge/${encodeURIComponent(i)}`),r=await fetch(a,{method:"DELETE"});await Te(r,{method:"DELETE",url:a})}async function TD(){const e=ge("meta"),i=await fetch(e);return await Te(i,{url:e}),await i.json()}async function ED(e){const i=ge(`settings/runtime/rate-limits?refresh=${e?"1":"0"}`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).usage??null}async function AD(e,i){const a=ge("conversations"),r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:e,groupId:i})});return await Te(r,{method:"POST",url:a}),(await r.json()).conversation}async function ND(e){const i=ge(`conversations/${e}/complex-task`),a=await fetch(i);return await Te(a,{url:i}),(await a.json()).task}async function DD(e,i){const a=ge(`conversations/${e}/complex-tasks/${encodeURIComponent(i)}`),r=await fetch(a);return await Te(r,{url:a}),(await r.json()).task}async function RD(e,i){const a=ge(`conversations/${e}/complex-task/${i}`),r=await fetch(a,{method:"POST"});return await Te(r,{method:"POST",url:a}),(await r.json()).task}async function _D(e,i,a){const r=ge(`conversations/${e}/clone`),u=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:i,groupId:a})});return await Te(u,{method:"POST",url:r}),await u.json()}async function MD(e){const i=ge(`conversations/${e}/clone/retry`),a=await fetch(i,{method:"POST"});return await Te(a,{method:"POST",url:i}),await a.json()}async function Mp(e,i={}){const a=new URLSearchParams;a.set("limit",String(i.limit??_v)),i.before&&a.set("before",i.before);const r=ge(`conversations/${e}?${a}`),u=await fetch(r);return await Te(u,{url:r}),(await u.json()).conversation}async function OD(e,i){const a=ge(`conversations/${e}/turns/${i}/history-events`),r=await fetch(a);return await Te(r,{url:a}),(await r.json()).events}async function Gc(e,i){const a=ge(`conversations/${e}`),r=await fetch(a,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});return await Te(r,{method:"PATCH",url:a}),(await r.json()).conversation}async function zD(e){const i=ge(`conversations/${e}`),a=await fetch(i,{method:"DELETE"});await Te(a,{method:"DELETE",url:i})}function LD(e){return e.title==="Phase boundary recommended"||e.title==="Long run in progress"}function uw(e){return e.length<=3?e.join(", "):`${e.slice(0,3).join(", ")} +${e.length-3}`}function ID(e,i){if(e.event==="server.error"||e.event==="client.error")return{id:e.id,kind:"error",title:"Error",body:aR(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 c=me(e.data),d=Ce(c.toolCallId),p=typeof c.controlIndex=="number"?c.controlIndex:null;if(d||p!==null){const g=e.event==="server.collaboration.message_staged",m=e.event==="server.collaboration.message_sent",b=Ce(c.audience),x=Ce(c.recipientWorkspaceId),S=x?[x]:Array.isArray(c.recipientWorkspaceIds)?c.recipientWorkspaceIds.filter(H=>typeof H=="string"):Array.isArray(c.recipients)?c.recipients.filter(H=>typeof H=="string"):[],w=S.filter(H=>H!=="ALL").map(H=>i.get(H)).filter(H=>!!H);let E="Topic";w.length>0?E=uw(w):S.length===1?E=S[0]==="ALL"?"Topic participants":Nl(S[0]):S.length>1?E=`${S.length} workspaces`:b==="public"||b==="all"?E="Topic participants":b==="owner"&&(E="Topic owner");const M=Ce(c.topicId);return{id:e.id,kind:"collaboration",title:`Send to ${E}`,body:M?`Topic ${Nl(M)}`:"Topic",createdAt:e.createdAt??new Date().toISOString(),itemId:d||`legacy-topic-message:${p}`,meta:g?"pending send":m?"done":"failed",output:g||m?Ce(c.contentMarkdown)||void 0:Ce(c.reason)||void 0,topicAction:"send",topicRecipientLabel:E,topicMessageContent:(g||m)&&Ce(c.contentMarkdown)||void 0}}}if(e.event==="codex.input_request"||e.event==="codex.input_or_approval_request"){const c=me(e.data);if(e.event==="codex.input_request"||c.method==="item/tool/requestUserInput"){const d=me(c.params),g=(Array.isArray(d.questions)?d.questions:[]).map(m=>{const b=me(m),x=typeof b.question=="string"?b.question:"Please provide the missing information.",S=Array.isArray(b.options)?b.options.map(w=>{const E=me(w);return typeof E.label=="string"?`- ${E.label}${typeof E.description=="string"?`: ${E.description}`:""}`:""}).filter(Boolean).join(`