openpond 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app-server.js +1 -1
- package/dist/chunks/{app-server-runtime-RBWHBX7T.js → app-server-runtime-ZXY5LJRB.js} +1 -1
- package/dist/chunks/chunk-BCXVKU6S.js +2 -0
- package/dist/chunks/{chunk-LFL4M4DL.js → chunk-FMLVT4EZ.js} +1 -1
- package/dist/chunks/{chunk-WDE3KN3N.js → chunk-NZLYYZLO.js} +2 -2
- package/dist/chunks/{chunk-RQLWYR5B.js → chunk-XAZ76RCR.js} +1 -1
- package/dist/chunks/{cli-3LLBTPP5.js → cli-VXFL2WME.js} +1 -1
- package/dist/chunks/{src-KNUCNVBC.js → src-UB37L2XB.js} +1 -1
- package/dist/chunks/{workspaces-ZWG55DFE.js → workspaces-TYFFU3CY.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/web/assets/{App-Dx38Dhlo.js → App-D1U6kSz8.js} +3 -3
- package/dist/web/assets/{AppDialog-DdWbnFnr.js → AppDialog-C_wj-KTH.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-BotH-2y4.js → AppTerminalPanel-GQhALHCi.js} +2 -2
- package/dist/web/assets/{AppsView-B3ybXi71.js → AppsView-Bc5PfPnk.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-CLE27mjT.js → BrowserSidebar-D8Ku-nD-.js} +1 -1
- package/dist/web/assets/{CartesianChart-SB3Jq3CQ.js → CartesianChart-BUEUHUwc.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-C3jO5y5v.js → CollaborationTabs-BTTdhqUf.js} +1 -1
- package/dist/web/assets/{CommandMenu-DqtJane1.js → CommandMenu-BB3412TF.js} +1 -1
- package/dist/web/assets/{CommunityView-Dg02tZmL.js → CommunityView-CaOqCQbn.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-BTJhG8aU.js → ComposerCreateImproveStrip-DKQQF6FT.js} +1 -1
- package/dist/web/assets/{GetStartedView-BlyP6VY8.js → GetStartedView-BLthAuLo.js} +1 -1
- package/dist/web/assets/HostedModelLearningReview--D5Soo61.js +1 -0
- package/dist/web/assets/{HostedModelLearningSettings-CiY2K8Fz.js → HostedModelLearningSettings-xuawAwZ1.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-cE1kuSWk.js → LabModelVersionDetailPage-nA_xJV4H.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-BrSa3H3m.js → LabSkillSidebar-BxaI8xjn.js} +1 -1
- package/dist/web/assets/{LabsRoute-CY7rB25U.js → LabsRoute-I1VgYVSW.js} +4 -4
- package/dist/web/assets/{MainChatThread-BM8l-LiB.js → MainChatThread-0yAFAApw.js} +2 -2
- package/dist/web/assets/{MainPane-CsAYR_EF.js → MainPane-BkK23NmD.js} +4 -4
- package/dist/web/assets/{MarkdownText-8GA7g1qR.js → MarkdownText-CSy6RUzu.js} +1 -1
- package/dist/web/assets/{Messages-CX08x24k.js → Messages-DRnD4ycT.js} +1 -1
- package/dist/web/assets/{NativeSkillSidebar-mSz4GlxA.js → NativeSkillSidebar-0kK4txXY.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-CHAC2Zid.js → NewExperienceSwitcher-CuHFmQZ1.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-5B17C6Vh.js → NewProjectDialog-QMbImvtq.js} +1 -1
- package/dist/web/assets/{OutputsPage-27Gp1K5N.js → OutputsPage-tJQj_C7K.js} +1 -1
- package/dist/web/assets/{ProjectsPage-DJpPuKBP.js → ProjectsPage-CHoeuMVm.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-C_4rbc1i.js → RightChatPanelStack-DdBHknXy.js} +1 -1
- package/dist/web/assets/{RightSidebarHomePanel-PHndCapL.js → RightSidebarHomePanel-DL9VscoI.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-CYQZ0Zal.js → ScheduledWorkPage-DVSk_tz1.js} +1 -1
- package/dist/web/assets/{SettingsView-CAH0vreE.css → SettingsView-CLSg--Vp.css} +1 -1
- package/dist/web/assets/SettingsView-DYXsc8pe.js +9 -0
- package/dist/web/assets/{TeamChatView-DRvqhiOV.js → TeamChatView-BdmLpNJQ.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-C8FbaVVP.js → TerminalOverlay-35INMyIo.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-BGsd95vF.js → TrainingCreationPanel-C4oA23lB.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-Bm6j-IuS.js → TrainingDraftPanel-DajmSUjT.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-CTCDOE-_.js → UsageSettingsSection-4mMW5CCE.js} +1 -1
- package/dist/web/assets/{WorkSidebarPanel-UaymQC_e.js → WorkSidebarPanel-0oh4ApC0.js} +1 -1
- package/dist/web/assets/{WorkspaceDiffPanel-D6mKLQha.js → WorkspaceDiffPanel-BfOdJANp.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-C4Uw5qMA.js → WorkspaceEnvironmentMenu-DCrxjVfu.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs--t9VpTCT.js → WorkspaceGitDialogs-mu5Mr3hW.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-CElU0vIN.js → WorkspaceMonacoEditor-CFC33Waw.js} +3 -3
- package/dist/web/assets/{arrow-up-right-C0HJHPjq.js → arrow-up-right-dJx7maFY.js} +1 -1
- package/dist/web/assets/{chat-file-links-D5q1as_h.js → chat-file-links-BXD1AwPF.js} +1 -1
- package/dist/web/assets/chevron-up-uZmnI2RY.js +1 -0
- package/dist/web/assets/{clipboard-wiphvxrN.js → clipboard-CCJZR-8j.js} +1 -1
- package/dist/web/assets/{cloud-upload-Bgm5_SSr.js → cloud-upload-CYQZw9m5.js} +1 -1
- package/dist/web/assets/{cssMode-DudNT1l3.js → cssMode-CKwxmzPX.js} +1 -1
- package/dist/web/assets/{folder-open-DLuZSDXn.js → folder-open-B9lPxBW0.js} +1 -1
- package/dist/web/assets/{folder-plus-DXN0q9GR.js → folder-plus-DgXtyqTf.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-CdiI4K5M.js → git-commit-horizontal-Cm0tPGvL.js} +1 -1
- package/dist/web/assets/{htmlMode-B2sAXhgB.js → htmlMode-Bwb6JdSr.js} +1 -1
- package/dist/web/assets/{index-DSK9XSir.js → index-Dfsd0LDx.js} +2 -2
- package/dist/web/assets/{info-DcmIP9D3.js → info-BLgd_8Oq.js} +1 -1
- package/dist/web/assets/{jsonMode-aQlrpuz5.js → jsonMode-DoZL4jgt.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-BMskOvs7.js → lspLanguageFeatures-BxirakcU.js} +1 -1
- package/dist/web/assets/{minimize-2-CvKd6Q_r.js → minimize-2-CP-_0nRE.js} +1 -1
- package/dist/web/assets/{monaco.contribution-tZUXzebU.js → monaco.contribution-BTNxSZpZ.js} +2 -2
- package/dist/web/assets/{monaco.contribution-VS3RCwFP.js → monaco.contribution-DHrI3HWL.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BHv_qQG9.js → monaco.contribution-Dxq_7cwt.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BSRllZgB.js → monaco.contribution-pBFeal1v.js} +2 -2
- package/dist/web/assets/{play-BzfQJMmu.js → play-B4cFsEn7.js} +1 -1
- package/dist/web/assets/{python-Bm9eN64d.js → python-DvAyA_jv.js} +1 -1
- package/dist/web/assets/{refresh-cw-Cvy0BqFv.js → refresh-cw-CzkAZOVW.js} +1 -1
- package/dist/web/assets/{save-miVdIz56.js → save-DlPx250u.js} +1 -1
- package/dist/web/assets/{square-DlJ_-dur.js → square-MKAcADT9.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-B8jte8Lm.js → toggleHighContrast-DbcI754Q.js} +1 -1
- package/dist/web/assets/{tsMode-CmAPBzqb.js → tsMode-CgGy_BG2.js} +1 -1
- package/dist/web/assets/{upload-C71OnfRd.js → upload-ZzMzt67j.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-D9hDhAba.js → useLocalAgentSchedules-BgKPG9Lf.js} +1 -1
- package/dist/web/assets/{wifi-off-DhI7P9WW.js → wifi-off-GL_4UdJA.js} +1 -1
- package/dist/web/assets/{workers-BDI2xQio.js → workers-ZMthqdmJ.js} +1 -1
- package/dist/web/assets/{yaml-DNSpZj5_.js → yaml-Czl4Tvh-.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunks/chunk-ADMQIREX.js +0 -2
- package/dist/web/assets/HostedModelLearningReview-BwSAO9y6.js +0 -1
- package/dist/web/assets/SettingsView-DQPMLKNH.js +0 -9
- package/dist/web/assets/chevron-up-B3Cyo8SJ.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-4mMW5CCE.js","./index-Dfsd0LDx.js","./index-C5EoPZr0.css","./App-D1U6kSz8.js","./App-7h_oHCFd.css","./arrow-up-right-dJx7maFY.js","./CartesianChart-BUEUHUwc.js","./UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r,j as e,_ as Sn}from"./index-Dfsd0LDx.js";import{c as je,ay as gs,t as kn,az as fs,aA as Cn,aB as as,X as oe,aC as ls,aD as Ws,aE as Rn,aF as Pn,aG as An,aH as Dn,aI as $n,v as T,aJ as In,P as fe,D as De,aK as En,aL as Vs,aM as On,aN as Qe,aO as Ks,aP as Mn,aQ as Tn,aR as Ln,W as Js,G as Ue,aS as zn,H as Un,Y as Te,h as is,aT as Ze,aU as Fe,af as Bn,C as Hn,aV as Ee,I as Xe,aW as _n,m as Le,aX as re,aY as Fn,aZ as es,a_ as ss,a$ as Ys,b0 as Gn,g as qn,av as Qs,b1 as Wn,ar as xs,B as Vn,f as Zs,b2 as Kn,b3 as Jn,x as Yn,b4 as Qn,U as ns,a6 as Ge,b5 as Ne,aj as Zn,b6 as Xn,b7 as et,b8 as st,b9 as nt,ba as tt,bb as at}from"./App-D1U6kSz8.js";import{R as ae}from"./refresh-cw-CzkAZOVW.js";import{T as ke,P as Xs,B as Be,W as lt,A as it,C as rt}from"./chat-file-links-BXD1AwPF.js";/* empty css */import{S as rs}from"./save-DlPx250u.js";import{F as en}from"./folder-open-B9lPxBW0.js";import{C as ot}from"./chevron-up-uZmnI2RY.js";import{P as sn}from"./play-B4cFsEn7.js";import{B as ct,a as nn,W as dt,S as ut}from"./wifi-off-GL_4UdJA.js";import{R as He,u as ht}from"./useLocalAgentSchedules-BgKPG9Lf.js";import{C as xe}from"./cloud-upload-CYQZw9m5.js";import{G as ze}from"./git-commit-horizontal-Cm0tPGvL.js";import{F as mt}from"./folder-plus-DgXtyqTf.js";import{A as pt}from"./AppDialog-C_wj-KTH.js";import{C as tn,W as gt}from"./WorkspaceDiffPanel-BfOdJANp.js";import"./MarkdownText-CSy6RUzu.js";import"./desktop-files-BQj1J-ob.js";import"./training-model-data-CKOkpBBL.js";import"./info-BLgd_8Oq.js";import"./minimize-2-CP-_0nRE.js";import"./clipboard-CCJZR-8j.js";const ft=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]],xt=je("clipboard-copy",ft);const jt=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],bt=je("eye",jt);const vt=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],yt=je("hard-drive",vt);const Nt=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],pe=je("key-round",Nt);const wt=[["path",{d:"M4.9 16.1C1 12.2 1 5.8 4.9 1.9",key:"s0qx1y"}],["path",{d:"M7.8 4.7a6.14 6.14 0 0 0-.8 7.5",key:"1idnkw"}],["circle",{cx:"12",cy:"9",r:"2",key:"1092wv"}],["path",{d:"M16.2 4.8c2 2 2.26 5.11.8 7.47",key:"ojru2q"}],["path",{d:"M19.1 1.9a9.96 9.96 0 0 1 0 14.1",key:"rhi7fg"}],["path",{d:"M9.5 18h5",key:"mfy3pd"}],["path",{d:"m8 22 4-11 4 11",key:"25yftu"}]],an=je("radio-tower",wt);const St=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],kt=je("rotate-cw",St);const Ct=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Rt=je("sliders-horizontal",Ct);const Pt=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}],["path",{d:"M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662",key:"154egf"}]],js=je("circle-user",Pt);function bs({connection:s,bannerOnly:n=!1,onOpen:a,onSaved:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[h,p]=r.useState(null),[o,g]=r.useState(!1),[m,u]=r.useState(null),[x,v]=r.useState(!1),[N,k]=r.useState(gs);kn(()=>k(gs()));const C=r.useRef(0),S=r.useCallback(async f=>{if(!s)return;const P=++C.current,I=await fs(s,"/v1/configuration",{signal:f});!f?.aborted&&P===C.current&&i(I)},[s]);r.useEffect(()=>{i(null),c(null),p(null),u(null);const f=new AbortController,P=()=>{S(f.signal).catch(O=>{f.signal.aborted||u(String(O))})};P();const I=window.setInterval(P,3e3);return()=>{C.current+=1,f.abort(),window.clearInterval(I)}},[S]);async function R(f,P){if(!(!s||!l)){v(!0),u(null);try{const I=f==="restore"?{action:f,revision:P,expectedRevision:l.rawRevision}:f==="validate"?{action:f,text:d??l.text??`schema_version = 1
|
|
3
|
+
`}:{action:f,text:d??l.text??`schema_version = 1
|
|
4
|
+
`,expectedRevision:h??l.rawRevision};await fs(s,"/v1/configuration",{method:"POST",body:JSON.stringify(I)}),f!=="validate"&&(c(null),p(null),await S(),await t?.()),u(f==="validate"?"Configuration is valid.":"Saved. Changes apply to the next turn.")}catch(I){u(I instanceof Error?I.message:String(I))}finally{v(!1)}}}return!s||n&&!l?.issue&&!N?null:e.jsxs("section",{className:`account-settings configuration-settings ${n?"configuration-banner":""}`,"aria-label":"Configuration",children:[n?null:e.jsxs("header",{children:[e.jsx("h1",{children:"Configuration"}),e.jsx("p",{children:"Manage your settings in one TOML file. The controls below save to the same file; unset an override to inherit its default."})]}),N?e.jsxs("p",{role:"alert",children:[N," ",e.jsx("button",{type:"button",onClick:Cn,children:"Retry saving preferences"})]}):null,l?.issue?e.jsxs("div",{role:"alert",children:[e.jsx("strong",{children:"Configuration needs attention"}),e.jsx("p",{children:l.issue.message}),e.jsx("p",{children:e.jsxs("code",{children:[l.issue.path,l.issue.line?`:${l.issue.line}:${l.issue.column??1}`:""]})}),e.jsxs("p",{children:[l.issue.action," Affected turns are blocked until this is corrected."]}),e.jsx("button",{type:"button",onClick:()=>{n?a?.():g(!0)},children:"Open configuration"})]}):null,n?null:e.jsxs("details",{open:o,onToggle:f=>g(f.currentTarget.open),children:[e.jsx("summary",{children:"Configuration file and sources"}),e.jsx("p",{children:e.jsx("code",{children:l?.path??"Loading…"})}),e.jsx("p",{children:"Unset an override to inherit its default. Changes apply to the next turn; current turns retain their model settings."}),e.jsx("textarea",{"aria-label":"TOML configuration",spellCheck:!1,rows:18,style:{width:"100%",fontFamily:"monospace"},value:d??l?.text??`schema_version = 1
|
|
5
|
+
`,onChange:f=>{d===null&&p(l?.rawRevision??null),c(f.target.value)}}),d!==null&&l?.rawRevision!==h?e.jsx("p",{role:"alert",children:"The file changed elsewhere. Reload before saving your edits."}):null,e.jsxs("div",{className:"configuration-actions",children:[e.jsx("button",{type:"button",disabled:x||!l,onClick:()=>{R("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:x||!l||d!==null&&l.rawRevision!==h,onClick:()=>{R("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:x,onClick:()=>{c(null),p(null),S().catch(f=>u(String(f)))},children:"Reload file"})]}),l?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:x,onChange:f=>{f.target.value&&R("restore",f.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),l.recoverableRevisions.map(f=>e.jsxs("option",{value:f.revision,children:[new Date(f.createdAt).toLocaleString()," · ",f.revision.slice(0,12)]},f.revision))]})]}):null,l?.effective?e.jsxs("details",{children:[e.jsx("summary",{children:"Effective values and sources"}),e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Setting"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Location"})]})}),e.jsx("tbody",{children:Object.entries(l.effective.provenance).map(([f,P])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(f).join(".")}),e.jsx("td",{children:P.layer==="user"?"Set here":`Inherited from ${P.layer}`}),e.jsx("td",{children:P.path})]},f))})]}),e.jsx("pre",{children:JSON.stringify(l.effective.document,null,2)})]}):null]}),m?e.jsx("p",{role:"status",children:m}):null]})}function vs({handle:s,image:n}){const a=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:n?e.jsx("img",{src:n,alt:""}):e.jsx("span",{children:a})})}function qe({state:s,label:n}){return e.jsx("span",{className:`account-state ${s}`,children:n??s.replace("_"," ")})}const ys="https://openpond.ai",Ns="https://api.openpond.ai";function At(s,n){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:n?.handle,currentBaseUrl:n?.baseUrl??null}}function Dt(s,n){return s==="update"&&n?{baseUrl:n.baseUrl??ys,apiBaseUrl:n.apiBaseUrl??Ns,chatApiBaseUrl:n.chatApiBaseUrl,environment:n.environment??"production"}:{baseUrl:ys,apiBaseUrl:Ns,environment:"production"}}function ws({account:s,busy:n,initialApiKey:a="",mode:t="update",onClose:l,onSave:i}){const d=r.useId(),c=t==="connect",[h,p]=r.useState(a),[o,g]=r.useState(null),[m,u]=r.useState(null);as(m),r.useEffect(()=>{p(a),g(null),u(null)},[s?.handle,a]);async function x(v){v.preventDefault(),g(null),u(null);const N=h.trim();if(c&&!N){g("API key is required.");return}try{const k=At(t,s),C=Dt(t,s);await i({...k,...C,apiKey:c?N:void 0})}catch(k){u(k instanceof Error?k.message:String(k))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&!n&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":d,onSubmit:v=>{x(v)},children:[e.jsx("button",{className:"git-dialog-close",disabled:n,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(oe,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(pe,{size:18}):e.jsx(ls,{size:18})}),e.jsx("h2",{id:d,children:c?"Add account":"Account environment"}),c?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):e.jsx("p",{children:"Update the web and API endpoints used by this account."}),c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:n,placeholder:"opk_...",type:"password",value:h,onChange:v=>p(v.target.value)})]}):null,o?e.jsx("div",{className:"profile-dialog-warning",children:o}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:n,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:n,type:"submit",children:[e.jsx(rs,{size:14}),e.jsx("span",{children:n?"Saving":c?"Connect account":"Update account"})]})]})]})})}const $t="Changing the active OpenPond account rechecks cloud projects, hosted agents, default team, and profile sync for that account. Local projects stay on this machine; projects uploaded from another account will need to be synced again for this account.";function It({payload:s,connection:n,saving:a,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:d,removeAccount:c,onPayload:h,onPreferences:p,onError:o,onToast:g}){const m=s?.account,u=m?.state??"loading",x=u==="signed_in",v=u==="signed_out",N=u==="auth_error",k=m?.email?.trim()||null,C=m?.accounts??[],[S,R]=r.useState([]),[,f]=r.useState(!1),[P,I]=r.useState(null),[O,j]=r.useState(null),[w,y]=r.useState(null),[b,z]=r.useState(null),[H,_]=r.useState(!1),[V,Z]=r.useState(null),[E,K]=r.useState(null),[U,ee]=r.useState(!1),{confirmAction:Y,confirmDialog:ce,resolveConfirmDialog:F}=Ws(),B=C.find($=>$.isActive)??C[0]??null,Q=s?.preferences.defaultTeamId?.trim()||null,te=w??Q,le=Rn(m),de=s?.accountMeta.asOf??"",X=be(m?.environment,B?.environment),se=x?be(B?.displayLabel,B?.handle,m?.label,m?.activeProfile?.handle,"Signed in"):N?"Account needs attention":v?"No account connected":"Loading account",ue=x?k??Ss(X):N?"Not connected":v?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",he=C.length>0,ie=N?Et(m?.error):null,D=r.useMemo(()=>S.filter($=>$.status==="active"),[S]),L=(r.useMemo(()=>te?D.find($=>$.teamId===te)??null:null,[D,te])??Pn(D))?.teamId??"",J=r.useMemo(()=>D.map($=>({value:$.teamId,label:be($.displayName,$.name,$.slug,"Team"),description:An($.role)})),[D]),W=L||J[0]?.value||"",Ae=J.length>0,pn=!n||!!O||!!P||D.length===0,ds=b?We(b):null,us=!!(ds&&V===ds),gn=x||N,fn=be(E?.version,s?.server.version,"Loading"),hs=E?E.devMode?"Dev mode":E.packaged?`${Lt(E.releaseChannel)} build`:"Local build":null,ms=Mt(be(B?.baseUrl,m?.activeProfile?.baseUrl,m?.baseUrl,"https://openpond.ai"));r.useEffect(()=>{const $=window.openpond?.getDesktopRuntimeInfo;if(!$)return;let q=!1;return $().then(G=>{q||K(G)}).catch(()=>{q||K(null)}),()=>{q=!0}},[]),r.useEffect(()=>{if(!n||!le){R([]),I(null),f(!1);return}let $=!1;const q=Dn(le);return q?(R(q),f(!1)):(R([]),f(!0)),I(null),$n({accountKey:le,force:!!de,fetchOrganizations:async()=>(await T.organizations(n)).organizations.map(In).filter(ne=>!!ne).filter(ne=>ne.status==="active")}).then(G=>{$||R(G)}).catch(G=>{$||(q||R([]),I(G instanceof Error?G.message:String(G)))}).finally(()=>{$||f(!1)}),()=>{$=!0}},[de,n,le]),r.useEffect(()=>{w&&Q===w&&y(null)},[Q,w]);async function xn($,q={notify:!0}){const G=D.find(ne=>ne.teamId===$)??null;if(!(!n||!G||O||(w??Q)===G.teamId)){y(G.teamId),j(G.teamId),o(null),On({teamId:G.teamId,accountKey:le,force:!0,fetchAgents:async ne=>(await T.listSandboxAgents(n,{teamId:ne})).agents}).catch(()=>{});try{p(await T.savePreferences(n,{defaultTeamId:G.teamId})),q.notify&&g?.("Default team updated","success")}catch(ne){y(null),o(ne instanceof Error?ne.message:String(ne))}finally{j(null)}}}async function _e($="Continue"){return gn?Y({title:"Change active OpenPond account?",body:$t,confirmLabel:$,cancelLabel:"Cancel"}):!0}async function jn($){await _e("Save account")&&(await l({apiKey:$.apiKey??"",handle:$.handle,baseUrl:$.baseUrl,apiBaseUrl:$.apiBaseUrl,environment:$.environment}),_(!1))}async function bn($){if(!n||!b)throw new Error("OpenPond server connection is not ready.");if(b.isActive&&!await _e("Save endpoints"))return;const q=We(b);Z(q),o(null);try{const G=await T.updateOpenPondAccountConfig(n,{handle:$.handle??b.handle,currentBaseUrl:$.currentBaseUrl,baseUrl:$.baseUrl,apiBaseUrl:$.apiBaseUrl,chatApiBaseUrl:$.chatApiBaseUrl,environment:Ot($.environment),setActive:b.isActive});h(G),g?.("Account endpoints updated","success"),z(null)}catch(G){throw o(G instanceof Error?G.message:String(G)),G}finally{Z(null)}}async function vn($){const q=$.handle?.trim()||"";q&&await _e("Switch account")&&await d(q,$.baseUrl)}async function yn($){const q=$.handle?.trim()||"";if(!q||$.isActive)return;const G=be($.displayLabel,$.email,$.handle,"this account");await Y({title:"Remove saved account?",body:`Remove ${G} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await c(q,$.baseUrl)&&g?.("Account removed","success")}async function Nn(){const $=window.openpond?.reloadDesktopApp;if(!(!$||U)){ee(!0),o(null);try{const q=await $();if(!q.ok)throw new Error(q.error??"OpenPond could not refresh the app.")}catch(q){ee(!1),o(q instanceof Error?q.message:String(q))}}}async function wn(){const $=window.openpond?.browser;$?.openExternal&&(await $.openExternal({conversationId:"openpond-account-sign-up",url:ms})).ok||window.open(ms,"_blank","noopener,noreferrer")}return e.jsxs("section",{className:"account-settings",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsx("h1",{children:"Account"}),e.jsxs("div",{className:"account-settings-title-actions",children:[e.jsxs("button",{className:"settings-secondary compact account-add-action",disabled:!n||a,type:"button",onClick:()=>_(!0),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!n||a||t,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(ae,{size:15,className:t?"settings-spin":void 0})})]})]}),e.jsxs("div",{className:"account-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx(vs,{handle:se,image:x?m?.avatarUrl??B?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:se}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:x&&k?"private-account-email":x?void 0:"account-summary-copy",tabIndex:x&&k?0:void 0,children:ue}),x&&Ae?e.jsx(De,{className:"account-team-dropdown",compact:!0,disabled:pn,label:"Default team",options:J,value:W,onChange:$=>{xn($)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(qe,{state:u,label:v?"not signed in":void 0})})]}),he?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"OpenPond accounts"}),e.jsxs("small",{children:[C.length," account",C.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),C.map($=>{const q=$.handle?.trim()||"",G=be($.displayLabel,$.handle,"Unknown account"),ne=$.email?.trim()||null,ps=We($);return e.jsxs("div",{className:"account-row",children:[e.jsx(vs,{handle:G,image:$.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:G}),ne?e.jsx("span",{className:"private-account-email",tabIndex:0,children:ne}):null,e.jsx("span",{children:Ss($.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(qe,{state:$.authHealth}),$.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!n||a||!!V||!q,type:"button","aria-label":`Configure ${G} environment`,title:"Configure account environment",onClick:()=>z($),children:e.jsx(ls,{size:15})}),$.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!q,type:"button",onClick:()=>{vn($)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!q,type:"button","aria-label":`Remove ${G}`,title:`Remove ${G}`,onClick:()=>{yn($)},children:e.jsx(ke,{size:13})})]})]})]},ps)})]}):null,m?.products&&m.products.length>0&&e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Products"}),e.jsxs("small",{children:[m.products.length," active"]})]}),m.products.map($=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:$.name}),e.jsx("span",{children:$.type})]}),e.jsx(qe,{state:$.status})]},$.id))]}),e.jsxs("div",{className:"settings-footnote account-build-footnote",children:[e.jsxs("div",{className:"account-build-details",children:[e.jsx("span",{children:"Build version"}),e.jsxs("div",{className:"account-build-version",children:[e.jsx("strong",{children:Tt(fn)}),hs?e.jsx("span",{className:`account-build-context${E?.devMode?" development":""}`,children:hs}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[E?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:U,type:"button",title:"Reload the local Electron app",onClick:()=>{Nn()},children:[e.jsx(ae,{className:U?"settings-spin":void 0,size:14}),e.jsx("span",{children:U?"Refreshing":"Refresh app"})]}):null,x?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{wn()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(En,{size:13})]})]})]}),ie?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:ie})]}):null,b?e.jsx(ws,{account:b,busy:us,onClose:()=>{us||z(null)},onSave:bn}):null,H?e.jsx(ws,{busy:a,mode:"connect",onClose:()=>{a||_(!1)},onSave:jn}):null,e.jsx(Vs,{state:ce,onResolve:F})]})}function We(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function be(...s){for(const n of s){const a=n?.trim();if(a)return a}return""}function Et(s){const n=s?.trim();if(!n)return null;const a=n.toLowerCase();return a.includes("protected deployment")?"OpenPond could not reach the account service. Restart and try again.":a.includes("unexpected token '<'")||a.includes("<!doctype")?"OpenPond received a web login page instead of account data. Restart and try again.":a.includes("401")||a.includes("unauthorized")||a.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":n.length>220?`${n.slice(0,217)}...`:n}function Ss(s){const n=s.trim().toLowerCase();return!n||n==="production"?"Production":"Environment"}function Ot(s){const n=s?.trim();return!n||n.toLowerCase()==="production"?"custom":n}function Mt(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function Tt(s){const n=s.trim();return!n||n==="Loading"?"Loading":n.startsWith("v")?n:`v${n}`}function Lt(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function zt({advancedWorkspaceControls:s,defaultBranchPrefix:n,defaultNewProjectDirectory:a,preferences:t,saving:l,steerActiveResponses:i,chooseDefaultProjectDirectory:d,saveDefaults:c,setAdvancedWorkspaceControls:h,setSteerActiveResponses:p,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:g}){const m=Qe(n)===t.defaultBranchPrefix&&a.trim()===t.defaultNewProjectDirectory&&s===t.advancedWorkspaceControls&&i===t.steerActiveResponses;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h2",{children:"General"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{c(u)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:i,disabled:l,onChange:u=>p(u.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Steer active responses"}),e.jsx("small",{children:"Send a new message into the active response immediately. Turn this off to queue it instead."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:u=>h(u.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Show advanced Git controls"}),e.jsx("small",{children:"Show branch, commit, and push controls for local project workflows."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Git branches"}),e.jsx("small",{children:"Used for advanced and non-managed branch creation"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Branch prefix"}),e.jsx("input",{value:n,disabled:l,placeholder:"feat/",onChange:u=>o(u.target.value)})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Projects"}),e.jsx("small",{children:"Used when starting a new local project from scratch"})]}),e.jsxs("div",{className:"settings-path-row",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"New project directory"}),e.jsx("input",{value:a,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:u=>g(u.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{d()},children:[e.jsx(en,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||m,children:e.jsx("span",{children:l?"Saving":"Save settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Qe(n),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||t.defaultNewProjectDirectory})]})]})}function Ut({diagnostics:s,diagnosticsAvailable:n,diagnosticsBusy:a,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:d,logViewBusy:c,logViewSummary:h,logViewportRef:p,tailLogs:o,copyRecentLogs:g,exportDiagnosticsBundle:m,loadOlderLogs:u,openLogsFolder:x,refreshLogView:v,toggleTailLogs:N}){const k=s.filter(S=>S.name==="diagnostic"&&S.status==="failed").slice().reverse().map(Bt),C=typeof window>"u"?void 0:window.openpond;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Diagnostics"}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Recent errors"}),e.jsxs("small",{children:[k.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:k.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):k.map(S=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Ks,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:S.message}),e.jsx("time",{dateTime:S.timestamp,children:S.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:S.surface}),S.status?e.jsx("span",{children:S.status}):null,S.sequence?e.jsxs("span",{children:["#",S.sequence]}):null]}),S.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:S.detail})]}):null]})]},S.id))})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Logs"}),e.jsx("small",{children:n?"Desktop":"Unavailable"})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Logs folder"}),e.jsx("span",{children:"Desktop and server logs"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.openLogsFolder,onClick:()=>{x()},children:[e.jsx(en,{size:15}),e.jsx("span",{children:a==="logs"?"Opening":"Open"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Diagnostics export"}),e.jsx("span",{children:"Support folder with diagnostics.txt"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.exportDiagnostics,onClick:()=>{m()},children:[e.jsx(Mn,{size:15}),e.jsx("span",{children:a==="export"?"Exporting":"Export"})]})]}),e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Recent logs"}),e.jsx("span",{children:"Last 1000 lines to clipboard"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!C?.copyRecentLogs,onClick:()=>{g()},children:[e.jsx(xt,{size:15}),e.jsx("span",{children:a==="copy"?"Copying":"Copy"})]})]})]}),e.jsxs("div",{className:"diagnostics-log-panel",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Log view"}),e.jsxs("div",{className:"settings-heading-actions diagnostics-log-actions",children:[e.jsx("small",{children:h}),e.jsx("button",{type:"button",className:`settings-icon-button ${o?"active":""}`,title:o?"Pause tail":"Tail logs","aria-label":o?"Pause tail":"Tail logs",disabled:!C?.readRecentLogs,onClick:N,children:o?e.jsx(Xs,{size:15}):e.jsx(sn,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!C?.readRecentLogs,onClick:()=>{v(i,"refresh")},children:e.jsx(ae,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!C?.readRecentLogs,onClick:u,children:[e.jsx(ot,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:p,className:"diagnostics-log-viewer",role:"log","aria-live":o?"polite":"off",children:d.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):d.map((S,R)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:S.file}),e.jsx("code",{children:S.line})]},`${S.file}:${S.timestamp}:${S.index}:${R}`))}),l&&e.jsxs("div",{className:"diagnostics-log-dir",children:[e.jsx("span",{children:"Source"}),e.jsx("strong",{children:l})]})]}),t&&e.jsxs("div",{className:`settings-footnote ${t.warning?"warning":""}`,children:[e.jsx("span",{children:t.label}),e.jsx("strong",{children:t.value})]})]})}function Bt(s){const n=ks(s.data),a=ks(n.context),l=ge(n.stack)??ge(n.detail)??ge(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:_t(s.timestamp),message:Ht(s,n),surface:ge(n.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function Ht(s,n){return ge(s.error)??ge(s.output)??ge(n.message)??ge(n.error)??"Diagnostic event"}function _t(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function ks(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function ge(s){return typeof s=="string"&&s.trim()?s.trim():null}const Cs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Ft({editorPreferences:s,lspStatus:n,preferences:a,restarting:t,saving:l,statusLoading:i,refreshLspStatus:d,restartLanguageServers:c,saveEditorSettings:h,setEditorPreferences:p,setLanguageCustomCommand:o,setLanguageMode:g}){const m=JSON.stringify(s)!==JSON.stringify(a.editor),u=new Map(n?.languages.map(x=>[x.language,x])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:x=>{h(x)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Language servers"}),e.jsx("small",{children:"Local tools"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Language servers"}),e.jsx(De,{value:s.languageServers,disabled:l,label:"Language servers",options:Tn,onChange:x=>p(v=>({...v,languageServers:x}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:x=>p(v=>({...v,diagnosticsWhileEditing:x.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Diagnostics while editing"}),e.jsx("small",{children:"Update Monaco markers as the local buffer changes."})]})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.checkOnSave,disabled:l||s.languageServers==="off",onChange:x=>p(v=>({...v,checkOnSave:x.target.checked}))}),e.jsxs("span",{children:[e.jsx("strong",{children:"Check on save"}),e.jsx("small",{children:"Refresh diagnostics after writing a file."})]})]}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Languages"}),e.jsx("small",{children:"Auto, disabled, or custom executable"})]}),e.jsx("div",{className:"lsp-language-list",children:Cs.map(x=>{const v=s.languages[x.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:x.label}),e.jsx("span",{children:Rs(u.get(x.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(De,{value:v.mode,disabled:l||s.languageServers==="off",label:`${x.label} language server mode`,options:Ln,onChange:N=>g(x.id,N)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:v.customCommand,disabled:l||s.languageServers==="off"||v.mode!=="custom",placeholder:x.placeholder,onChange:N=>o(x.id,N.target.value)})]})]},x.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!m,children:e.jsx("span",{children:l?"Saving":"Save editor settings"})})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"LSP status"}),e.jsxs("div",{className:"settings-heading-actions",children:[e.jsx("small",{children:i?"Checking":n?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:i||t,onClick:()=>{d()},children:e.jsx(ae,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{c()},children:[e.jsx(kt,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),Cs.map(x=>{const v=u.get(x.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:x.label}),e.jsx("span",{title:v?.command??v?.message??void 0,children:v?.command??v?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${v?.status??"missing"}`,children:Rs(v,i)})]},x.id)})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Project config"}),e.jsx("strong",{children:"Uses tsconfig, pyrightconfig, pyproject, and Cargo files when present"})]})]})}function Rs(s,n){return n&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function Ps({contextCompactionAutoEnabled:s,embedded:n=!1,preferences:a,saving:t,saveDefaults:l,setContextCompactionAutoEnabled:i}){return e.jsxs("section",{className:`account-settings${n?" account-settings-embedded":""}`,children:[n?e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Context"}),e.jsx("small",{children:"Compaction defaults for long chats"})]}):e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:d=>{l(d)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Compaction"}),e.jsx("small",{children:"Controls automatic compaction for long OpenPond and BYOK chats"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:t,onChange:d=>i(d.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Auto compact long chats"}),e.jsx("small",{children:"Summarize older turns at 85% context before the selected model runs out. The transcript stays visible."})]})]}),e.jsx("button",{className:"settings-primary",disabled:t||s===a.contextCompaction.autoEnabled,children:e.jsx("span",{children:t?"Saving":"Save context"})})]})]})}function Gt({subagentsEnabled:s,subagentDelegationMode:n,subagentsUseDefaultModel:a,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:d,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:h,preferences:p,providers:o,saving:g,saveDefaults:m,changeSubagentsProvider:u,setSubagentsEnabled:x,setSubagentDelegationMode:v,setSubagentsUseDefaultModel:N,setSubagentsModel:k,setSubagentsMaxConcurrentRuns:C,setSubagentsMaxConcurrentRunsPerProvider:S,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:R,setSubagentRoleEnabled:f,setSubagentRoleIsolationMode:P,setSubagentRoleMaxConcurrentRuns:I,setSubagentRoleModel:O,setSubagentRolePeerMessages:j,setSubagentRoleToolPolicy:w,changeSubagentRoleProvider:y}){const b=Js(o,{enabledOnly:!0}),z=a?p.defaultChatProvider:t,H=a?p.defaultChatModel:l,_=ln(Ue(z,o),H),V=a?null:{providerId:t,modelId:l.trim()},Z=Jt({enabled:s,delegationMode:n,defaultModelRef:V,roles:i,maxConcurrentRuns:d,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:h},p);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:E=>{m(E)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Agents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${Z?"":" dirty"}`,disabled:g||Z,children:e.jsx("span",{children:g?"Saving":"Save agents"})}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":"Allow subagents",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:g,onChange:E=>x(E.target.checked)}),e.jsx("span",{})]})]})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Default delegation"}),e.jsx("small",{children:"Used unless a task overrides it from the composer."})]})}),e.jsx("div",{className:"subagent-field-grid two",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Subagent use"}),e.jsxs("select",{value:n,disabled:g||!s,onChange:E=>v(E.target.value),children:[e.jsx("option",{value:"manual",children:"Manual"}),e.jsx("option",{value:"balanced",children:"Balanced"}),e.jsx("option",{value:"proactive",children:"Proactive"})]})]})})]}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsx("div",{children:e.jsx("span",{children:"Default model"})})}),e.jsxs("div",{className:"subagent-field-grid two",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Provider"}),e.jsx("select",{value:z,disabled:g||!s,onChange:E=>{N(!1),u(E.target.value)},children:b.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:H,disabled:g||!s,onChange:E=>{N(!1),k(E.target.value)},children:_.map(E=>e.jsx("option",{value:E.value,children:E.label},E.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(E=>{const K=zn.find(B=>B.id===E.id),U=E.modelRef?.providerId??z,ee=E.modelRef?.modelId||Un(U,o)||H,Y=Kt(b,o,{providerId:U,modelId:ee}),ce=Me(U,ee),F=g||!s||!E.enabled;return e.jsxs("section",{className:`subagent-role-row${E.enabled?"":" disabled"}`,children:[e.jsxs("div",{className:"subagent-settings-card-header subagent-role-header",children:[e.jsxs("div",{className:"subagent-role-title",children:[e.jsx("span",{children:K?.label??E.id}),e.jsx("small",{children:K?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${K?.label??E.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:E.enabled,disabled:g||!s,onChange:B=>f(E.id,B.target.checked)}),e.jsx("span",{})]})]}),e.jsxs("div",{className:"subagent-role-controls",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:ce,disabled:F,onChange:B=>{const Q=Y.find(te=>te.value===B.target.value);Q&&(y(E.id,Q.providerId),O(E.id,Q.modelId))},children:Y.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:E.isolationMode,disabled:F,onChange:B=>P(E.id,B.target.value),children:qt.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:E.toolPolicy,disabled:F,onChange:B=>w(E.id,B.target.value),children:Wt.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:E.peerMessages,disabled:F,onChange:B=>j(E.id,B.target.value),children:Vt.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))})]})]}),e.jsx("div",{className:"subagent-role-budget-grid",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Role concurrency"}),e.jsx("input",{type:"number",min:1,max:16,value:E.maxConcurrentRuns,disabled:F,onChange:B=>I(E.id,As(B.target.value,1))})]})})]},E.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:d,disabled:g||!s,onChange:E=>C(As(E.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:g||!s,onChange:E=>S(ts(E.target.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per workspace"}),e.jsx("input",{type:"number",min:1,max:32,value:h??"",placeholder:"No cap",disabled:g||!s,onChange:E=>R(ts(E.target.value))})]})]})]})]})})}const qt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Wt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Vt=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function ln(s,n){const a=n.trim();return!a||s.some(t=>t.value===a)?s:[{value:a,label:a},...s]}function Me(s,n){return JSON.stringify([s,n])}function Kt(s,n,a){const t=[];for(const l of s){const i=ln(Ue(l.value,n),l.value===a.providerId?a.modelId:"");for(const d of i)t.push({value:Me(l.value,d.value),label:`${l.label} / ${d.label}`,providerId:l.value,modelId:d.value})}return a.modelId&&!t.some(l=>l.value===Me(a.providerId,a.modelId))&&t.unshift({value:Me(a.providerId,a.modelId),label:`${Te(a.providerId,n)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),t}function ts(s){const n=s.trim();if(!n)return null;const a=Number(n);return Number.isFinite(a)?a:null}function As(s,n){return ts(s)??n}function Jt(s,n){const a=n.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Yt(s.defaultModelRef,a.defaultModelRef)&&s.maxConcurrentRuns===a.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===a.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===a.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(a.roles)}function Yt(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Qt=[{mode:"all",label:"All new messages",detail:"Show an in-app alert for every Team Chat message."},{mode:"direct_mentions",label:"Direct messages and mentions",detail:"Show alerts for direct messages and messages that mention you."},{mode:"none",label:"Nothing",detail:"Keep unread counts without showing message alerts."}];function Zt({currentUserId:s,enabled:n,mode:a,threads:t,onModeChange:l,onThreadMuteChange:i}){const[d,c]=r.useState(null),[h,p]=r.useState(null);as(h);const o=r.useMemo(()=>t.filter(u=>u.archivedAt===null).map(u=>({thread:u,label:Xt(u,s)})).sort((u,x)=>{const v=+!!x.thread.mutedAt-+!!u.thread.mutedAt;return v!==0?v:u.label.localeCompare(x.label)}),[s,t]),g=o.filter(({thread:u})=>!!u.mutedAt).length,m=r.useCallback(async u=>{c(u.id),p(null),await i(u.id,!u.mutedAt)||p("Could not update this conversation. Try again."),c(null)},[i]);return e.jsxs("section",{className:"account-settings notifications-settings",children:[e.jsx("h1",{children:"Notifications"}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Team chat notifications"}),e.jsx("small",{children:"In-app alerts"})]}),e.jsx("div",{className:"notification-mode-list",role:"radiogroup","aria-label":"Notify me about",children:Qt.map(u=>e.jsxs("label",{className:`notification-mode-option${a===u.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===u.mode,onChange:()=>l(u.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:u.label}),e.jsx("small",{children:u.detail})]})]},u.mode))})]}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Conversation overrides"}),e.jsx("small",{children:g===1?"1 muted":`${g} muted`})]}),n?o.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):o.map(({thread:u,label:x})=>{const v=!!u.mutedAt,N=d===u.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${v?" muted":""}`,children:v?e.jsx(ct,{size:15}):e.jsx(nn,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:x}),e.jsx("small",{children:v?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:d!==null,onClick:()=>{m(u)},children:N?"Saving":v?"Unmute":"Mute"})]},u.id)}):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Connect a team to manage conversation overrides."})})]}),e.jsx("div",{className:"settings-footnote",children:e.jsx("span",{children:"Muted conversations never show alerts. Unread counts remain available."})})]})}function Xt(s,n){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(a=>a.userId!==n)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(a=>a.userId!==n).map(a=>a.name).join(", ")||"Group conversation"}function ea({canSaveCurrentTemplate:s,personalizationTemplateId:n,personalizationTemplateOptions:a,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:d,soulDraft:c,templateNameDraft:h,changePersonalizationTemplate:p,changeSoulDraft:o,openSaveAsNew:g,resetPersonalizationDraft:m,savePersonalization:u,setSaveAsNewOpen:x,setTemplateNameDraft:v}){function N(k){k.preventDefault(),u(t)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:N,children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agent style"}),e.jsx("div",{className:"settings-heading-actions",children:t?e.jsxs(e.Fragment,{children:[e.jsx("input",{className:"settings-heading-input",value:h,onChange:k=>v(k.target.value),placeholder:"Name","aria-label":"Template name"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Cancel","aria-label":"Cancel",disabled:l,onClick:()=>x(!1),children:e.jsx(oe,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!c.trim()||!h.trim(),onClick:()=>{u(!0)},children:e.jsx(is,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:d?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:l||!i||!c.trim(),onClick:g,children:e.jsx(fe,{size:15})})]})})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Template"}),e.jsx(De,{value:n,disabled:l||a.length===0,label:"Personalization template",options:a,onChange:k=>{p(k)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:k=>o(k.target.value),spellCheck:!1})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Reset to template","aria-label":"Reset to template",disabled:l||!i,onClick:m,children:e.jsx(He,{size:15})}),d&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(rs,{size:15})})]})]})]})}function sa({connection:s,profile:n,selectedDefaultTeamId:a}){const t=ht(s),l=aa(t.schedules);return as(t.error,{prefix:"Local schedules"}),e.jsxs("div",{className:"account-list profile-agent-list","aria-label":"Profile agents",children:[e.jsx("div",{className:"account-list-heading profile-agent-list-heading",children:e.jsx("span",{children:"Agents"})}),e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-agent-table","aria-label":"Profile agents table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-agent-column"}),e.jsx("col",{className:"profile-action-column"}),e.jsx("col",{className:"profile-check-column"}),e.jsx("col",{className:"profile-sync-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Agent"}),e.jsx("th",{scope:"col",children:"Action"}),e.jsx("th",{scope:"col",children:"Check"}),e.jsx("th",{scope:"col",children:"Sync"})]})}),e.jsxs("tbody",{children:[l.active.map(i=>e.jsx(Ds,{pending:t.pendingScheduleIds.has(i.id),schedule:i,refreshing:t.loading,onRefresh:()=>{t.refresh()},onRun:()=>{t.run(i)},onToggle:()=>{t.toggle(i)}},i.id)),e.jsx(na,{}),n.agents.map(i=>e.jsx(ta,{agent:i,defaultAction:n.summary.defaultAction,profile:n,selectedDefaultTeamId:a},i.id)),l.paused.map(i=>e.jsx(Ds,{pending:t.pendingScheduleIds.has(i.id),schedule:i,refreshing:t.loading,onRefresh:()=>{t.refresh()},onRun:()=>{t.run(i)},onToggle:()=>{t.toggle(i)}},i.id))]})]})})]})}function na(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset Builder"}),e.jsx("span",{children:"Built in · every Profile"})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:"Design · Materialize · Test"})})}),e.jsx("td",{children:e.jsx($e,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx($e,{status:{state:"ready",label:"Built in"}})})]})}function ta({agent:s,defaultAction:n,profile:a,selectedDefaultTeamId:t}){const l=ra(a,s,t);return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsx("span",{title:s.path,children:s.path})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{children:n??"None"})})}),e.jsx("td",{children:e.jsx($e,{status:l.check})}),e.jsx("td",{children:e.jsx($e,{status:l.sync})})]})}function Ds({pending:s,refreshing:n,schedule:a,onRefresh:t,onRun:l,onToggle:i}){const d=la(a),c=a.enabled?"Pause schedule":"Resume schedule";return e.jsxs("tr",{className:"profile-agent-row profile-schedule-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Be,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.localProjectName}),e.jsxs("span",{title:a.scheduleName,children:["schedule: ",a.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:a.targetAction,children:a.targetAction})})}),e.jsx("td",{children:e.jsx($e,{status:d})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:ia(a),children:a.enabled?a.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${a.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:n,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:t,children:e.jsx(ae,{size:14,className:n?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${a.scheduleName} now`,onClick:l,children:e.jsx(He,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(Xs,{size:14}):e.jsx(sn,{size:14})})]})]})})]})}function $e({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function aa(s){const n=[],a=[];for(const t of s)t.enabled?n.push(t):a.push(t);return n.sort((t,l)=>$s(t)-$s(l)),{active:n,paused:a}}function $s(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function la(s){return s.enabled?s.lastError||s.lastRunStatus==="failed"?{state:"warning",label:"Failed"}:s.lastRunStatus==="running"?{state:"loading",label:"Running"}:s.lastRunStatus==="queued"?{state:"loading",label:"Queued"}:s.lastRunStatus==="skipped"?{state:"warning",label:"Skipped"}:s.lastRunStatus==="succeeded"?{state:"ready",label:"Succeeded"}:{state:"loading",label:"Scheduled"}:{state:"disabled",label:"Paused"}}function ia(s){const n=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&n.push(`next ${Is(s.nextRunAt)}`),s.lastRunAt&&n.push(`last ${Is(s.lastRunAt)}`),n.join(" - ")}function Is(s){const n=new Date(s);return Number.isFinite(n.getTime())?n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function ra(s,n,a){if(!n.enabled)return{check:{state:"disabled",label:"Disabled"},sync:{state:"disabled",label:"Disabled"}};if(s.error)return{check:{state:"warning",label:"Error"},sync:{state:"warning",label:"Blocked"}};if(s.setupGate.blockingCount>0)return{check:{state:"warning",label:"Setup"},sync:{state:"warning",label:"Blocked"}};if(s.git?.dirty||ca(s,n)>0)return{check:{state:"loading",label:"Pending"},sync:{state:"warning",label:"Changed"}};if(s.catalog.stale)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(!s.lastCheck)return{check:{state:"loading",label:"Unchecked"},sync:{state:"loading",label:"Waiting"}};if(s.lastCheck.status==="failed")return{check:{state:"warning",label:"Failed"},sync:{state:"warning",label:"Blocked"}};if(!s.summary.checkFresh)return{check:{state:"loading",label:"Stale"},sync:{state:"loading",label:"Waiting"}};if(oa(s,a))return{check:{state:"ready",label:"Passed"},sync:{state:"warning",label:"Sync acct"}};const t=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null;return!(s.summary.hostedHead??s.hosted?.sourceCommitSha??null)&&!l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Not synced"}}:t&&l&&t!==l?{check:{state:"ready",label:"Passed"},sync:{state:"loading",label:"Needed"}}:{check:{state:"ready",label:"Passed"},sync:{state:"ready",label:"Synced"}}}function oa(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}function ca(s,n){let a=0;s.diff.changedAgents.includes(n.id)&&(a+=1),s.diff.newAgents.includes(n.id)&&(a+=1),s.diff.deletedAgents.includes(n.id)&&(a+=1);const t=n.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===t||i.startsWith(`${t}/`)||i.startsWith(`agents/${n.id}/`))&&(a+=1)}return a}async function da(s){const n=s.catalog.workflows.find(l=>l.workflow.id===s.workflowId);if(!n)throw new Error("Selected Profile workflow is unavailable.");const a=s.client??T,t=await a.createSession(s.connection,{experience:"work",provider:"openpond",currentProfile:s.catalog.profileRef,profileWorkflowBinding:n.binding,title:n.workflow.label});return await a.sendTurn(s.connection,t.id,{prompt:n.workflow.label,workflowInput:s.value,approvalPolicy:"on-request",sandbox:"workspace-write",codexPermissionMode:"default"}),t.id}function ua({connection:s,selectedProfileKey:n,onError:a,onOpenSession:t,onToast:l}){const[i,d]=r.useState(null),[c,h]=r.useState(!1),[p,o]=r.useState(null),[g,m]=r.useState("{}"),[u,x]=r.useState(!1),[v,N]=r.useState(null);r.useEffect(()=>{if(!s||!n){d(null);return}let S=!0;return h(!0),d(null),o(null),N(null),T.profileWorkflows(s).then(R=>{S&&d(R)}).catch(R=>{S&&N(R instanceof Error?R.message:String(R))}).finally(()=>{S&&h(!1)}),()=>{S=!1}},[s,n]);const k=i?.workflows.find(S=>S.workflow.id===p);async function C(S){if(S.preventDefault(),!s||!i||!k||u)return;let R;try{R=JSON.parse(g)}catch{N("Workflow input must be valid JSON.");return}x(!0),N(null),a(null);try{const f=await da({connection:s,catalog:i,workflowId:k.workflow.id,value:R});t?.(f),l?.(`Started ${k.workflow.label}`,"success"),o(null),m("{}")}catch(f){const P=f instanceof Error?f.message:String(f);N(P),a(P)}finally{x(!1)}}return n?e.jsxs("section",{"aria-label":"Profile workflows",className:"profile-workflows",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Workflows"}),e.jsx("p",{children:"Run a workflow from this Profile’s released source."})]}),c?e.jsx("p",{children:"Loading workflows…"}):null,v?e.jsx("p",{role:"alert",children:v}):null,i&&i.workflows.length===0?e.jsx("p",{children:"No workflows in this Profile yet."}):null,i?.workflows.map(S=>e.jsxs("div",{className:"profile-workflows-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:S.workflow.label}),e.jsx("p",{children:S.workflow.description}),e.jsxs("small",{children:["Source ",S.binding.sourceRevision.slice(0,10)," · release ",S.binding.harnessRelease.contentHash.slice(0,10)]})]}),e.jsx("button",{disabled:u,onClick:()=>{N(null),m("{}"),o(S.workflow.id)},type:"button",children:"Run"})]},S.workflow.id)),k?e.jsxs("form",{className:"profile-workflows-form",onSubmit:C,children:[e.jsxs("h4",{children:["Run ",k.workflow.label]}),e.jsx("label",{htmlFor:"profile-workflow-input",children:"Input JSON"}),e.jsx("textarea",{id:"profile-workflow-input",onChange:S=>m(S.target.value),value:g}),e.jsx("pre",{children:JSON.stringify(k.workflow.inputSchema,null,2)}),e.jsx("button",{disabled:u,type:"submit",children:u?"Starting…":"Start workflow"}),e.jsx("button",{disabled:u,onClick:()=>o(null),type:"button",children:"Cancel"})]}):null]}):null}function ha({actions:s,busy:n,library:a,onSelect:t}){const l=a.profiles.find(d=>Ze(d.ref,a.lastUsed))??a.profiles[0]??null,i=l?Fe(l.ref):"";return e.jsxs("div",{className:"profile-selector-bar",children:[e.jsxs("label",{className:"profile-selector-control",children:[e.jsx("select",{"aria-label":"Active profile",disabled:n||a.profiles.length===0,value:i,onChange:d=>{const c=Bn(a,d.currentTarget.value),h=a.profiles.find(p=>Ze(p.ref,c));h&&t(h)},children:a.profiles.length?a.profiles.map(d=>e.jsx("option",{value:Fe(d.ref),children:d.name},Fe(d.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Hn,{"aria-hidden":"true",size:14})]}),s]})}function ma({addDisabled:s,commitDisabled:n,commitLabel:a,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:d,syncStatus:c,onAdd:h,onCommit:p,onRefresh:o,onRepo:g,onSync:m}){const[u,x]=r.useState(!1),v=r.useRef(null);r.useEffect(()=>{if(!u)return;function k(S){v.current?.contains(S.target)||x(!1)}function C(S){S.key==="Escape"&&x(!1)}return document.addEventListener("pointerdown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("pointerdown",k),document.removeEventListener("keydown",C)}},[u]);function N(k){x(!1),k()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:v,children:[e.jsx("button",{"aria-expanded":u,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>x(k=>!k),children:e.jsx(ls,{size:15})}),u?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>N(p),children:[e.jsx(ze,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>N(m),children:[e.jsx(xe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:d}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>N(g),children:[e.jsx(Ee,{size:14}),e.jsx("span",{children:"Repository"})]}),e.jsx("div",{className:"profile-settings-menu-separator",role:"separator"}),e.jsxs("button",{disabled:t,role:"menuitem",type:"button",onClick:()=>N(o),children:[e.jsx(ae,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>N(h),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const pa=[{id:"actions",label:"Actions",detail:"Profile-level reusable actions"},{id:"prompts",label:"Prompts",detail:"Shared prompt files"},{id:"goals",label:"Goals",detail:"Goal definitions; never started automatically"},{id:"evals",label:"Evals",detail:"Evaluation definitions and fixtures"},{id:"examples",label:"Examples",detail:"Example inputs and usage"},{id:"tasksets",label:"Tasksets",detail:"Training and evaluation tasksets"},{id:"extensions",label:"Extension declarations",detail:"Third-party extension metadata"}];function ga({connection:s,entry:n,onClose:a,onPublished:t}){const[l,i]=r.useState("github"),[d,c]=r.useState(""),[h,p]=r.useState(`${n.name}-profile`),[o,g]=r.useState("public"),[m,u]=r.useState(()=>n.state.agents.filter(b=>b.enabled).map(b=>b.id)),[x,v]=r.useState(()=>n.state.skills.filter(b=>b.enabled).map(b=>b.name)),[N,k]=r.useState([]),[C,S]=r.useState(null),[R,f]=r.useState(null),[P,I]=r.useState(null),O=r.useMemo(()=>({ref:n.ref,selection:{agentIds:m,skillNames:x,optionalContent:N},target:{provider:l,owner:d.trim()||null,repository:h.trim(),visibility:l==="github"?"public":o}}),[m,n.ref,N,d,l,h,x,o]);function j(b,z,H){return H?[...new Set([...b,z])]:b.filter(_=>_!==z)}async function w(b){if(b.preventDefault(),!(!h.trim()||R)){f("preview"),I(null);try{S(await T.profilePublicationPreview(s,O))}catch(z){I(z instanceof Error?z.message:String(z))}finally{f(null)}}}async function y(){if(!(!C||C.blockedReasons.length>0||R)){f("publish"),I(null);try{const b=await T.profilePublicationPublish(s,{...O,expectedSourceHash:C.sourceHash,confirmed:!0});t(`Published ${n.name} to ${b.owner}/${b.repository}`),a()}catch(b){I(b instanceof Error?b.message:String(b))}finally{f(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:b=>b.stopPropagation(),onSubmit:w,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!R,type:"button","aria-label":"Close",onClick:a,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(xe,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",n.name]}),e.jsx("p",{children:"Choose the exact Agents, Skills, and optional files to share. OpenPond will show the complete file list before it pushes anything."}),C?e.jsx(fa,{preview:C}):e.jsxs(e.Fragment,{children:[e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:"Destination"}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="github",onChange:()=>{i("github"),g("public")}}),e.jsx(Xe,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"GitHub"}),e.jsx("small",{children:"Published publicly with your signed-in gh CLI"})]})]}),e.jsxs("label",{className:"profile-publication-provider",children:[e.jsx("input",{type:"radio",checked:l==="openpond_git",onChange:()=>{i("openpond_git"),g("private")}}),e.jsx(_n,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[l==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:d,placeholder:"Uses gh account",onChange:b=>c(b.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:h,onChange:b=>p(b.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:o,onChange:b=>g(b.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ve,{title:"Agents",empty:"No Agents in this Profile",children:n.state.agents.map(b=>e.jsx(Ke,{checked:m.includes(b.id),label:b.name,detail:b.path,onChange:z=>u(H=>j(H,b.id,z))},b.id))}),e.jsx(Ve,{title:"Skills",empty:"No Skills in this Profile",children:n.state.skills.map(b=>e.jsx(Ke,{checked:x.includes(b.name),label:b.name,detail:b.description||b.path,onChange:z=>v(H=>j(H,b.name,z))},b.name))}),e.jsx(Ve,{title:"Optional content",empty:"",children:pa.map(b=>e.jsx(Ke,{checked:N.includes(b.id),label:b.label,detail:b.detail,onChange:z=>k(H=>j(H,b.id,z))},b.id))})]}),P?e.jsx("div",{className:"profile-dialog-warning",children:P}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!R,type:"button",onClick:C?()=>S(null):a,children:C?"Back":"Cancel"}),C?e.jsxs("button",{className:"git-dialog-primary",disabled:!!R||C.blockedReasons.length>0,type:"button",onClick:()=>{y()},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:R==="publish"?"Publishing":C.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!R||!h.trim(),type:"submit",children:R==="preview"?"Building preview":"Review exact files"})]})]})})}function Ve({title:s,empty:n,children:a}){const t=Array.isArray(a)?a.length:a?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),t?a:e.jsx("span",{className:"profile-publication-empty",children:n})]})}function Ke({checked:s,label:n,detail:a,onChange:t}){return e.jsxs("label",{className:"profile-publication-selection",children:[e.jsx("input",{type:"checkbox",checked:s,onChange:l=>t(l.currentTarget.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:n}),e.jsx("small",{children:a})]})]})}function fa({preview:s}){const n=s.files.reduce((a,t)=>a+t.sizeBytes,0);return e.jsxs("div",{className:"profile-publication-preview",children:[e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[s.files.length," files · ",Es(n)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(a=>e.jsx("div",{className:"profile-dialog-warning",children:a},a)),s.warnings.map(a=>e.jsx("div",{className:"profile-publication-warning",children:a},a)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(a=>e.jsxs("div",{children:[e.jsx("span",{title:a.path,children:a.path}),e.jsxs("small",{children:[a.category," · ",Es(a.sizeBytes)]})]},a.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(a=>e.jsx("code",{children:a},a))]}):null]})}function Es(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function xa({section:s="all",catalogPresentation:n="list",payload:a,connection:t,onPayload:l,onError:i,onToast:d,onSkillCommand:c,onOpenSession:h,overviewContent:p}){const[o,g]=r.useState(""),[m,u]=r.useState(null),[x,v]=r.useState(!1),[N,k]=r.useState(null),[C,S]=r.useState(null),R=a?.profile??null,f=a?.preferences.defaultTeamId?.trim()||"",P=s==="all"||s==="profile"||s==="controls",I=s==="all"||s==="profile",O=s==="all"||s==="agents",j=s==="all"||s==="profile";async function w(U){t&&(l(await T.bootstrap(t)),d?.(U,"success"))}async function y(U,ee){if(!(!t||m)){u(U),i(null);try{await ee()}catch(Y){i(Y instanceof Error?Y.message:String(Y))}finally{u(null)}}}function b(){y("init",async()=>{await T.profileInit(t,{}),await w("Profile initialized")})}function z(){y("commit",async()=>{await T.profileCommit(t,{message:o.trim()||null}),g(""),await w("Profile commit complete")})}function H(){y("push",async()=>{if(!f)throw new Error("Select a default team before syncing a hosted profile.");await T.profileCheck(t,{kind:"all"}),await T.profilePush(t,{teamId:f,ensureHosted:!0,message:null}),await w("Profile synced to hosted profile repo")})}function _(U){y(`select:${U.ref.profileId}`,async()=>{await T.profileSelect(t,U.ref),await w(`Using ${U.name}`)})}function V(U){y("add",async()=>{U.source==="blank"?await T.profileInit(t,{path:U.path,profile:U.profile,template:"blank-profile"}):U.source==="local"?await T.profileLoad(t,U):await T.profileInstall(t,U),v(!1),await w(U.source==="blank"?`${U.profile} created`:"Profile added")})}function Z(U){y("update",async()=>{await T.profileUpdate(t,U.ref),await w(`${U.name} updated`)})}function E(U){y("remove",async()=>{await T.profileRemove(t,U.ref),k(null),await w("Profile removed from this device")})}function K(){y("refresh",async()=>{await w("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[R?.mode==="local"?e.jsxs(e.Fragment,{children:[P?e.jsxs(e.Fragment,{children:[I&&n==="select"?e.jsx(ha,{actions:e.jsx(Os,{connection:t,onAdd:()=>v(!0),onRefresh:K,presentation:"menu",profile:R,profileBusy:m,profileCommitMessage:o,selectedDefaultTeamId:f,syncDisabledReason:Ms(R,f),setProfileCommitMessage:g,submitProfileCommit:z,submitProfilePush:H}),busy:!!m,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:_}):e.jsxs(e.Fragment,{children:[I?e.jsx(ja,{busy:!!m,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>v(!0),onRefresh:K,onRemove:k,onPublish:S,onUpdate:Z,onSelect:_}):null,e.jsx(Os,{connection:t,profile:R,profileBusy:m,profileCommitMessage:o,selectedDefaultTeamId:f,syncDisabledReason:Ms(R,f),setProfileCommitMessage:g,submitProfileCommit:z,submitProfilePush:H})]}),p]}):null,O?e.jsx(sa,{connection:t,profile:R,selectedDefaultTeamId:f}):null,j?e.jsxs(e.Fragment,{children:[e.jsx(Sa,{onSkillCommand:c,profile:R}),e.jsx(ua,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null,onError:i,onOpenSession:h,onToast:d})]}):null]}):s==="agents"?e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Agents"}),e.jsx("small",{children:"Profile required"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Open Profile to create or load a Profile before managing agents."})]})]}):e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Summary"}),e.jsx("small",{children:"Not loaded"})]}),e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No local Profile loaded"}),e.jsx("span",{children:"Create an empty Profile, start with an Agent template, or add an existing repository."}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!m,type:"button",onClick:()=>v(!0),children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!m,type:"button",onClick:b,children:[e.jsx(fe,{size:14}),e.jsx("span",{children:m==="init"?"Creating":"Create starter Profile"})]})]})]}),x?e.jsx(ba,{busy:!!m,onClose:()=>v(!1),onSubmit:V}):null,N?e.jsx(va,{busy:!!m,entry:N,onClose:()=>k(null),onConfirm:()=>E(N)}):null,C&&t?e.jsx(ga,{connection:t,entry:C,onClose:()=>S(null),onPublished:U=>d?.(U,"success")}):null]})}function ja({busy:s,library:n,onAdd:a,onRefresh:t,onRemove:l,onPublish:i,onSelect:d,onUpdate:c}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[n.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:t,children:[e.jsx(ae,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(fe,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),n.profiles.map(h=>{const p=Ze(h.ref,n.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${p?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||d(h)},onKeyDown:o=>{s||o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),d(h))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Ee,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:h.name}),e.jsx("span",{title:h.repoPath,children:h.repoPath})]})]}),e.jsx(rn,{status:{state:h.state.error?"warning":"ready",label:h.state.error?"error":p?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:h.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:h.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[h.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),c(h)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),c(h))},children:[e.jsx(ae,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:o=>{o.stopPropagation(),i(h)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),i(h))},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${h.name}`,onClick:o=>{o.stopPropagation(),l(h)},onKeyDown:o=>{o.key!=="Enter"&&o.key!==" "||(o.preventDefault(),o.stopPropagation(),l(h))},children:[e.jsx(ke,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${h.ref.source}:${h.ref.repositoryId}:${h.ref.profileId}`)})]})}function ba({busy:s,onClose:n,onSubmit:a}){const[t,l]=r.useState("blank"),[i,d]=r.useState(""),[c,h]=r.useState(""),[p,o]=r.useState("");function g(m){if(m.preventDefault(),s)return;if(t==="blank"){const x=p.trim();if(!x)return;a({source:t,path:i.trim()||null,profile:x});return}if(t==="local"){const x=i.trim();if(!x)return;a({source:t,path:x,profile:p.trim()||null});return}const u=c.trim();u&&a({source:t,repositoryId:u,profile:p.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:m=>m.stopPropagation(),onSubmit:g,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:n,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Ee,{size:18})}),e.jsx("h2",{id:"add-profile-title",children:"Add Profile"}),e.jsx("p",{children:"Create a blank Profile, add a local repository, or install a shareable Profile from Git."}),e.jsxs("div",{className:"profile-add-source-options",children:[e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="blank",onChange:()=>l("blank")}),"New blank"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="local",onChange:()=>l("local")}),"Local"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="github",onChange:()=>l("github")}),"GitHub"]}),e.jsxs("label",{children:[e.jsx("input",{type:"radio",checked:t==="openpond_git",onChange:()=>l("openpond_git")}),"OpenPond Git"]})]}),t==="blank"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path (optional)"}),e.jsx("input",{disabled:s,value:i,placeholder:"Uses the default local Profile repository",onChange:m=>d(m.currentTarget.value)})]}):t==="local"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository path"}),e.jsx("input",{autoFocus:!0,disabled:s,value:i,placeholder:"/path/to/profile-repo",onChange:m=>d(m.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[t==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:c,placeholder:"owner/repository",onChange:m=>h(m.currentTarget.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:t==="blank"?"Profile name":"Profile name (optional)"}),e.jsx("input",{autoFocus:t==="blank",disabled:s,value:p,placeholder:t==="blank"?"research":"Uses repository default",onChange:m=>o(m.currentTarget.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:s||!(t==="blank"?p:t==="local"?i:c).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function va({busy:s,entry:n,onClose:a,onConfirm:t}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"remove-profile-title",onMouseDown:l=>l.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(ke,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",n.name,"?"]}),e.jsx("p",{children:"This removes the Profile from OpenPond on this device. It does not delete the repository or any source files."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:n.name}),e.jsx("span",{children:n.repoPath})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:s,type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary danger",disabled:s,type:"button",onClick:t,children:"Remove"})]})]})})}function Os({connection:s,onAdd:n,onRefresh:a,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:d,selectedDefaultTeamId:c,syncDisabledReason:h,setProfileCommitMessage:p,submitProfileCommit:o,submitProfilePush:g}){const[m,u]=r.useState(!1),[x,v]=r.useState(!1),[N,k]=r.useState(!1),C=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&n&&a?e.jsx(ma,{addDisabled:!!i,commitDisabled:C,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:C,repoDisabled:!!i||!l,syncDisabled:C||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Je(l,c):null,onAdd:n,onCommit:()=>v(!0),onRefresh:a,onRepo:()=>u(!0),onSync:()=>k(!0)}):e.jsx("div",{className:"profile-control-panel",children:e.jsxs("div",{className:"profile-control-toolbar",children:[e.jsxs("div",{className:"profile-control-actions",children:[e.jsxs("button",{className:"settings-secondary",disabled:C,type:"button",onClick:()=>v(!0),children:[e.jsx(ze,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:C||!l,type:"button",onClick:()=>k(!0),children:[e.jsx(xe,{size:14}),e.jsx("span",{children:i==="push"?"Syncing":"Sync"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!!i||!l,type:"button",onClick:()=>u(!0),children:[e.jsx(Ee,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Je(l,c)}`,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Je(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),m&&l?e.jsx(wa,{profile:l,profileBusy:i,onClose:()=>u(!1)}):null,x?e.jsx(ya,{disabled:C,profileBusy:i,profileCommitMessage:d,setProfileCommitMessage:p,submitProfileCommit:o,onClose:()=>v(!1)}):null,N&&l?e.jsx(Na,{disabled:C,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:h,submitProfilePush:g,onClose:()=>k(!1)}):null]})}function ya({disabled:s,profileBusy:n,profileCommitMessage:a,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function d(c){c.preventDefault(),!s&&(l(),i())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:i,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:c=>c.stopPropagation(),onSubmit:d,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(ze,{size:18})}),e.jsx("h2",{id:"profile-commit-dialog-title",children:"Commit profile"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Commit message"}),e.jsx("input",{autoFocus:!0,value:a,disabled:!!n,placeholder:"Update OpenPond profile",onChange:c=>t(c.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!n,type:"button",onClick:i,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(ze,{size:14}),e.jsx("span",{children:n==="commit"?"Committing":"Commit"})]})]})]})})}function Na({disabled:s,profile:n,profileBusy:a,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:d}){const c=Ca(n,t),h=c.reduce((g,m)=>g+m.count,0),p=!s&&!l;function o(g){g.preventDefault(),p&&(i(),d())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:g=>g.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:d,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(xe,{size:18})}),e.jsx("h2",{id:"profile-sync-dialog-title",children:"Sync profile"}),e.jsx("p",{className:"profile-sync-explainer",children:"Sync publishes this committed Profile source for your team, so its Agents can be shared in team chat and attached to hosted sandboxes."}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsxs("strong",{children:[h," ",h===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",Ce(n.summary.localHead??n.git?.head)," - Last pushed"," ",Ce(n.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(g=>e.jsxs("div",{className:`profile-dialog-diff-row ${g.tone??""}`,children:[e.jsx("strong",{children:g.label}),e.jsx("span",{children:g.detail})]},g.label))}):e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:e.jsxs("div",{className:"profile-dialog-diff-row",children:[e.jsx("strong",{children:"Aligned"}),e.jsx("span",{children:"Current local profile source has already been pushed."})]})}),l?e.jsx("div",{className:"profile-dialog-warning",children:l}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:d,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!p,type:"submit",children:[e.jsx(xe,{size:14}),e.jsx("span",{children:a==="push"?"Syncing":"Confirm sync"})]})]})]})})}function wa({profile:s,profileBusy:n,onClose:a}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("div",{className:"git-dialog profile-path-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-path-dialog-title",onMouseDown:t=>t.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:a,children:e.jsx(oe,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Ee,{size:18})}),e.jsx("h2",{id:"profile-path-dialog-title",children:"Profile repo"}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Profile repo path"}),e.jsx("input",{"aria-label":"Profile repo path",readOnly:!0,value:s.repoPath??""})]}),e.jsxs("div",{className:"profile-dialog-summary",children:[e.jsx("strong",{children:s.git?.isRepo?"Git-backed":"Git setup required"}),e.jsxs("span",{children:[s.git?.branch??"No branch"," · ",Ce(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!n,type:"button",onClick:a,children:"Close"})})]})})}function Sa({onSkillCommand:s,profile:n}){const a=n.skills.slice().sort((i,d)=>i.name.localeCompare(d.name)),t=!s;function l(i){s?.(i)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[n.skillCatalog.skillCount," tracked"]})})]}),a.length?e.jsx("div",{className:"profile-table-frame",children:e.jsxs("table",{className:"profile-data-table profile-skill-table","aria-label":"Profile skills table",children:[e.jsxs("colgroup",{children:[e.jsx("col",{className:"profile-skill-name-column"}),e.jsx("col",{className:"profile-skill-trigger-column"}),e.jsx("col",{className:"profile-skill-status-column"}),e.jsx("col",{className:"profile-skill-source-column"}),e.jsx("col",{className:"profile-skill-actions-column"})]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Skill"}),e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Source"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:a.map(i=>e.jsx(ka,{commandDisabled:t,onSkillCommand:l,skill:i},i.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function ka({commandDisabled:s,onSkillCommand:n,skill:a}){const t=a.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:a.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Le,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:a.name}),e.jsx("span",{title:a.path,children:a.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:a.description,children:a.description||"No description"}),e.jsx("td",{children:e.jsx(rn,{status:t})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:a.sourcePath,children:a.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!a.enabled,type:"button",title:`Use ${a.name}`,onClick:()=>n(`$${a.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${a.name}`,onClick:()=>n(`/skill edit ${a.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function rn({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Ce(s){return s?s.slice(0,10):"None"}function Je(s,n){return on(s,n)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${Ce(s.hosted.sourceCommitSha)}`:"Not pushed"}function Ms(s,n){return n?s.git?.head?s.git.dirty?"Commit local profile changes before syncing.":null:"Commit the profile before syncing.":"Select a default team before syncing."}function Ca(s,n){const a=[],t=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(on(s,n)&&a.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?a.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):t&&l&&t!==l&&a.push({label:"Commit",detail:`Local ${Ce(t)} has not been pushed since ${Ce(l)}.`,count:1}),s.git?.dirty){const c=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const d=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return d>0&&a.push({label:"Profile changes",detail:Ra(s),count:d,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&a.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&a.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),a}function Ra(s){const n=[],a=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return a&&n.push(`${a} agent ${a===1?"change":"changes"}`),s.diff.changedActions.length&&n.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&n.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&n.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&n.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&n.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),n.join(", ")||"Profile source has local changes."}function on(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}const Pa=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Aa=120,Da=new Set(["openai","xai","zai"]),$a=new Set(["chatgpt-subscription"]),Ia="https://api.z.ai/api/coding/paas/v4";function Ts(s){return s.split(/[\n,]/).map(n=>n.trim()).filter(Boolean)}function cn(s){return s?s.available?"Ready":s.credential.connected?"Configured":s.credential.lastError||s.lastError?"Needs attention":s.id==="codex"?"Needs Codex login":s.routing.localByok?"Needs key":s.enabled?"Enabled":"Off":"Unknown"}function dn(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Ls(s){return s.credential.connected?s.credential.redacted?s.credential.redacted:s.credential.source==="chatgpt_subscription"?"ChatGPT subscription":s.credential.source:s.credential.lastError??"Not connected"}function Ea(s){return s?.trim().replace(/\/+$/,"")??""}function un(s,n){return s.id==="zai"&&Ea(n.providers.zai?.baseUrl)===Ia}function Oa(s,n){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":un(s,n)?"Coding Plan key":"API key"}function Ma(s,n){const a=n.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const t=Math.max(a?.models.length??0,s.modelIds.length),l=s.defaultModel?ss(s.defaultModel,n,s.id):"",i=t===1?"1 model":`${t} models`,d=Oa(s,n);return[cn(s),d,a?i:"",l].filter(Boolean).join(" · ")}function Ta(s){return s!=="openpond"&&es(s)}function os(s){return s?Da.has(s.id)||s.credentialModes.some(n=>$a.has(n)):!1}function La(s){return os(s)?["api","subscription"]:["api"]}function zs(s,n){return!s||!n||!os(s)?"api":s.credential.source==="chatgpt_subscription"||un(s,n)?"subscription":"api"}function Us(s,n){const a=Fn.filter(t=>!!s?.statuses[t]);return n?a.filter(t=>os(s?.statuses[t])):a}function za(s){if(!s)return"Never";const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function Ua(s,n,a=Aa){const t=[],l=new Set,i=new Set(n.map(c=>c.trim()).filter(Boolean)),d=c=>{l.has(c.value)||t.length>=a||(l.add(c.value),t.push(c))};for(const c of s)i.has(c.value)&&d(c);for(const c of s)d(c);return t}function Ba({account:s,codex:n,providers:a,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:d,refreshProviderModels:c,saveProviderConfig:h,saveProviderCredential:p,startOpenAiSubscriptionAuth:o,validateProvider:g}){const[m,u]=r.useState(null),[x,v]=r.useState(!1),N=r.useMemo(()=>Us(a,!1),[a]),k=r.useMemo(()=>Us(a,x),[a,x]),C=m?a?.statuses[m]??null:null;function S(R,f){u(R),f&&d(R)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),a?e.jsxs("div",{className:"provider-manager-panel",children:[e.jsxs("div",{className:"account-list-heading provider-manager-heading",children:[e.jsxs("div",{className:"provider-manager-title-row",children:[e.jsx("span",{children:"Model providers"}),e.jsxs("label",{className:"settings-check-row compact provider-subscription-filter",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:R=>v(R.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[k.length," of ",N.length," presets"]})]}),k.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:k.map(R=>{const f=a.statuses[R],P=a.modelCaches[R],I=f.modelIds.length>0&&(P?.models.length??0)<f.modelIds.length,O=t?.startsWith(`${R}:`)??!1,j=Ta(R),w=R==="openpond"||!!a.providers[R]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${f.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:w,disabled:!j||O,onChange:y=>{S(R,!1),h(R,{enabled:y.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:f.displayName})}),e.jsxs("div",{className:`provider-row-status ${dn(f)}`,children:[O?e.jsx(re,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Ma(f,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{S(R,I)},children:"Details"})]},R)})}):e.jsxs("div",{className:"empty-account-list provider-manager-empty",children:[e.jsx("strong",{children:"No subscription providers"}),e.jsx("span",{children:"Turn off the filter to show API-key providers."})]})]}):null,l?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:l})]}):null,m&&C&&a?e.jsx(Ha,{account:s,codex:n,providerId:m,providerBusy:t,settings:a,status:C,onClose:()=>u(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:h,onSaveCredential:p,onStartOpenAiSubscriptionAuth:o,onValidate:g}):null]})}function Ha({account:s,codex:n,providerId:a,providerBusy:t,settings:l,status:i,onClose:d,onDeleteCredential:c,onRefreshModels:h,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:g,onValidate:m}){const u=l.providers[a],x=l.modelCaches[a],v=r.useId(),N=r.useRef(a),k=Math.max(x?.models.length??0,i.modelIds.length),C=i.routing.localByok&&es(a)&&a!=="codex",S=r.useMemo(()=>C?La(i):[],[C,i]),R=S.includes("subscription"),[f,P]=r.useState(()=>zs(i,l)),I=C&&f==="subscription"&&R,O=w=>`${v}-${w}-panel`,j=a==="codex"?"Codex app server":u?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(N.current!==a){N.current=a,P(zs(i,l));return}C&&!S.includes(f)&&P("api")},[f,S,C,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:w=>w.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:d,children:e.jsx(oe,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Te(a,l)})]}),e.jsx("div",{className:`provider-state-pill ${dn(i)}`,children:cn(i)})]}),C?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:S.map(w=>e.jsx("button",{type:"button",role:"tab",id:`${v}-${w}`,className:f===w?"active":void 0,"aria-selected":f===w,"aria-controls":O(w),onClick:()=>P(w),children:w==="api"?"API":"Subscription"},w))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Ls(i),children:Ls(i)})]}),I?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:j,children:j})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:u?.defaultModel??i.defaultModel??void 0,children:u?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:x?.lastError??void 0,children:[k," cached · ",za(x?.fetchedAt)]})]})]}),a==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:n?.account?.email??void 0,children:n?.account?.label??n?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:n?.binaryPath??void 0,children:n?.binaryPath??"Not found"})]})]}):null,i.credential.lastError||x?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??x?.lastError??i.lastError??void 0,children:i.credential.lastError??x?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(_a,{providerBusy:t,status:i,onValidate:m}):C&&u&&x?e.jsx(Fa,{credentialTab:f,credentialTabsId:v,hasSubscriptionTab:R,providerId:a,providerBusy:t,settings:l,status:i,onDeleteCredential:c,onRefreshModels:h,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:g,onValidate:m}):i.routing.localByok&&!es(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Ks,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function _a({providerBusy:s,status:n,onValidate:a}){const t=s==="codex:validate";return e.jsxs("div",{className:"provider-dialog-body codex-provider-body",children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(pe,{size:15}),e.jsxs("span",{children:["Uses your local ",e.jsx("code",{children:"codex login"})," session through the Codex app server. This route is separate from OpenAI Platform API-key billing."]})]}),e.jsx("div",{className:"settings-button-row codex-provider-actions",children:e.jsxs("button",{type:"button",className:"settings-secondary",disabled:t,onClick:()=>{a("codex",{modelId:n.defaultModel??void 0})},children:[t?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ys,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function Fa({credentialTab:s,credentialTabsId:n,hasSubscriptionTab:a,providerId:t,providerBusy:l,settings:i,status:d,onDeleteCredential:c,onRefreshModels:h,onSaveConfig:p,onSaveCredential:o,onStartOpenAiSubscriptionAuth:g,onValidate:m}){const u=i.providers[t],x=r.useMemo(()=>Ue(t,i),[t,i]),v=`provider-models-${t}`,N=r.useRef(t),[k,C]=r.useState(u.baseUrl??""),[S,R]=r.useState(u.defaultModel??""),[f,P]=r.useState(u.modelOverrides.join(`
|
|
6
|
+
`)),[I,O]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[j,w]=r.useState("local_secret"),[y,b]=r.useState(""),[z,H]=r.useState(""),_=l===`${t}:config`,V=l===`${t}:credential`,Z=l===`${t}:validate`,E=l===`${t}:models`,K=l==="openai:credential",U=t==="openai",ee=t==="xai",Y=t==="zai",F=(M=>`${n}-${M}-panel`)(s),B=s==="subscription"&&a,Q=s==="subscription"&&Y?"coding-plan":"api",te=Q==="coding-plan"?"Coding Plan key":"API key",le=d.credential.connected?Q==="coding-plan"?"Replace saved plan key":"Replace saved key":te,de=Q==="coding-plan"?"Save plan key":"Save key",X=r.useMemo(()=>Ua(x,[S,...Ts(f)]),[S,x,f]),se=Math.max(0,x.length-X.length);r.useEffect(()=>{if(N.current!==t){N.current=t,O({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),C(u.baseUrl??""),R(u.defaultModel??""),P(u.modelOverrides.join(`
|
|
7
|
+
`));return}I.baseUrl||C(u.baseUrl??""),I.defaultModel||R(u.defaultModel??""),I.modelOverrides||P(u.modelOverrides.join(`
|
|
8
|
+
`))},[u.baseUrl,u.defaultModel,u.modelOverrides,I.baseUrl,I.defaultModel,I.modelOverrides,t]);const ue=j==="env"?!!z.trim():!!y.trim();async function he(M){M.preventDefault(),await p(t,{enabled:!0,baseUrl:k.trim()||null,defaultModel:S.trim()||null,modelOverrides:Ts(f)}),O({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function ie(M){if(M.preventDefault(),!!ue){if(j==="env"){await o(t,{source:"env",envVar:z.trim()});return}await o(t,{source:"local_secret",value:y}),b("")}}function D({panel:M=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:M?F:void 0,role:M?"tabpanel":void 0,"aria-labelledby":M?`${n}-${s}`:void 0,onSubmit:L=>{ie(L)},children:[e.jsxs("div",{className:"provider-card-grid credential-grid",children:[e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Credential source"}),e.jsx(De,{value:j,disabled:V,label:"Credential source",options:Pa,onChange:L=>w(L)})]}),j==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:z,disabled:V,placeholder:"PROVIDER_API_KEY",onChange:L=>H(L.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:te}),e.jsx("input",{type:"password",value:y,disabled:V,placeholder:le,autoComplete:"off",onChange:L=>b(L.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:V||!ue,children:[V?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:V?"Saving":de})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:V||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]})}function A(){return U?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"ChatGPT subscription auth opens OpenAI login and stores a refresh token locally. API keys remain available under the API tab for raw Platform billing."})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{type:"button",className:"settings-secondary",disabled:K,onClick:()=>{g("browser")},children:[K?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:K?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:K,onClick:()=>{g("device")},children:[K?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:K||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ke,{size:15})})]})]}):ee?e.jsx("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"SuperGrok includes Grok app and Grok Build access. xAI API calls here still use an xAI Console API key with API credits or invoiced billing, so there is no separate Connect SuperGrok step yet."})]})}):Y?e.jsxs("div",{className:"provider-subscription-panel",id:F,role:"tabpanel","aria-labelledby":`${n}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(pe,{size:15}),e.jsx("span",{children:"GLM Coding Plan uses a plan API key with the dedicated Coding endpoint. General Z.ai API keys and balances are separate."})]}),D({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[B?null:e.jsxs("form",{className:"provider-card-form",onSubmit:M=>{he(M)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:k,disabled:_,placeholder:"https://api.example.com/v1",onChange:M=>{O(L=>({...L,baseUrl:!0})),C(M.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:v,value:S,disabled:_,placeholder:"Model id",onChange:M=>{O(L=>({...L,defaultModel:!0})),R(M.currentTarget.value)}}),e.jsx("datalist",{id:v,children:X.map(M=>e.jsx("option",{value:M.value,children:M.label},M.value))}),se>0?e.jsxs("small",{children:[se," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:_,children:[_?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(rs,{size:14}),e.jsx("span",{children:_?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:E,onClick:()=>{h(t)},children:[E?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(ae,{size:14}),e.jsx("span",{children:E?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Z||!S.trim(),onClick:()=>{m(t,{baseUrl:k.trim()||void 0,modelId:S.trim()||void 0})},children:[Z?e.jsx(re,{size:14,className:"settings-spin"}):e.jsx(Ys,{size:14}),e.jsx("span",{children:Z?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:B?A():D()})]})}function Ga({status:s,busy:n,flashTailscaleUp:a,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:d,copyTailscaleUpCommand:c,copyServeCommand:h,copyServeSetupUrl:p,copyOperatorCommand:o,createRemoteLink:g}){const m=s?.tailscale.installed??!1,u=s?.serve.enabled??!1,x=s?.serve.reachable??!1,v=!!(s?.webUiAvailable&&m),N=u?!!s?.remoteWebUrl:v,C=(s?.tailscale.peers??[]).filter(f=>!f.isSelf),S=!!s?.tailscale.error?.includes("set --operator"),R=!!(u&&s?.remoteWebUrl);return e.jsxs("section",{className:"account-settings remote-access-settings",children:[e.jsx("h1",{children:"Remote access"}),e.jsxs("div",{className:"account-summary remote-access-summary",children:[e.jsxs("div",{className:"account-summary-main",children:[e.jsx("div",{className:`remote-access-icon ${x?"online":u?"configured":""}`,children:m?e.jsx(an,{size:18}):e.jsx(dt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:x?"Tailscale Serve is reachable":u?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Va(s):"Checking Tailscale"})]})]}),e.jsxs("div",{className:"account-summary-actions",children:[e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh remote access","aria-label":"Refresh remote access",disabled:n!==null,onClick:()=>{t()},children:e.jsx(ae,{className:n==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n!==null||!m||!u&&!v,onClick:()=>{u?i():l()},children:[e.jsx(Gn,{size:15}),e.jsx("span",{children:u?n==="disable"?"Turning off":"Turn off":n==="enable"?"Turning on":"Turn on"})]})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsx("div",{className:"account-list-heading remote-access-link-heading",children:e.jsxs("div",{children:[e.jsx("span",{children:"OpenPond link"}),e.jsx("small",{children:R?"Browser UI":"Tailscale + Serve"})]})}),R&&e.jsx(me,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:n==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||n!==null,onAction:d}),e.jsx(me,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:a,actionLabel:n==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||n!==null,onAction:c}),e.jsx(me,{label:"Serve command",value:s?.serveCommand??null,actionLabel:n==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||n!==null,onAction:h}),s?.serve.setupUrl&&e.jsx(me,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:n==="copy-serve-setup"?"Copying":"Copy",disabled:n!==null,onAction:p}),S&&e.jsx(me,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:n==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||n!==null,onAction:o}),e.jsx(me,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(me,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(me,{label:"Disable command",value:s?.disableCommand??null})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading remote-access-link-heading",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Authorized clients"}),e.jsxs("small",{children:[C.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:n!==null||!N,onClick:()=>{g()},children:e.jsx("span",{children:u?"Copy link":"Create link"})})]}),s?C.length===0?e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No clients reported"}),e.jsx("span",{children:s?.tailscale.running?"Tailscale did not return peer devices.":"Tailscale is not running."})]}):C.map(f=>e.jsx(Wa,{peer:f},f.id)):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"Checking clients"}),e.jsx("span",{children:"Loading tailnet devices."})]})]}),e.jsxs("div",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Remote environment"}),e.jsx("small",{children:s?.tailscale.tailnetName??"Tailnet"})]}),e.jsx(qa,{status:s})]}),s?.serve.configText&&e.jsxs("div",{className:"remote-access-config",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Tailscale config"}),e.jsx("small",{children:s.serve.enabled?"OpenPond target found":"No OpenPond target"})]}),e.jsx("pre",{children:s.serve.configText})]})]})}function me({actionLabel:s,disabled:n,flash:a,label:t,onAction:l,value:i}){return e.jsxs("div",{className:"product-row remote-access-value-row",children:[e.jsxs("div",{children:[e.jsx("strong",{className:a?"flash":void 0,children:t}),e.jsx("code",{children:i??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:n,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function qa({status:s}){const n=[{label:"State",value:s?.tailscale.backendState??"Unknown"},{label:"Machine",value:s?.tailscale.machineName??"Unknown"},{label:"Tailnet",value:s?.tailscale.tailnetName??"Unknown"}],a=[{label:"Tailscale IP",value:s?.tailscale.tailscaleIps.join(", ")||"Unknown"},{label:"HTTPS host",value:s?.serve.httpsHost??s?.tailscale.dnsName??"Unknown"}];return e.jsxs("div",{className:"remote-access-environment",children:[e.jsx("div",{className:"remote-access-environment-row three",children:n.map(t=>e.jsx(Bs,{label:t.label,value:t.value},t.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(t=>e.jsx(Bs,{label:t.label,value:t.value},t.label))})]})}function Bs({label:s,value:n}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:n})]})}function Wa({peer:s}){return e.jsxs("div",{className:"account-row remote-access-peer-row",children:[e.jsx("div",{className:`remote-access-peer-dot ${s.online?"online":""}`}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:s.name}),e.jsx("span",{children:s.dnsName??s.tailscaleIps[0]??"No address"})]}),e.jsx("span",{className:`account-state ${s.online?"signed_in":""}`,children:s.online?"Online":"Offline"}),e.jsx("span",{className:"account-state",children:s.os??"Unknown"})]})}function Va(s){return s.tailscale.installed?s.tailscale.running?s.webUiAvailable?s.serve.reachable?s.remoteUrl??"Tailnet link ready":s.remoteUrl?`${s.remoteUrl} ready to configure`:"Tailnet DNS unavailable":"Browser UI is not served by this process":s.tailscale.authUrl?"Tailscale needs sign-in":"Tailscale is not running":"Tailscale is not installed"}const Ka=[{items:[{section:"account",label:"Account",Icon:js},{section:"notifications",label:"Notifications",Icon:nn},{section:"providers",label:"Providers",Icon:Qs},{section:"usage",label:"Activity",Icon:Wn}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:lt},{section:"harness-refiner",label:"Refiner",Icon:xs},{section:"harness-continuous-review",label:"Continuous Review",Icon:ae},{section:"harness-contents",label:"Contents",Icon:Vn},{section:"harness-releases",label:"Releases",Icon:it}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:Rt},{section:"personalization",label:"Personalization",Icon:xs},{section:"editor",label:"Editor",Icon:rt},{section:"skills",label:"Skills",Icon:Le}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:js},{section:"subagents",label:"Agents",Icon:Be}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:yt},{section:"remote",label:"Remote Access",Icon:an},{section:"diagnostics",label:"Diagnostics",Icon:ut}]}];function Ja({section:s,onBack:n,onSectionChange:a}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back","aria-label":"Back to app",onClick:n,children:[e.jsx(qn,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Ka.map((t,l)=>e.jsxs("div",{className:"settings-nav-group",children:[t.label?e.jsx("div",{className:"settings-nav-heading",children:t.label}):null,t.items.map(({section:i,label:d,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:d})]},i))]},t.label??`settings-${l}`))})]})}function Ya({catalog:s,connection:n,onCatalog:a,onError:t,onOpenExtension:l,onToast:i}){const[d,c]=r.useState(""),[h,p]=r.useState(""),[o,g]=r.useState(null),[m,u]=r.useState(null),[x,v]=r.useState(null),N=r.useCallback(j=>{const w=j instanceof Error?j.message:String(j);v(w),t(w),i?.(w,"error")},[t,i]),k=r.useCallback(()=>{v(null),t(null)},[t]),C=r.useCallback(async j=>{if(j?.preventDefault(),!(!n||!d.trim()||m)){k(),u("preview");try{const w=await T.extensionPreview(n,{source:d.trim(),...h.trim()?{ref:h.trim()}:{}});g(w)}catch(w){g(null),N(w)}finally{u(null)}}},[m,k,n,N,h,d]),S=r.useCallback(async()=>{if(!(!n||!o||m)){k(),u("install");try{const j=await T.extensionAdd(n,{source:o.repositoryUrl,ref:o.requestedRef});a(j.catalog),c(""),p(""),g(null),i?.(`Installed ${j.extension.owner}/${j.extension.repo}.`,"success")}catch(j){N(j)}finally{u(null)}}},[m,k,n,a,i,o,N]),R=r.useCallback(async j=>{if(!(!n||m)){k(),u(`update:${j.id}`);try{const w=await T.extensionUpdate(n,j);a(w.catalog);const y=w.extension.resolvedCommit===j.resolvedCommit&&w.extension.packageHash===j.packageHash;i?.(y?`${j.owner}/${j.repo} is already current.`:`Updated ${j.owner}/${j.repo}.`,"success")}catch(w){N(w)}finally{u(null)}}},[m,k,n,a,i,N]),f=r.useCallback(async()=>{if(!(!n||m||s.extensions.length===0)){k(),u("update-all");try{const j=await T.extensionUpdateAll(n);a(j.catalog);const w=`Updated ${j.updated.length}; ${j.unchanged.length} already current${j.failed.length?`; ${j.failed.length} failed`:""}.`;i?.(w,j.failed.length?"error":"success"),j.failed.length&&v(j.failed.map(y=>y.error).join(" "))}catch(j){N(j)}finally{u(null)}}},[m,s.extensions.length,k,n,a,i,N]),P=r.useCallback(async j=>{if(!(!n||m)&&window.confirm(`Remove ${j.owner}/${j.repo} and its ${j.skills.length} installed skill${j.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){k(),u(`remove:${j.id}`);try{const w=await T.extensionRemove(n,j);a(w.catalog),i?.(`Removed ${j.owner}/${j.repo}.`,"success")}catch(w){N(w)}finally{u(null)}}},[m,k,n,a,i,N]),I=r.useCallback(j=>{c(j),g(null),v(null)},[]),O=r.useCallback(j=>{p(j),g(null),v(null)},[]);return e.jsxs("div",{className:"account-list native-skills-list github-extensions-list",children:[e.jsxs("div",{className:"account-list-heading github-extensions-heading",children:[e.jsx("span",{children:"Third-party extensions"}),e.jsxs("div",{className:"github-extensions-heading-actions",children:[e.jsxs("small",{children:[s.extensions.length," installed from GitHub"]}),e.jsxs("button",{className:"settings-secondary compact",disabled:!n||m!==null||s.extensions.length===0,type:"button",onClick:()=>{f()},children:[m==="update-all"?e.jsx(re,{className:"settings-spin",size:13}):e.jsx(ae,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:j=>{C(j)},children:[e.jsxs("div",{className:"github-extension-add-copy",children:[e.jsx("strong",{children:"Add a GitHub skill pack"}),e.jsx("span",{children:"Use a skills-CLI-compatible owner/repo or GitHub URL. OpenPond installs it locally without running setup code."})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{disabled:!n||m!==null,placeholder:"owner/repo",value:d,onChange:j=>I(j.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!n||m!==null,placeholder:"Default branch",value:h,onChange:j=>O(j.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!d.trim()||m!==null,type:"submit",children:[m==="preview"?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(Xe,{size:14}),m==="preview"?"Checking":"Preview"]})]}),x||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:x??s.error}):null,o?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[o.owner,"/",o.repo]}),e.jsxs("span",{children:[o.skills.length," skill",o.skills.length===1?"":"s"," at ",o.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:o.skills.map(j=>e.jsx("span",{children:j.name},j.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:m!==null,type:"button",onClick:()=>{S()},children:[m==="install"?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(fe,{size:14}),m==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(j=>{const w=m===`update:${j.id}`,y=m===`remove:${j.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${j.owner}/${j.repo} extension source`,className:"github-extension-open",disabled:!n||m!==null,type:"button",onClick:()=>l(j),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Xe,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[j.owner,"/",j.repo]}),e.jsx("span",{children:j.skills.map(b=>b.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[j.skills.length," skill",j.skills.length===1?"":"s"]}),e.jsxs("span",{children:[j.requestedRef," · ",j.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${j.validationStatus==="valid"?"":"invalid"}`,children:j.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(Zs,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${j.owner}/${j.repo}`,className:"settings-icon-button ghost",disabled:m!==null,title:"Update extension",type:"button",onClick:()=>{R(j)},children:w?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(ae,{size:14})}),e.jsx("button",{"aria-label":`Remove ${j.owner}/${j.repo}`,className:"settings-icon-button ghost danger",disabled:m!==null,title:"Remove extension",type:"button",onClick:()=>{P(j)},children:y?e.jsx(re,{className:"settings-spin",size:14}):e.jsx(ke,{size:14})})]})]},j.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Qa({onOpenSkill:s,onOpenExtension:n,personalSkills:a,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:d,onToast:c}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(Ya,{catalog:t,connection:l,onCatalog:i,onError:d,onOpenExtension:n,onToast:c}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),a.length?a.map(h=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:h.name}),e.jsx("span",{children:h.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:h.resourceFiles.length?`${h.resourceFiles.length} packaged resource${h.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:h.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${h.validationStatus==="valid"?"":"invalid"}`,children:h.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},h.sourcePath)):e.jsx("div",{className:"skills-settings-empty",children:"No personal Codex skills found."})]}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"App integration skills"}),e.jsx("small",{children:"Bundled with this OpenPond build"})]}),Kn.map(h=>{const p=Jn(h.provider)?.label??h.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(h),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(Le,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:h.name}),e.jsx("span",{children:h.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:p}),e.jsx("span",{children:h.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(Zs,{size:16,"aria-hidden":"true"})]},h.name)})]})]})}const cs="default";function Za({connection:s,embedded:n=!1,onError:a,onPreferences:t,preferences:l,providers:i}){const d=l.training,[c,h]=r.useState(Ye(d.defaultModelRef)),[p,o]=r.useState(d.creationMode),[g,m]=r.useState(d.autoApproveEvidence),[u,x]=r.useState(!1),v=r.useMemo(()=>Js(i,{includeUnavailable:!0}),[i]),N=r.useMemo(()=>v.map(f=>({provider:f,models:Ue(f.value,i)})).filter(f=>f.models.length>0),[v,i]),k=Xa(c),C=Yn(l.defaultChatProvider,l.defaultChatModel,i)?` · ${el(l.codexReasoningEffort)} reasoning`:"",S=sl(k,d.defaultModelRef??null)&&p===d.creationMode&&g===d.autoApproveEvidence;r.useEffect(()=>{h(Ye(d.defaultModelRef)),o(d.creationMode),m(d.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,d.autoApproveEvidence,d.creationMode,d.defaultModelRef]);async function R(f){if(f.preventDefault(),!!s){x(!0),a(null);try{t(await T.savePreferences(s,{training:{defaultModelRef:k,creationMode:p,autoApproveEvidence:g}}))}catch(P){a(P instanceof Error?P.message:String(P))}finally{x(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${n?" embedded":""}`,children:[n?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:f=>{R(f)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:c,disabled:u,onChange:f=>h(f.target.value),children:[e.jsxs("option",{value:cs,children:["Use chat default — ",Te(l.defaultChatProvider,i)," · ",ss(l.defaultChatModel,i,l.defaultChatProvider),C]}),N.map(f=>e.jsx("optgroup",{label:f.provider.label,children:f.models.map(P=>e.jsx("option",{value:Ye({providerId:f.provider.value,modelId:P.value}),children:P.label},P.value))},f.provider.value))]}),e.jsx("small",{children:"By default, /train follows the same provider, model, and reasoning level selected for chat."})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Default flow"}),e.jsx("small",{children:"Used by /train and Task Creator unless you choose another mode"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Task Creator mode"}),e.jsxs("select",{value:p,disabled:u,onChange:f=>o(f.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:g,disabled:u,onChange:f=>m(f.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:u||S,children:e.jsx("span",{children:u?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:k?`${Te(k.providerId,i)} / ${ss(k.modelId,i,k.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function Ye(s){return s?JSON.stringify([s.providerId,s.modelId]):cs}function Xa(s){if(s===cs)return null;try{const n=JSON.parse(s);return!Array.isArray(n)||n.length!==2||typeof n[0]!="string"||typeof n[1]!="string"?null:{providerId:n[0],modelId:n[1]}}catch{return null}}function el(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function sl(s,n){return s?.providerId===n?.providerId&&s?.modelId===n?.modelId}function nl({disabled:s,onChange:n,storageRoots:a,value:t}){const l=r.useId(),[i,d]=r.useState(!1),c=Hs(t),h=g=>g.datasetStorePath,p="Dataset",o=a.find(g=>Hs(h(g))===c)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:l,children:[p," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${p} storage drive`,className:"model-storage-select",disabled:s,id:l,title:t??"No Dataset storage configured",value:t??"",onChange:g=>n(g.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!o?e.jsx("option",{value:t,children:"Manual location"}):null,a.map(g=>e.jsxs("option",{disabled:!g.mounted||!g.writable,title:h(g),value:h(g),children:[g.label," · ",il(g.kind)," · ",rl(g)]},g.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":"Add manual Dataset storage location",onClick:()=>d(!0),children:e.jsx(fe,{size:15})})]}),i?tl(e.jsx(al,{initialPath:t??"",purpose:"dataset",onClose:()=>d(!1),onUse:g=>{n(g),d(!1)}})):null]})}function tl(s){return typeof document>"u"?s:Qn.createPortal(s,document.body)}function al({initialPath:s,onClose:n,onUse:a,purpose:t="model"}){const l=r.useId(),[i,d]=r.useState(s),c=ll(i);r.useEffect(()=>{const p=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);function h(p){p.preventDefault(),p.stopPropagation(),!c&&a(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:p=>{p.target===p.currentTarget&&n()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:h,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${t} storage`,onClick:n,children:e.jsx(oe,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(mt,{size:18})}),e.jsxs("h2",{id:l,children:["Manual ",t," storage"]}),e.jsx("p",{children:"Enter an absolute path to a folder mounted on this machine."}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Mounted folder path"}),e.jsx("input",{autoFocus:!0,spellCheck:!1,value:i,placeholder:t==="dataset"?"/mnt/OpenPond/datasets":"/mnt/models or /run/user/…/gvfs/…",onChange:p=>d(p.target.value)})]}),e.jsx("div",{className:"model-storage-dialog-note",children:"For SMB, connect the share in Files or Finder first, then paste its mounted folder path. OpenPond uses your operating system’s existing connection and credentials."}),i.trim()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!c,type:"submit",children:"Use location"})]})]})})}function ll(s){const n=s.trim();return n?/^[a-z][a-z\d+.-]*:\/\//i.test(n)?"Use the mounted folder path, not an smb:// or other network URL.":n==="~"||n.startsWith("~/")||n.startsWith("/")||n.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(n)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function il(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function rl(s){return s.mounted?s.writable?`${ol(s.freeBytes)} free`:"Read only":"Not mounted"}function Hs(s){const n=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.toLowerCase():n}function ol(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const n=["KB","MB","GB","TB"];let a=s,t=-1;do a/=1024,t+=1;while(a>=1024&&t<n.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${n[t]}`}function cl({state:s,catalog:n,busy:a,catalogLoading:t,onRefresh:l,onSave:i}){const[d,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const h=r.useMemo(()=>s?.storageRoots.find(m=>_s(m.datasetStorePath)===_s(d))??null,[d,s?.storageRoots]),p=d===(s?.settings.datasetStorePath??null),o=n?.datasets??[];async function g(m){m.preventDefault(),await i(d)}return e.jsxs("section",{className:"account-settings compute-settings dataset-storage-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Dataset Storage"}),e.jsx("p",{className:"dataset-storage-intro",children:"Choose where Dataset artifacts are saved and review registered Datasets without loading their rows."})]}),e.jsx("button",{"aria-label":"Refresh Dataset storage",className:"settings-icon-button",disabled:a!==null||t,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(ae,{className:t?"settings-spin":void 0,size:15})})]}),e.jsx("div",{className:"account-summary",children:e.jsx("div",{className:"account-summary-main compute-summary-main",children:e.jsxs("div",{children:[e.jsx("strong",{children:h?.label??(d?"Manual location":"Not configured")}),e.jsx("small",{children:d??"Choose a writable local or mounted location before importing a Dataset."}),h?e.jsxs("small",{children:[ml(h.kind)," · ",h.freeBytes==null?"Free space unknown":`${hn(h.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:m=>{g(m)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(nl,{disabled:a!==null,onChange:c,storageRoots:s?.storageRoots??[],value:d}),e.jsx("button",{className:"settings-primary",disabled:a!==null||p,children:a==="save"?"Saving":"Save Dataset storage"})]}),e.jsxs("div",{className:"account-list dataset-storage-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Registered Datasets"}),e.jsx("small",{children:o.length})]}),o.length?o.map(m=>e.jsx(dl,{dataset:m},m.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function dl({dataset:s}){const n=s.storageKind==="parquet"?"Parquet":"Inline Taskset";return e.jsxs("div",{className:"compute-row dataset-storage-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:s.name}),e.jsxs("small",{children:[mn(s.rowCount)," rows"," · ",ul(s)," · ",n," · ",s.sizeBytes==null?"Size unavailable":hn(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?hl(s.status):"Unavailable"})]})}function ul(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,a])=>Number(a)>0).map(([a,t])=>`${mn(Number(t))} ${a}`).join(" · ")||"No split rows"}function hn(s){if(s<1024)return`${s} B`;const n=["KB","MB","GB","TB"];let a=s,t=-1;do a/=1024,t+=1;while(a>=1024&&t<n.length-1);return`${a>=10?a.toFixed(0):a.toFixed(1)} ${n[t]}`}function mn(s){return new Intl.NumberFormat().format(s)}function _s(s){return s?.replace(/[\\/]+$/,"")??""}function hl(s){return s.replaceAll("_"," ").replace(/^./,n=>n.toUpperCase())}function ml(s){return s.replace(/^./,n=>n.toUpperCase())}function Ie(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Se(s){return s?s.slice(0,10):"none"}function ye(s){const n=s.replaceAll("_"," ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}function pl(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":ye(s)}function gl({review:s}){const n=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:n.map(([a,t])=>e.jsxs("div",{className:t?"linked":"pending",children:[e.jsx("span",{children:a}),e.jsx("code",{children:t?Se(t.contentHash):"Not created"})]},a))})}function fl({candidate:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.status}`,children:pl(s.status)}),e.jsx("strong",{children:s.statement}),e.jsxs("small",{children:[s.occurrences.length," occurrence",s.occurrences.length===1?"":"s"]}),e.jsx("time",{children:Ie(s.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.resolution?.reason??s.recurrenceFamily}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Pattern"}),e.jsx("dd",{children:s.recurrenceFamily})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Fingerprint"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.fingerprint)})})]})]}),s.occurrences.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsx("summary",{children:"Evidence receipts"}),e.jsx("ul",{className:"harness-evidence-list",children:s.occurrences.map(n=>e.jsxs("li",{children:[e.jsx("span",{children:ye(n.kind)}),e.jsx("code",{children:Se(n.evidence.contentHash)}),e.jsx("time",{children:Ie(n.occurredAt)})]},`${n.evidence.id}:${n.evidence.contentHash}`))})]}):null]})]})}function xl({accepting:s,onAcceptTasksetReview:n,review:a}){const t=a.classification==="taskset"&&a.nextAuthority==="human_review"&&a.tasksetProposal===null;return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${a.classification}`,children:ye(a.classification)}),e.jsx("strong",{children:a.claim?.statement??a.reason}),e.jsxs("small",{children:[a.selectedEvidence.length," selected"]}),e.jsx("time",{children:Ie(a.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:a.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:a.claim?.independentOccurrences??0})," independent occurrences"]}),e.jsxs("span",{children:["Next: ",e.jsx("strong",{children:ye(a.nextAuthority)})]})]}),e.jsx(gl,{review:a}),t?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>n(a),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null]})]})}function jl({receipt:s}){return e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:ye(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsxs("small",{children:[ye(s.signal.strength)," signal"]}),e.jsx("time",{children:Ie(s.createdAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("dl",{className:"harness-compact-metadata",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Review"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:Se(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function bl({acceptingReviewId:s,candidates:n,onAcceptTasksetReview:a,qualifications:t,reviews:l,schedule:i}){const d=i.activityEnabled||i.enabled;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx("section",{className:"harness-history-section","aria-label":"Continuous Review status",children:e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-review-status-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Trigger"}),e.jsx("th",{children:"Last review"}),e.jsx("th",{children:"Last result"})]})}),e.jsx("tbody",{children:e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`harness-status ${d?"harness-status-advanced":""}`,children:d?"On":"Off"})}),e.jsx("td",{children:i.activityEnabled?`${i.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:Ie(i.lastRunAt)}),e.jsx("td",{children:i.lastResult?ye(i.lastResult.classification):"No completed review"})]})})]})})}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Patterns"}),e.jsx("p",{children:"Recurring evidence being watched or ready for the Refiner."})]}),e.jsx("span",{children:n.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:n.length?n.map(c=>e.jsx(fl,{candidate:c},`${c.id}:${c.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No recurring patterns are being tracked."})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review history"}),e.jsx("p",{children:"Receipts stay compact; expand one for evidence and downstream lineage."})]}),e.jsx("span",{children:l.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:l.length?l.map(c=>e.jsx(xl,{accepting:s===c.id,onAcceptTasksetReview:a,review:c},`${c.id}:${c.contentHash}`)):e.jsx("div",{className:"harness-empty compact",children:"No Continuous Review receipts yet."})})]}),t.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Training handoffs"}),e.jsx("p",{children:"Evidence-bound qualification receipts created for Models."})]}),e.jsx("span",{children:t.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:t.map(c=>e.jsx(jl,{receipt:c},`${c.id}:${c.contentHash}`))})]}):null]})}const vl="Update the Refiner Review Profile. Inspect the current profile first, ask what should change if it is not already clear, and show the exact release transition.";function Fs(s){const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function we(s){return s?s.slice(0,10):"none"}function yl({busyReleaseHash:s,history:n,onRequestRelease:a,onStartAuthoring:t}){const l=r.useMemo(()=>{const i=new Map;for(const d of n.transitions)i.has(d.nextRelease.contentHash)||i.set(d.nextRelease.contentHash,d);return i},[n.transitions]);return e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review Profile"}),e.jsx("p",{children:"Separately versioned policy composed with the immutable Refiner Core."})]}),t?e.jsx("button",{className:"settings-primary compact",onClick:()=>t(vl),type:"button",children:"Edit with Work"}):null]}),e.jsxs("div",{className:"harness-summary-grid",children:[e.jsxs("article",{children:[e.jsx("span",{children:"Active release"}),e.jsx("strong",{children:we(n.binding.release.contentHash)}),e.jsxs("small",{children:["Binding revision ",n.binding.revision]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Profile"}),e.jsx("strong",{children:n.currentRelease.profile.name}),e.jsxs("small",{children:[n.currentRelease.profile.id,"@",n.currentRelease.profile.version]})]}),e.jsxs("article",{children:[e.jsx("span",{children:"Core"}),e.jsx("strong",{children:n.currentRelease.coreVersion}),e.jsx("small",{children:we(n.currentRelease.coreHash)})]})]}),e.jsx("p",{children:n.currentRelease.profile.objective}),n.currentRelease.profile.instructions.length?e.jsx("div",{className:"harness-edit-list",children:n.currentRelease.profile.instructions.map(i=>e.jsx("section",{className:"harness-edit",children:e.jsxs("div",{children:[e.jsx("strong",{children:i.id}),e.jsx("span",{children:i.text})]})},i.id))}):e.jsx("div",{className:"harness-empty compact",children:"The default profile adds no instructions beyond the Refiner Core."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Profile releases"}),e.jsx("p",{children:"Immutable definition history. Rollback changes future reviews only."})]}),e.jsx("span",{children:n.releases.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Profile"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:n.releases.map(i=>{const d=i.contentHash===n.binding.release.contentHash,c=!d&&l.get(i.contentHash)?.bindingChanged===!1,h=c?"activate":"rollback";return e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("strong",{children:i.profile.name}),e.jsxs("small",{children:[i.profile.id,"@",i.profile.version," · ",i.profile.instructions.length," instructions"]})]}),e.jsx("td",{children:e.jsx("code",{children:we(i.contentHash)})}),e.jsx("td",{children:Fs(i.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:d?"active":c?"draft":"immutable"})}),e.jsx("td",{children:d?null:e.jsx("button",{"aria-label":`${c?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(i,h),title:`${c?"Activate":"Roll back"} Refiner release`,type:"button",children:c?e.jsx(is,{size:14}):e.jsx(He,{size:14})})})]},i.contentHash)})})]})})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Definition changes"}),e.jsx("p",{children:"Receipts record which release changed, why, and which authoring Skill produced it."})]}),e.jsx("span",{children:n.transitions.length})]}),e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Operation"}),e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Release transition"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Created"})]})}),e.jsx("tbody",{children:n.transitions.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("span",{className:"harness-status",children:[i.operation,i.bindingChanged?" · active":" · draft"]})}),e.jsxs("td",{children:[e.jsx("strong",{children:i.reason}),e.jsx("small",{children:i.authoringSkillHash?`Skill ${we(i.authoringSkillHash)}`:i.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[we(i.previousRelease?.contentHash)," → ",we(i.nextRelease.contentHash)]})}),e.jsx("td",{children:i.validation.valid?"Passed":i.validation.messages.join("; ")}),e.jsx("td",{children:Fs(i.createdAt)})]},i.contentHash))})]})})]})]})}const Nl={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},wl={overview:{title:"Harness overview",description:"Current state, items needing attention, and recent learning activity."},refiner:{title:"Refiner",description:"Validated per-turn improvements and recommendations routed outside the Harness."},"continuous-review":{title:"Continuous Review",description:"Recurring patterns found across completed work and their immutable review receipts."},contents:{title:"Harness contents",description:"The instructions, skills, agents, and memory available in the current release."},releases:{title:"Harness releases",description:"Immutable versions, diffs, and rollback controls."}};function Re(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Pe(s){return s?s.slice(0,10):"none"}function Gs(s,n,a){return{workspaceId:s,baseRelease:n?{id:n.id,contentHash:n.contentHash}:null,targetRelease:{id:a.id,contentHash:a.contentHash},title:a.current?"Current Harness release":`Harness release ${Pe(a.contentHash)}`}}function Sl({review:s,busy:n,onReview:a}){return e.jsxs("article",{className:"harness-history-card harness-review-card",children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("div",{className:"harness-history-kicker",children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"review required"}),e.jsxs("span",{children:[s.proposal.route," · ",s.proposal.edits[0]?.operation??"change"]})]}),e.jsx("h2",{children:s.proposal.expectedOutcome})]}),e.jsx("time",{children:Re(s.proposal.createdAt)})]}),e.jsx("p",{children:s.proposal.edits.map(t=>t.summary).join(" ")}),e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Exact edits (",s.proposal.edits.length,")"]}),e.jsx("div",{className:"harness-edit-list",children:s.proposal.edits.map(t=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.operation," · ",t.target]}),e.jsx("span",{children:t.summary})]}),t.content!==null?e.jsx("pre",{children:t.content}):e.jsx("p",{children:"File deleted."})]},t.id))})]}),s.validations.length?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Validation receipts (",s.validations.length,")"]}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(t=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${t.status}`,children:t.status}),e.jsx("strong",{children:t.kind.replaceAll("_"," ")}),e.jsx("span",{children:t.summary})]},t.id))})]}):null,e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>a(s,"decline"),type:"button",children:[e.jsx(oe,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:n||s.validations.some(t=>t.status!=="passed"),onClick:()=>a(s,"approve"),type:"button",children:[e.jsx(is,{size:13})," Approve and release"]})]})]})}function kl({change:s,onClose:n}){const a=s.proposal;return e.jsxs(pt,{ariaLabel:"Refiner change details",backdropClassName:"harness-details-dialog-backdrop",className:"harness-details-dialog",onClose:n,children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("h2",{children:a?.expectedOutcome??s.receipt.reason}),e.jsx("p",{children:s.receipt.reason})]}),e.jsx("button",{"aria-label":"Close change details",onClick:n,type:"button",children:e.jsx(oe,{size:16})})]}),e.jsxs("div",{className:"harness-details-dialog-body",children:[a?.edits.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Exact edits"}),e.jsx("div",{className:"harness-edit-list",children:a.edits.map(t=>e.jsxs("article",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[t.operation," · ",t.target]}),e.jsx("span",{children:t.summary})]}),t.content!==null?e.jsx("pre",{children:t.content}):e.jsx("p",{children:"File deleted."})]},t.id))})]}):null,s.validations.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Validation"}),e.jsx("div",{className:"harness-validation-list",children:s.validations.map(t=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${t.status}`,children:t.status}),e.jsx("strong",{children:t.kind.replaceAll("_"," ")}),e.jsx("span",{children:t.summary})]},t.id))})]}):null]})]})}function Cl({history:s,reviewingProposalId:n,onReviewProposal:a}){const t=r.useMemo(()=>[...s.changes.map(l=>({id:`change:${l.receipt.id}`,at:l.receipt.createdAt,kind:"Refiner",title:l.proposal?.expectedOutcome??l.receipt.reason,detail:l.receipt.decision.replaceAll("_"," ")})),...s.routes.map(l=>({id:`route:${l.decision.id}`,at:l.decision.createdAt,kind:"Routed",title:l.decision.reason,detail:l.decision.route})),...s.evaluationReviews.map(l=>({id:`review:${l.id}`,at:l.createdAt,kind:"Continuous Review",title:l.claim?.statement??l.reason,detail:l.classification.replaceAll("_"," ")}))].sort((l,i)=>i.at.localeCompare(l.at)).slice(0,6),[s]);return e.jsxs("div",{className:"harness-page-sections",children:[s.pendingReviews.length?e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Needs review"}),e.jsx("p",{children:"Sensitive or high-impact proposals require your approval."})]}),e.jsx("span",{children:s.pendingReviews.length})]}),s.pendingReviews.map(l=>e.jsx(Sl,{busy:n!==null,onReview:a,review:l},`${l.proposal.id}:${l.proposal.contentHash}`))]}):null,e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Recent activity"}),e.jsx("p",{children:"The latest events from both learning loops."})]}),e.jsx("span",{children:t.length})]}),t.length?e.jsx("div",{className:"harness-activity-list",children:t.map(l=>e.jsxs("article",{children:[e.jsx("span",{children:l.kind}),e.jsxs("div",{children:[e.jsx("strong",{children:l.title}),e.jsx("small",{children:l.detail})]}),e.jsx("time",{children:Re(l.at)})]},l.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function Rl({history:s,refiner:n,busyReleaseHash:a,onRequestRefinerRelease:t,onStartRefinerAuthoring:l,onOpenChangeDiff:i,onOpenSourceSession:d}){const[c,h]=r.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(yl,{busyReleaseHash:a,history:n,onRequestRelease:t,onStartAuthoring:l}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Applied changes"}),e.jsx("p",{children:"Every release transition with exact edits and validation receipts."})]}),e.jsx("span",{children:s.changes.length})]}),s.changes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-refiner-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Target"}),e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Result"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:s.changes.map(p=>{const o=p.trigger?.runRef??null,g=p.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:g?.expectedOutcome??p.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:g?.edits[0]?.target??g?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Pe(p.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Re(p.receipt.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:`harness-status harness-status-${p.receipt.decision}`,children:p.receipt.decision.replaceAll("_"," ")})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View evidence and exact edits",className:"harness-table-icon-action",onClick:()=>h(p),title:"View evidence and exact edits",type:"button",children:e.jsx(bt,{size:14})}),p.receipt.nextRelease?e.jsx("button",{"aria-label":"View release diff",className:"harness-table-icon-action",onClick:()=>i(p),title:"View release diff",type:"button",children:e.jsx(tn,{size:14})}):null,o&&d?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>d(o),title:"Open source conversation",type:"button",children:e.jsx(Qs,{size:14})}):null]})})]},`${p.receipt.id}:${p.receipt.contentHash}`)})})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness changes have been applied."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Routed recommendations"}),e.jsx("p",{children:"Observations sent to runtime, product, Tasksets, or training without mutating the Harness."})]}),e.jsx("span",{children:s.routes.length})]}),s.routes.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-route-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Recommendation"}),e.jsx("th",{children:"Source evidence"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Route"})]})}),e.jsx("tbody",{children:s.routes.map(p=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("p",{children:p.decision.reason})}),e.jsx("td",{children:e.jsx("p",{children:p.trigger?.reason??"Completed work"})}),e.jsx("td",{children:Re(p.decision.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:p.decision.route})})]},`${p.decision.id}:${p.decision.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No recommendations have been routed."})]}),c?e.jsx(kl,{change:c,onClose:()=>h(null)}):null]})}function Pl(s){return s.includes("/skills/")||s.startsWith("skills/")?"Skill":s.includes("/agents/")||s.startsWith("agents/")?"Agent":s.includes("memory")?"Memory":s.endsWith(".md")?"Instruction":"File"}function Al(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function Dl({history:s,onOpenCurrentRelease:n}){const a=s.releases.find(t=>t.current)??s.releases[0]??null;return e.jsxs("div",{className:"harness-page-sections",children:[e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Current release"}),e.jsx("p",{children:"Read-only source contents currently supplied by the Personal Harness."})]}),a?e.jsx("button",{className:"settings-secondary compact",onClick:n,type:"button",children:"View release diff"}):null]}),a?.files.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Type"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Size"}),e.jsx("th",{children:"Revision"})]})}),e.jsx("tbody",{children:a.files.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:Pl(t.path)})}),e.jsx("td",{children:e.jsx("code",{children:t.path})}),e.jsx("td",{children:Al(t.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Pe(t.contentHash)})})]},t.id))})]})}):e.jsx("div",{className:"harness-empty compact",children:"The current release has no source files."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Memory"}),e.jsx("p",{children:"Bounded memory available through search; it is not copied into every prompt."})]}),e.jsx("span",{children:s.memories.length})]}),e.jsx("div",{className:"harness-disclosure-list",children:s.memories.length?s.memories.map(t=>e.jsxs("details",{className:"harness-disclosure-row",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"harness-status",children:"Memory"}),e.jsx("strong",{children:t.key}),e.jsxs("small",{children:["revision ",t.revision]}),e.jsx("time",{children:Re(t.updatedAt)})]}),e.jsxs("div",{className:"harness-disclosure-body",children:[e.jsx("p",{children:t.content}),t.tags.length?e.jsx("small",{children:t.tags.join(" · ")}):null]})]},`${t.id}:${t.revision}`)):e.jsx("div",{className:"harness-empty compact",children:"No Harness memory has been saved."})})]})]})}function $l({busy:s,history:n,onOpenDiff:a,onRequestRollback:t}){return e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Release history"}),e.jsx("p",{children:"New work uses the current release; active runs stay pinned to the version they started with."})]}),e.jsx("span",{children:n.releases.length})]}),n.releases.length?e.jsx("div",{className:"harness-table-wrap",children:e.jsxs("table",{className:"harness-table harness-release-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Release"}),e.jsx("th",{children:"Contents"}),e.jsx("th",{children:"Created"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:n.releases.map((l,i)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("div",{className:"harness-release-identity",children:[e.jsx("strong",{children:l.id}),e.jsx("code",{children:Pe(l.contentHash)})]})}),e.jsxs("td",{children:[l.files.length," files"]}),e.jsx("td",{children:Re(l.createdAt)}),e.jsx("td",{children:l.current?e.jsx("span",{className:"harness-current-pill",children:"Current"}):e.jsx("span",{className:"harness-status",children:"Previous"})}),e.jsx("td",{children:e.jsxs("div",{className:"harness-inline-actions",children:[e.jsx("button",{"aria-label":"View release changes",className:"harness-table-icon-action",onClick:()=>a(n.releases[i+1]??null,l),title:"View release changes",type:"button",children:e.jsx(tn,{size:14})}),l.current?null:e.jsx("button",{"aria-label":"Roll back to release",className:"harness-table-icon-action",disabled:s,onClick:()=>t(l),title:"Roll back to release",type:"button",children:e.jsx(He,{size:14})})]})})]},`${l.id}:${l.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function Il({connection:s,enabled:n,onAcceptEvaluationReview:a,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:d,onStartRefinerAuthoring:c,onToast:h,page:p}){const[o,g]=r.useState(null),[m,u]=r.useState(null),[x,v]=r.useState(null),[N,k]=r.useState(!1),[C,S]=r.useState(null),[R,f]=r.useState(null),[P,I]=r.useState(!1),[O,j]=r.useState(!1),[w,y]=r.useState(null),{confirmAction:b,confirmDialog:z,resolveConfirmDialog:H}=Ws(),_=!!(o?.evaluationReviewSchedule.activityEnabled||o?.evaluationReviewSchedule.enabled),[V,Z]=r.useState(!1),[E,K]=r.useState(!1);r.useEffect(()=>{o&&Z(o.backgroundReview.enabled)},[o?.backgroundReview.enabled]),r.useEffect(()=>{K(_)},[_]);const U=r.useCallback(async()=>{if(s){k(!0);try{const[D,A]=await Promise.all([T.harnessHistory(s),T.refinerHistory(s)]);g(D),u(A);const M=D.releases.findIndex(J=>J.current),L=M>=0?D.releases[M]:null;D.workspace&&L&&l(Gs(D.workspace.id,D.releases[M+1]??null,L)),t(null)}catch(D){t(D instanceof Error?D.message:String(D))}finally{k(!1)}}},[s,l,t]);r.useEffect(()=>{n&&U()},[n,p,U]);const ee=r.useCallback(async D=>{if(!(!s||!o?.workspace)){j(!0);try{const A=await T.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:D});g(A.history),t(null),h?.(`Continuous Review completed: ${A.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(A){t(A instanceof Error?A.message:String(A))}finally{j(!1)}}},[s,o,t,h]),Y=r.useCallback(async(D,A,M)=>{if(!(!s||!o?.workspace)){I(!0);try{let L=o;D==="refiner"&&A!==o.backgroundReview.enabled&&(L=(await T.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:A})).history);const J=o.evaluationReviewSchedule.activityEnabled||o.evaluationReviewSchedule.enabled;if(D==="continuous-review"&&(M!==J||o.evaluationReviewSchedule.enabled)){const W=o.evaluationReviewSchedule;L=(await T.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,enabled:!1,activityEnabled:M,activityBatchSize:W.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:W.maxEstimatedCostUsd})).history}g(L),t(null),h?.(`${D==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(L){t(L instanceof Error?L.message:String(L))}finally{I(!1)}}},[s,o,t,h]),ce=r.useCallback(async D=>{if(o?.workspace){y(D.id);try{await a(o.workspace.id,{id:D.id,contentHash:D.contentHash})&&(t(null),h?.("Taskset review opened in Models.","success"))}catch(A){t(A instanceof Error?A.message:String(A))}finally{y(null)}}},[o?.workspace,a,t,h]),F=r.useCallback((D,A)=>{o?.workspace&&i(Gs(o.workspace.id,D,A))},[o?.workspace,i]),B=r.useCallback(D=>{!o?.workspace||!D.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:D.receipt.previousRelease,targetRelease:D.receipt.nextRelease,title:D.proposal?.expectedOutcome??D.receipt.reason})},[o?.workspace,i]),Q=r.useCallback(async D=>{if(!(!s||!o?.workspace)){S(D.contentHash);try{const A=await T.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:D.id,contentHash:D.contentHash}});g(A.history),t(null),h?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(A){t(A instanceof Error?A.message:String(A))}finally{S(null)}}},[s,o?.workspace,t,h]),te=r.useCallback(async D=>{await b({title:"Roll back Harness release?",body:`New work will use ${Pe(D.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await Q(D)},[b,Q]),le=r.useCallback(async(D,A)=>{if(!(!s||!await b({title:A==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${D.profile.name} at ${Pe(D.contentHash)}. Existing work remains pinned.`,confirmLabel:A==="activate"?"Activate":"Roll back"}))){v(D.contentHash);try{const L={release:{id:D.id,contentHash:D.contentHash},reason:`${A==="activate"?"Activate":"Rollback"} from Settings to ${D.profile.id}@${D.profile.version}.`,actor:"settings-user"};u(await(A==="activate"?T.activateRefinerRelease(s,L):T.rollbackRefinerRelease(s,L))),t(null),h?.(`Refiner ${A==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(L){t(L instanceof Error?L.message:String(L))}finally{v(null)}}},[b,s,t,h]),de=r.useCallback(async(D,A)=>{if(!(!s||!o?.workspace)){f(D.proposal.id);try{const M=await T.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:D.proposal.id,contentHash:D.proposal.contentHash},decision:A});g(M.history),t(null),h?.(A==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",A==="approve"?"success":"info")}catch(M){t(M instanceof Error?M.message:String(M))}finally{f(null)}}},[s,o?.workspace,t,h]),X=o?.releases.find(D=>D.current)??o?.releases[0]??null,se=X?o?.releases.indexOf(X)??-1:-1,ue=wl[p],he=o?p==="refiner"?V!==o.backgroundReview.enabled:E!==_||o.evaluationReviewSchedule.enabled:!1,ie=p==="refiner"||p==="continuous-review";return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title harness-page-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:ue.title}),e.jsx("p",{children:ue.description})]}),o?.workspace&&ie?e.jsxs("div",{className:"harness-page-header-actions",children:[p==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:O,onClick:()=>{ee(o.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:O?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:p==="refiner"?V?"On":"Off":E?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":p==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:p==="refiner"?V:E,disabled:P,onChange:D=>p==="refiner"?Z(D.target.checked):K(D.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:P||!he,onClick:()=>{Y(p,V,E)},type:"button",children:P?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&N&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace&&p==="overview"?e.jsx(Cl,{history:o,onReviewProposal:de,reviewingProposalId:R}):null,o&&m&&p==="refiner"?e.jsx(Rl,{busyReleaseHash:x,history:o,refiner:m,onOpenChangeDiff:B,onOpenSourceSession:d,onRequestRefinerRelease:(D,A)=>{le(D,A)},onStartRefinerAuthoring:c}):null,o?.workspace&&p==="continuous-review"?e.jsx(bl,{acceptingReviewId:w,candidates:o.refinementCandidates,onAcceptTasksetReview:D=>{ce(D)},qualifications:o.modelImprovementQualifications,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??Nl}):null,o?.workspace&&p==="contents"?e.jsx(Dl,{history:o,onOpenCurrentRelease:()=>{X&&F(se>=0?o.releases[se+1]??null:null,X)}}):null,o?.workspace&&p==="releases"?e.jsx($l,{busy:C!==null,history:o,onOpenDiff:F,onRequestRollback:D=>{te(D)}}):null,e.jsx(Vs,{onResolve:H,state:z})]})}function qs(s){return s?s.slice(0,10):"initial"}function El({connection:s,expanded:n,onResizeStart:a,onToggleExpanded:t,selection:l}){const[i,d]=r.useState(null),[c,h]=r.useState(null),[p,o]=r.useState(!0),g=r.useCallback(async()=>{h(null),o(!0);try{d(await T.harnessReleaseDiff(s,l))}catch(x){d(null),h(x instanceof Error?x.message:String(x))}finally{o(!1)}},[s,l]);r.useEffect(()=>{g()},[g]);const m=r.useMemo(()=>i?{appId:`harness:${l.workspaceId}`,repoPath:l.title,initialized:!0,dirty:i.filesChanged>0,filesChanged:i.filesChanged,additions:i.additions,deletions:i.deletions,repoFiles:i.files.map(x=>x.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),u=`${l.title} · ${qs(l.baseRelease?.contentHash)} → ${qs(l.targetRelease.contentHash)}`;return e.jsx(gt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:m,editorPreferences:null,expanded:n,filesWithPreview:!0,loading:p,onOpenBrowserUrl:()=>{},onRefresh:g,onResizeStart:a,onToggleExpanded:t,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:u})}function Ol({connection:s,onError:n,onPayload:a}){const[t,l]=r.useState(!1),[i,d]=r.useState(!1);async function c(g,m){if(s){l(!0),n(null);try{const u=await T.switchOpenPondAccount(s,{handle:g,baseUrl:m??null}),x=await T.savePreferences(s,{defaultTeamId:null});a({...u,preferences:x.preferences})}catch(u){n(u instanceof Error?u.message:String(u))}finally{l(!1)}}}async function h(g,m){if(!s)return!1;l(!0),n(null);try{return a(await T.removeOpenPondAccount(s,{handle:g,baseUrl:m??null})),!0}catch(u){return n(u instanceof Error?u.message:String(u)),!1}finally{l(!1)}}async function p(g){if(!(!s||!g.apiKey.trim())){l(!0),n(null);try{const m=g.handle?.trim(),u=g.environment?.trim(),x=await T.saveOpenPondAccount(s,{apiKey:g.apiKey.trim(),handle:m||void 0,baseUrl:g.baseUrl,apiBaseUrl:g.apiBaseUrl,environment:u||"custom",setActive:!0}),v=await T.savePreferences(s,{defaultTeamId:null});a({...x,preferences:v.preferences})}catch(m){throw n(m instanceof Error?m.message:String(m)),m}finally{l(!1)}}}async function o(){if(s){d(!0),n(null);try{a(await T.refreshOpenPondAccounts(s))}catch(g){n(g instanceof Error?g.message:String(g))}finally{d(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:o,removeAccount:h,saveAccount:p,switchAccount:c}}function Ml({connection:s,onError:n,onPreferences:a,preferences:t,providers:l}){const[i,d]=r.useState(t.defaultBranchPrefix),[c,h]=r.useState(t.defaultNewProjectDirectory),[p,o]=r.useState(t.advancedWorkspaceControls),[g,m]=r.useState(t.steerActiveResponses),[u,x]=r.useState(t.contextCompaction.autoEnabled),[v,N]=r.useState(t.subagents.enabled),[k,C]=r.useState(t.subagents.delegationMode),[S,R]=r.useState(!t.subagents.defaultModelRef),[f,P]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[I,O]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[j,w]=r.useState(t.subagents.roles),[y,b]=r.useState(t.subagents.maxConcurrentRuns),[z,H]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[_,V]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[Z,E]=r.useState(!1),K=S?null:{providerId:f,modelId:I.trim()},U=v!==t.subagents.enabled||k!==t.subagents.delegationMode||!Tl(K,t.subagents.defaultModelRef)||y!==t.subagents.maxConcurrentRuns||z!==t.subagents.maxConcurrentRunsPerProvider||_!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(j)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{d(t.defaultBranchPrefix),h(t.defaultNewProjectDirectory),o(t.advancedWorkspaceControls),m(t.steerActiveResponses),x(t.contextCompaction.autoEnabled),N(t.subagents.enabled),C(t.subagents.delegationMode),R(!t.subagents.defaultModelRef),P(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),O(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),w(t.subagents.roles),b(t.subagents.maxConcurrentRuns),H(t.subagents.maxConcurrentRunsPerProvider),V(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.steerActiveResponses,t.contextCompaction.autoEnabled,t.subagents]);function ee(A){P(A),O(M=>ns(A,M,l))}function Y(){return S?t.defaultChatProvider:f}function ce(){return S?t.defaultChatModel:I}function F(A,M){w(L=>L.map(J=>J.id===A?M(J):J))}function B(A,M){F(A,L=>({...L,enabled:M}))}function Q(A,M){F(A,L=>({...L,background:M}))}function te(A,M){F(A,L=>{if(M)return{...L,modelRef:null};const J=L.modelRef?.providerId??Y(),W=L.modelRef?.modelId??ce();return{...L,modelRef:Ge(J,W,l)??null}})}function le(A,M){F(A,L=>({...L,modelRef:Ge(M,L.modelRef?.modelId??ce(),l)??null}))}function de(A,M){F(A,L=>{const J=L.modelRef?.providerId??Y(),W=M.trim();return{...L,modelRef:W?{providerId:J,modelId:W}:null}})}function X(A,M){F(A,L=>({...L,isolationMode:M}))}function se(A,M){F(A,L=>({...L,toolPolicy:M}))}function ue(A,M){F(A,L=>({...L,peerMessages:M}))}function he(A,M){F(A,L=>({...L,maxConcurrentRuns:ve(M,1,16)}))}async function ie(){let A=null;if(window.openpond?.selectFolder){const M=await window.openpond.selectFolder();if(M.canceled)return;A=M.path}else A=window.prompt("Default new project directory",c);A?.trim()&&h(A.trim())}async function D(A){if(A.preventDefault(),!!s){E(!0),n(null);try{a(await T.savePreferences(s,{defaultBranchPrefix:Qe(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:p,steerActiveResponses:g,contextCompaction:{...t.contextCompaction,autoEnabled:u},subagents:{enabled:v,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:k,defaultModelRef:S?null:Ge(f,I,l)??null,roles:j,maxConcurrentRuns:ve(y,1,32),maxConcurrentRunsPerProvider:z===null?null:ve(z,1,32),maxConcurrentRunsPerWorkspaceTarget:_===null?null:ve(_,1,32)}}))}catch(M){n(M instanceof Error?M.message:String(M))}finally{E(!1)}}}return{advancedWorkspaceControls:p,steerActiveResponses:g,contextCompactionAutoEnabled:u,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:v,subagentDelegationMode:k,subagentsUseDefaultModel:S,subagentsProvider:f,subagentsModel:I,subagentRoles:j,subagentsMaxConcurrentRuns:y,subagentsMaxConcurrentRunsPerProvider:z,subagentsMaxConcurrentRunsPerWorkspaceTarget:_,subagentsDirty:U,saving:Z,chooseDefaultProjectDirectory:ie,saveDefaults:D,changeSubagentsProvider:ee,changeSubagentRoleProvider:le,setAdvancedWorkspaceControls:o,setSteerActiveResponses:m,setContextCompactionAutoEnabled:x,setDefaultBranchPrefix:d,setDefaultNewProjectDirectory:h,setSubagentsUseDefaultModel:R,setSubagentsModel:O,setSubagentsEnabled:N,setSubagentDelegationMode:A=>C(A),setSubagentsMaxConcurrentRuns:A=>b(ve(A,1,32)),setSubagentsMaxConcurrentRunsPerProvider:A=>H(A===null?null:ve(A,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:A=>V(A===null?null:ve(A,1,32)),setSubagentRoleBackground:Q,setSubagentRoleEnabled:B,setSubagentRoleIsolationMode:X,setSubagentRoleMaxConcurrentRuns:he,setSubagentRoleModel:de,setSubagentRolePeerMessages:ue,setSubagentRoleToolPolicy:se,setSubagentRoleUseDefaultModel:te}}function ve(s,n,a){return Number.isFinite(s)?Math.min(a,Math.max(n,Math.trunc(s))):n}function Tl(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Ll=15e3,zl=100,Ul=100,Bl=2500;function Hl({onError:s,section:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(zl),[h,p]=r.useState([]),[o,g]=r.useState(null),[m,u]=r.useState(!0),x=r.useRef(null),[v,N]=r.useState(null),k=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),S=!!window.openpond?.readRecentLogs?`${h.length} of ${d} line${d===1?"":"s"}${m?" tailing":""}`:"Unavailable";r.useEffect(()=>{n==="diagnostics"&&R(d,"refresh",{quiet:!0})},[n]),r.useEffect(()=>{if(n!=="diagnostics"||!m||!window.openpond?.readRecentLogs)return;let w=!1;const y=window.setInterval(()=>{w||(w=!0,R(d,"refresh",{quiet:!0}).finally(()=>{w=!1}))},Bl);return()=>window.clearInterval(y)},[n,m,d]),r.useEffect(()=>{if(n!=="diagnostics"||!m)return;const w=x.current;w&&(w.scrollTop=w.scrollHeight)},[n,m,h]);async function R(w=d,y="refresh",b={}){const z=window.openpond?.readRecentLogs;if(!z){const H="Log view is not available in this runtime.";b.quiet||(N({label:"Logs",value:H,warning:!0}),s(H));return}b.quiet||i(y);try{const H=await Oe(z(w),"Read logs");if(!H.ok)throw new Error(H.error);c(H.lineLimit),g(H.logDir),p(H.lines),b.quiet?N(_=>_?.label==="Logs"?null:_):N(null)}catch(H){const _=H instanceof Error?H.message:String(H);N({label:"Logs",value:_,warning:!0}),b.quiet||s(_)}finally{b.quiet||i(null)}}function f(){u(!1),R(d+Ul,"older")}function P(){const w=!m;u(w),w&&R(d,"refresh",{quiet:!0})}async function I(){const w=window.openpond?.openLogsFolder;if(!w){const y="Desktop logs are not available in this runtime.";N({label:"Logs",value:y,warning:!0}),s(y);return}t("logs"),s(null);try{const y=await Oe(w(),"Open logs");if(!y.ok)throw new Error(y.error??"Could not open the logs folder.");N(null)}catch(y){const b=y instanceof Error?y.message:String(y);N({label:"Logs",value:b,warning:!0}),s(b)}finally{t(null)}}async function O(){const w=window.openpond?.copyRecentLogs;if(!w){const y="Recent log copy is not available in this runtime.";N({label:"Copy",value:y,warning:!0}),s(y);return}t("copy"),s(null);try{const y=await Oe(w(1e3),"Copy recent logs");if(!y.ok)throw new Error(y.error??"Could not copy recent logs.");N({label:"Copy",value:y.lines?`Copied ${y.lines} recent log lines.`:"Copied recent logs."})}catch(y){const b=y instanceof Error?y.message:String(y);N({label:"Copy",value:b,warning:!0}),s(b)}finally{t(null)}}async function j(){const w=window.openpond?.exportDiagnostics;if(!w){const y="Diagnostics export is not available in this runtime.";N({label:"Export",value:y,warning:!0}),s(y);return}t("export"),s(null);try{const y=await Oe(w(),"Export diagnostics");if(!y.ok)throw new Error(y.error??"Could not export diagnostics.");N({label:"Export",value:y.path?`Saved to ${y.path}`:"Diagnostics exported."})}catch(y){const b=y instanceof Error?y.message:String(y);N({label:"Export",value:b,warning:!0}),s(b)}finally{t(null)}}return{diagnosticsAvailable:k,diagnosticsBusy:a,diagnosticsStatus:v,logDir:o,logLineLimit:d,logLines:h,logViewBusy:l,logViewSummary:S,logViewportRef:x,tailLogs:m,copyRecentLogs:O,exportDiagnosticsBundle:j,loadOlderLogs:f,openLogsFolder:I,refreshLogView:R,toggleTailLogs:P}}async function Oe(s,n){let a;try{return await Promise.race([s,new Promise((t,l)=>{a=window.setTimeout(()=>{l(new Error(`${n} did not receive a desktop response.`))},Ll)})])}finally{a!==void 0&&window.clearTimeout(a)}}function _l({connection:s,enabled:n,onError:a,onPreferences:t,onToast:l,preferences:i}){const[d,c]=r.useState(i.editor),[h,p]=r.useState(null),[o,g]=r.useState(!1),[m,u]=r.useState(!1),[x,v]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const N=r.useCallback(async()=>{if(s){u(!0);try{p(await T.workspaceLspSettingsStatus(s))}catch(f){a(f instanceof Error?f.message:String(f))}finally{u(!1)}}},[s,a]);r.useEffect(()=>{!n||!s||N()},[s,n,N]);function k(f,P){c(I=>({...I,languages:{...I.languages,[f]:{...I.languages[f],mode:P}}}))}function C(f,P){c(I=>({...I,languages:{...I.languages,[f]:{...I.languages[f],customCommand:P}}}))}async function S(f){if(f.preventDefault(),!!s){g(!0),a(null);try{const P=await T.savePreferences(s,{editor:d});t(P),p(await T.workspaceLspSettingsStatus(s))}catch(P){a(P instanceof Error?P.message:String(P))}finally{g(!1)}}}async function R(){if(s){v(!0),a(null);try{await T.restartWorkspaceLsp(s),p(await T.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(f){a(f instanceof Error?f.message:String(f))}finally{v(!1)}}}return{editorPreferences:d,lspStatus:h,restarting:x,saving:o,statusLoading:m,refreshLspStatus:N,restartLanguageServers:R,saveEditorSettings:S,setEditorPreferences:c,setLanguageCustomCommand:C,setLanguageMode:k}}function Fl({connection:s,onError:n,onPayload:a,personalization:t}){const l=r.useMemo(()=>t.templates.map(j=>({value:j.id,label:j.name,description:j.id===t.activeTemplateId?"Selected":j.source==="built_in"?j.description:void 0})),[t.activeTemplateId,t.templates]),[i,d]=r.useState(t.activeTemplateId),[c,h]=r.useState(t.soul),[p,o]=r.useState(""),[g,m]=r.useState(!1),[u,x]=r.useState(!1),v=t.templates.find(j=>j.id===i)??t.templates[0],N=v?.source==="custom",k=v?c!==v.content:!0,C=i!==t.activeTemplateId||c!==t.soul||k,S=!!(N&&c.trim()&&v&&C);r.useEffect(()=>{d(t.activeTemplateId),h(t.soul);const j=t.templates.find(w=>w.id===t.activeTemplateId);o(j?`${j.name} Copy`:""),m(!1)},[t.activeTemplateId,t.soul,t.templates]);async function R(j=!1){if(!j&&!N)return;const w=j?p:v?.name;if(!(!s||!c.trim()||!w?.trim())){x(!0),n(null);try{a(await T.savePersonalization(s,{activeTemplateId:i,templateName:w,soul:c,saveAsNew:j})),m(!1)}catch(y){n(y instanceof Error?y.message:String(y))}finally{x(!1)}}}async function f(j){const w=t.templates.find(y=>y.id===j);if(w&&(d(w.id),o(`${w.name} Copy`),h(w.content),m(!1),!!s)){x(!0),n(null);try{a(await T.savePersonalization(s,{activeTemplateId:w.id,templateName:w.name,soul:w.content,saveAsNew:!1}))}catch(y){n(y instanceof Error?y.message:String(y))}finally{x(!1)}}}function P(){v&&(o(`${v.name} Copy`),h(v.content),m(!1))}function I(j){h(j),v&&!N&&j!==v.content&&m(!0)}function O(){v&&(o(`${v.name} Copy`),m(!0))}return{canSaveCurrentTemplate:S,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:g,saving:u,selectedPersonalizationTemplate:v,selectedTemplateIsCustom:N,soulDraft:c,templateNameDraft:p,changePersonalizationTemplate:f,changeSoulDraft:I,openSaveAsNew:O,resetPersonalizationDraft:P,savePersonalization:R,setSaveAsNewOpen:m,setTemplateNameDraft:o}}function Gl({connection:s,onError:n,onPreferences:a,onProviders:t,preferences:l,providers:i}){const[d,c]=r.useState(l.defaultChatProvider),[h,p]=r.useState(l.defaultChatModel),[o,g]=r.useState(!1),[m,u]=r.useState(null),[x,v]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),p(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function N(y){if(y.preventDefault(),!!s){g(!0),n(null);try{a(await T.savePreferences(s,{defaultChatProvider:d,defaultChatModel:ns(d,h,i)}))}catch(b){n(b instanceof Error?b.message:String(b))}finally{g(!1)}}}function k(y){c(y),p(b=>ns(y,b,i))}async function C(y,b,z){if(!s)return null;u(`${y}:${b}`),v(null),n(null);try{return await z()}catch(H){return n(H instanceof Error?H.message:String(H)),null}finally{u(null)}}async function S(y,b){await C(y,"config",async()=>{const z=await T.saveProviderSettings(s,{providers:{[y]:b}});return t(z),z})}async function R(y,b){await C(y,"credential",async()=>{const z=await T.saveProviderCredential(s,y,b);return t(z),z})}async function f(y){await C(y,"credential",async()=>{const b=await T.deleteProviderCredential(s,y,{});return t(b),b})}async function P(y){return C("openai","credential",async()=>{const b=await T.startOpenAiSubscriptionAuth(s,{method:y});return b.method==="browser"?(window.open(b.url,"_blank","noopener,noreferrer"),v("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(b.url,"_blank","noopener,noreferrer"),v(`OpenAI device login started. Enter code ${b.userCode}.`)),I(b.expiresAt),b})}async function I(y){if(s)for(;Date.now()<y;){await new Promise(b=>setTimeout(b,2500));try{const b=await T.providerSettings(s);t(b);const z=b.statuses.openai?.credential;if(z?.connected&&z.source==="chatgpt_subscription"){v("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function O(y){await C(y,"models",async()=>{const b=await T.refreshProviderModels(s,y,{force:!0});return t(b.providers),b})}async function j(y){await C(y,"models",async()=>{const b=await T.loadProviderModels(s,y,{limit:500});return t(b.providers),b})}async function w(y,b={}){await C(y,"validate",async()=>{const z=await T.validateProviderCredential(s,y,b);return v(z.ok?`${y} validated${z.modelId?` with ${z.modelId}`:""}.`:z.errors.join(`
|
|
9
|
+
`)||`${y} validation failed.`),t(z.providers),z})}return{defaultModel:h,defaultProvider:d,providerBusy:m,saving:o,validationMessage:x,changeDefaultProvider:k,deleteProviderCredential:f,loadProviderModels:j,refreshProviderModels:O,saveProviderConfig:S,saveProviderCredential:R,saveProviders:N,setDefaultModel:p,startOpenAiSubscriptionAuth:P,validateProvider:w}}function ql({connection:s,enabled:n,onError:a,onToast:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[h,p]=r.useState(!1),o=r.useRef(null),g=r.useCallback(async(P={})=>{if(s){P.quiet||c("refresh");try{const I=await T.remoteAccess(s);i(I),a(null)}catch(I){a(I instanceof Error?I.message:String(I))}finally{P.quiet||c(null)}}},[s,a]);r.useEffect(()=>{!n||!s||g({quiet:!0})},[s,n,g]),r.useEffect(()=>()=>{o.current!==null&&window.clearTimeout(o.current)},[]);function m(){o.current!==null&&window.clearTimeout(o.current),p(!1),window.setTimeout(()=>{p(!0),o.current=window.setTimeout(()=>{p(!1),o.current=null},1500)},0)}async function u(){if(a(null),!!s)try{i(await T.remoteAccess(s))}catch{}}async function x(){if(!s)return null;l&&!l.tailscale.running&&m(),c("enable");try{const P=await T.enableRemoteAccess(s);return i(P.status),a(null),P.status.tailscale.running?!P.status.serve.enabled&&P.status.serve.error&&t?.(P.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":P.message||P.status.serve.error,"error"):(m(),t?.(P.message||"Tailscale is not running. Run Tailscale up first.","error")),P.status}catch{return await u(),m(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{c(null)}}async function v(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){c("disable");try{const P=await T.disableRemoteAccess(s);i(P.status),a(null)}catch{await u()}finally{c(null)}}}async function N(){l?.remoteWebUrl&&(c("copy-link"),await Ne(l.remoteWebUrl),c(null))}async function k(){l?.serveCommand&&(c("copy-command"),await Ne(l.serveCommand),c(null))}async function C(){l?.serve.setupUrl&&(c("copy-serve-setup"),await Ne(l.serve.setupUrl),c(null))}async function S(){l?.tailscaleUpCommand&&(c("copy-up-command"),await Ne(l.tailscaleUpCommand),c(null))}async function R(){l?.operatorCommand&&(c("copy-operator"),await Ne(l.operatorCommand),c(null))}async function f(){if(!l?.serve.enabled){const P=await x();P?.serve.enabled&&P.remoteWebUrl&&await Ne(P.remoteWebUrl);return}await N()}return{status:l,busy:d,flashTailscaleUp:h,refresh:g,enableRemoteAccess:x,disableRemoteAccess:v,copyRemoteLink:N,copyTailscaleUpCommand:S,copyServeCommand:k,copyServeSetupUrl:C,copyOperatorCommand:R,createRemoteLink:f}}function Wl(s){const[n,a]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{a(await T.datasetStorageState(s.connection)),s.onError(null)}catch(c){s.onError(c instanceof Error?c.message:String(c))}finally{l(null)}}},[s.connection,s.onError]),d=r.useCallback(async c=>{if(!s.connection||!c)return!1;l("save");try{return a(await T.updateDatasetStorage(s.connection,c)),s.onError(null),!0}catch(h){return s.onError(h instanceof Error?h.message:String(h)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:n,busy:t,refresh:i,save:d}}function Vl(s){const{connection:n,enabled:a,onError:t,profileId:l}=s,[i,d]=r.useState(null),[c,h]=r.useState(!1),p=r.useCallback(async()=>{if(n){h(!0);try{d(await T.datasetCatalog(n,l)),t(null)}catch(o){t(Kl(o))}finally{h(!1)}}},[n,t,l]);return r.useEffect(()=>{a&&p()},[a,p]),{catalog:i,loading:c,refresh:p}}function Kl(s){return s instanceof Error?s.message:String(s)}const Jl=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function Yl(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const Ql=r.lazy(()=>Sn(()=>import("./UsageSettingsSection-4mMW5CCE.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function vi({payload:s,connection:n,diagnostics:a,onPayload:t,onError:l,onToast:i,onBack:d,onOpenSourceSession:c,onStartRefinerAuthoring:h,onAcceptEvaluationReview:p,onOpenSkill:o,onOpenExtension:g,teamChatCurrentUserId:m,teamChatEnabled:u,teamChatNotificationMode:x,teamChatThreads:v,onTeamChatNotificationModeChange:N,onTeamChatThreadMuteChange:k,diffPanelWidth:C,diffPanelResizing:S,diffPanelExpanded:R,onDiffPanelResizeStart:f,onDiffPanelExpandedChange:P,initialSection:I="account"}){const[O,j]=r.useState(I),[w,y]=r.useState(null),[b,z]=r.useState(!1),H=s?.codex??null,_=r.useMemo(()=>Zn(s?.preferences),[s?.preferences]),V=s?.personalization??Xn,Z=a??s?.diagnostics??[],E=et()&&st(n?.platform),K=r.useCallback(W=>{s&&t({...s,providers:W})},[t,s]),U=r.useCallback(W=>{s&&t({...s,preferences:W.preferences})},[t,s]),ee=r.useCallback(W=>{s&&t({...s,extensionCatalog:W})},[t,s]),Y=Ol({connection:n,onError:l,onPayload:t}),ce=Gl({connection:n,onError:l,onPayload:t,onPreferences:U,onProviders:K,preferences:_,providers:s?.providers??null}),F=Ml({connection:n,onError:l,onPayload:t,onPreferences:U,preferences:_,providers:s?.providers??null}),B=_l({connection:n,enabled:O==="editor",onError:l,onPayload:t,onPreferences:U,onToast:i,preferences:_}),Q=Fl({connection:n,onError:l,onPayload:t,personalization:V}),te=Hl({onError:l,section:O}),le=ql({connection:n,enabled:O==="remote",onError:l,onToast:i}),de=O==="dataset-storage",X=Wl({connection:n,enabled:de,onError:l}),se=Vl({connection:n,enabled:de,onError:l,profileId:s?.profile.activeProfile??"default"}),ue=X.save,he=r.useCallback(async()=>{await Promise.all([X.refresh(),se.refresh()])},[X.refresh,se.refresh]),ie=r.useCallback(()=>O!=="subagents"||!F.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[F.subagentsDirty,O]),D=r.useCallback(W=>{W!==O&&ie()&&(z(!1),P(!1),j(W),nt({kind:"settings",section:W}))},[ie,P,O]),A=r.useCallback(()=>{ie()&&(z(!1),P(!1),d())},[ie,d,P]);r.useEffect(()=>{j(I)},[I]),r.useEffect(()=>{if(O!=="subagents"||!F.subagentsDirty)return;const W=Ae=>{Ae.preventDefault(),Ae.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",W),()=>window.removeEventListener("beforeunload",W)},[F.subagentsDirty,O]);const M={"--diff-panel-width":`${C}px`},L=Jl.has(O),J=L&&b&&w;return e.jsxs("div",{className:`settings-shell ${E?"platform-macos":""} ${J?"harness-diff-open":""} ${R?"harness-diff-expanded":""} ${S?"diff-panel-resizing":""}`,style:M,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[L?e.jsx("button",{type:"button",className:`topbar-diff-button ${J?"active":""}`,title:`${J?"Hide":"Show"} sidebar`,"aria-label":`${J?"Hide":"Show"} sidebar`,"aria-pressed":!!J,disabled:!w,onClick:()=>z(W=>!W),children:e.jsx(tt,{size:16})}):null,e.jsx(at,{platform:n?.platform})]}),e.jsx(Ja,{section:O,onBack:A,onSectionChange:D}),e.jsxs("main",{className:`settings-content ${O==="profile"||L?"settings-content-wide":""}`,children:[O!=="configuration"?e.jsx(bs,{connection:n,bannerOnly:!0,onOpen:()=>D("configuration")}):null,O==="account"?e.jsx(It,{payload:s,connection:n,onPayload:t,onPreferences:U,onError:l,onToast:i,...Y}):O==="notifications"?e.jsx(Zt,{currentUserId:m,enabled:u,mode:x,threads:v,onModeChange:N,onThreadMuteChange:k}):L?e.jsx(Il,{connection:n,enabled:L,onAcceptEvaluationReview:p,onError:l,onDefaultReleaseDiff:y,onOpenSourceSession:c,onStartRefinerAuthoring:h,onOpenReleaseDiff:W=>{y(W),z(!0)},onToast:i,page:Yl(O)}):O==="profile"?e.jsx(xa,{payload:s,connection:n,onPayload:t,onError:l,onToast:i,onOpenSession:c}):O==="skills"?e.jsx(Qa,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:n,onExtensionCatalog:ee,onError:l,onToast:i,onOpenSkill:o,onOpenExtension:g}):O==="providers"?e.jsx(Ba,{account:s?.account??null,codex:H,providers:s?.providers??null,...ce}):O==="dataset-storage"?e.jsx(cl,{state:X.state,catalog:se.catalog,busy:X.busy,catalogLoading:se.loading,onRefresh:he,onSave:ue}):O==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(bs,{connection:n,onSaved:async()=>{n&&t(await T.bootstrap(n))}}),e.jsx(zt,{preferences:_,...F}),e.jsx(Ps,{embedded:!0,preferences:_,...F})]}):O==="context"?e.jsx(Ps,{preferences:_,...F}):O==="training"?e.jsx(Za,{connection:n,onError:l,onPreferences:U,preferences:_,providers:s?.providers??null}):O==="subagents"?e.jsx(Gt,{preferences:_,providers:s?.providers??null,...F}):O==="editor"?e.jsx(Ft,{preferences:_,...B}):O==="remote"?e.jsx(Ga,{...le}):O==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(Ql,{account:s?.account??null,connection:n,enabled:O==="usage",onError:l,onOpenSourceSession:c})}):O==="personalization"?e.jsx(ea,{...Q}):e.jsx(Ut,{diagnostics:Z,...te})]}),L&&n&&J?e.jsx(El,{connection:n,expanded:R,onResizeStart:f,onToggleExpanded:()=>P(!R),selection:J}):null]})}export{vi as SettingsView};
|