openpond 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/app-server.d.ts +2 -0
  2. package/dist/app-server.js +1 -1
  3. package/dist/chunks/{app-server-runtime-TAFUJGQS.js → app-server-runtime-HD5JPAPM.js} +1 -1
  4. package/dist/chunks/{chunk-UQ4OBVRS.js → chunk-4S5RDPKU.js} +1 -1
  5. package/dist/chunks/{chunk-3QVNGZFY.js → chunk-AH2O6IVI.js} +1 -1
  6. package/dist/chunks/chunk-FRWPAVCD.js +5 -0
  7. package/dist/chunks/{chunk-OTUTSGMI.js → chunk-JKE45L33.js} +1 -1
  8. package/dist/chunks/{chunk-RFPSEQO2.js → chunk-PGTNQ3XD.js} +305 -304
  9. package/dist/chunks/{cli-AUDD3IP5.js → cli-FKNLUIZM.js} +1 -1
  10. package/dist/chunks/src-W5JJF2NL.js +319 -0
  11. package/dist/chunks/{workspaces-EGHYKQZF.js → workspaces-O5VJG3TD.js} +1 -1
  12. package/dist/cli.js +1 -1
  13. package/dist/web/assets/{App-BGI70Zj6.js → App-CYWcs7S8.js} +3 -3
  14. package/dist/web/assets/{AppDialog-D4siaKMi.js → AppDialog-Ba0_0yq9.js} +1 -1
  15. package/dist/web/assets/{AppTerminalPanel-DSaxM9R8.js → AppTerminalPanel-Dkmrs9vr.js} +2 -2
  16. package/dist/web/assets/{AppsView-C14dtBI0.js → AppsView-DTw4bGn4.js} +1 -1
  17. package/dist/web/assets/{BrowserSidebar-BbB0tvuH.js → BrowserSidebar-BCDyYFbR.js} +1 -1
  18. package/dist/web/assets/{CartesianChart-GJVxLGBn.js → CartesianChart-RJq_kOU1.js} +1 -1
  19. package/dist/web/assets/{CollaborationTabs-wT2ymsi7.js → CollaborationTabs-DYzFEvn3.js} +1 -1
  20. package/dist/web/assets/{CommandMenu-DLe1d-iP.js → CommandMenu-Gzomv0-I.js} +1 -1
  21. package/dist/web/assets/{CommunityView-BoTn5n7e.js → CommunityView-Bbw9POsY.js} +1 -1
  22. package/dist/web/assets/{ComposerCreateImproveStrip-S2sXX8UJ.js → ComposerCreateImproveStrip-CxCSccrw.js} +1 -1
  23. package/dist/web/assets/{GetStartedView-DhpWR1nb.js → GetStartedView-D2H-GOva.js} +1 -1
  24. package/dist/web/assets/HostedModelLearningReview-DAxcFdXC.js +1 -0
  25. package/dist/web/assets/{HostedModelLearningSettings-BN4bvlGK.js → HostedModelLearningSettings-CrImZ5SD.js} +1 -1
  26. package/dist/web/assets/{LabModelVersionDetailPage-B0jRK9u9.js → LabModelVersionDetailPage-VLeQbYWF.js} +1 -1
  27. package/dist/web/assets/{LabSkillSidebar-CoHjFsXh.js → LabSkillSidebar-xFIOwcAU.js} +1 -1
  28. package/dist/web/assets/{LabsRoute-B5UTYHeh.js → LabsRoute--K78Pb_V.js} +4 -4
  29. package/dist/web/assets/{MainChatThread-CcH2yLdM.js → MainChatThread-D3G6QbR9.js} +2 -2
  30. package/dist/web/assets/{MainPane-BT58d6eG.js → MainPane-BB8WIemH.js} +4 -4
  31. package/dist/web/assets/{MarkdownText-D43uIpOy.js → MarkdownText-DQBTMcMm.js} +1 -1
  32. package/dist/web/assets/{Messages-DarNW0e1.js → Messages-B1G4vIqt.js} +1 -1
  33. package/dist/web/assets/{NativeSkillSidebar-3yNmqIFw.js → NativeSkillSidebar-DmcODSGl.js} +1 -1
  34. package/dist/web/assets/{NewExperienceSwitcher-Cle9jAk2.js → NewExperienceSwitcher-Dt0KJMMW.js} +1 -1
  35. package/dist/web/assets/{NewProjectDialog-DFAGQHU5.js → NewProjectDialog-BPGkYiMW.js} +1 -1
  36. package/dist/web/assets/{OutputsPage-BvoFsIeo.js → OutputsPage-CtK7mzhz.js} +1 -1
  37. package/dist/web/assets/{ProjectsPage-DLo3YoMa.js → ProjectsPage-0eahr0nB.js} +1 -1
  38. package/dist/web/assets/{RightChatPanelStack-B4v_t1S8.js → RightChatPanelStack-AOmhhZJT.js} +1 -1
  39. package/dist/web/assets/{RightSidebarHomePanel-jZW_Bepf.js → RightSidebarHomePanel-CsGIwtRW.js} +1 -1
  40. package/dist/web/assets/{ScheduledWorkPage-DLX-weE0.js → ScheduledWorkPage-CrPOFA5V.js} +1 -1
  41. package/dist/web/assets/{SettingsView-B9Tn0_zX.css → SettingsView-BaWWvIJW.css} +1 -1
  42. package/dist/web/assets/SettingsView-Y9Vz9_lU.js +9 -0
  43. package/dist/web/assets/{TeamChatView-BqhLy7OA.js → TeamChatView-eBh9hneg.js} +1 -1
  44. package/dist/web/assets/{TerminalOverlay-CJTUNqkk.js → TerminalOverlay-KwRmvkV1.js} +1 -1
  45. package/dist/web/assets/{TrainingCreationPanel-smGwEmo9.js → TrainingCreationPanel-A1koEF_3.js} +1 -1
  46. package/dist/web/assets/{TrainingDraftPanel-B2UKQHN3.js → TrainingDraftPanel-D4NJSj08.js} +1 -1
  47. package/dist/web/assets/{UsageSettingsSection-eyvYtzgi.js → UsageSettingsSection-CLjJKcpc.js} +1 -1
  48. package/dist/web/assets/{WorkSidebarPanel-DoruAoEt.js → WorkSidebarPanel-CvJn9X1R.js} +1 -1
  49. package/dist/web/assets/{WorkspaceDiffPanel-DeHSMDXy.js → WorkspaceDiffPanel-DSYhWDjl.js} +3 -3
  50. package/dist/web/assets/{WorkspaceEnvironmentMenu-sgYQj7uK.js → WorkspaceEnvironmentMenu-DrE4bKpT.js} +1 -1
  51. package/dist/web/assets/{WorkspaceGitDialogs-WpfoEpEk.js → WorkspaceGitDialogs-CrzqcjWN.js} +1 -1
  52. package/dist/web/assets/{WorkspaceMonacoEditor-jqG5AL7d.js → WorkspaceMonacoEditor-BVyxy7WJ.js} +3 -3
  53. package/dist/web/assets/{arrow-up-right-Dw1pcY62.js → arrow-up-right-BjYBprzW.js} +1 -1
  54. package/dist/web/assets/{chat-file-links-BYbiaIO1.js → chat-file-links-CY9VJ--b.js} +1 -1
  55. package/dist/web/assets/chevron-up-TrVwfRay.js +1 -0
  56. package/dist/web/assets/{clipboard-Dfk4RCIt.js → clipboard-Da8F6Qgl.js} +1 -1
  57. package/dist/web/assets/{cloud-upload-BCFuH4X6.js → cloud-upload-vaEzoz43.js} +1 -1
  58. package/dist/web/assets/{cssMode-D4TD1xov.js → cssMode-Dv3-w8Kc.js} +1 -1
  59. package/dist/web/assets/{folder-open-DvI8m5Sx.js → folder-open-C3Shiqpe.js} +1 -1
  60. package/dist/web/assets/{folder-plus-By8mYY0v.js → folder-plus-L8wD4iw3.js} +1 -1
  61. package/dist/web/assets/{git-commit-horizontal-BaO4kijC.js → git-commit-horizontal-CDk6sZyt.js} +1 -1
  62. package/dist/web/assets/{htmlMode-M02_qd4A.js → htmlMode-BZ5NH84R.js} +1 -1
  63. package/dist/web/assets/{index-BvXW3YXD.js → index-6TZT9oax.js} +2 -2
  64. package/dist/web/assets/{info-Dc_GhhOz.js → info-BzFeT6rZ.js} +1 -1
  65. package/dist/web/assets/{jsonMode-DiQI8vFK.js → jsonMode-DkpuUCXl.js} +1 -1
  66. package/dist/web/assets/{lspLanguageFeatures-tEe-JDHC.js → lspLanguageFeatures-BxsmW-WO.js} +1 -1
  67. package/dist/web/assets/{minimize-2-DGtAI2xp.js → minimize-2-DnM3eNEG.js} +1 -1
  68. package/dist/web/assets/{monaco.contribution-1SG8tKDo.js → monaco.contribution-CVC59ttJ.js} +2 -2
  69. package/dist/web/assets/{monaco.contribution-COeaSn0J.js → monaco.contribution-CbMHUsGo.js} +2 -2
  70. package/dist/web/assets/{monaco.contribution-BdUm7liL.js → monaco.contribution-DZPLEe65.js} +2 -2
  71. package/dist/web/assets/{monaco.contribution-4H5UNLKI.js → monaco.contribution-iPQTj3JR.js} +2 -2
  72. package/dist/web/assets/{play-Dm-ygxKN.js → play-DW0yNt2R.js} +1 -1
  73. package/dist/web/assets/{python-rqeHprul.js → python-DTpbj29X.js} +1 -1
  74. package/dist/web/assets/{refresh-cw-BIkrZ0pv.js → refresh-cw-BAHopOmY.js} +1 -1
  75. package/dist/web/assets/{save-EdH_bDsl.js → save-CFWKqkyZ.js} +1 -1
  76. package/dist/web/assets/{square-pCmN_gDj.js → square-AVaXWpWj.js} +1 -1
  77. package/dist/web/assets/{toggleHighContrast-BJSQSsib.js → toggleHighContrast-CZKHQ-c0.js} +1 -1
  78. package/dist/web/assets/{tsMode-3mUrkBEX.js → tsMode-BgOjIJPM.js} +1 -1
  79. package/dist/web/assets/{upload-BPPE0xhi.js → upload-nqv0d2Sb.js} +1 -1
  80. package/dist/web/assets/{useLocalAgentSchedules-CHOz2V-t.js → useLocalAgentSchedules-xIEcLU8F.js} +1 -1
  81. package/dist/web/assets/{wifi-off-217UMa2b.js → wifi-off-C6HLWTJm.js} +1 -1
  82. package/dist/web/assets/{workers-T9yMlI_c.js → workers-BNRLU1LU.js} +1 -1
  83. package/dist/web/assets/{yaml-DjGDwz3-.js → yaml-dAmUAqyv.js} +1 -1
  84. package/dist/web/index.html +1 -1
  85. package/package.json +1 -1
  86. package/dist/chunks/chunk-RB7BWSFJ.js +0 -5
  87. package/dist/chunks/src-VWAWQGVE.js +0 -319
  88. package/dist/web/assets/HostedModelLearningReview-BHboiGq4.js +0 -1
  89. package/dist/web/assets/SettingsView-Bjf1bZOw.js +0 -9
  90. package/dist/web/assets/chevron-up-DI8qm7Ek.js +0 -1
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-CLjJKcpc.js","./index-6TZT9oax.js","./index-C5EoPZr0.css","./App-CYWcs7S8.js","./App-7h_oHCFd.css","./arrow-up-right-BjYBprzW.js","./CartesianChart-RJq_kOU1.js","./UsageSettingsSection-Csg3diiE.css"])))=>i.map(i=>d[i]);
2
+ import{r,j as e,_ as Rn}from"./index-6TZT9oax.js";import{c as je,ay as gs,t as Pn,az as xs,aA as An,aB as ls,X as ue,aC as is,aD as Js,aE as In,aF as Dn,aG as En,aH as $n,aI as Mn,v as M,aJ as On,P as ge,D as De,aK as Ln,aL as Ys,aM as Tn,aN as Ze,aO as Qs,aP as zn,aQ as Un,aR as Bn,W as Zs,G as Be,aS as Hn,H as _n,Y as Te,h as rs,aT as Xe,aU as Ge,af as Fn,C as Gn,aV as Me,I as es,aW as qn,m as ze,aX as de,aY as Wn,aZ as ss,a_ as ns,a$ as Xs,b0 as Vn,g as Kn,av as en,b1 as Jn,ar as js,B as Yn,f as sn,b2 as Qn,b3 as Zn,x as Xn,b4 as et,U as ts,a6 as qe,b5 as Ne,aj as st,b6 as nt,b7 as tt,b8 as at,b9 as lt,ba as it,bb as rt}from"./App-CYWcs7S8.js";import{R as oe}from"./refresh-cw-BAHopOmY.js";import{T as Ce,P as nn,B as He,W as ot,A as ct,C as dt}from"./chat-file-links-CY9VJ--b.js";/* empty css */import{S as os}from"./save-CFWKqkyZ.js";import{F as tn}from"./folder-open-C3Shiqpe.js";import{C as ut}from"./chevron-up-TrVwfRay.js";import{P as an}from"./play-DW0yNt2R.js";import{B as ht,a as ln,W as mt,S as pt}from"./wifi-off-C6HLWTJm.js";import{R as _e,u as ft}from"./useLocalAgentSchedules-xIEcLU8F.js";import{C as xe}from"./cloud-upload-vaEzoz43.js";import{G as Ue}from"./git-commit-horizontal-CDk6sZyt.js";import{F as gt}from"./folder-plus-L8wD4iw3.js";import{A as xt}from"./AppDialog-Ba0_0yq9.js";import{C as rn,W as jt}from"./WorkspaceDiffPanel-DSYhWDjl.js";import"./MarkdownText-DQBTMcMm.js";import"./desktop-files-BQj1J-ob.js";import"./training-model-data-CKOkpBBL.js";import"./info-BzFeT6rZ.js";import"./minimize-2-DnM3eNEG.js";import"./clipboard-Da8F6Qgl.js";const vt=[["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"}]],bt=je("clipboard-copy",vt);const yt=[["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"}]],Nt=je("eye",yt);const wt=[["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"}]],St=je("hard-drive",wt);const kt=[["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",kt);const Ct=[["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"}]],on=je("radio-tower",Ct);const Rt=[["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"}]],Pt=je("rotate-cw",Rt);const At=[["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"}]],It=je("sliders-horizontal",At);const Dt=[["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"}]],vs=je("circle-user",Dt);function bs({connection:s,bannerOnly:n=!1,onOpen:a,onSaved:t}){const[l,i]=r.useState(null),[o,d]=r.useState(null),[u,p]=r.useState(null),[c,f]=r.useState(!1),[h,m]=r.useState(null),[g,y]=r.useState(!1),[w,R]=r.useState(gs);Pn(()=>R(gs()));const S=r.useRef(0),A=r.useCallback(async x=>{if(!s)return;const k=++S.current,D=await xs(s,"/v1/configuration",{signal:x});!x?.aborted&&k===S.current&&i(D)},[s]);r.useEffect(()=>{i(null),d(null),p(null),m(null);const x=new AbortController,k=()=>{A(x.signal).catch(E=>{x.signal.aborted||m(String(E))})};k();const D=window.setInterval(k,3e3);return()=>{S.current+=1,x.abort(),window.clearInterval(D)}},[A]);async function C(x,k){if(!(!s||!l)){y(!0),m(null);try{const D=x==="restore"?{action:x,revision:k,expectedRevision:l.rawRevision}:x==="validate"?{action:x,text:o??l.text??`schema_version = 1
3
+ `}:{action:x,text:o??l.text??`schema_version = 1
4
+ `,expectedRevision:u??l.rawRevision};await xs(s,"/v1/configuration",{method:"POST",body:JSON.stringify(D)}),x!=="validate"&&(d(null),p(null),await A(),await t?.()),m(x==="validate"?"Configuration is valid.":"Saved. Changes apply to the next turn.")}catch(D){m(D instanceof Error?D.message:String(D))}finally{y(!1)}}}return!s||n&&!l?.issue&&!w?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."})]}),w?e.jsxs("p",{role:"alert",children:[w," ",e.jsx("button",{type:"button",onClick:An,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?.():f(!0)},children:"Open configuration"})]}):null,n?null:e.jsxs("details",{open:c,onToggle:x=>f(x.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:o??l?.text??`schema_version = 1
5
+ `,onChange:x=>{o===null&&p(l?.rawRevision??null),d(x.target.value)}}),o!==null&&l?.rawRevision!==u?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:g||!l,onClick:()=>{C("validate")},children:"Validate"}),e.jsx("button",{type:"button",disabled:g||!l||o!==null&&l.rawRevision!==u,onClick:()=>{C("replace")},children:"Save config"}),e.jsx("button",{type:"button",disabled:g,onClick:()=>{d(null),p(null),A().catch(x=>m(String(x)))},children:"Reload file"})]}),l?.recoverableRevisions.length?e.jsxs("label",{children:["Restore a verified revision ",e.jsxs("select",{value:"",disabled:g,onChange:x=>{x.target.value&&C("restore",x.target.value)},children:[e.jsx("option",{value:"",children:"Choose a revision…"}),l.recoverableRevisions.map(x=>e.jsxs("option",{value:x.revision,children:[new Date(x.createdAt).toLocaleString()," · ",x.revision.slice(0,12)]},x.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(([x,k])=>e.jsxs("tr",{children:[e.jsx("td",{children:JSON.parse(x).join(".")}),e.jsx("td",{children:k.layer==="user"?"Set here":`Inherited from ${k.layer}`}),e.jsx("td",{children:k.path})]},x))})]}),e.jsx("pre",{children:JSON.stringify(l.effective.document,null,2)})]}):null]}),h?e.jsx("p",{role:"status",children:h}):null]})}function ys({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 We({state:s,label:n}){return e.jsx("span",{className:`account-state ${s}`,children:n??s.replace("_"," ")})}const Ns="https://openpond.ai",ws="https://api.openpond.ai";function Et(s,n){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:n?.handle,currentBaseUrl:n?.baseUrl??null}}function $t(s,n){return s==="update"&&n?{baseUrl:n.baseUrl??Ns,apiBaseUrl:n.apiBaseUrl??ws,chatApiBaseUrl:n.chatApiBaseUrl,environment:n.environment??"production"}:{baseUrl:Ns,apiBaseUrl:ws,environment:"production"}}function Ss({account:s,busy:n,initialApiKey:a="",mode:t="update",onClose:l,onSave:i}){const o=r.useId(),d=t==="connect",[u,p]=r.useState(a),[c,f]=r.useState(null),[h,m]=r.useState(null);ls(h),r.useEffect(()=>{p(a),f(null),m(null)},[s?.handle,a]);async function g(y){y.preventDefault(),f(null),m(null);const w=u.trim();if(d&&!w){f("API key is required.");return}try{const R=Et(t,s),S=$t(t,s);await i({...R,...S,apiKey:d?w:void 0})}catch(R){m(R instanceof Error?R.message:String(R))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&!n&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":o,onSubmit:y=>{g(y)},children:[e.jsx("button",{className:"git-dialog-close",disabled:n,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(ue,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:d?e.jsx(pe,{size:18}):e.jsx(is,{size:18})}),e.jsx("h2",{id:o,children:d?"Add account":"Account environment"}),d?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."}),d?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:u,onChange:y=>p(y.target.value)})]}):null,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",disabled:n,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:n,type:"submit",children:[e.jsx(os,{size:14}),e.jsx("span",{children:n?"Saving":d?"Connect account":"Update account"})]})]})]})})}const Mt="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 Ot({payload:s,connection:n,saving:a,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:o,removeAccount:d,onPayload:u,onPreferences:p,onError:c,onToast:f}){const h=s?.account,m=h?.state??"loading",g=m==="signed_in",y=m==="signed_out",w=m==="auth_error",R=h?.email?.trim()||null,S=h?.accounts??[],[A,C]=r.useState([]),[,x]=r.useState(!1),[k,D]=r.useState(null),[E,v]=r.useState(null),[P,N]=r.useState(null),[j,z]=r.useState(null),[F,q]=r.useState(!1),[Y,Q]=r.useState(null),[T,ee]=r.useState(null),[X,V]=r.useState(!1),{confirmAction:H,confirmDialog:te,resolveConfirmDialog:W}=Js(),G=S.find(L=>L.isActive)??S[0]??null,ne=s?.preferences.defaultTeamId?.trim()||null,ae=P??ne,le=In(h),ie=s?.accountMeta.asOf??"",b=ve(h?.environment,G?.environment),$=g?ve(G?.displayLabel,G?.handle,h?.label,h?.activeProfile?.handle,"Signed in"):w?"Account needs attention":y?"No account connected":"Loading account",_=g?R??ks(b):w?"Not connected":y?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",he=S.length>0,ce=w?Lt(h?.error):null,O=r.useMemo(()=>A.filter(L=>L.status==="active"),[A]),B=(r.useMemo(()=>ae?O.find(L=>L.teamId===ae)??null:null,[O,ae])??Dn(O))?.teamId??"",se=r.useMemo(()=>O.map(L=>({value:L.teamId,label:ve(L.displayName,L.name,L.slug,"Team"),description:En(L.role)})),[O]),Z=B||se[0]?.value||"",Ie=se.length>0,xn=!n||!!E||!!k||O.length===0,us=j?Ve(j):null,hs=!!(us&&Y===us),jn=g||w,vn=ve(T?.version,s?.server.version,"Loading"),ms=T?T.devMode?"Dev mode":T.packaged?`${Bt(T.releaseChannel)} build`:"Local build":null,ps=zt(ve(G?.baseUrl,h?.activeProfile?.baseUrl,h?.baseUrl,"https://openpond.ai"));r.useEffect(()=>{const L=window.openpond?.getDesktopRuntimeInfo;if(!L)return;let J=!1;return L().then(K=>{J||ee(K)}).catch(()=>{J||ee(null)}),()=>{J=!0}},[]),r.useEffect(()=>{if(!n||!le){C([]),D(null),x(!1);return}let L=!1;const J=$n(le);return J?(C(J),x(!1)):(C([]),x(!0)),D(null),Mn({accountKey:le,force:!!ie,fetchOrganizations:async()=>(await M.organizations(n)).organizations.map(On).filter(re=>!!re).filter(re=>re.status==="active")}).then(K=>{L||C(K)}).catch(K=>{L||(J||C([]),D(K instanceof Error?K.message:String(K)))}).finally(()=>{L||x(!1)}),()=>{L=!0}},[ie,n,le]),r.useEffect(()=>{P&&ne===P&&N(null)},[ne,P]);async function bn(L,J={notify:!0}){const K=O.find(re=>re.teamId===L)??null;if(!(!n||!K||E||(P??ne)===K.teamId)){N(K.teamId),v(K.teamId),c(null),Tn({teamId:K.teamId,accountKey:le,force:!0,fetchAgents:async re=>(await M.listSandboxAgents(n,{teamId:re})).agents}).catch(()=>{});try{p(await M.savePreferences(n,{defaultTeamId:K.teamId})),J.notify&&f?.("Default team updated","success")}catch(re){N(null),c(re instanceof Error?re.message:String(re))}finally{v(null)}}}async function Fe(L="Continue"){return jn?H({title:"Change active OpenPond account?",body:Mt,confirmLabel:L,cancelLabel:"Cancel"}):!0}async function yn(L){await Fe("Save account")&&(await l({apiKey:L.apiKey??"",handle:L.handle,baseUrl:L.baseUrl,apiBaseUrl:L.apiBaseUrl,environment:L.environment}),q(!1))}async function Nn(L){if(!n||!j)throw new Error("OpenPond server connection is not ready.");if(j.isActive&&!await Fe("Save endpoints"))return;const J=Ve(j);Q(J),c(null);try{const K=await M.updateOpenPondAccountConfig(n,{handle:L.handle??j.handle,currentBaseUrl:L.currentBaseUrl,baseUrl:L.baseUrl,apiBaseUrl:L.apiBaseUrl,chatApiBaseUrl:L.chatApiBaseUrl,environment:Tt(L.environment),setActive:j.isActive});u(K),f?.("Account endpoints updated","success"),z(null)}catch(K){throw c(K instanceof Error?K.message:String(K)),K}finally{Q(null)}}async function wn(L){const J=L.handle?.trim()||"";J&&await Fe("Switch account")&&await o(J,L.baseUrl)}async function Sn(L){const J=L.handle?.trim()||"";if(!J||L.isActive)return;const K=ve(L.displayLabel,L.email,L.handle,"this account");await H({title:"Remove saved account?",body:`Remove ${K} 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 d(J,L.baseUrl)&&f?.("Account removed","success")}async function kn(){const L=window.openpond?.reloadDesktopApp;if(!(!L||X)){V(!0),c(null);try{const J=await L();if(!J.ok)throw new Error(J.error??"OpenPond could not refresh the app.")}catch(J){V(!1),c(J instanceof Error?J.message:String(J))}}}async function Cn(){const L=window.openpond?.browser;L?.openExternal&&(await L.openExternal({conversationId:"openpond-account-sign-up",url:ps})).ok||window.open(ps,"_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:()=>q(!0),children:[e.jsx(ge,{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(oe,{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(ys,{handle:$,image:g?h?.avatarUrl??G?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:$}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:g&&R?"private-account-email":g?void 0:"account-summary-copy",tabIndex:g&&R?0:void 0,children:_}),g&&Ie?e.jsx(De,{className:"account-team-dropdown",compact:!0,disabled:xn,label:"Default team",options:se,value:Z,onChange:L=>{bn(L)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(We,{state:m,label:y?"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:[S.length," account",S.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),S.map(L=>{const J=L.handle?.trim()||"",K=ve(L.displayLabel,L.handle,"Unknown account"),re=L.email?.trim()||null,fs=Ve(L);return e.jsxs("div",{className:"account-row",children:[e.jsx(ys,{handle:K,image:L.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:K}),re?e.jsx("span",{className:"private-account-email",tabIndex:0,children:re}):null,e.jsx("span",{children:ks(L.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(We,{state:L.authHealth}),L.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:"settings-icon-button ghost account-endpoint-action",disabled:!n||a||!!Y||!J,type:"button","aria-label":`Configure ${K} environment`,title:"Configure account environment",onClick:()=>z(L),children:e.jsx(is,{size:15})}),L.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:a||!J,type:"button",onClick:()=>{wn(L)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:a||!J,type:"button","aria-label":`Remove ${K}`,title:`Remove ${K}`,onClick:()=>{Sn(L)},children:e.jsx(Ce,{size:13})})]})]})]},fs)})]}):null,h?.products&&h.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:[h.products.length," active"]})]}),h.products.map(L=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:L.name}),e.jsx("span",{children:L.type})]}),e.jsx(We,{state:L.status})]},L.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:Ut(vn)}),ms?e.jsx("span",{className:`account-build-context${T?.devMode?" development":""}`,children:ms}):null]})]}),e.jsxs("div",{className:"account-build-actions",children:[T?.canReload?e.jsxs("button",{className:"settings-secondary compact",disabled:X,type:"button",title:"Reload the local Electron app",onClick:()=>{kn()},children:[e.jsx(oe,{className:X?"settings-spin":void 0,size:14}),e.jsx("span",{children:X?"Refreshing":"Refresh app"})]}):null,g?null:e.jsxs("button",{className:"settings-primary compact account-sign-up-action",type:"button",onClick:()=>{Cn()},children:[e.jsx("span",{children:"Sign up"}),e.jsx(Ln,{size:13})]})]})]}),ce?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:ce})]}):null,j?e.jsx(Ss,{account:j,busy:hs,onClose:()=>{hs||z(null)},onSave:Nn}):null,F?e.jsx(Ss,{busy:a,mode:"connect",onClose:()=>{a||q(!1)},onSave:yn}):null,e.jsx(Ys,{state:te,onResolve:W})]})}function Ve(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function ve(...s){for(const n of s){const a=n?.trim();if(a)return a}return""}function Lt(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 ks(s){const n=s.trim().toLowerCase();return!n||n==="production"?"Production":"Environment"}function Tt(s){const n=s?.trim();return!n||n.toLowerCase()==="production"?"custom":n}function zt(s){try{return new URL("/login",s).toString()}catch{return"https://openpond.ai/login"}}function Ut(s){const n=s.trim();return!n||n==="Loading"?"Loading":n.startsWith("v")?n:`v${n}`}function Bt(s){return s&&`${s[0].toUpperCase()}${s.slice(1)}`}function Ht({advancedWorkspaceControls:s,defaultBranchPrefix:n,defaultNewProjectDirectory:a,preferences:t,saving:l,steerActiveResponses:i,chooseDefaultProjectDirectory:o,saveDefaults:d,setAdvancedWorkspaceControls:u,setSteerActiveResponses:p,setDefaultBranchPrefix:c,setDefaultNewProjectDirectory:f}){const h=Ze(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:m=>{d(m)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:i,disabled:l,onChange:m=>p(m.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:m=>u(m.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:m=>c(m.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:m=>f(m.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{o()},children:[e.jsx(tn,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||h,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:[Ze(n),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:a||t.defaultNewProjectDirectory})]})]})}function _t({diagnostics:s,diagnosticsAvailable:n,diagnosticsBusy:a,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:o,logViewBusy:d,logViewSummary:u,logViewportRef:p,tailLogs:c,copyRecentLogs:f,exportDiagnosticsBundle:h,loadOlderLogs:m,openLogsFolder:g,refreshLogView:y,toggleTailLogs:w}){const R=s.filter(A=>A.name==="diagnostic"&&A.status==="failed").slice().reverse().map(Ft),S=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:[R.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:R.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):R.map(A=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Qs,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:A.message}),e.jsx("time",{dateTime:A.timestamp,children:A.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:A.surface}),A.status?e.jsx("span",{children:A.status}):null,A.sequence?e.jsxs("span",{children:["#",A.sequence]}):null]}),A.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:A.detail})]}):null]})]},A.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||!S?.openLogsFolder,onClick:()=>{g()},children:[e.jsx(tn,{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||!S?.exportDiagnostics,onClick:()=>{h()},children:[e.jsx(zn,{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||!S?.copyRecentLogs,onClick:()=>{f()},children:[e.jsx(bt,{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:u}),e.jsx("button",{type:"button",className:`settings-icon-button ${c?"active":""}`,title:c?"Pause tail":"Tail logs","aria-label":c?"Pause tail":"Tail logs",disabled:!S?.readRecentLogs,onClick:w,children:c?e.jsx(nn,{size:15}):e.jsx(an,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:d!==null||!S?.readRecentLogs,onClick:()=>{y(i,"refresh")},children:e.jsx(oe,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:d!==null||!S?.readRecentLogs,onClick:m,children:[e.jsx(ut,{size:15}),e.jsx("span",{children:d==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:p,className:"diagnostics-log-viewer",role:"log","aria-live":c?"polite":"off",children:o.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:d?"Loading logs":"No log lines"}):o.map((A,C)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:A.file}),e.jsx("code",{children:A.line})]},`${A.file}:${A.timestamp}:${A.index}:${C}`))}),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 Ft(s){const n=Cs(s.data),a=Cs(n.context),l=fe(n.stack)??fe(n.detail)??fe(a.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:qt(s.timestamp),message:Gt(s,n),surface:fe(n.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function Gt(s,n){return fe(s.error)??fe(s.output)??fe(n.message)??fe(n.error)??"Diagnostic event"}function qt(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function Cs(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function fe(s){return typeof s=="string"&&s.trim()?s.trim():null}const Rs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function Wt({editorPreferences:s,lspStatus:n,preferences:a,restarting:t,saving:l,statusLoading:i,refreshLspStatus:o,restartLanguageServers:d,saveEditorSettings:u,setEditorPreferences:p,setLanguageCustomCommand:c,setLanguageMode:f}){const h=JSON.stringify(s)!==JSON.stringify(a.editor),m=new Map(n?.languages.map(g=>[g.language,g])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:g=>{u(g)},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:Un,onChange:g=>p(y=>({...y,languageServers:g}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:g=>p(y=>({...y,diagnosticsWhileEditing:g.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:g=>p(y=>({...y,checkOnSave:g.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:Rs.map(g=>{const y=s.languages[g.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:g.label}),e.jsx("span",{children:Ps(m.get(g.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(De,{value:y.mode,disabled:l||s.languageServers==="off",label:`${g.label} language server mode`,options:Bn,onChange:w=>f(g.id,w)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:y.customCommand,disabled:l||s.languageServers==="off"||y.mode!=="custom",placeholder:g.placeholder,onChange:w=>c(g.id,w.target.value)})]})]},g.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!h,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:()=>{o()},children:e.jsx(oe,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{d()},children:[e.jsx(Pt,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),Rs.map(g=>{const y=m.get(g.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:g.label}),e.jsx("span",{title:y?.command??y?.message??void 0,children:y?.command??y?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${y?.status??"missing"}`,children:Ps(y,i)})]},g.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 Ps(s,n){return n&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function As({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:o=>{l(o)},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:o=>i(o.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 Vt({subagentsEnabled:s,subagentDelegationMode:n,subagentsUseDefaultModel:a,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:o,subagentsMaxConcurrentRunsPerProvider:d,subagentsMaxConcurrentRunsPerWorkspaceTarget:u,preferences:p,providers:c,saving:f,saveDefaults:h,changeSubagentsProvider:m,setSubagentsEnabled:g,setSubagentDelegationMode:y,setSubagentsUseDefaultModel:w,setSubagentsModel:R,setSubagentsMaxConcurrentRuns:S,setSubagentsMaxConcurrentRunsPerProvider:A,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:C,setSubagentRoleEnabled:x,setSubagentRoleIsolationMode:k,setSubagentRoleMaxConcurrentRuns:D,setSubagentRoleModel:E,setSubagentRolePeerMessages:v,setSubagentRoleToolPolicy:P,changeSubagentRoleProvider:N}){const j=Zs(c,{enabledOnly:!0}),z=a?p.defaultChatProvider:t,F=a?p.defaultChatModel:l,q=cn(Be(z,c),F),Y=a?null:{providerId:t,modelId:l.trim()},Q=Zt({enabled:s,delegationMode:n,defaultModelRef:Y,roles:i,maxConcurrentRuns:o,maxConcurrentRunsPerProvider:d,maxConcurrentRunsPerWorkspaceTarget:u},p);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:T=>{h(T)},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${Q?"":" dirty"}`,disabled:f||Q,children:e.jsx("span",{children:f?"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:f,onChange:T=>g(T.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:f||!s,onChange:T=>y(T.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:f||!s,onChange:T=>{w(!1),m(T.target.value)},children:j.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:F,disabled:f||!s,onChange:T=>{w(!1),R(T.target.value)},children:q.map(T=>e.jsx("option",{value:T.value,children:T.label},T.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(T=>{const ee=Hn.find(G=>G.id===T.id),X=T.modelRef?.providerId??z,V=T.modelRef?.modelId||_n(X,c)||F,H=Qt(j,c,{providerId:X,modelId:V}),te=Le(X,V),W=f||!s||!T.enabled;return e.jsxs("section",{className:`subagent-role-row${T.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:ee?.label??T.id}),e.jsx("small",{children:ee?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${ee?.label??T.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:T.enabled,disabled:f||!s,onChange:G=>x(T.id,G.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:te,disabled:W,onChange:G=>{const ne=H.find(ae=>ae.value===G.target.value);ne&&(N(T.id,ne.providerId),E(T.id,ne.modelId))},children:H.map(G=>e.jsx("option",{value:G.value,children:G.label},G.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:T.isolationMode,disabled:W,onChange:G=>k(T.id,G.target.value),children:Kt.map(G=>e.jsx("option",{value:G.value,children:G.label},G.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:T.toolPolicy,disabled:W,onChange:G=>P(T.id,G.target.value),children:Jt.map(G=>e.jsx("option",{value:G.value,children:G.label},G.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:T.peerMessages,disabled:W,onChange:G=>v(T.id,G.target.value),children:Yt.map(G=>e.jsx("option",{value:G.value,children:G.label},G.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:T.maxConcurrentRuns,disabled:W,onChange:G=>D(T.id,Is(G.target.value,1))})]})})]},T.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:o,disabled:f||!s,onChange:T=>S(Is(T.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:d??"",placeholder:"No cap",disabled:f||!s,onChange:T=>A(as(T.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:u??"",placeholder:"No cap",disabled:f||!s,onChange:T=>C(as(T.target.value))})]})]})]})]})})}const Kt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],Jt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],Yt=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function cn(s,n){const a=n.trim();return!a||s.some(t=>t.value===a)?s:[{value:a,label:a},...s]}function Le(s,n){return JSON.stringify([s,n])}function Qt(s,n,a){const t=[];for(const l of s){const i=cn(Be(l.value,n),l.value===a.providerId?a.modelId:"");for(const o of i)t.push({value:Le(l.value,o.value),label:`${l.label} / ${o.label}`,providerId:l.value,modelId:o.value})}return a.modelId&&!t.some(l=>l.value===Le(a.providerId,a.modelId))&&t.unshift({value:Le(a.providerId,a.modelId),label:`${Te(a.providerId,n)} / ${a.modelId}`,providerId:a.providerId,modelId:a.modelId}),t}function as(s){const n=s.trim();if(!n)return null;const a=Number(n);return Number.isFinite(a)?a:null}function Is(s,n){return as(s)??n}function Zt(s,n){const a=n.subagents;return s.enabled===a.enabled&&s.delegationMode===a.delegationMode&&Xt(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 Xt(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const ea=[{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 sa({currentUserId:s,enabled:n,mode:a,threads:t,onModeChange:l,onThreadMuteChange:i}){const[o,d]=r.useState(null),[u,p]=r.useState(null);ls(u);const c=r.useMemo(()=>t.filter(m=>m.archivedAt===null).map(m=>({thread:m,label:na(m,s)})).sort((m,g)=>{const y=+!!g.thread.mutedAt-+!!m.thread.mutedAt;return y!==0?y:m.label.localeCompare(g.label)}),[s,t]),f=c.filter(({thread:m})=>!!m.mutedAt).length,h=r.useCallback(async m=>{d(m.id),p(null),await i(m.id,!m.mutedAt)||p("Could not update this conversation. Try again."),d(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:ea.map(m=>e.jsxs("label",{className:`notification-mode-option${a===m.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:a===m.mode,onChange:()=>l(m.mode)}),e.jsxs("span",{children:[e.jsx("strong",{children:m.label}),e.jsx("small",{children:m.detail})]})]},m.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:f===1?"1 muted":`${f} muted`})]}),n?c.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):c.map(({thread:m,label:g})=>{const y=!!m.mutedAt,w=o===m.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${y?" muted":""}`,children:y?e.jsx(ht,{size:15}):e.jsx(ln,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:g}),e.jsx("small",{children:y?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:o!==null,onClick:()=>{h(m)},children:w?"Saving":y?"Unmute":"Mute"})]},m.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 na(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 ta({canSaveCurrentTemplate:s,personalizationTemplateId:n,personalizationTemplateOptions:a,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:o,soulDraft:d,templateNameDraft:u,changePersonalizationTemplate:p,changeSoulDraft:c,openSaveAsNew:f,resetPersonalizationDraft:h,savePersonalization:m,setSaveAsNewOpen:g,setTemplateNameDraft:y}){function w(R){R.preventDefault(),m(t)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Personalization"}),e.jsxs("form",{className:"provider-settings-form personalization-form",onSubmit:w,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:u,onChange:R=>y(R.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:()=>g(!1),children:e.jsx(ue,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!d.trim()||!u.trim(),onClick:()=>{m(!0)},children:e.jsx(rs,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:o?"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||!d.trim(),onClick:f,children:e.jsx(ge,{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:R=>{p(R)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:d,onChange:R=>c(R.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:h,children:e.jsx(_e,{size:15})}),o&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(os,{size:15})})]})]})]})}function aa({connection:s,profile:n,selectedDefaultTeamId:a}){const t=ft(s),l=ra(t.schedules);return ls(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(la,{}),n.agents.map(i=>e.jsx(ia,{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 la(){return e.jsxs("tr",{className:"profile-agent-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(He,{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(Ee,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Ee,{status:{state:"ready",label:"Built in"}})})]})}function ia({agent:s,defaultAction:n,profile:a,selectedDefaultTeamId:t}){const l=da(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(He,{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(Ee,{status:l.check})}),e.jsx("td",{children:e.jsx(Ee,{status:l.sync})})]})}function Ds({pending:s,refreshing:n,schedule:a,onRefresh:t,onRun:l,onToggle:i}){const o=oa(a),d=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(He,{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(Ee,{status:o})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:ca(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(oe,{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(_e,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:d,"aria-label":`${d}: ${a.scheduleName}`,onClick:i,children:a.enabled?e.jsx(nn,{size:14}):e.jsx(an,{size:14})})]})]})})]})}function Ee({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function ra(s){const n=[],a=[];for(const t of s)t.enabled?n.push(t):a.push(t);return n.sort((t,l)=>Es(t)-Es(l)),{active:n,paused:a}}function Es(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function oa(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 ca(s){const n=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&n.push(`next ${$s(s.nextRunAt)}`),s.lastRunAt&&n.push(`last ${$s(s.lastRunAt)}`),n.join(" - ")}function $s(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 da(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||ha(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(ua(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 ua(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}function ha(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 ma(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??M,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 pa({connection:s,selectedProfileKey:n,onError:a,onOpenSession:t,onToast:l,onEvaluate:i}){const[o,d]=r.useState(null),[u,p]=r.useState(!1),[c,f]=r.useState(null),[h,m]=r.useState("{}"),[g,y]=r.useState(!1),[w,R]=r.useState(null);r.useEffect(()=>{if(!s||!n){d(null);return}let C=!0;return p(!0),d(null),f(null),R(null),M.profileWorkflows(s).then(x=>{C&&d(x)}).catch(x=>{C&&R(x instanceof Error?x.message:String(x))}).finally(()=>{C&&p(!1)}),()=>{C=!1}},[s,n]);const S=o?.workflows.find(C=>C.workflow.id===c);async function A(C){if(C.preventDefault(),!s||!o||!S||g)return;let x;try{x=JSON.parse(h)}catch{R("Workflow input must be valid JSON.");return}y(!0),R(null),a(null);try{const k=await ma({connection:s,catalog:o,workflowId:S.workflow.id,value:x});t?.(k),l?.(`Started ${S.workflow.label}`,"success"),f(null),m("{}")}catch(k){const D=k instanceof Error?k.message:String(k);R(D),a(D)}finally{y(!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."})]}),u?e.jsx("p",{children:"Loading workflows…"}):null,w?e.jsx("p",{role:"alert",children:w}):null,o&&o.workflows.length===0?e.jsx("p",{children:"No workflows in this Profile yet."}):null,o?.workflows.map(C=>e.jsxs("div",{className:"profile-workflows-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:C.workflow.label}),e.jsx("p",{children:C.workflow.description}),e.jsxs("small",{children:["Source ",C.binding.sourceRevision.slice(0,10)," · release ",C.binding.harnessRelease.contentHash.slice(0,10)]})]}),e.jsx("button",{disabled:g,onClick:()=>{R(null),m("{}"),f(C.workflow.id)},type:"button",children:"Run"}),i?e.jsx("button",{disabled:g,onClick:()=>i(C.workflow.id),type:"button",children:"Evaluate"}):null]},C.workflow.id)),S?e.jsxs("form",{className:"profile-workflows-form",onSubmit:A,children:[e.jsxs("h4",{children:["Run ",S.workflow.label]}),e.jsx("label",{htmlFor:"profile-workflow-input",children:"Input JSON"}),e.jsx("textarea",{id:"profile-workflow-input",onChange:C=>m(C.target.value),value:h}),e.jsx("pre",{children:JSON.stringify(S.workflow.inputSchema,null,2)}),e.jsx("button",{disabled:g,type:"submit",children:g?"Starting…":"Start workflow"}),e.jsx("button",{disabled:g,onClick:()=>f(null),type:"button",children:"Cancel"})]}):null]}):null}function Ms(s){return s.policy.kind==="model"?`${s.policy.model.provider}/${s.policy.model.model}`:"Fixture"}function fa({comparison:s}){const n=[...new Set(s.members.map(t=>t.source.sourceRevision))],a=[...new Set(s.members.map(Ms))];return e.jsxs("table",{className:"profile-evaluations-comparison-matrix",children:[e.jsxs("caption",{children:["Same frozen Taskset ",s.tasksetRelease.id," across Profile source and model choices"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Profile source"}),a.map(t=>e.jsx("th",{scope:"col",children:t},t))]})}),e.jsx("tbody",{children:n.map(t=>e.jsxs("tr",{children:[e.jsx("th",{scope:"row",title:t,children:t.slice(0,12)}),a.map(l=>{const i=s.members.filter(o=>o.source.sourceRevision===t&&Ms(o)===l);return e.jsx("td",{children:i.length?i.map(o=>e.jsxs("div",{children:[e.jsx("strong",{children:o.score===null?"No score":`${Math.round(o.score*100)}%`}),e.jsxs("small",{children:[" · Run ",o.runManifest.id]})]},o.runManifest.id)):"—"},l)})]},t))})]})}function Os(s){switch(s.kind){case"profile":return"Complete Profile";case"workflow":return`Workflow · ${s.workflowId}`;case"skill":return`Skill · ${s.skillPath}`;case"agent_action":return`Agent action · ${s.actionId}`}}function we(s){const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function ga(s){return Object.values(s.statuses).flatMap(n=>{if(!n.enabled||!n.available||!n.credential.connected)return[];const a=s.providers[n.id];return[...new Set([...n.modelIds,...s.modelCaches[n.id]?.models.map(l=>l.id)??[],...a?.modelOverrides??[],n.defaultModel,a?.defaultModel].filter(l=>!!l))].map(l=>({key:JSON.stringify([n.id,l]),providerId:n.id,modelId:l,label:`${n.displayName} · ${l}`}))})}function xa({connection:s,selectedProfileKey:n,focusTarget:a}){const t=r.useRef(null),[l,i]=r.useState(null),[o,d]=r.useState(null),[u,p]=r.useState(50),[c,f]=r.useState(20),[h,m]=r.useState(20),[g,y]=r.useState([]),[w,R]=r.useState(!1),[S,A]=r.useState(null),[C,x]=r.useState([]),[k,D]=r.useState(""),[E,v]=r.useState(null),[P,N]=r.useState(!1),[j,z]=r.useState(!1),[F,q]=r.useState(null),[Y,Q]=r.useState(null),[T,ee]=r.useState(!1),[X,V]=r.useState(null);if(r.useEffect(()=>{if(!s||!n){i(null),x([]),v(null);return}let b=!0;return ee(!0),i(null),d(null),p(50),f(20),m(20),y([]),x([]),D(""),v(null),Q(null),V(null),M.profileEvaluations(s).then($=>{b&&i($)}).catch($=>{b&&V($ instanceof Error?$.message:String($))}).finally(()=>{b&&ee(!1)}),M.providerSettings(s).then($=>{if(!b)return;const _=ga($);x(_),D(_[0]?.key??"")}).catch($=>{b&&V($ instanceof Error?$.message:String($))}),()=>{b=!1}},[s,n]),r.useEffect(()=>{if(!a||!l)return;const b=l.definitions.find($=>$.target.kind===a.kind&&(a.kind==="profile"||a.kind==="workflow"&&$.target.kind==="workflow"&&$.target.workflowId===a.id||a.kind==="skill"&&$.target.kind==="skill"&&$.target.skillPath===a.id));d(b?.id??null),Q(b?null:"No evaluation definition is saved for this Profile component."),t.current?.scrollIntoView({behavior:"smooth",block:"start"})},[l,a]),!n)return null;const H=l?.definitions.find(b=>b.id===o),te=H?l?.runs.filter(b=>b.manifest.profileEvaluation?.definitionId===H.id)??[]:[],W=async()=>{const b=C.find(_=>_.key===k);if(!s||!H||!b||P)return;const $={id:`evaluation-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),definitionId:H.id,modelRef:{providerId:b.providerId,modelId:b.modelId}};N(!0),v(null),Q(null),V(null);try{v({request:$,prepared:await M.profileEvaluationPrepare(s,$)})}catch(_){V(_ instanceof Error?_.message:String(_))}finally{N(!1)}},G=async()=>{if(!(!s||!E||j)){z(!0),V(null);try{const b=await M.profileEvaluationRun(s,{...E.request,expectedManifestHash:E.prepared.manifest.contentHash});i(await M.profileEvaluations(s)),v(null),Q(`Run ${b.manifest.id} ${b.passed?"passed":"did not pass"}.`)}catch(b){V(b instanceof Error?b.message:String(b))}finally{z(!1)}}},ne=async b=>{const $=C.find(_=>_.key===k);if(!(!s||!$||F)){q(b),Q(null),V(null);try{const _=await M.profileEvaluationRunSuite(s,{id:`suite-${crypto.randomUUID()}`,createdAt:new Date().toISOString(),suiteId:b,modelRef:{providerId:$.providerId,modelId:$.modelId}});i(await M.profileEvaluations(s)),Q(`Suite ${_.id} ${_.passed?"passed":"did not pass"}.`)}catch(_){V(_ instanceof Error?_.message:String(_))}finally{q(null)}}},ae=b=>{y($=>$.includes(b)?$.filter(_=>_!==b):[...$,b])},le=async()=>{if(!(!s||g.length<2||w)){R(!0),V(null);try{await M.profileEvaluationCompare(s,g),i(await M.profileEvaluations(s)),y([])}catch(b){V(b instanceof Error?b.message:String(b))}finally{R(!1)}}},ie=async(b,$)=>{if(!(!s||S)){A($),V(null);try{const _=await M.profileEvaluationSaveReport(s,b,$);i(await M.profileEvaluations(s)),Q(`Report ${_.id} saved to Profile source. Commit and publish the Profile when ready.`)}catch(_){V(_ instanceof Error?_.message:String(_))}finally{A(null)}}};return e.jsxs("section",{ref:t,"aria-label":"Profile evaluations",className:"profile-evaluations",children:[e.jsxs("div",{className:"profile-workflows-header",children:[e.jsx("h3",{children:"Evaluations"}),e.jsx("p",{children:"Checks and retained results for this Profile’s released components."})]}),T?e.jsx("p",{children:"Loading evaluations…"}):null,X?e.jsx("p",{role:"alert",children:X}):null,Y?e.jsx("p",{role:"status",children:Y}):null,l&&l.definitions.length===0?e.jsx("p",{children:"No evaluations in this Profile yet."}):null,l?.suites.length?e.jsxs("div",{className:"profile-evaluations-suites","aria-label":"Evaluation suites",children:[e.jsx("label",{htmlFor:"profile-evaluation-suite-model",children:"Suite model"}),e.jsx("select",{id:"profile-evaluation-suite-model",value:k,disabled:!!F,onChange:b=>D(b.target.value),children:C.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),C.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run a suite."}):null,l.suites.map(b=>e.jsxs("div",{className:"profile-evaluations-suite",children:[e.jsx("strong",{children:b.label}),e.jsxs("span",{children:[b.scope==="profile"?"Profile suite":"Component suite"," · ",b.definitionIds.length," checks"]}),e.jsx("button",{type:"button",disabled:!k||!!F||j,onClick:()=>{ne(b.id)},children:F===b.id?"Running suite…":"Run suite"}),l.suiteRuns.filter($=>$.suiteId===b.id).slice(0,5).map($=>e.jsxs("details",{className:"profile-evaluations-suite-run",children:[e.jsxs("summary",{children:[we($.completedAt)," · ",$.passed?"Passed":"Did not pass"," · ",$.members.length," checks"]}),e.jsxs("small",{children:["Profile source ",$.sourceRevision.slice(0,12)," · Suite run ",$.id]}),e.jsx("button",{type:"button",disabled:!!S,onClick:()=>{ie("suite",$.id)},children:S===$.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:$.members.map(_=>e.jsxs("li",{children:[e.jsx("strong",{children:$.sourceRevision===l.sourceRevision?l.definitions.find(he=>he.id===_.definitionId)?.label??_.definitionId:_.definitionId}),e.jsxs("span",{children:[_.passed?"Passed":"Did not pass"," · ",_.score===null?"No score":`${Math.round(_.score*100)}%`," · Run ",_.runManifest.id]})]},_.runManifest.id))})]},$.id))]},b.id))]}):null,l?.definitions.map(b=>{const $=l.runs.find(_=>_.manifest.profileEvaluation?.definitionId===b.id);return e.jsxs("div",{className:"profile-evaluations-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:b.label}),e.jsx("p",{children:b.description||Os(b.target)}),e.jsxs("small",{children:[Os(b.target)," · ",b.taskIds.length," tasks · ",b.seeds.length," seeds"]}),$?e.jsxs("small",{children:["Latest: ",$.passed?"Passed":"Did not pass"," · ",$.metric.value===null?"No score":`${Math.round($.metric.value*100)}%`," · ",we($.completedAt)]}):null]}),e.jsx("button",{type:"button","aria-expanded":o===b.id,onClick:()=>{d(o===b.id?null:b.id),p(50),f(20),v(null)},children:o===b.id?"Hide details":"View details"})]},b.id)}),H?e.jsxs("div",{className:"profile-evaluations-detail",children:[e.jsx("h4",{children:H.label}),e.jsxs("p",{children:["Taskset ",H.tasksetRelease.id," · ",H.tasksetRelease.contentHash.slice(0,12)]}),e.jsxs("p",{children:["Frozen split: ",H.split," · Minimum pass rate: ",Math.round(H.criterion.minimumPassRate*100),"%"]}),e.jsxs("div",{className:"profile-evaluations-run-form",children:[e.jsx("label",{htmlFor:"profile-evaluation-model",children:"Model"}),e.jsx("select",{id:"profile-evaluation-model",value:k,disabled:P||j,onChange:b=>{D(b.target.value),v(null)},children:C.map(b=>e.jsx("option",{value:b.key,children:b.label},b.key))}),C.length===0?e.jsx("p",{children:"Connect a provider and load its models in Providers settings to run this check."}):null,e.jsx("button",{type:"button",disabled:!k||P||j,onClick:()=>{W()},children:P?"Checking run…":"Check run setup"}),E?e.jsxs("div",{className:"profile-evaluations-run-plan",children:[e.jsx("strong",{children:"Run setup"}),e.jsxs("small",{children:["Profile source ",E.prepared.manifest.profileEvaluation?.sourceRevision.slice(0,12)," · Harness ",E.prepared.manifest.execution.kind==="harness"?E.prepared.manifest.execution.harnessRelease.id:""]}),e.jsxs("small",{children:["Taskset ",E.prepared.taskset.id," · ",E.prepared.manifest.population.length," attempts · ",E.prepared.manifest.limits.timeoutMs/1e3,"s per attempt"]}),e.jsxs("small",{children:["Connected app scopes: ",E.prepared.taskset.connectedAppScopes.join(", ")||"none declared"]}),e.jsx("button",{type:"button",disabled:j,onClick:()=>{G()},children:j?"Running evaluation…":"Run evaluation"})]}):null]}),e.jsxs("div",{className:"profile-evaluations-cases",children:[e.jsx("strong",{children:"Task cases"}),e.jsx("ul",{children:H.taskIds.slice(0,u).map(b=>e.jsx("li",{children:b},b))}),H.taskIds.length>u?e.jsx("button",{type:"button",onClick:()=>p(b=>b+50),children:"Show more cases"}):null,e.jsxs("span",{children:["Seeds: ",H.seeds.join(", ")]})]}),e.jsxs("div",{className:"profile-evaluations-history",children:[e.jsx("strong",{children:"Run history"}),te.length===0?e.jsx("p",{children:"No runs for this check yet."}):e.jsx("ul",{children:te.slice(0,c).map(b=>e.jsxs("li",{children:[e.jsxs("span",{children:[we(b.completedAt)," · ",b.passed?"Passed":"Did not pass"," · ",b.receiptRefs.length," attempts"]}),e.jsxs("small",{children:["Model ",b.manifest.policy.kind==="model"?`${b.manifest.policy.model.provider}/${b.manifest.policy.model.model}`:"fixture"," · Source ",b.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · Run ",b.manifest.id]}),e.jsx("button",{type:"button",disabled:!!S,onClick:()=>{ie("run",b.manifest.id)},children:S===b.manifest.id?"Saving report…":"Save report to Profile"})]},b.manifest.id))}),te.length>c?e.jsx("button",{type:"button",onClick:()=>f(b=>b+20),children:"Show more runs"}):null]})]}):null,l&&l.runs.length>1?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Compare evaluation runs",children:[e.jsx("h4",{children:"Compare runs"}),e.jsx("p",{children:"Select two or more runs. Comparisons require the same Taskset, cases, environment, grading policy, limits, and runtime."}),e.jsx("div",{className:"profile-evaluations-comparison-runs",children:l.runs.slice(0,h).map(b=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:g.includes(b.manifest.id),onChange:()=>ae(b.manifest.id),disabled:w}),e.jsxs("span",{children:[e.jsxs("strong",{children:[b.manifest.profileEvaluation?.definitionId??"Profile evaluation"," · ",b.metric.value===null?"No score":`${Math.round(b.metric.value*100)}%`]}),e.jsxs("small",{children:[we(b.completedAt)," · ",b.manifest.policy.kind==="model"?`${b.manifest.policy.model.provider}/${b.manifest.policy.model.model}`:"fixture"," · Source ",b.manifest.profileEvaluation?.sourceRevision.slice(0,10)," · ",b.manifest.id]})]})]},b.manifest.id))}),l.runs.length>h?e.jsx("button",{type:"button",onClick:()=>m(b=>b+20),children:"Show more runs"}):null,e.jsx("button",{type:"button",disabled:g.length<2||w,onClick:()=>{le()},children:w?"Comparing…":`Save comparison of ${g.length} runs`})]}):null,l&&l.comparisons.length>0?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Saved evaluation comparisons",children:[e.jsx("h4",{children:"Saved comparisons"}),e.jsx("ul",{children:l.comparisons.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[we(b.createdAt)," · ",b.members.length," runs"]}),e.jsx("button",{type:"button",disabled:!!S,onClick:()=>{ie("comparison",b.id)},children:S===b.id?"Saving report…":"Save report to Profile"}),e.jsx("ul",{children:b.members.map($=>e.jsxs("li",{children:[$.source.definitionId," · ",$.policy.kind==="model"?`${$.policy.model.provider}/${$.policy.model.model}`:"fixture"," · Source ",$.source.sourceRevision.slice(0,10)," · ",$.score===null?"No score":`${Math.round($.score*100)}%`]},$.runManifest.id))}),e.jsx(fa,{comparison:b})]},b.id))})]}):null,l?.reports.length?e.jsxs("div",{className:"profile-evaluations-detail","aria-label":"Profile evaluation reports",children:[e.jsx("h4",{children:"Reports saved in Profile source"}),e.jsx("ul",{children:l.reports.map(b=>e.jsxs("li",{children:[e.jsxs("strong",{children:[we(b.createdAt)," · ",b.summary.passedChecks,"/",b.summary.totalChecks," checks passed"]}),e.jsxs("small",{children:["Tested source ",b.testedSources.map($=>$.sourceRevision.slice(0,10)).join(", ")," · Evidence ",b.evidence.map($=>$.id).join(", ")]})]},b.id))})]}):null]})}function ja({actions:s,busy:n,library:a,onSelect:t}){const l=a.profiles.find(o=>Xe(o.ref,a.lastUsed))??a.profiles[0]??null,i=l?Ge(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:o=>{const d=Fn(a,o.currentTarget.value),u=a.profiles.find(p=>Xe(p.ref,d));u&&t(u)},children:a.profiles.length?a.profiles.map(o=>e.jsx("option",{value:Ge(o.ref),children:o.name},Ge(o.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(Gn,{"aria-hidden":"true",size:14})]}),s]})}function va({addDisabled:s,commitDisabled:n,commitLabel:a,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:o,syncStatus:d,onAdd:u,onCommit:p,onRefresh:c,onRepo:f,onSync:h}){const[m,g]=r.useState(!1),y=r.useRef(null);r.useEffect(()=>{if(!m)return;function R(A){y.current?.contains(A.target)||g(!1)}function S(A){A.key==="Escape"&&g(!1)}return document.addEventListener("pointerdown",R),document.addEventListener("keydown",S),()=>{document.removeEventListener("pointerdown",R),document.removeEventListener("keydown",S)}},[m]);function w(R){g(!1),R()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:y,children:[e.jsx("button",{"aria-expanded":m,"aria-haspopup":"menu","aria-label":"Profile settings",className:"settings-icon-button ghost profile-settings-menu-trigger",type:"button",onClick:()=>g(R=>!R),children:e.jsx(is,{size:15})}),m?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:n,role:"menuitem",type:"button",onClick:()=>w(p),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:a})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>w(h),children:[e.jsx(xe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:o}),d?e.jsx("small",{children:d}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>w(f),children:[e.jsx(Me,{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:()=>w(c),children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>w(u),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const ba=[{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 ya({connection:s,entry:n,onClose:a,onPublished:t}){const[l,i]=r.useState("github"),[o,d]=r.useState(""),[u,p]=r.useState(`${n.name}-profile`),[c,f]=r.useState("public"),[h,m]=r.useState(()=>n.state.agents.filter(j=>j.enabled).map(j=>j.id)),[g,y]=r.useState(()=>n.state.skills.filter(j=>j.enabled).map(j=>j.name)),[w,R]=r.useState([]),[S,A]=r.useState(null),[C,x]=r.useState(null),[k,D]=r.useState(null),E=r.useMemo(()=>({ref:n.ref,selection:{agentIds:h,skillNames:g,optionalContent:w},target:{provider:l,owner:o.trim()||null,repository:u.trim(),visibility:l==="github"?"public":c}}),[h,n.ref,w,o,l,u,g,c]);function v(j,z,F){return F?[...new Set([...j,z])]:j.filter(q=>q!==z)}async function P(j){if(j.preventDefault(),!(!u.trim()||C)){x("preview"),D(null);try{A(await M.profilePublicationPreview(s,E))}catch(z){D(z instanceof Error?z.message:String(z))}finally{x(null)}}}async function N(){if(!(!S||S.blockedReasons.length>0||C)){x("publish"),D(null);try{const j=await M.profilePublicationPublish(s,{...E,expectedSourceHash:S.sourceHash,confirmed:!0});t(`Published ${n.name} to ${j.owner}/${j.repository}`),a()}catch(j){D(j instanceof Error?j.message:String(j))}finally{x(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:j=>j.stopPropagation(),onSubmit:P,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!C,type:"button","aria-label":"Close",onClick:a,children:e.jsx(ue,{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."}),S?e.jsx(Na,{preview:S}):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"),f("public")}}),e.jsx(es,{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"),f("private")}}),e.jsx(qn,{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:o,placeholder:"Uses gh account",onChange:j=>d(j.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:u,onChange:j=>p(j.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:c,onChange:j=>f(j.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(Ke,{title:"Agents",empty:"No Agents in this Profile",children:n.state.agents.map(j=>e.jsx(Je,{checked:h.includes(j.id),label:j.name,detail:j.path,onChange:z=>m(F=>v(F,j.id,z))},j.id))}),e.jsx(Ke,{title:"Skills",empty:"No Skills in this Profile",children:n.state.skills.map(j=>e.jsx(Je,{checked:g.includes(j.name),label:j.name,detail:j.description||j.path,onChange:z=>y(F=>v(F,j.name,z))},j.name))}),e.jsx(Ke,{title:"Optional content",empty:"",children:ba.map(j=>e.jsx(Je,{checked:w.includes(j.id),label:j.label,detail:j.detail,onChange:z=>R(F=>v(F,j.id,z))},j.id))})]}),k?e.jsx("div",{className:"profile-dialog-warning",children:k}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!C,type:"button",onClick:S?()=>A(null):a,children:S?"Back":"Cancel"}),S?e.jsxs("button",{className:"git-dialog-primary",disabled:!!C||S.blockedReasons.length>0,type:"button",onClick:()=>{N()},children:[e.jsx(xe,{size:14}),e.jsx("span",{children:C==="publish"?"Publishing":S.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!C||!u.trim(),type:"submit",children:C==="preview"?"Building preview":"Review exact files"})]})]})})}function Ke({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 Je({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 Na({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 · ",Ls(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," · ",Ls(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 Ls(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function wa({section:s="all",catalogPresentation:n="list",payload:a,connection:t,onPayload:l,onError:i,onToast:o,onSkillCommand:d,onOpenSession:u,overviewContent:p}){const[c,f]=r.useState(""),[h,m]=r.useState(null),[g,y]=r.useState(!1),[w,R]=r.useState(null),[S,A]=r.useState(null),[C,x]=r.useState(null),k=a?.profile??null,D=a?.preferences.defaultTeamId?.trim()||"",E=s==="all"||s==="profile"||s==="controls",v=s==="all"||s==="profile",P=s==="all"||s==="agents",N=s==="all"||s==="profile";async function j(H){t&&(l(await M.bootstrap(t)),o?.(H,"success"))}async function z(H,te){if(!(!t||h)){m(H),i(null);try{await te()}catch(W){i(W instanceof Error?W.message:String(W))}finally{m(null)}}}function F(){z("init",async()=>{await M.profileInit(t,{}),await j("Profile initialized")})}function q(){z("commit",async()=>{await M.profileCommit(t,{message:c.trim()||null}),f(""),await j("Profile commit complete")})}function Y(){z("push",async()=>{if(!D)throw new Error("Select a default team before syncing a hosted profile.");await M.profileCheck(t,{kind:"all"}),await M.profilePush(t,{teamId:D,ensureHosted:!0,message:null}),await j("Profile synced to hosted profile repo")})}function Q(H){z(`select:${H.ref.profileId}`,async()=>{await M.profileSelect(t,H.ref),await j(`Using ${H.name}`)})}function T(H){z("add",async()=>{H.source==="blank"?await M.profileInit(t,{path:H.path,profile:H.profile,template:"blank-profile"}):H.source==="local"?await M.profileLoad(t,H):await M.profileInstall(t,H),y(!1),await j(H.source==="blank"?`${H.profile} created`:"Profile added")})}function ee(H){z("update",async()=>{await M.profileUpdate(t,H.ref),await j(`${H.name} updated`)})}function X(H){z("remove",async()=>{await M.profileRemove(t,H.ref),R(null),await j("Profile removed from this device")})}function V(){z("refresh",async()=>{await j("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[k?.mode==="local"?e.jsxs(e.Fragment,{children:[E?e.jsxs(e.Fragment,{children:[v&&n==="select"?e.jsx(ja,{actions:e.jsx(Ts,{connection:t,onAdd:()=>y(!0),onRefresh:V,presentation:"menu",profile:k,profileBusy:h,profileCommitMessage:c,selectedDefaultTeamId:D,syncDisabledReason:zs(k,D),setProfileCommitMessage:f,submitProfileCommit:q,submitProfilePush:Y}),busy:!!h,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:Q}):e.jsxs(e.Fragment,{children:[v?e.jsx(Sa,{busy:!!h,library:a?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>y(!0),onRefresh:V,onRemove:R,onPublish:A,onUpdate:ee,onSelect:Q}):null,e.jsx(Ts,{connection:t,profile:k,profileBusy:h,profileCommitMessage:c,selectedDefaultTeamId:D,syncDisabledReason:zs(k,D),setProfileCommitMessage:f,submitProfileCommit:q,submitProfilePush:Y})]}),p]}):null,P?e.jsx(aa,{connection:t,profile:k,selectedDefaultTeamId:D}):null,N?e.jsxs(e.Fragment,{children:[e.jsx(Ia,{onSkillCommand:d,onEvaluate:H=>x({kind:"skill",id:H}),profile:k}),e.jsx(pa,{connection:t,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null,onError:i,onOpenSession:u,onToast:o,onEvaluate:H=>x({kind:"workflow",id:H})}),e.jsx(xa,{connection:t,focusTarget:C,selectedProfileKey:a?.profileLibrary?.lastUsed?JSON.stringify(a.profileLibrary.lastUsed):null})]}):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||!!h,type:"button",onClick:()=>y(!0),children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!h,type:"button",onClick:F,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:h==="init"?"Creating":"Create starter Profile"})]})]})]}),g?e.jsx(ka,{busy:!!h,onClose:()=>y(!1),onSubmit:T}):null,w?e.jsx(Ca,{busy:!!h,entry:w,onClose:()=>R(null),onConfirm:()=>X(w)}):null,S&&t?e.jsx(ya,{connection:t,entry:S,onClose:()=>A(null),onPublished:H=>o?.(H,"success")}):null]})}function Sa({busy:s,library:n,onAdd:a,onRefresh:t,onRemove:l,onPublish:i,onSelect:o,onUpdate:d}){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(oe,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:a,children:[e.jsx(ge,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),n.profiles.map(u=>{const p=Xe(u.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||o(u)},onKeyDown:c=>{s||c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),o(u))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(Me,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:u.name}),e.jsx("span",{title:u.repoPath,children:u.repoPath})]})]}),e.jsx(dn,{status:{state:u.state.error?"warning":"ready",label:u.state.error?"error":p?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:u.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:u.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[u.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),d(u)},onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),c.stopPropagation(),d(u))},children:[e.jsx(oe,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),i(u)},onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),c.stopPropagation(),i(u))},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 ${u.name}`,onClick:c=>{c.stopPropagation(),l(u)},onKeyDown:c=>{c.key!=="Enter"&&c.key!==" "||(c.preventDefault(),c.stopPropagation(),l(u))},children:[e.jsx(Ce,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${u.ref.source}:${u.ref.repositoryId}:${u.ref.profileId}`)})]})}function ka({busy:s,onClose:n,onSubmit:a}){const[t,l]=r.useState("blank"),[i,o]=r.useState(""),[d,u]=r.useState(""),[p,c]=r.useState("");function f(h){if(h.preventDefault(),s)return;if(t==="blank"){const g=p.trim();if(!g)return;a({source:t,path:i.trim()||null,profile:g});return}if(t==="local"){const g=i.trim();if(!g)return;a({source:t,path:g,profile:p.trim()||null});return}const m=d.trim();m&&a({source:t,repositoryId:m,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:h=>h.stopPropagation(),onSubmit:f,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:n,children:e.jsx(ue,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Me,{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:h=>o(h.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:h=>o(h.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:d,placeholder:"owner/repository",onChange:h=>u(h.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:h=>c(h.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:d).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function Ca({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(ue,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Ce,{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 Ts({connection:s,onAdd:n,onRefresh:a,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:o,selectedDefaultTeamId:d,syncDisabledReason:u,setProfileCommitMessage:p,submitProfileCommit:c,submitProfilePush:f}){const[h,m]=r.useState(!1),[g,y]=r.useState(!1),[w,R]=r.useState(!1),S=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&n&&a?e.jsx(va,{addDisabled:!!i,commitDisabled:S,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:S,repoDisabled:!!i||!l,syncDisabled:S||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ye(l,d):null,onAdd:n,onCommit:()=>y(!0),onRefresh:a,onRepo:()=>m(!0),onSync:()=>R(!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:S,type:"button",onClick:()=>y(!0),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:S||!l,type:"button",onClick:()=>R(!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:()=>m(!0),children:[e.jsx(Me,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ye(l,d)}`,children:[e.jsx(xe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ye(l,d)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),h&&l?e.jsx(Aa,{profile:l,profileBusy:i,onClose:()=>m(!1)}):null,g?e.jsx(Ra,{disabled:S,profileBusy:i,profileCommitMessage:o,setProfileCommitMessage:p,submitProfileCommit:c,onClose:()=>y(!1)}):null,w&&l?e.jsx(Pa,{disabled:S,profile:l,profileBusy:i,selectedDefaultTeamId:d,syncDisabledReason:u,submitProfilePush:f,onClose:()=>R(!1)}):null]})}function Ra({disabled:s,profileBusy:n,profileCommitMessage:a,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function o(d){d.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:d=>d.stopPropagation(),onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(ue,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Ue,{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:d=>t(d.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(Ue,{size:14}),e.jsx("span",{children:n==="commit"?"Committing":"Commit"})]})]})]})})}function Pa({disabled:s,profile:n,profileBusy:a,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:o}){const d=Ea(n,t),u=d.reduce((f,h)=>f+h.count,0),p=!s&&!l;function c(f){f.preventDefault(),p&&(i(),o())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:o,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:f=>f.stopPropagation(),onSubmit:c,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:o,children:e.jsx(ue,{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:[u," ",u===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",Re(n.summary.localHead??n.git?.head)," - Last pushed"," ",Re(n.hosted?.lastPushedLocalHead)]})]}),d.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:d.map(f=>e.jsxs("div",{className:`profile-dialog-diff-row ${f.tone??""}`,children:[e.jsx("strong",{children:f.label}),e.jsx("span",{children:f.detail})]},f.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:o,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 Aa({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(ue,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Me,{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"," · ",Re(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 Ia({onSkillCommand:s,onEvaluate:n,profile:a}){const t=a.skills.slice().sort((o,d)=>o.name.localeCompare(d.name)),l=!s;function i(o){s?.(o)}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:[a.skillCatalog.skillCount," tracked"]})})]}),t.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:t.map(o=>e.jsx(Da,{commandDisabled:l,onSkillCommand:i,onEvaluate:n,skill:o},o.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 Da({commandDisabled:s,onSkillCommand:n,onEvaluate:a,skill:t}){const l=t.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:t.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(ze,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{title:t.path,children:t.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:t.description,children:t.description||"No description"}),e.jsx("td",{children:e.jsx(dn,{status:l})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:t.sourcePath,children:t.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[a?e.jsx("button",{className:"settings-secondary compact",type:"button",onClick:()=>a(t.path),children:"Evaluate"}):null,e.jsx("button",{className:"settings-secondary compact",disabled:s||!t.enabled,type:"button",title:`Use ${t.name}`,onClick:()=>n(`$${t.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${t.name}`,onClick:()=>n(`/skill edit ${t.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function dn({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Re(s){return s?s.slice(0,10):"None"}function Ye(s,n){return un(s,n)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${Re(s.hosted.sourceCommitSha)}`:"Not pushed"}function zs(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 Ea(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(un(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 ${Re(t)} has not been pushed since ${Re(l)}.`,count:1}),s.git?.dirty){const d=(s.git.fileCount??s.git.files.length)||(s.diff.fileCount??s.diff.files.length)||1;a.push({label:"Uncommitted files",detail:`${d} local ${d===1?"file":"files"} changed.`,count:d,tone:"warning"})}const o=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 o>0&&a.push({label:"Profile changes",detail:$a(s),count:o,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 $a(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 un(s,n){const a=s.hosted?.teamId?.trim()??"";return!!(a&&n&&a!==n)}const Ma=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],Oa=120,La=new Set(["openai","xai","zai"]),Ta=new Set(["chatgpt-subscription"]),za="https://api.z.ai/api/coding/paas/v4";function Us(s){return s.split(/[\n,]/).map(n=>n.trim()).filter(Boolean)}function hn(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 mn(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Bs(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 Ua(s){return s?.trim().replace(/\/+$/,"")??""}function pn(s,n){return s.id==="zai"&&Ua(n.providers.zai?.baseUrl)===za}function Ba(s,n){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":pn(s,n)?"Coding Plan key":"API key"}function Ha(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?ns(s.defaultModel,n,s.id):"",i=t===1?"1 model":`${t} models`,o=Ba(s,n);return[hn(s),o,a?i:"",l].filter(Boolean).join(" · ")}function _a(s){return s!=="openpond"&&ss(s)}function cs(s){return s?La.has(s.id)||s.credentialModes.some(n=>Ta.has(n)):!1}function Fa(s){return cs(s)?["api","subscription"]:["api"]}function Hs(s,n){return!s||!n||!cs(s)?"api":s.credential.source==="chatgpt_subscription"||pn(s,n)?"subscription":"api"}function _s(s,n){const a=Wn.filter(t=>!!s?.statuses[t]);return n?a.filter(t=>cs(s?.statuses[t])):a}function Ga(s){if(!s)return"Never";const n=new Date(s);return Number.isNaN(n.getTime())?s:n.toLocaleString()}function qa(s,n,a=Oa){const t=[],l=new Set,i=new Set(n.map(d=>d.trim()).filter(Boolean)),o=d=>{l.has(d.value)||t.length>=a||(l.add(d.value),t.push(d))};for(const d of s)i.has(d.value)&&o(d);for(const d of s)o(d);return t}function Wa({account:s,codex:n,providers:a,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:o,refreshProviderModels:d,saveProviderConfig:u,saveProviderCredential:p,startOpenAiSubscriptionAuth:c,validateProvider:f}){const[h,m]=r.useState(null),[g,y]=r.useState(!1),w=r.useMemo(()=>_s(a,!1),[a]),R=r.useMemo(()=>_s(a,g),[a,g]),S=h?a?.statuses[h]??null:null;function A(C,x){m(C),x&&o(C)}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:g,onChange:C=>y(C.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[R.length," of ",w.length," presets"]})]}),R.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:R.map(C=>{const x=a.statuses[C],k=a.modelCaches[C],D=x.modelIds.length>0&&(k?.models.length??0)<x.modelIds.length,E=t?.startsWith(`${C}:`)??!1,v=_a(C),P=C==="openpond"||!!a.providers[C]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${x.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:P,disabled:!v||E,onChange:N=>{A(C,!1),u(C,{enabled:N.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:x.displayName})}),e.jsxs("div",{className:`provider-row-status ${mn(x)}`,children:[E?e.jsx(de,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:Ha(x,a)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{A(C,D)},children:"Details"})]},C)})}):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,h&&S&&a?e.jsx(Va,{account:s,codex:n,providerId:h,providerBusy:t,settings:a,status:S,onClose:()=>m(null),onDeleteCredential:i,onRefreshModels:d,onSaveConfig:u,onSaveCredential:p,onStartOpenAiSubscriptionAuth:c,onValidate:f}):null]})}function Va({account:s,codex:n,providerId:a,providerBusy:t,settings:l,status:i,onClose:o,onDeleteCredential:d,onRefreshModels:u,onSaveConfig:p,onSaveCredential:c,onStartOpenAiSubscriptionAuth:f,onValidate:h}){const m=l.providers[a],g=l.modelCaches[a],y=r.useId(),w=r.useRef(a),R=Math.max(g?.models.length??0,i.modelIds.length),S=i.routing.localByok&&ss(a)&&a!=="codex",A=r.useMemo(()=>S?Fa(i):[],[S,i]),C=A.includes("subscription"),[x,k]=r.useState(()=>Hs(i,l)),D=S&&x==="subscription"&&C,E=P=>`${y}-${P}-panel`,v=a==="codex"?"Codex app server":m?.baseUrl??(a==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(w.current!==a){w.current=a,k(Hs(i,l));return}S&&!A.includes(x)&&k("api")},[x,A,S,a,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:o,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:P=>P.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:o,children:e.jsx(ue,{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 ${mn(i)}`,children:hn(i)})]}),S?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:A.map(P=>e.jsx("button",{type:"button",role:"tab",id:`${y}-${P}`,className:x===P?"active":void 0,"aria-selected":x===P,"aria-controls":E(P),onClick:()=>k(P),children:P==="api"?"API":"Subscription"},P))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Bs(i),children:Bs(i)})]}),D?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:v,children:v})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:m?.defaultModel??i.defaultModel??void 0,children:m?.defaultModel??i.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:g?.lastError??void 0,children:[R," cached · ",Ga(g?.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||g?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??g?.lastError??i.lastError??void 0,children:i.credential.lastError??g?.lastError??i.lastError})]}):null]}),a==="codex"?e.jsx(Ka,{providerBusy:t,status:i,onValidate:h}):S&&m&&g?e.jsx(Ja,{credentialTab:x,credentialTabsId:y,hasSubscriptionTab:C,providerId:a,providerBusy:t,settings:l,status:i,onDeleteCredential:d,onRefreshModels:u,onSaveConfig:p,onSaveCredential:c,onStartOpenAiSubscriptionAuth:f,onValidate:h}):i.routing.localByok&&!ss(a)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Qs,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function Ka({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(de,{size:14,className:"settings-spin"}):e.jsx(Xs,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function Ja({credentialTab:s,credentialTabsId:n,hasSubscriptionTab:a,providerId:t,providerBusy:l,settings:i,status:o,onDeleteCredential:d,onRefreshModels:u,onSaveConfig:p,onSaveCredential:c,onStartOpenAiSubscriptionAuth:f,onValidate:h}){const m=i.providers[t],g=r.useMemo(()=>Be(t,i),[t,i]),y=`provider-models-${t}`,w=r.useRef(t),[R,S]=r.useState(m.baseUrl??""),[A,C]=r.useState(m.defaultModel??""),[x,k]=r.useState(m.modelOverrides.join(`
6
+ `)),[D,E]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[v,P]=r.useState("local_secret"),[N,j]=r.useState(""),[z,F]=r.useState(""),q=l===`${t}:config`,Y=l===`${t}:credential`,Q=l===`${t}:validate`,T=l===`${t}:models`,ee=l==="openai:credential",X=t==="openai",V=t==="xai",H=t==="zai",W=(U=>`${n}-${U}-panel`)(s),G=s==="subscription"&&a,ne=s==="subscription"&&H?"coding-plan":"api",ae=ne==="coding-plan"?"Coding Plan key":"API key",le=o.credential.connected?ne==="coding-plan"?"Replace saved plan key":"Replace saved key":ae,ie=ne==="coding-plan"?"Save plan key":"Save key",b=r.useMemo(()=>qa(g,[A,...Us(x)]),[A,g,x]),$=Math.max(0,g.length-b.length);r.useEffect(()=>{if(w.current!==t){w.current=t,E({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),S(m.baseUrl??""),C(m.defaultModel??""),k(m.modelOverrides.join(`
7
+ `));return}D.baseUrl||S(m.baseUrl??""),D.defaultModel||C(m.defaultModel??""),D.modelOverrides||k(m.modelOverrides.join(`
8
+ `))},[m.baseUrl,m.defaultModel,m.modelOverrides,D.baseUrl,D.defaultModel,D.modelOverrides,t]);const _=v==="env"?!!z.trim():!!N.trim();async function he(U){U.preventDefault(),await p(t,{enabled:!0,baseUrl:R.trim()||null,defaultModel:A.trim()||null,modelOverrides:Us(x)}),E({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function ce(U){if(U.preventDefault(),!!_){if(v==="env"){await c(t,{source:"env",envVar:z.trim()});return}await c(t,{source:"local_secret",value:N}),j("")}}function O({panel:U=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:U?W:void 0,role:U?"tabpanel":void 0,"aria-labelledby":U?`${n}-${s}`:void 0,onSubmit:B=>{ce(B)},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:v,disabled:Y,label:"Credential source",options:Ma,onChange:B=>P(B)})]}),v==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:z,disabled:Y,placeholder:"PROVIDER_API_KEY",onChange:B=>F(B.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ae}),e.jsx("input",{type:"password",value:N,disabled:Y,placeholder:le,autoComplete:"off",onChange:B=>j(B.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:Y||!_,children:[Y?e.jsx(de,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:Y?"Saving":ie})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${o.displayName} credential`,disabled:Y||!o.credential.connected,onClick:()=>{d(t)},children:e.jsx(Ce,{size:15})})]})]})}function I(){return X?e.jsxs("div",{className:"provider-subscription-panel",id:W,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:ee,onClick:()=>{f("browser")},children:[ee?e.jsx(de,{size:14,className:"settings-spin"}):e.jsx(pe,{size:14}),e.jsx("span",{children:ee?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:ee,onClick:()=>{f("device")},children:[ee?e.jsx(de,{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 ${o.displayName} credential`,disabled:ee||!o.credential.connected,onClick:()=>{d(t)},children:e.jsx(Ce,{size:15})})]})]}):V?e.jsx("div",{className:"provider-subscription-panel",id:W,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."})]})}):H?e.jsxs("div",{className:"provider-subscription-panel",id:W,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."})]}),O({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[G?null:e.jsxs("form",{className:"provider-card-form",onSubmit:U=>{he(U)},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:R,disabled:q,placeholder:"https://api.example.com/v1",onChange:U=>{E(B=>({...B,baseUrl:!0})),S(U.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:y,value:A,disabled:q,placeholder:"Model id",onChange:U=>{E(B=>({...B,defaultModel:!0})),C(U.currentTarget.value)}}),e.jsx("datalist",{id:y,children:b.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))}),$>0?e.jsxs("small",{children:[$," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:q,children:[q?e.jsx(de,{size:14,className:"settings-spin"}):e.jsx(os,{size:14}),e.jsx("span",{children:q?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:T,onClick:()=>{u(t)},children:[T?e.jsx(de,{size:14,className:"settings-spin"}):e.jsx(oe,{size:14}),e.jsx("span",{children:T?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:Q||!A.trim(),onClick:()=>{h(t,{baseUrl:R.trim()||void 0,modelId:A.trim()||void 0})},children:[Q?e.jsx(de,{size:14,className:"settings-spin"}):e.jsx(Xs,{size:14}),e.jsx("span",{children:Q?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:G?I():O()})]})}function Ya({status:s,busy:n,flashTailscaleUp:a,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:o,copyTailscaleUpCommand:d,copyServeCommand:u,copyServeSetupUrl:p,copyOperatorCommand:c,createRemoteLink:f}){const h=s?.tailscale.installed??!1,m=s?.serve.enabled??!1,g=s?.serve.reachable??!1,y=!!(s?.webUiAvailable&&h),w=m?!!s?.remoteWebUrl:y,S=(s?.tailscale.peers??[]).filter(x=>!x.isSelf),A=!!s?.tailscale.error?.includes("set --operator"),C=!!(m&&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 ${g?"online":m?"configured":""}`,children:h?e.jsx(on,{size:18}):e.jsx(mt,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:g?"Tailscale Serve is reachable":m?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?Xa(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(oe,{className:n==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:n!==null||!h||!m&&!y,onClick:()=>{m?i():l()},children:[e.jsx(Vn,{size:15}),e.jsx("span",{children:m?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:C?"Browser UI":"Tailscale + Serve"})]})}),C&&e.jsx(me,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:n==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||n!==null,onAction:o}),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:d}),e.jsx(me,{label:"Serve command",value:s?.serveCommand??null,actionLabel:n==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||n!==null,onAction:u}),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}),A&&e.jsx(me,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:n==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||n!==null,onAction:c}),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:[S.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:n!==null||!w,onClick:()=>{f()},children:e.jsx("span",{children:m?"Copy link":"Create link"})})]}),s?S.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."})]}):S.map(x=>e.jsx(Za,{peer:x},x.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(Fs,{label:t.label,value:t.value},t.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:a.map(t=>e.jsx(Fs,{label:t.label,value:t.value},t.label))})]})}function Fs({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 Za({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 Xa(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 el=[{items:[{section:"account",label:"Account",Icon:vs},{section:"notifications",label:"Notifications",Icon:ln},{section:"providers",label:"Providers",Icon:en},{section:"usage",label:"Activity",Icon:Jn}]},{label:"Harness",items:[{section:"harness",label:"Overview",Icon:ot},{section:"harness-refiner",label:"Refiner",Icon:js},{section:"harness-continuous-review",label:"Continuous Review",Icon:oe},{section:"harness-contents",label:"Contents",Icon:Yn},{section:"harness-releases",label:"Releases",Icon:ct}]},{label:"Customization",items:[{section:"configuration",label:"Configuration",Icon:It},{section:"personalization",label:"Personalization",Icon:js},{section:"editor",label:"Editor",Icon:dt},{section:"skills",label:"Skills",Icon:ze}]},{label:"Agents",items:[{section:"profile",label:"Profiles",Icon:vs},{section:"subagents",label:"Agents",Icon:He}]},{label:"System",items:[{section:"dataset-storage",label:"Dataset Storage",Icon:St},{section:"remote",label:"Remote Access",Icon:on},{section:"diagnostics",label:"Diagnostics",Icon:pt}]}];function sl({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(Kn,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:el.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:o,Icon:d})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>a(i),children:[e.jsx(d,{size:16}),e.jsx("span",{children:o})]},i))]},t.label??`settings-${l}`))})]})}function nl({catalog:s,connection:n,onCatalog:a,onError:t,onOpenExtension:l,onToast:i}){const[o,d]=r.useState(""),[u,p]=r.useState(""),[c,f]=r.useState(null),[h,m]=r.useState(null),[g,y]=r.useState(null),w=r.useCallback(v=>{const P=v instanceof Error?v.message:String(v);y(P),t(P),i?.(P,"error")},[t,i]),R=r.useCallback(()=>{y(null),t(null)},[t]),S=r.useCallback(async v=>{if(v?.preventDefault(),!(!n||!o.trim()||h)){R(),m("preview");try{const P=await M.extensionPreview(n,{source:o.trim(),...u.trim()?{ref:u.trim()}:{}});f(P)}catch(P){f(null),w(P)}finally{m(null)}}},[h,R,n,w,u,o]),A=r.useCallback(async()=>{if(!(!n||!c||h)){R(),m("install");try{const v=await M.extensionAdd(n,{source:c.repositoryUrl,ref:c.requestedRef});a(v.catalog),d(""),p(""),f(null),i?.(`Installed ${v.extension.owner}/${v.extension.repo}.`,"success")}catch(v){w(v)}finally{m(null)}}},[h,R,n,a,i,c,w]),C=r.useCallback(async v=>{if(!(!n||h)){R(),m(`update:${v.id}`);try{const P=await M.extensionUpdate(n,v);a(P.catalog);const N=P.extension.resolvedCommit===v.resolvedCommit&&P.extension.packageHash===v.packageHash;i?.(N?`${v.owner}/${v.repo} is already current.`:`Updated ${v.owner}/${v.repo}.`,"success")}catch(P){w(P)}finally{m(null)}}},[h,R,n,a,i,w]),x=r.useCallback(async()=>{if(!(!n||h||s.extensions.length===0)){R(),m("update-all");try{const v=await M.extensionUpdateAll(n);a(v.catalog);const P=`Updated ${v.updated.length}; ${v.unchanged.length} already current${v.failed.length?`; ${v.failed.length} failed`:""}.`;i?.(P,v.failed.length?"error":"success"),v.failed.length&&y(v.failed.map(N=>N.error).join(" "))}catch(v){w(v)}finally{m(null)}}},[h,s.extensions.length,R,n,a,i,w]),k=r.useCallback(async v=>{if(!(!n||h)&&window.confirm(`Remove ${v.owner}/${v.repo} and its ${v.skills.length} installed skill${v.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){R(),m(`remove:${v.id}`);try{const P=await M.extensionRemove(n,v);a(P.catalog),i?.(`Removed ${v.owner}/${v.repo}.`,"success")}catch(P){w(P)}finally{m(null)}}},[h,R,n,a,i,w]),D=r.useCallback(v=>{d(v),f(null),y(null)},[]),E=r.useCallback(v=>{p(v),f(null),y(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||h!==null||s.extensions.length===0,type:"button",onClick:()=>{x()},children:[h==="update-all"?e.jsx(de,{className:"settings-spin",size:13}):e.jsx(oe,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:v=>{S(v)},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||h!==null,placeholder:"owner/repo",value:o,onChange:v=>D(v.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!n||h!==null,placeholder:"Default branch",value:u,onChange:v=>E(v.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!n||!o.trim()||h!==null,type:"submit",children:[h==="preview"?e.jsx(de,{className:"settings-spin",size:14}):e.jsx(es,{size:14}),h==="preview"?"Checking":"Preview"]})]}),g||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:g??s.error}):null,c?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[c.owner,"/",c.repo]}),e.jsxs("span",{children:[c.skills.length," skill",c.skills.length===1?"":"s"," at ",c.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:c.skills.map(v=>e.jsx("span",{children:v.name},v.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:h!==null,type:"button",onClick:()=>{A()},children:[h==="install"?e.jsx(de,{className:"settings-spin",size:14}):e.jsx(ge,{size:14}),h==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(v=>{const P=h===`update:${v.id}`,N=h===`remove:${v.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${v.owner}/${v.repo} extension source`,className:"github-extension-open",disabled:!n||h!==null,type:"button",onClick:()=>l(v),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(es,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsxs("strong",{children:[v.owner,"/",v.repo]}),e.jsx("span",{children:v.skills.map(j=>j.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[v.skills.length," skill",v.skills.length===1?"":"s"]}),e.jsxs("span",{children:[v.requestedRef," · ",v.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${v.validationStatus==="valid"?"":"invalid"}`,children:v.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(sn,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${v.owner}/${v.repo}`,className:"settings-icon-button ghost",disabled:h!==null,title:"Update extension",type:"button",onClick:()=>{C(v)},children:P?e.jsx(de,{className:"settings-spin",size:14}):e.jsx(oe,{size:14})}),e.jsx("button",{"aria-label":`Remove ${v.owner}/${v.repo}`,className:"settings-icon-button ghost danger",disabled:h!==null,title:"Remove extension",type:"button",onClick:()=>{k(v)},children:N?e.jsx(de,{className:"settings-spin",size:14}):e.jsx(Ce,{size:14})})]})]},v.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function tl({onOpenSkill:s,onOpenExtension:n,personalSkills:a,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:o,onToast:d}){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(nl,{catalog:t,connection:l,onCatalog:i,onError:o,onOpenExtension:n,onToast:d}),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(u=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:u.name}),e.jsx("span",{children:u.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:u.resourceFiles.length?`${u.resourceFiles.length} packaged resource${u.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:u.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${u.validationStatus==="valid"?"":"invalid"}`,children:u.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},u.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"})]}),Qn.map(u=>{const p=Zn(u.provider)?.label??u.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(u),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx(ze,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:u.name}),e.jsx("span",{children:u.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:p}),e.jsx("span",{children:u.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(sn,{size:16,"aria-hidden":"true"})]},u.name)})]})]})}const ds="default";function al({connection:s,embedded:n=!1,onError:a,onPreferences:t,preferences:l,providers:i}){const o=l.training,[d,u]=r.useState(Qe(o.defaultModelRef)),[p,c]=r.useState(o.creationMode),[f,h]=r.useState(o.autoApproveEvidence),[m,g]=r.useState(!1),y=r.useMemo(()=>Zs(i,{includeUnavailable:!0}),[i]),w=r.useMemo(()=>y.map(x=>({provider:x,models:Be(x.value,i)})).filter(x=>x.models.length>0),[y,i]),R=ll(d),S=Xn(l.defaultChatProvider,l.defaultChatModel,i)?` · ${il(l.codexReasoningEffort)} reasoning`:"",A=rl(R,o.defaultModelRef??null)&&p===o.creationMode&&f===o.autoApproveEvidence;r.useEffect(()=>{u(Qe(o.defaultModelRef)),c(o.creationMode),h(o.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,o.autoApproveEvidence,o.creationMode,o.defaultModelRef]);async function C(x){if(x.preventDefault(),!!s){g(!0),a(null);try{t(await M.savePreferences(s,{training:{defaultModelRef:R,creationMode:p,autoApproveEvidence:f}}))}catch(k){a(k instanceof Error?k.message:String(k))}finally{g(!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:x=>{C(x)},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:d,disabled:m,onChange:x=>u(x.target.value),children:[e.jsxs("option",{value:ds,children:["Use chat default — ",Te(l.defaultChatProvider,i)," · ",ns(l.defaultChatModel,i,l.defaultChatProvider),S]}),w.map(x=>e.jsx("optgroup",{label:x.provider.label,children:x.models.map(k=>e.jsx("option",{value:Qe({providerId:x.provider.value,modelId:k.value}),children:k.label},k.value))},x.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:m,onChange:x=>c(x.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:f,disabled:m,onChange:x=>h(x.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:m||A,children:e.jsx("span",{children:m?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:R?`${Te(R.providerId,i)} / ${ns(R.modelId,i,R.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 Qe(s){return s?JSON.stringify([s.providerId,s.modelId]):ds}function ll(s){if(s===ds)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 il(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function rl(s,n){return s?.providerId===n?.providerId&&s?.modelId===n?.modelId}function ol({disabled:s,onChange:n,storageRoots:a,value:t}){const l=r.useId(),[i,o]=r.useState(!1),d=Gs(t),u=f=>f.datasetStorePath,p="Dataset",c=a.find(f=>Gs(u(f))===d)??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:f=>n(f.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!c?e.jsx("option",{value:t,children:"Manual location"}):null,a.map(f=>e.jsxs("option",{disabled:!f.mounted||!f.writable,title:u(f),value:u(f),children:[f.label," · ",hl(f.kind)," · ",ml(f)]},f.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:()=>o(!0),children:e.jsx(ge,{size:15})})]}),i?cl(e.jsx(dl,{initialPath:t??"",purpose:"dataset",onClose:()=>o(!1),onUse:f=>{n(f),o(!1)}})):null]})}function cl(s){return typeof document>"u"?s:et.createPortal(s,document.body)}function dl({initialPath:s,onClose:n,onUse:a,purpose:t="model"}){const l=r.useId(),[i,o]=r.useState(s),d=ul(i);r.useEffect(()=>{const p=c=>{c.key==="Escape"&&n()};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]);function u(p){p.preventDefault(),p.stopPropagation(),!d&&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:u,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${t} storage`,onClick:n,children:e.jsx(ue,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(gt,{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=>o(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()&&d?e.jsx("div",{className:"profile-dialog-warning",children:d}):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:!!d,type:"submit",children:"Use location"})]})]})})}function ul(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 hl(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function ml(s){return s.mounted?s.writable?`${pl(s.freeBytes)} free`:"Read only":"Not mounted"}function Gs(s){const n=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(n)?n.toLowerCase():n}function pl(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 fl({state:s,catalog:n,busy:a,catalogLoading:t,onRefresh:l,onSave:i}){const[o,d]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{d(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const u=r.useMemo(()=>s?.storageRoots.find(h=>qs(h.datasetStorePath)===qs(o))??null,[o,s?.storageRoots]),p=o===(s?.settings.datasetStorePath??null),c=n?.datasets??[];async function f(h){h.preventDefault(),await i(o)}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(oe,{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:u?.label??(o?"Manual location":"Not configured")}),e.jsx("small",{children:o??"Choose a writable local or mounted location before importing a Dataset."}),u?e.jsxs("small",{children:[vl(u.kind)," · ",u.freeBytes==null?"Free space unknown":`${fn(u.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:h=>{f(h)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx(ol,{disabled:a!==null,onChange:d,storageRoots:s?.storageRoots??[],value:o}),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:c.length})]}),c.length?c.map(h=>e.jsx(gl,{dataset:h},h.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function gl({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:[gn(s.rowCount)," rows"," · ",xl(s)," · ",n," · ",s.sizeBytes==null?"Size unavailable":fn(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?jl(s.status):"Unavailable"})]})}function xl(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])=>`${gn(Number(t))} ${a}`).join(" · ")||"No split rows"}function fn(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 gn(s){return new Intl.NumberFormat().format(s)}function qs(s){return s?.replace(/[\\/]+$/,"")??""}function jl(s){return s.replaceAll("_"," ").replace(/^./,n=>n.toUpperCase())}function vl(s){return s.replace(/^./,n=>n.toUpperCase())}function $e(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function ke(s){return s?s.slice(0,10):"none"}function ye(s){const n=s.replaceAll("_"," ");return`${n.charAt(0).toUpperCase()}${n.slice(1)}`}function bl(s){return s==="unresolved"?"Watching":s==="confirmed"?"Ready for Refiner":ye(s)}function yl({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?ke(t.contentHash):"Not created"})]},a))})}function Nl({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:bl(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:$e(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:ke(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:ke(n.evidence.contentHash)}),e.jsx("time",{children:$e(n.occurredAt)})]},`${n.evidence.id}:${n.evidence.contentHash}`))})]}):null]})]})}function wl({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:$e(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(yl,{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 Sl({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:$e(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:ke(s.review.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Taskset"}),e.jsx("dd",{children:e.jsx("code",{children:ke(s.tasksetRelease?.contentHash)})})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Baseline"}),e.jsx("dd",{children:e.jsx("code",{children:ke(s.baselineEvaluation?.contentHash)})})]})]})]})]})}function kl({acceptingReviewId:s,candidates:n,onAcceptTasksetReview:a,qualifications:t,reviews:l,schedule:i}){const o=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 ${o?"harness-status-advanced":""}`,children:o?"On":"Off"})}),e.jsx("td",{children:i.activityEnabled?`${i.activityBatchSize} new outcomes`:"Manual only"}),e.jsx("td",{children:$e(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(d=>e.jsx(Nl,{candidate:d},`${d.id}:${d.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(d=>e.jsx(wl,{accepting:s===d.id,onAcceptTasksetReview:a,review:d},`${d.id}:${d.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(d=>e.jsx(Sl,{receipt:d},`${d.id}:${d.contentHash}`))})]}):null]})}const Cl="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 Ws(s){const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Se(s){return s?s.slice(0,10):"none"}function Rl({busyReleaseHash:s,history:n,onRequestRelease:a,onStartAuthoring:t}){const l=r.useMemo(()=>{const i=new Map;for(const o of n.transitions)i.has(o.nextRelease.contentHash)||i.set(o.nextRelease.contentHash,o);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(Cl),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:Se(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:Se(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 o=i.contentHash===n.binding.release.contentHash,d=!o&&l.get(i.contentHash)?.bindingChanged===!1,u=d?"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:Se(i.contentHash)})}),e.jsx("td",{children:Ws(i.createdAt)}),e.jsx("td",{children:e.jsx("span",{className:"harness-status",children:o?"active":d?"draft":"immutable"})}),e.jsx("td",{children:o?null:e.jsx("button",{"aria-label":`${d?"Activate":"Roll back"} Refiner release`,className:"harness-table-icon-action",disabled:s!==null,onClick:()=>a(i,u),title:`${d?"Activate":"Roll back"} Refiner release`,type:"button",children:d?e.jsx(rs,{size:14}):e.jsx(_e,{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 ${Se(i.authoringSkillHash)}`:i.actor})]}),e.jsx("td",{children:e.jsxs("code",{children:[Se(i.previousRelease?.contentHash)," → ",Se(i.nextRelease.contentHash)]})}),e.jsx("td",{children:i.validation.valid?"Passed":i.validation.messages.join("; ")}),e.jsx("td",{children:Ws(i.createdAt)})]},i.contentHash))})]})})]})]})}const Pl={enabled:!1,activityEnabled:!1,activityBatchSize:10,cadence:"manual",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null},Al={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 Pe(s){if(!s)return"Not yet";const n=new Date(s);return Number.isNaN(n.valueOf())?s:n.toLocaleString()}function Ae(s){return s?s.slice(0,10):"none"}function Vs(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 ${Ae(a.contentHash)}`}}function Il({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:Pe(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(ue,{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(rs,{size:13})," Approve and release"]})]})]})}function Dl({change:s,onClose:n}){const a=s.proposal;return e.jsxs(xt,{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(ue,{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 El({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(Il,{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:Pe(l.at)})]},l.id))}):e.jsx("div",{className:"harness-empty compact",children:"No Harness learning activity yet."})]})]})}function $l({history:s,refiner:n,busyReleaseHash:a,onRequestRefinerRelease:t,onStartRefinerAuthoring:l,onOpenChangeDiff:i,onOpenSourceSession:o}){const[d,u]=r.useState(null);return e.jsxs("div",{className:"harness-page-sections",children:[e.jsx(Rl,{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 c=p.trigger?.runRef??null,f=p.proposal;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("strong",{children:f?.expectedOutcome??p.receipt.reason})}),e.jsx("td",{children:e.jsx("code",{children:f?.edits[0]?.target??f?.route??"workspace"})}),e.jsx("td",{children:e.jsx("code",{children:Ae(p.receipt.nextRelease?.contentHash)})}),e.jsx("td",{children:Pe(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:()=>u(p),title:"View evidence and exact edits",type:"button",children:e.jsx(Nt,{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(rn,{size:14})}):null,c&&o?e.jsx("button",{"aria-label":"Open source conversation",className:"harness-table-icon-action",onClick:()=>o(c),title:"Open source conversation",type:"button",children:e.jsx(en,{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:Pe(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."})]}),d?e.jsx(Dl,{change:d,onClose:()=>u(null)}):null]})}function Ml(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 Ol(s){return s<1024?`${s} B`:`${(s/1024).toFixed(s<10240?1:0)} KB`}function Ll({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:Ml(t.path)})}),e.jsx("td",{children:e.jsx("code",{children:t.path})}),e.jsx("td",{children:Ol(t.sizeBytes)}),e.jsx("td",{children:e.jsx("code",{children:Ae(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:Pe(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 Tl({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:Ae(l.contentHash)})]})}),e.jsxs("td",{children:[l.files.length," files"]}),e.jsx("td",{children:Pe(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(rn,{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(_e,{size:14})})]})})]},`${l.id}:${l.contentHash}`))})]})}):e.jsx("div",{className:"harness-empty compact",children:"No Harness releases exist yet."})]})}function zl({connection:s,enabled:n,onAcceptEvaluationReview:a,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:o,onStartRefinerAuthoring:d,onToast:u,page:p}){const[c,f]=r.useState(null),[h,m]=r.useState(null),[g,y]=r.useState(null),[w,R]=r.useState(!1),[S,A]=r.useState(null),[C,x]=r.useState(null),[k,D]=r.useState(!1),[E,v]=r.useState(!1),[P,N]=r.useState(null),{confirmAction:j,confirmDialog:z,resolveConfirmDialog:F}=Js(),q=!!(c?.evaluationReviewSchedule.activityEnabled||c?.evaluationReviewSchedule.enabled),[Y,Q]=r.useState(!1),[T,ee]=r.useState(!1);r.useEffect(()=>{c&&Q(c.backgroundReview.enabled)},[c?.backgroundReview.enabled]),r.useEffect(()=>{ee(q)},[q]);const X=r.useCallback(async()=>{if(s){R(!0);try{const[O,I]=await Promise.all([M.harnessHistory(s),M.refinerHistory(s)]);f(O),m(I);const U=O.releases.findIndex(se=>se.current),B=U>=0?O.releases[U]:null;O.workspace&&B&&l(Vs(O.workspace.id,O.releases[U+1]??null,B)),t(null)}catch(O){t(O instanceof Error?O.message:String(O))}finally{R(!1)}}},[s,l,t]);r.useEffect(()=>{n&&X()},[n,p,X]);const V=r.useCallback(async O=>{if(!(!s||!c?.workspace)){v(!0);try{const I=await M.reviewHarnessEvaluation(s,{workspaceId:c.workspace.id,maxEstimatedCostUsd:O});f(I.history),t(null),u?.(`Continuous Review completed: ${I.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{v(!1)}}},[s,c,t,u]),H=r.useCallback(async(O,I,U)=>{if(!(!s||!c?.workspace)){D(!0);try{let B=c;O==="refiner"&&I!==c.backgroundReview.enabled&&(B=(await M.updateHarnessBackgroundReview(s,{workspaceId:c.workspace.id,enabled:I})).history);const se=c.evaluationReviewSchedule.activityEnabled||c.evaluationReviewSchedule.enabled;if(O==="continuous-review"&&(U!==se||c.evaluationReviewSchedule.enabled)){const Z=c.evaluationReviewSchedule;B=(await M.updateHarnessEvaluationReviewSchedule(s,{workspaceId:c.workspace.id,enabled:!1,activityEnabled:U,activityBatchSize:Z.activityBatchSize,cadence:"manual",maxEstimatedCostUsd:Z.maxEstimatedCostUsd})).history}f(B),t(null),u?.(`${O==="refiner"?"Refiner":"Continuous Review"} settings applied.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{D(!1)}}},[s,c,t,u]),te=r.useCallback(async O=>{if(c?.workspace){N(O.id);try{await a(c.workspace.id,{id:O.id,contentHash:O.contentHash})&&(t(null),u?.("Taskset review opened in Models.","success"))}catch(I){t(I instanceof Error?I.message:String(I))}finally{N(null)}}},[c?.workspace,a,t,u]),W=r.useCallback((O,I)=>{c?.workspace&&i(Vs(c.workspace.id,O,I))},[c?.workspace,i]),G=r.useCallback(O=>{!c?.workspace||!O.receipt.nextRelease||i({workspaceId:c.workspace.id,baseRelease:O.receipt.previousRelease,targetRelease:O.receipt.nextRelease,title:O.proposal?.expectedOutcome??O.receipt.reason})},[c?.workspace,i]),ne=r.useCallback(async O=>{if(!(!s||!c?.workspace)){A(O.contentHash);try{const I=await M.rollbackHarness(s,{workspaceId:c.workspace.id,targetRelease:{id:O.id,contentHash:O.contentHash}});f(I.history),t(null),u?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(I){t(I instanceof Error?I.message:String(I))}finally{A(null)}}},[s,c?.workspace,t,u]),ae=r.useCallback(async O=>{await j({title:"Roll back Harness release?",body:`New work will use ${Ae(O.contentHash)}. Active runs remain pinned to their current release.`,confirmLabel:"Roll back"})&&await ne(O)},[j,ne]),le=r.useCallback(async(O,I)=>{if(!(!s||!await j({title:I==="activate"?"Activate Refiner release?":"Roll back Refiner release?",body:`Future reviews will use ${O.profile.name} at ${Ae(O.contentHash)}. Existing work remains pinned.`,confirmLabel:I==="activate"?"Activate":"Roll back"}))){y(O.contentHash);try{const B={release:{id:O.id,contentHash:O.contentHash},reason:`${I==="activate"?"Activate":"Rollback"} from Settings to ${O.profile.id}@${O.profile.version}.`,actor:"settings-user"};m(await(I==="activate"?M.activateRefinerRelease(s,B):M.rollbackRefinerRelease(s,B))),t(null),u?.(`Refiner ${I==="activate"?"activated":"rolled back"}. Existing work remains pinned.`,"success")}catch(B){t(B instanceof Error?B.message:String(B))}finally{y(null)}}},[j,s,t,u]),ie=r.useCallback(async(O,I)=>{if(!(!s||!c?.workspace)){x(O.proposal.id);try{const U=await M.reviewHarnessProposal(s,{workspaceId:c.workspace.id,proposal:{id:O.proposal.id,contentHash:O.proposal.contentHash},decision:I});f(U.history),t(null),u?.(I==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",I==="approve"?"success":"info")}catch(U){t(U instanceof Error?U.message:String(U))}finally{x(null)}}},[s,c?.workspace,t,u]),b=c?.releases.find(O=>O.current)??c?.releases[0]??null,$=b?c?.releases.indexOf(b)??-1:-1,_=Al[p],he=c?p==="refiner"?Y!==c.backgroundReview.enabled:T!==q||c.evaluationReviewSchedule.enabled:!1,ce=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:_.title}),e.jsx("p",{children:_.description})]}),c?.workspace&&ce?e.jsxs("div",{className:"harness-page-header-actions",children:[p==="continuous-review"?e.jsx("button",{className:"settings-secondary compact",disabled:E,onClick:()=>{V(c.evaluationReviewSchedule.maxEstimatedCostUsd)},type:"button",children:E?"Reviewing…":"Review now"}):null,e.jsxs("label",{className:"harness-page-toggle",children:[e.jsx("span",{children:p==="refiner"?Y?"On":"Off":T?"On":"Off"}),e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{"aria-label":p==="refiner"?"Enable Refiner":"Enable Continuous Review",checked:p==="refiner"?Y:T,disabled:k,onChange:O=>p==="refiner"?Q(O.target.checked):ee(O.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("button",{className:"settings-primary compact",disabled:k||!he,onClick:()=>{H(p,Y,T)},type:"button",children:k?"Applying…":"Apply changes"})]}):null]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&w&&!c?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,c&&!c.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,c?.workspace&&p==="overview"?e.jsx(El,{history:c,onReviewProposal:ie,reviewingProposalId:C}):null,c&&h&&p==="refiner"?e.jsx($l,{busyReleaseHash:g,history:c,refiner:h,onOpenChangeDiff:G,onOpenSourceSession:o,onRequestRefinerRelease:(O,I)=>{le(O,I)},onStartRefinerAuthoring:d}):null,c?.workspace&&p==="continuous-review"?e.jsx(kl,{acceptingReviewId:P,candidates:c.refinementCandidates,onAcceptTasksetReview:O=>{te(O)},qualifications:c.modelImprovementQualifications,reviews:c.evaluationReviews,schedule:c.evaluationReviewSchedule??Pl}):null,c?.workspace&&p==="contents"?e.jsx(Ll,{history:c,onOpenCurrentRelease:()=>{b&&W($>=0?c.releases[$+1]??null:null,b)}}):null,c?.workspace&&p==="releases"?e.jsx(Tl,{busy:S!==null,history:c,onOpenDiff:W,onRequestRollback:O=>{ae(O)}}):null,e.jsx(Ys,{onResolve:F,state:z})]})}function Ks(s){return s?s.slice(0,10):"initial"}function Ul({connection:s,expanded:n,onResizeStart:a,onToggleExpanded:t,selection:l}){const[i,o]=r.useState(null),[d,u]=r.useState(null),[p,c]=r.useState(!0),f=r.useCallback(async()=>{u(null),c(!0);try{o(await M.harnessReleaseDiff(s,l))}catch(g){o(null),u(g instanceof Error?g.message:String(g))}finally{c(!1)}},[s,l]);r.useEffect(()=>{f()},[f]);const h=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(g=>g.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),m=`${l.title} · ${Ks(l.baseRelease?.contentHash)} → ${Ks(l.targetRelease.contentHash)}`;return e.jsx(jt,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:h,editorPreferences:null,expanded:n,filesWithPreview:!0,loading:p,onOpenBrowserUrl:()=>{},onRefresh:f,onResizeStart:a,onToggleExpanded:t,readOnly:!0,workspaceError:d,workspaceInitialized:!0,workspaceName:m})}function Bl({connection:s,onError:n,onPayload:a}){const[t,l]=r.useState(!1),[i,o]=r.useState(!1);async function d(f,h){if(s){l(!0),n(null);try{const m=await M.switchOpenPondAccount(s,{handle:f,baseUrl:h??null}),g=await M.savePreferences(s,{defaultTeamId:null});a({...m,preferences:g.preferences})}catch(m){n(m instanceof Error?m.message:String(m))}finally{l(!1)}}}async function u(f,h){if(!s)return!1;l(!0),n(null);try{return a(await M.removeOpenPondAccount(s,{handle:f,baseUrl:h??null})),!0}catch(m){return n(m instanceof Error?m.message:String(m)),!1}finally{l(!1)}}async function p(f){if(!(!s||!f.apiKey.trim())){l(!0),n(null);try{const h=f.handle?.trim(),m=f.environment?.trim(),g=await M.saveOpenPondAccount(s,{apiKey:f.apiKey.trim(),handle:h||void 0,baseUrl:f.baseUrl,apiBaseUrl:f.apiBaseUrl,environment:m||"custom",setActive:!0}),y=await M.savePreferences(s,{defaultTeamId:null});a({...g,preferences:y.preferences})}catch(h){throw n(h instanceof Error?h.message:String(h)),h}finally{l(!1)}}}async function c(){if(s){o(!0),n(null);try{a(await M.refreshOpenPondAccounts(s))}catch(f){n(f instanceof Error?f.message:String(f))}finally{o(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:c,removeAccount:u,saveAccount:p,switchAccount:d}}function Hl({connection:s,onError:n,onPreferences:a,preferences:t,providers:l}){const[i,o]=r.useState(t.defaultBranchPrefix),[d,u]=r.useState(t.defaultNewProjectDirectory),[p,c]=r.useState(t.advancedWorkspaceControls),[f,h]=r.useState(t.steerActiveResponses),[m,g]=r.useState(t.contextCompaction.autoEnabled),[y,w]=r.useState(t.subagents.enabled),[R,S]=r.useState(t.subagents.delegationMode),[A,C]=r.useState(!t.subagents.defaultModelRef),[x,k]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[D,E]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[v,P]=r.useState(t.subagents.roles),[N,j]=r.useState(t.subagents.maxConcurrentRuns),[z,F]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[q,Y]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[Q,T]=r.useState(!1),ee=A?null:{providerId:x,modelId:D.trim()},X=y!==t.subagents.enabled||R!==t.subagents.delegationMode||!_l(ee,t.subagents.defaultModelRef)||N!==t.subagents.maxConcurrentRuns||z!==t.subagents.maxConcurrentRunsPerProvider||q!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(v)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{o(t.defaultBranchPrefix),u(t.defaultNewProjectDirectory),c(t.advancedWorkspaceControls),h(t.steerActiveResponses),g(t.contextCompaction.autoEnabled),w(t.subagents.enabled),S(t.subagents.delegationMode),C(!t.subagents.defaultModelRef),k(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),E(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),P(t.subagents.roles),j(t.subagents.maxConcurrentRuns),F(t.subagents.maxConcurrentRunsPerProvider),Y(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.steerActiveResponses,t.contextCompaction.autoEnabled,t.subagents]);function V(I){k(I),E(U=>ts(I,U,l))}function H(){return A?t.defaultChatProvider:x}function te(){return A?t.defaultChatModel:D}function W(I,U){P(B=>B.map(se=>se.id===I?U(se):se))}function G(I,U){W(I,B=>({...B,enabled:U}))}function ne(I,U){W(I,B=>({...B,background:U}))}function ae(I,U){W(I,B=>{if(U)return{...B,modelRef:null};const se=B.modelRef?.providerId??H(),Z=B.modelRef?.modelId??te();return{...B,modelRef:qe(se,Z,l)??null}})}function le(I,U){W(I,B=>({...B,modelRef:qe(U,B.modelRef?.modelId??te(),l)??null}))}function ie(I,U){W(I,B=>{const se=B.modelRef?.providerId??H(),Z=U.trim();return{...B,modelRef:Z?{providerId:se,modelId:Z}:null}})}function b(I,U){W(I,B=>({...B,isolationMode:U}))}function $(I,U){W(I,B=>({...B,toolPolicy:U}))}function _(I,U){W(I,B=>({...B,peerMessages:U}))}function he(I,U){W(I,B=>({...B,maxConcurrentRuns:be(U,1,16)}))}async function ce(){let I=null;if(window.openpond?.selectFolder){const U=await window.openpond.selectFolder();if(U.canceled)return;I=U.path}else I=window.prompt("Default new project directory",d);I?.trim()&&u(I.trim())}async function O(I){if(I.preventDefault(),!!s){T(!0),n(null);try{a(await M.savePreferences(s,{defaultBranchPrefix:Ze(i),defaultNewProjectDirectory:d.trim(),advancedWorkspaceControls:p,steerActiveResponses:f,contextCompaction:{...t.contextCompaction,autoEnabled:m},subagents:{enabled:y,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:R,defaultModelRef:A?null:qe(x,D,l)??null,roles:v,maxConcurrentRuns:be(N,1,32),maxConcurrentRunsPerProvider:z===null?null:be(z,1,32),maxConcurrentRunsPerWorkspaceTarget:q===null?null:be(q,1,32)}}))}catch(U){n(U instanceof Error?U.message:String(U))}finally{T(!1)}}}return{advancedWorkspaceControls:p,steerActiveResponses:f,contextCompactionAutoEnabled:m,defaultBranchPrefix:i,defaultNewProjectDirectory:d,subagentsEnabled:y,subagentDelegationMode:R,subagentsUseDefaultModel:A,subagentsProvider:x,subagentsModel:D,subagentRoles:v,subagentsMaxConcurrentRuns:N,subagentsMaxConcurrentRunsPerProvider:z,subagentsMaxConcurrentRunsPerWorkspaceTarget:q,subagentsDirty:X,saving:Q,chooseDefaultProjectDirectory:ce,saveDefaults:O,changeSubagentsProvider:V,changeSubagentRoleProvider:le,setAdvancedWorkspaceControls:c,setSteerActiveResponses:h,setContextCompactionAutoEnabled:g,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:u,setSubagentsUseDefaultModel:C,setSubagentsModel:E,setSubagentsEnabled:w,setSubagentDelegationMode:I=>S(I),setSubagentsMaxConcurrentRuns:I=>j(be(I,1,32)),setSubagentsMaxConcurrentRunsPerProvider:I=>F(I===null?null:be(I,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:I=>Y(I===null?null:be(I,1,32)),setSubagentRoleBackground:ne,setSubagentRoleEnabled:G,setSubagentRoleIsolationMode:b,setSubagentRoleMaxConcurrentRuns:he,setSubagentRoleModel:ie,setSubagentRolePeerMessages:_,setSubagentRoleToolPolicy:$,setSubagentRoleUseDefaultModel:ae}}function be(s,n,a){return Number.isFinite(s)?Math.min(a,Math.max(n,Math.trunc(s))):n}function _l(s,n){return(s?.providerId??null)===(n?.providerId??null)&&(s?.modelId??null)===(n?.modelId??null)}const Fl=15e3,Gl=100,ql=100,Wl=2500;function Vl({onError:s,section:n}){const[a,t]=r.useState(null),[l,i]=r.useState(null),[o,d]=r.useState(Gl),[u,p]=r.useState([]),[c,f]=r.useState(null),[h,m]=r.useState(!0),g=r.useRef(null),[y,w]=r.useState(null),R=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),A=!!window.openpond?.readRecentLogs?`${u.length} of ${o} line${o===1?"":"s"}${h?" tailing":""}`:"Unavailable";r.useEffect(()=>{n==="diagnostics"&&C(o,"refresh",{quiet:!0})},[n]),r.useEffect(()=>{if(n!=="diagnostics"||!h||!window.openpond?.readRecentLogs)return;let P=!1;const N=window.setInterval(()=>{P||(P=!0,C(o,"refresh",{quiet:!0}).finally(()=>{P=!1}))},Wl);return()=>window.clearInterval(N)},[n,h,o]),r.useEffect(()=>{if(n!=="diagnostics"||!h)return;const P=g.current;P&&(P.scrollTop=P.scrollHeight)},[n,h,u]);async function C(P=o,N="refresh",j={}){const z=window.openpond?.readRecentLogs;if(!z){const F="Log view is not available in this runtime.";j.quiet||(w({label:"Logs",value:F,warning:!0}),s(F));return}j.quiet||i(N);try{const F=await Oe(z(P),"Read logs");if(!F.ok)throw new Error(F.error);d(F.lineLimit),f(F.logDir),p(F.lines),j.quiet?w(q=>q?.label==="Logs"?null:q):w(null)}catch(F){const q=F instanceof Error?F.message:String(F);w({label:"Logs",value:q,warning:!0}),j.quiet||s(q)}finally{j.quiet||i(null)}}function x(){m(!1),C(o+ql,"older")}function k(){const P=!h;m(P),P&&C(o,"refresh",{quiet:!0})}async function D(){const P=window.openpond?.openLogsFolder;if(!P){const N="Desktop logs are not available in this runtime.";w({label:"Logs",value:N,warning:!0}),s(N);return}t("logs"),s(null);try{const N=await Oe(P(),"Open logs");if(!N.ok)throw new Error(N.error??"Could not open the logs folder.");w(null)}catch(N){const j=N instanceof Error?N.message:String(N);w({label:"Logs",value:j,warning:!0}),s(j)}finally{t(null)}}async function E(){const P=window.openpond?.copyRecentLogs;if(!P){const N="Recent log copy is not available in this runtime.";w({label:"Copy",value:N,warning:!0}),s(N);return}t("copy"),s(null);try{const N=await Oe(P(1e3),"Copy recent logs");if(!N.ok)throw new Error(N.error??"Could not copy recent logs.");w({label:"Copy",value:N.lines?`Copied ${N.lines} recent log lines.`:"Copied recent logs."})}catch(N){const j=N instanceof Error?N.message:String(N);w({label:"Copy",value:j,warning:!0}),s(j)}finally{t(null)}}async function v(){const P=window.openpond?.exportDiagnostics;if(!P){const N="Diagnostics export is not available in this runtime.";w({label:"Export",value:N,warning:!0}),s(N);return}t("export"),s(null);try{const N=await Oe(P(),"Export diagnostics");if(!N.ok)throw new Error(N.error??"Could not export diagnostics.");w({label:"Export",value:N.path?`Saved to ${N.path}`:"Diagnostics exported."})}catch(N){const j=N instanceof Error?N.message:String(N);w({label:"Export",value:j,warning:!0}),s(j)}finally{t(null)}}return{diagnosticsAvailable:R,diagnosticsBusy:a,diagnosticsStatus:y,logDir:c,logLineLimit:o,logLines:u,logViewBusy:l,logViewSummary:A,logViewportRef:g,tailLogs:h,copyRecentLogs:E,exportDiagnosticsBundle:v,loadOlderLogs:x,openLogsFolder:D,refreshLogView:C,toggleTailLogs:k}}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.`))},Fl)})])}finally{a!==void 0&&window.clearTimeout(a)}}function Kl({connection:s,enabled:n,onError:a,onPreferences:t,onToast:l,preferences:i}){const[o,d]=r.useState(i.editor),[u,p]=r.useState(null),[c,f]=r.useState(!1),[h,m]=r.useState(!1),[g,y]=r.useState(!1);r.useEffect(()=>{d(i.editor)},[i.editor]);const w=r.useCallback(async()=>{if(s){m(!0);try{p(await M.workspaceLspSettingsStatus(s))}catch(x){a(x instanceof Error?x.message:String(x))}finally{m(!1)}}},[s,a]);r.useEffect(()=>{!n||!s||w()},[s,n,w]);function R(x,k){d(D=>({...D,languages:{...D.languages,[x]:{...D.languages[x],mode:k}}}))}function S(x,k){d(D=>({...D,languages:{...D.languages,[x]:{...D.languages[x],customCommand:k}}}))}async function A(x){if(x.preventDefault(),!!s){f(!0),a(null);try{const k=await M.savePreferences(s,{editor:o});t(k),p(await M.workspaceLspSettingsStatus(s))}catch(k){a(k instanceof Error?k.message:String(k))}finally{f(!1)}}}async function C(){if(s){y(!0),a(null);try{await M.restartWorkspaceLsp(s),p(await M.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(x){a(x instanceof Error?x.message:String(x))}finally{y(!1)}}}return{editorPreferences:o,lspStatus:u,restarting:g,saving:c,statusLoading:h,refreshLspStatus:w,restartLanguageServers:C,saveEditorSettings:A,setEditorPreferences:d,setLanguageCustomCommand:S,setLanguageMode:R}}function Jl({connection:s,onError:n,onPayload:a,personalization:t}){const l=r.useMemo(()=>t.templates.map(v=>({value:v.id,label:v.name,description:v.id===t.activeTemplateId?"Selected":v.source==="built_in"?v.description:void 0})),[t.activeTemplateId,t.templates]),[i,o]=r.useState(t.activeTemplateId),[d,u]=r.useState(t.soul),[p,c]=r.useState(""),[f,h]=r.useState(!1),[m,g]=r.useState(!1),y=t.templates.find(v=>v.id===i)??t.templates[0],w=y?.source==="custom",R=y?d!==y.content:!0,S=i!==t.activeTemplateId||d!==t.soul||R,A=!!(w&&d.trim()&&y&&S);r.useEffect(()=>{o(t.activeTemplateId),u(t.soul);const v=t.templates.find(P=>P.id===t.activeTemplateId);c(v?`${v.name} Copy`:""),h(!1)},[t.activeTemplateId,t.soul,t.templates]);async function C(v=!1){if(!v&&!w)return;const P=v?p:y?.name;if(!(!s||!d.trim()||!P?.trim())){g(!0),n(null);try{a(await M.savePersonalization(s,{activeTemplateId:i,templateName:P,soul:d,saveAsNew:v})),h(!1)}catch(N){n(N instanceof Error?N.message:String(N))}finally{g(!1)}}}async function x(v){const P=t.templates.find(N=>N.id===v);if(P&&(o(P.id),c(`${P.name} Copy`),u(P.content),h(!1),!!s)){g(!0),n(null);try{a(await M.savePersonalization(s,{activeTemplateId:P.id,templateName:P.name,soul:P.content,saveAsNew:!1}))}catch(N){n(N instanceof Error?N.message:String(N))}finally{g(!1)}}}function k(){y&&(c(`${y.name} Copy`),u(y.content),h(!1))}function D(v){u(v),y&&!w&&v!==y.content&&h(!0)}function E(){y&&(c(`${y.name} Copy`),h(!0))}return{canSaveCurrentTemplate:A,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:f,saving:m,selectedPersonalizationTemplate:y,selectedTemplateIsCustom:w,soulDraft:d,templateNameDraft:p,changePersonalizationTemplate:x,changeSoulDraft:D,openSaveAsNew:E,resetPersonalizationDraft:k,savePersonalization:C,setSaveAsNewOpen:h,setTemplateNameDraft:c}}function Yl({connection:s,onError:n,onPreferences:a,onProviders:t,preferences:l,providers:i}){const[o,d]=r.useState(l.defaultChatProvider),[u,p]=r.useState(l.defaultChatModel),[c,f]=r.useState(!1),[h,m]=r.useState(null),[g,y]=r.useState(null);r.useEffect(()=>{d(l.defaultChatProvider),p(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function w(N){if(N.preventDefault(),!!s){f(!0),n(null);try{a(await M.savePreferences(s,{defaultChatProvider:o,defaultChatModel:ts(o,u,i)}))}catch(j){n(j instanceof Error?j.message:String(j))}finally{f(!1)}}}function R(N){d(N),p(j=>ts(N,j,i))}async function S(N,j,z){if(!s)return null;m(`${N}:${j}`),y(null),n(null);try{return await z()}catch(F){return n(F instanceof Error?F.message:String(F)),null}finally{m(null)}}async function A(N,j){await S(N,"config",async()=>{const z=await M.saveProviderSettings(s,{providers:{[N]:j}});return t(z),z})}async function C(N,j){await S(N,"credential",async()=>{const z=await M.saveProviderCredential(s,N,j);return t(z),z})}async function x(N){await S(N,"credential",async()=>{const j=await M.deleteProviderCredential(s,N,{});return t(j),j})}async function k(N){return S("openai","credential",async()=>{const j=await M.startOpenAiSubscriptionAuth(s,{method:N});return j.method==="browser"?(window.open(j.url,"_blank","noopener,noreferrer"),y("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(j.url,"_blank","noopener,noreferrer"),y(`OpenAI device login started. Enter code ${j.userCode}.`)),D(j.expiresAt),j})}async function D(N){if(s)for(;Date.now()<N;){await new Promise(j=>setTimeout(j,2500));try{const j=await M.providerSettings(s);t(j);const z=j.statuses.openai?.credential;if(z?.connected&&z.source==="chatgpt_subscription"){y("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function E(N){await S(N,"models",async()=>{const j=await M.refreshProviderModels(s,N,{force:!0});return t(j.providers),j})}async function v(N){await S(N,"models",async()=>{const j=await M.loadProviderModels(s,N,{limit:500});return t(j.providers),j})}async function P(N,j={}){await S(N,"validate",async()=>{const z=await M.validateProviderCredential(s,N,j);return y(z.ok?`${N} validated${z.modelId?` with ${z.modelId}`:""}.`:z.errors.join(`
9
+ `)||`${N} validation failed.`),t(z.providers),z})}return{defaultModel:u,defaultProvider:o,providerBusy:h,saving:c,validationMessage:g,changeDefaultProvider:R,deleteProviderCredential:x,loadProviderModels:v,refreshProviderModels:E,saveProviderConfig:A,saveProviderCredential:C,saveProviders:w,setDefaultModel:p,startOpenAiSubscriptionAuth:k,validateProvider:P}}function Ql({connection:s,enabled:n,onError:a,onToast:t}){const[l,i]=r.useState(null),[o,d]=r.useState(null),[u,p]=r.useState(!1),c=r.useRef(null),f=r.useCallback(async(k={})=>{if(s){k.quiet||d("refresh");try{const D=await M.remoteAccess(s);i(D),a(null)}catch(D){a(D instanceof Error?D.message:String(D))}finally{k.quiet||d(null)}}},[s,a]);r.useEffect(()=>{!n||!s||f({quiet:!0})},[s,n,f]),r.useEffect(()=>()=>{c.current!==null&&window.clearTimeout(c.current)},[]);function h(){c.current!==null&&window.clearTimeout(c.current),p(!1),window.setTimeout(()=>{p(!0),c.current=window.setTimeout(()=>{p(!1),c.current=null},1500)},0)}async function m(){if(a(null),!!s)try{i(await M.remoteAccess(s))}catch{}}async function g(){if(!s)return null;l&&!l.tailscale.running&&h(),d("enable");try{const k=await M.enableRemoteAccess(s);return i(k.status),a(null),k.status.tailscale.running?!k.status.serve.enabled&&k.status.serve.error&&t?.(k.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":k.message||k.status.serve.error,"error"):(h(),t?.(k.message||"Tailscale is not running. Run Tailscale up first.","error")),k.status}catch{return await m(),h(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{d(null)}}async function y(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){d("disable");try{const k=await M.disableRemoteAccess(s);i(k.status),a(null)}catch{await m()}finally{d(null)}}}async function w(){l?.remoteWebUrl&&(d("copy-link"),await Ne(l.remoteWebUrl),d(null))}async function R(){l?.serveCommand&&(d("copy-command"),await Ne(l.serveCommand),d(null))}async function S(){l?.serve.setupUrl&&(d("copy-serve-setup"),await Ne(l.serve.setupUrl),d(null))}async function A(){l?.tailscaleUpCommand&&(d("copy-up-command"),await Ne(l.tailscaleUpCommand),d(null))}async function C(){l?.operatorCommand&&(d("copy-operator"),await Ne(l.operatorCommand),d(null))}async function x(){if(!l?.serve.enabled){const k=await g();k?.serve.enabled&&k.remoteWebUrl&&await Ne(k.remoteWebUrl);return}await w()}return{status:l,busy:o,flashTailscaleUp:u,refresh:f,enableRemoteAccess:g,disableRemoteAccess:y,copyRemoteLink:w,copyTailscaleUpCommand:A,copyServeCommand:R,copyServeSetupUrl:S,copyOperatorCommand:C,createRemoteLink:x}}function Zl(s){const[n,a]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{a(await M.datasetStorageState(s.connection)),s.onError(null)}catch(d){s.onError(d instanceof Error?d.message:String(d))}finally{l(null)}}},[s.connection,s.onError]),o=r.useCallback(async d=>{if(!s.connection||!d)return!1;l("save");try{return a(await M.updateDatasetStorage(s.connection,d)),s.onError(null),!0}catch(u){return s.onError(u instanceof Error?u.message:String(u)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:n,busy:t,refresh:i,save:o}}function Xl(s){const{connection:n,enabled:a,onError:t,profileId:l}=s,[i,o]=r.useState(null),[d,u]=r.useState(!1),p=r.useCallback(async()=>{if(n){u(!0);try{o(await M.datasetCatalog(n,l)),t(null)}catch(c){t(ei(c))}finally{u(!1)}}},[n,t,l]);return r.useEffect(()=>{a&&p()},[a,p]),{catalog:i,loading:d,refresh:p}}function ei(s){return s instanceof Error?s.message:String(s)}const si=new Set(["harness","harness-refiner","harness-continuous-review","harness-contents","harness-releases"]);function ni(s){return s==="harness-refiner"?"refiner":s==="harness-continuous-review"?"continuous-review":s==="harness-contents"?"contents":s==="harness-releases"?"releases":"overview"}const ti=r.lazy(()=>Rn(()=>import("./UsageSettingsSection-CLjJKcpc.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Ci({payload:s,connection:n,diagnostics:a,onPayload:t,onError:l,onToast:i,onBack:o,onOpenSourceSession:d,onStartRefinerAuthoring:u,onAcceptEvaluationReview:p,onOpenSkill:c,onOpenExtension:f,teamChatCurrentUserId:h,teamChatEnabled:m,teamChatNotificationMode:g,teamChatThreads:y,onTeamChatNotificationModeChange:w,onTeamChatThreadMuteChange:R,diffPanelWidth:S,diffPanelResizing:A,diffPanelExpanded:C,onDiffPanelResizeStart:x,onDiffPanelExpandedChange:k,initialSection:D="account"}){const[E,v]=r.useState(D),[P,N]=r.useState(null),[j,z]=r.useState(!1),F=s?.codex??null,q=r.useMemo(()=>st(s?.preferences),[s?.preferences]),Y=s?.personalization??nt,Q=a??s?.diagnostics??[],T=tt()&&at(n?.platform),ee=r.useCallback(Z=>{s&&t({...s,providers:Z})},[t,s]),X=r.useCallback(Z=>{s&&t({...s,preferences:Z.preferences})},[t,s]),V=r.useCallback(Z=>{s&&t({...s,extensionCatalog:Z})},[t,s]),H=Bl({connection:n,onError:l,onPayload:t}),te=Yl({connection:n,onError:l,onPayload:t,onPreferences:X,onProviders:ee,preferences:q,providers:s?.providers??null}),W=Hl({connection:n,onError:l,onPayload:t,onPreferences:X,preferences:q,providers:s?.providers??null}),G=Kl({connection:n,enabled:E==="editor",onError:l,onPayload:t,onPreferences:X,onToast:i,preferences:q}),ne=Jl({connection:n,onError:l,onPayload:t,personalization:Y}),ae=Vl({onError:l,section:E}),le=Ql({connection:n,enabled:E==="remote",onError:l,onToast:i}),ie=E==="dataset-storage",b=Zl({connection:n,enabled:ie,onError:l}),$=Xl({connection:n,enabled:ie,onError:l,profileId:s?.profile.activeProfile??"default"}),_=b.save,he=r.useCallback(async()=>{await Promise.all([b.refresh(),$.refresh()])},[b.refresh,$.refresh]),ce=r.useCallback(()=>E!=="subagents"||!W.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[W.subagentsDirty,E]),O=r.useCallback(Z=>{Z!==E&&ce()&&(z(!1),k(!1),v(Z),lt({kind:"settings",section:Z}))},[ce,k,E]),I=r.useCallback(()=>{ce()&&(z(!1),k(!1),o())},[ce,o,k]);r.useEffect(()=>{v(D)},[D]),r.useEffect(()=>{if(E!=="subagents"||!W.subagentsDirty)return;const Z=Ie=>{Ie.preventDefault(),Ie.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",Z),()=>window.removeEventListener("beforeunload",Z)},[W.subagentsDirty,E]);const U={"--diff-panel-width":`${S}px`},B=si.has(E),se=B&&j&&P;return e.jsxs("div",{className:`settings-shell ${T?"platform-macos":""} ${se?"harness-diff-open":""} ${C?"harness-diff-expanded":""} ${A?"diff-panel-resizing":""}`,style:U,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[B?e.jsx("button",{type:"button",className:`topbar-diff-button ${se?"active":""}`,title:`${se?"Hide":"Show"} sidebar`,"aria-label":`${se?"Hide":"Show"} sidebar`,"aria-pressed":!!se,disabled:!P,onClick:()=>z(Z=>!Z),children:e.jsx(it,{size:16})}):null,e.jsx(rt,{platform:n?.platform})]}),e.jsx(sl,{section:E,onBack:I,onSectionChange:O}),e.jsxs("main",{className:`settings-content ${E==="profile"||B?"settings-content-wide":""}`,children:[E!=="configuration"?e.jsx(bs,{connection:n,bannerOnly:!0,onOpen:()=>O("configuration")}):null,E==="account"?e.jsx(Ot,{payload:s,connection:n,onPayload:t,onPreferences:X,onError:l,onToast:i,...H}):E==="notifications"?e.jsx(sa,{currentUserId:h,enabled:m,mode:g,threads:y,onModeChange:w,onThreadMuteChange:R}):B?e.jsx(zl,{connection:n,enabled:B,onAcceptEvaluationReview:p,onError:l,onDefaultReleaseDiff:N,onOpenSourceSession:d,onStartRefinerAuthoring:u,onOpenReleaseDiff:Z=>{N(Z),z(!0)},onToast:i,page:ni(E)}):E==="profile"?e.jsx(wa,{payload:s,connection:n,onPayload:t,onError:l,onToast:i,onOpenSession:d}):E==="skills"?e.jsx(tl,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:n,onExtensionCatalog:V,onError:l,onToast:i,onOpenSkill:c,onOpenExtension:f}):E==="providers"?e.jsx(Wa,{account:s?.account??null,codex:F,providers:s?.providers??null,...te}):E==="dataset-storage"?e.jsx(fl,{state:b.state,catalog:$.catalog,busy:b.busy,catalogLoading:$.loading,onRefresh:he,onSave:_}):E==="configuration"?e.jsxs("div",{className:"settings-stacked-sections configuration-page",children:[e.jsx(bs,{connection:n,onSaved:async()=>{n&&t(await M.bootstrap(n))}}),e.jsx(Ht,{preferences:q,...W}),e.jsx(As,{embedded:!0,preferences:q,...W})]}):E==="context"?e.jsx(As,{preferences:q,...W}):E==="training"?e.jsx(al,{connection:n,onError:l,onPreferences:X,preferences:q,providers:s?.providers??null}):E==="subagents"?e.jsx(Vt,{preferences:q,providers:s?.providers??null,...W}):E==="editor"?e.jsx(Wt,{preferences:q,...G}):E==="remote"?e.jsx(Ya,{...le}):E==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(ti,{account:s?.account??null,connection:n,enabled:E==="usage",onError:l,onOpenSourceSession:d})}):E==="personalization"?e.jsx(ta,{...ne}):e.jsx(_t,{diagnostics:Q,...ae})]}),B&&n&&se?e.jsx(Ul,{connection:n,expanded:C,onResizeStart:x,onToggleExpanded:()=>k(!C),selection:se}):null]})}export{Ci as SettingsView};