openpond 0.0.61 → 0.0.63

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 (108) hide show
  1. package/dist/chunks/{actions-command-QVYIPEN5.js → actions-command-DZ6D7JTO.js} +2 -2
  2. package/dist/chunks/{app-layer-GCNXR4F3.js → app-layer-TUAFALOE.js} +5 -5
  3. package/dist/chunks/{app-server-runtime-737DBOSH.js → app-server-runtime-O26LVUYH.js} +7 -7
  4. package/dist/chunks/{apps-JB3POF6Z.js → apps-KSZRA7Y2.js} +5 -5
  5. package/dist/chunks/{chunk-NPEWMLRH.js → chunk-66KQLYSH.js} +1 -1
  6. package/dist/chunks/{chunk-ZJPLJP2Q.js → chunk-6FKBOGA4.js} +2 -2
  7. package/dist/chunks/{chunk-6RMGHEFF.js → chunk-7IFPXSSJ.js} +1 -1
  8. package/dist/chunks/{chunk-5HMXXGWZ.js → chunk-7UVEB2AZ.js} +2 -2
  9. package/dist/chunks/{chunk-32R4GQD3.js → chunk-IXA5PMXC.js} +2 -2
  10. package/dist/chunks/{chunk-XIUCBUUQ.js → chunk-J2REM7LE.js} +1 -1
  11. package/dist/chunks/{chunk-XSHMPOQV.js → chunk-JGOP4GCK.js} +6 -0
  12. package/dist/chunks/{chunk-TOMMZN6V.js → chunk-JTFDOA2P.js} +41 -16
  13. package/dist/chunks/{chunk-IZ3XGRAG.js → chunk-K4JEWEJQ.js} +1 -1
  14. package/dist/chunks/{chunk-L5JTI6LQ.js → chunk-KGU437HZ.js} +4 -2
  15. package/dist/chunks/{chunk-ZAX7MLQJ.js → chunk-LEL5AQJU.js} +1 -1
  16. package/dist/chunks/{chunk-B3WVCPXG.js → chunk-PLDCQVNW.js} +71 -6
  17. package/dist/chunks/{chunk-YSVY4O42.js → chunk-T55IL3GI.js} +1 -1
  18. package/dist/chunks/{chunk-BQQS5RRI.js → chunk-V2CTXKS2.js} +156 -61
  19. package/dist/chunks/{chunk-LBIVEX6V.js → chunk-YDH34BGG.js} +35 -33
  20. package/dist/chunks/{cli-MFFCFH3P.js → cli-LPFU4ULD.js} +6 -6
  21. package/dist/chunks/{core-commands-KCFU7U5Y.js → core-commands-OEOBYFIW.js} +6 -6
  22. package/dist/chunks/{desktop-test-FEQVX4N4.js → desktop-test-BRLZF3O7.js} +5 -5
  23. package/dist/chunks/{extension-M4DH25KH.js → extension-5BUCIDKG.js} +1 -1
  24. package/dist/chunks/{help-ZUIE4EPY.js → help-MT6VPW4X.js} +1 -1
  25. package/dist/chunks/{opchat-7KRZIFFD.js → opchat-O4DVKNFW.js} +5 -5
  26. package/dist/chunks/{organizations-ZWPFNM6K.js → organizations-ACNOJ57Q.js} +7 -7
  27. package/dist/chunks/{profile-GF57OWI6.js → profile-7LLWXAJE.js} +12 -7
  28. package/dist/chunks/{project-agent-65MXZHGM.js → project-agent-RVYQYTU2.js} +27 -7
  29. package/dist/chunks/{sandbox-command-WH2OQRHP.js → sandbox-command-QST23BX5.js} +6 -6
  30. package/dist/chunks/{sandbox-template-W5HU24TF.js → sandbox-template-N7UG3P6V.js} +7 -7
  31. package/dist/chunks/{src-YUIJKNIC.js → src-CPM5Q7T5.js} +4 -4
  32. package/dist/chunks/{src-O5QXOQ5H.js → src-M37V6NVU.js} +60 -13
  33. package/dist/chunks/{teams-bot-5ATLXSHC.js → teams-bot-ITTI47XS.js} +5 -5
  34. package/dist/chunks/{workspaces-4XJ3GXL4.js → workspaces-CYBR37US.js} +2 -2
  35. package/dist/cli.js +13 -13
  36. package/dist/index.js +6 -0
  37. package/dist/sandbox/client-handles.d.ts +2 -1
  38. package/dist/sandbox/client.d.ts +3 -1
  39. package/dist/sandbox/types/org-project-agent.d.ts +13 -0
  40. package/dist/web/assets/{AppDialog-BvdkukM_.js → AppDialog-wIb8mGQ0.js} +1 -1
  41. package/dist/web/assets/{AppsView-9h3-BQbk.js → AppsView-D097dPIV.js} +1 -1
  42. package/dist/web/assets/{BrowserSidebar-C6WJ5wIu.js → BrowserSidebar-DrD-o_yB.js} +1 -1
  43. package/dist/web/assets/{CommandMenu-C7en9zgQ.js → CommandMenu-L5LelA2h.js} +1 -1
  44. package/dist/web/assets/{CommunityView-CoqI6Dks.js → CommunityView-DUJ8NryS.js} +1 -1
  45. package/dist/web/assets/{ComposerCreateImproveStrip-DMq6A2Ba.js → ComposerCreateImproveStrip-BP-7DmQG.js} +1 -1
  46. package/dist/web/assets/{GetStartedView-B-zgx1jI.js → GetStartedView-B7gB6Hii.js} +1 -1
  47. package/dist/web/assets/{LabModelVersionDetailPage-CkNOBygO.js → LabModelVersionDetailPage-CNDz2a6I.js} +1 -1
  48. package/dist/web/assets/{LabSkillSidebar-CmRHuu78.js → LabSkillSidebar-BImOQcjk.js} +1 -1
  49. package/dist/web/assets/{LabsRoute-DLPZqEev.js → LabsRoute-BauSK1is.js} +3 -3
  50. package/dist/web/assets/{MainChatThread-CFGsODmc.js → MainChatThread-BZvAqQO6.js} +2 -2
  51. package/dist/web/assets/MainPane-CuhwxMxg.js +6 -0
  52. package/dist/web/assets/{MarkdownText-C4Ixpl-i.js → MarkdownText-gwAue4u5.js} +1 -1
  53. package/dist/web/assets/{Messages-DmEk_BWS.js → Messages-DijmQL-z.js} +8 -8
  54. package/dist/web/assets/{NativeSkillSidebar-Cn824hrX.js → NativeSkillSidebar-aCkrdGa0.js} +1 -1
  55. package/dist/web/assets/{NewProjectDialog-BFEDv4Ga.js → NewProjectDialog-D98WIQzr.js} +1 -1
  56. package/dist/web/assets/{OutputsPage-hfQyqQzx.js → OutputsPage-BA0c6cfy.js} +1 -1
  57. package/dist/web/assets/{RightChatPanelStack-CiPKX3Ea.js → RightChatPanelStack-DKDEmrEH.js} +1 -1
  58. package/dist/web/assets/{ScheduledWorkPage-CyoZsUCe.js → ScheduledWorkPage-DeHi99mv.js} +1 -1
  59. package/dist/web/assets/SettingsView--fL3Ecuy.js +6 -0
  60. package/dist/web/assets/SettingsView-BS5m5vdt.css +1 -0
  61. package/dist/web/assets/TeamChatView-D2mCoLZ3.js +3 -0
  62. package/dist/web/assets/{TerminalOverlay-CpsPuPIM.js → TerminalOverlay-BHMsVp4L.js} +1 -1
  63. package/dist/web/assets/{TrainingCreationPanel-DMLpUVbJ.js → TrainingCreationPanel-CPnMWgkt.js} +1 -1
  64. package/dist/web/assets/{TrainingDraftPanel-gAhpwkYs.js → TrainingDraftPanel-0scEtzSW.js} +1 -1
  65. package/dist/web/assets/{UsageSettingsSection-WBtxLhBx.js → UsageSettingsSection-COoCLLg6.js} +1 -1
  66. package/dist/web/assets/{WorkspaceDiffPanel-CUpwqvzZ.js → WorkspaceDiffPanel-BFTwZ_dB.js} +5 -5
  67. package/dist/web/assets/{WorkspaceEnvironmentMenu-LIbOBT4f.js → WorkspaceEnvironmentMenu-DFlkdd9T.js} +3 -3
  68. package/dist/web/assets/{WorkspaceGitDialogs-8y7rRSou.js → WorkspaceGitDialogs-Dt3LO27Z.js} +1 -1
  69. package/dist/web/assets/{WorkspaceMonacoEditor-BpHmWrCD.js → WorkspaceMonacoEditor-3g05teoR.js} +3 -3
  70. package/dist/web/assets/{arrow-up-right-3TbyK1ec.js → arrow-up-right-DYGSWA2J.js} +1 -1
  71. package/dist/web/assets/{chevron-up-C4tTuxXs.js → chevron-up-4qfvI9iW.js} +1 -1
  72. package/dist/web/assets/{cloud-upload-ZGHLWEn3.js → cloud-upload-COReKxOy.js} +1 -1
  73. package/dist/web/assets/{cssMode-kfZCOm_r.js → cssMode-BbH67BYF.js} +1 -1
  74. package/dist/web/assets/{folder-open-C4WG_lDr.js → folder-open-9OjGqNgP.js} +1 -1
  75. package/dist/web/assets/{folder-plus-CKRaDeR3.js → folder-plus-DF5E6zr3.js} +1 -1
  76. package/dist/web/assets/{git-branch-yLi5tff8.js → git-branch-eCwyZXMl.js} +1 -1
  77. package/dist/web/assets/{git-commit-horizontal-BPyGYak3.js → git-commit-horizontal-cPm51DqY.js} +1 -1
  78. package/dist/web/assets/{htmlMode-DT--Et9k.js → htmlMode-DD6Oge4x.js} +1 -1
  79. package/dist/web/assets/{index--lwjVZXT.js → index-BO2W2U23.js} +66 -66
  80. package/dist/web/assets/index-BRLugX1S.js +1 -0
  81. package/dist/web/assets/{index-B_HvNtwl.css → index-Y7IoiSlQ.css} +1 -1
  82. package/dist/web/assets/{info-CzzHwSUb.js → info-p1mFpqBI.js} +1 -1
  83. package/dist/web/assets/{jsonMode-CKg1GzqC.js → jsonMode-C2Xd56A_.js} +1 -1
  84. package/dist/web/assets/{lspLanguageFeatures-B76Yo6xo.js → lspLanguageFeatures-BjYEk4gJ.js} +1 -1
  85. package/dist/web/assets/{monaco.contribution-BRuQU-2A.js → monaco.contribution-Bo-5m7yy.js} +2 -2
  86. package/dist/web/assets/{monaco.contribution-CLpGfCSS.js → monaco.contribution-C7WMqwmc.js} +2 -2
  87. package/dist/web/assets/{monaco.contribution-CS3H8RrD.js → monaco.contribution-DzWlEgU1.js} +2 -2
  88. package/dist/web/assets/{monaco.contribution-DqeexNAI.js → monaco.contribution-quEPEMQZ.js} +2 -2
  89. package/dist/web/assets/{play-EDFh3BPS.js → play-Ctx-iMqd.js} +1 -1
  90. package/dist/web/assets/{python-De_Vr_hD.js → python-Cm64qCpk.js} +1 -1
  91. package/dist/web/assets/{refresh-cw-DRJJ-X1U.js → refresh-cw-Bn28jIl0.js} +1 -1
  92. package/dist/web/assets/{save-BSxqIWP6.js → save-BM5IQX65.js} +1 -1
  93. package/dist/web/assets/{square-BV-Vgh5a.js → square-DAGpFfSr.js} +1 -1
  94. package/dist/web/assets/{toggleHighContrast-1Suz4cxo.js → toggleHighContrast-DLW8Fnck.js} +1 -1
  95. package/dist/web/assets/{tsMode-DMyzpvFI.js → tsMode-BleUN_8S.js} +1 -1
  96. package/dist/web/assets/{upload-jVxCW0dO.js → upload-vaAKFfxi.js} +1 -1
  97. package/dist/web/assets/{useLocalAgentSchedules-DNpnOBA8.js → useLocalAgentSchedules-Ccenbqf6.js} +1 -1
  98. package/dist/web/assets/{wifi-off-IzGGiOX_.js → wifi-off-DJA9KReb.js} +1 -1
  99. package/dist/web/assets/{workers-Crdnk6Zy.js → workers-CFG-afha.js} +1 -1
  100. package/dist/web/assets/{yaml-CF3tmjgW.js → yaml-Cs8iZKVC.js} +1 -1
  101. package/dist/web/index.html +2 -2
  102. package/docs/command-reference.md +2 -0
  103. package/package.json +1 -1
  104. package/dist/web/assets/MainPane-B2kcZpM0.js +0 -6
  105. package/dist/web/assets/SettingsView-BZkrIOc0.css +0 -1
  106. package/dist/web/assets/SettingsView-DWWs9gel.js +0 -6
  107. package/dist/web/assets/TeamChatView-C4RWAO8c.js +0 -3
  108. package/dist/web/assets/index-C9-OtZl8.js +0 -1
@@ -1,6 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./UsageSettingsSection-WBtxLhBx.js","./index--lwjVZXT.js","./index-B_HvNtwl.css","./arrow-up-right-3TbyK1ec.js","./index-C9-OtZl8.js","./UsageSettingsSection-O8VK0qBL.css"])))=>i.map(i=>d[i]);
2
- import{c as ge,j as e,r,ay as ls,X as le,az as la,aA as ia,aB as ra,aC as oa,aD as ca,aE as da,P as me,aF as ua,aG as ha,p as I,aH as ma,aI as Ye,aJ as Is,aK as pa,aL as ga,aM as fa,L as Ms,u as Le,aN as xa,v as ja,M as Ee,d as Os,aO as Qe,aP as _e,ah as va,C as ba,aQ as ya,aR as ke,G as Ze,a1 as Na,i as $e,aS as ae,aT as wa,aU as Xe,aV as es,a4 as Ts,A as Sa,a2 as Ca,a3 as ka,B as Pa,as as Ra,a as Ls,aW as Aa,aX as Da,q as Ea,J as ss,a8 as He,aY as je,ak as $a,aZ as Ia,a_ as Ma,a$ as Oa,$ as Ta,b0 as La,_ as za}from"./index--lwjVZXT.js";import{R as te}from"./refresh-cw-DRJJ-X1U.js";import{D as Se,T as ve,P as zs,B as ze,W as Fe,C as Ua}from"./MarkdownText-C4Ixpl-i.js";/* empty css */import{S as is}from"./save-BSxqIWP6.js";import{F as Us}from"./folder-open-C4WG_lDr.js";import{C as Ba}from"./chevron-up-C4tTuxXs.js";import{P as Bs}from"./play-EDFh3BPS.js";import{B as _a,a as _s,W as Ha,S as Fa}from"./wifi-off-IzGGiOX_.js";import{R as Ie,u as Ga}from"./useLocalAgentSchedules-DNpnOBA8.js";import{C as pe}from"./cloud-upload-ZGHLWEn3.js";import{G as Me}from"./git-commit-horizontal-BPyGYak3.js";import{r as qa}from"./index-C9-OtZl8.js";import{F as Wa}from"./folder-plus-CKRaDeR3.js";import{WorkspaceDiffPanel as Va}from"./WorkspaceDiffPanel-CUpwqvzZ.js";import"./training-model-data-V8276E5q.js";import"./info-CzzHwSUb.js";const Ka=[["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"}]],Ja=ge("clipboard-copy",Ka);const Ya=[["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"}]],Qa=ge("hard-drive",Ya);const Za=[["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"}]],ue=ge("key-round",Za);const Xa=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],et=ge("power",Xa);const st=[["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"}]],Hs=ge("radio-tower",st);const at=[["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"}]],tt=ge("rotate-cw",at);const nt=[["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"}]],Fs=ge("sliders-horizontal",nt);const lt=[["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"}]],it=ge("circle-user",lt);function ds({handle:s,image:a}){const n=s?.trim().slice(0,1).toUpperCase()||"+";return e.jsx("div",{className:"account-avatar",children:a?e.jsx("img",{src:a,alt:""}):e.jsx("span",{children:n})})}function Ge({state:s,label:a}){return e.jsx("span",{className:`account-state ${s}`,children:a??s.replace("_"," ")})}const as="https://openpond.ai",ts="https://api.openpond.ai";function rt(s,a){return s==="connect"?{handle:void 0,currentBaseUrl:null}:{handle:a?.handle,currentBaseUrl:a?.baseUrl??null}}function us(s,a){const n=a.trim().replace(/\/+$/,"");if(!n)throw new Error(`${s} is required.`);try{const t=new URL(n);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("unsupported protocol")}catch{throw new Error(`${s} must be an absolute http or https URL.`)}return n}function hs({account:s,busy:a,initialApiKey:n="",mode:t="update",onClose:l,onSave:i}){const d=r.useId(),c=t==="connect",[o,f]=r.useState(n),[x,h]=r.useState(!1),[u,m]=r.useState(s?.baseUrl??as),[j,b]=r.useState(s?.apiBaseUrl??ts),[S,C]=r.useState(null),[k,P]=r.useState(null);ls(k),r.useEffect(()=>{f(n),h(!1),m(s?.baseUrl??as),b(s?.apiBaseUrl??ts),C(null),P(null)},[s?.apiBaseUrl,s?.baseUrl,s?.handle,n]);async function D(g){g.preventDefault(),C(null),P(null);const E=o.trim();if(c&&!E){C("API key is required.");return}let R,z;try{R=us("Base URL",u),z=us("API base URL",j)}catch(p){C(p instanceof Error?p.message:String(p));return}try{const p=rt(t,s);await i({...p,baseUrl:R,apiBaseUrl:z,apiKey:c?E:void 0,environment:c?ot(R,z):s?.environment??null})}catch(p){P(p instanceof Error?p.message:String(p))}}return e.jsx("div",{className:"git-dialog-backdrop account-endpoint-dialog-backdrop",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&!a&&l()},children:e.jsxs("form",{className:"git-dialog account-endpoint-dialog",role:"dialog","aria-modal":"true","aria-labelledby":d,onSubmit:g=>{D(g)},children:[e.jsx("button",{className:"git-dialog-close",disabled:a,type:"button",title:"Close","aria-label":"Close",onClick:l,children:e.jsx(le,{size:16})}),e.jsx("div",{className:"git-dialog-icon",children:c?e.jsx(ue,{size:18}):e.jsx(Fs,{size:18})}),e.jsx("h2",{id:d,children:c?"Add account":"Account endpoints"}),c?e.jsx("p",{children:"Enter your OpenPond API key to connect another account."}):null,c?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API key"}),e.jsx("input",{autoFocus:!0,disabled:a,placeholder:"opk_...",type:"password",value:o,onChange:g=>f(g.target.value)})]}):null,c?e.jsxs("label",{className:"git-dialog-toggle account-dialog-advanced-toggle",children:[e.jsx("input",{checked:x,disabled:a,type:"checkbox",onChange:g=>h(g.target.checked)}),e.jsx("span",{}),"Advanced"]}):null,!c||x?e.jsxs("div",{className:"account-dialog-advanced-fields",children:[e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{autoFocus:!c,disabled:a,inputMode:"url",value:u,onChange:g=>m(g.target.value)})]}),e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"API base URL"}),e.jsx("input",{disabled:a,inputMode:"url",value:j,onChange:g=>b(g.target.value)})]})]}):null,S?e.jsx("div",{className:"profile-dialog-warning",children:S}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:a,type:"button",onClick:l,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:a,type:"submit",children:[e.jsx(is,{size:14}),e.jsx("span",{children:a?"Saving":c?"Connect account":"Update account"})]})]})]})})}function ot(s,a){return s===as&&a===ts?"production":"custom"}const ct="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 dt({payload:s,connection:a,saving:n,refreshingAccounts:t,saveAccount:l,refreshAccounts:i,switchAccount:d,removeAccount:c,onPayload:o,onPreferences:f,onError:x,onToast:h}){const u=s?.account,m=u?.state??"loading",j=m==="signed_in",b=m==="signed_out",S=m==="auth_error",C=u?.email?.trim()||null,k=u?.accounts??[],[P,D]=r.useState([]),[,g]=r.useState(!1),[E,R]=r.useState(null),[z,p]=r.useState(null),[N,y]=r.useState(null),[v,M]=r.useState(null),[T,q]=r.useState(!1),[V,A]=r.useState(null),{confirmAction:w,confirmDialog:O,resolveConfirmDialog:Q}=la(),J=k.find($=>$.isActive)??k[0]??null,W=s?.preferences.defaultTeamId?.trim()||null,Z=N??W,K=ia(u),U=s?.accountMeta.asOf??"",se=Ne(u?.environment,J?.environment),ie=j?Ne(J?.displayLabel,J?.handle,u?.label,u?.activeProfile?.handle,"Signed in"):S?"Account needs attention":b?"No account connected":"Loading account",ce=j?C??ms(se):S?"Not connected":b?"Cloud projects, hosted agents, and team defaults are disabled until you sign in.":"Checking account status.",re=k.length>0,ne=S?ut(u?.error):null,ee=r.useMemo(()=>P.filter($=>$.status==="active"),[P]),L=(r.useMemo(()=>Z?ee.find($=>$.teamId===Z)??null:null,[ee,Z])??ra(ee))?.teamId??"",_=r.useMemo(()=>ee.map($=>({value:$.teamId,label:Ne($.displayName,$.name,$.slug,"Team"),description:oa($.role)})),[ee]),F=L||_[0]?.value||"",B=_.length>0,H=!a||!!z||!!E||ee.length===0,ye=v?qe(v):null,cs=!!(ye&&V===ye),Zs=j||S;r.useEffect(()=>{if(!a||!K){D([]),R(null),g(!1);return}let $=!1;const Y=ca(K);return Y?(D(Y),g(!1)):(D([]),g(!0)),R(null),da({accountKey:K,force:!!U,fetchOrganizations:async()=>(await I.organizations(a)).organizations.map(ma).filter(X=>!!X).filter(X=>X.status==="active")}).then(G=>{$||D(G)}).catch(G=>{$||(Y||D([]),R(G instanceof Error?G.message:String(G)))}).finally(()=>{$||g(!1)}),()=>{$=!0}},[U,a,K]),r.useEffect(()=>{N&&W===N&&y(null)},[W,N]);async function Xs($,Y={notify:!0}){const G=ee.find(X=>X.teamId===$)??null;if(!(!a||!G||z||(N??W)===G.teamId)){y(G.teamId),p(G.teamId),x(null),ha({teamId:G.teamId,accountKey:K,force:!0,fetchAgents:async X=>(await I.listSandboxAgents(a,{teamId:X})).agents}).catch(()=>{});try{f(await I.savePreferences(a,{defaultTeamId:G.teamId})),Y.notify&&h?.("Default team updated","success")}catch(X){y(null),x(X instanceof Error?X.message:String(X))}finally{p(null)}}}async function Ue($="Continue"){return Zs?w({title:"Change active OpenPond account?",body:ct,confirmLabel:$,cancelLabel:"Cancel"}):!0}async function ea($){await Ue("Save account")&&(await l({apiKey:$.apiKey??"",handle:$.handle,baseUrl:$.baseUrl,apiBaseUrl:$.apiBaseUrl,environment:$.environment}),q(!1))}async function sa($){if(!a||!v)throw new Error("OpenPond server connection is not ready.");if(v.isActive&&!await Ue("Save endpoints"))return;const Y=qe(v);A(Y),x(null);try{const G=await I.updateOpenPondAccountConfig(a,{handle:$.handle??v.handle,currentBaseUrl:$.currentBaseUrl,baseUrl:$.baseUrl,apiBaseUrl:$.apiBaseUrl,chatApiBaseUrl:null,environment:ht($.environment),setActive:v.isActive});o(G),h?.("Account endpoints updated","success"),M(null)}catch(G){throw x(G instanceof Error?G.message:String(G)),G}finally{A(null)}}async function aa($){const Y=$.handle?.trim()||"";Y&&await Ue("Switch account")&&await d(Y,$.baseUrl)}async function ta($){const Y=$.handle?.trim()||"";if(!Y||$.isActive)return;const G=Ne($.displayLabel,$.email,$.handle,"this account");await w({title:"Remove saved account?",body:`Remove ${G} from this device? Its saved credential and endpoint settings will be deleted. This does not delete any OpenPond cloud data.`,confirmLabel:"Remove account",cancelLabel:"Cancel",tone:"danger"})&&await c(Y,$.baseUrl)&&h?.("Account removed","success")}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:!a||n,type:"button",onClick:()=>q(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add account"})]}),e.jsx("button",{className:"settings-icon-button ghost",disabled:!a||n||t,title:"Refresh accounts and team data","aria-label":"Refresh accounts and team data",type:"button",onClick:()=>{i()},children:e.jsx(te,{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(ds,{handle:ie,image:j?u?.avatarUrl??J?.avatarUrl??null:null}),e.jsxs("div",{children:[e.jsx("span",{children:"Active account"}),e.jsx("strong",{children:ie}),e.jsxs("div",{className:"account-summary-meta",children:[e.jsx("small",{className:j&&C?"private-account-email":j?void 0:"account-summary-copy",tabIndex:j&&C?0:void 0,children:ce}),j&&B?e.jsx(Se,{className:"account-team-dropdown",compact:!0,disabled:H,label:"Default team",options:_,value:F,onChange:$=>{Xs($)}}):null]})]})]}),e.jsx("div",{className:"account-summary-actions",children:e.jsx(Ge,{state:m,label:b?"not signed in":void 0})})]}),re?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:[k.length," account",k.length===1?"":"s"]})]}),e.jsx("p",{className:"account-list-note",children:"Switch to another account before removing the active account."}),k.map($=>{const Y=$.handle?.trim()||"",G=Ne($.displayLabel,$.handle,"Unknown account"),X=$.email?.trim()||null,Be=mt($.environment),na=qe($);return e.jsxs("div",{className:"account-row",children:[e.jsx(ds,{handle:G,image:$.avatarUrl??null}),e.jsxs("div",{className:"account-details",children:[e.jsx("strong",{children:G}),X?e.jsx("span",{className:"private-account-email",tabIndex:0,children:X}):null,e.jsx("span",{children:ms($.environment??"production")})]}),e.jsxs("div",{className:"account-row-actions",children:[e.jsx(Ge,{state:$.authHealth}),$.isActive?e.jsx("span",{className:"active-pill",children:"Active"}):null,e.jsx("button",{className:`account-env-toggle ${Be?"active":""}`,disabled:!a||n||!!V||!Y,type:"button","aria-label":`Configure ${G} environment endpoints`,"aria-pressed":Be,title:"Configure environment endpoints",onClick:()=>M($),children:e.jsx("span",{className:"account-env-toggle-switch","aria-hidden":"true"})}),$.isActive?null:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"inline-action",disabled:n||!Y,type:"button",onClick:()=>{aa($)},children:"Use"}),e.jsx("button",{className:"inline-action danger account-remove-action",disabled:n||!Y,type:"button","aria-label":`Remove ${G}`,title:`Remove ${G}`,onClick:()=>{ta($)},children:e.jsx(ve,{size:13})})]})]})]},na)})]}):null,u?.products&&u.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:[u.products.length," active"]})]}),u.products.map($=>e.jsxs("div",{className:"product-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:$.name}),e.jsx("span",{children:$.type})]}),e.jsx(Ge,{state:$.status})]},$.id))]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:s?.server.runtimeVersion??"Runtime loading"}),e.jsx("strong",{children:a?.serverUrl??"loading"})]}),ne?e.jsxs("div",{className:"settings-footnote warning account-error-footnote",children:[e.jsx("span",{children:"Account error"}),e.jsx("strong",{children:ne})]}):null,v?e.jsx(hs,{account:v,busy:cs,onClose:()=>{cs||M(null)},onSave:sa}):null,T?e.jsx(hs,{busy:n,mode:"connect",onClose:()=>{n||q(!1)},onSave:ea}):null,e.jsx(ua,{state:O,onResolve:Q})]})}function qe(s){return`${s.handle.trim().toLowerCase()}|${s.baseUrl??"default"}`}function Ne(...s){for(const a of s){const n=a?.trim();if(n)return n}return""}function ut(s){const a=s?.trim();if(!a)return null;const n=a.toLowerCase();return n.includes("protected deployment")||n.includes("vercel_auth_enabled")?"Staging is protected by Vercel. Restart OpenPond after signing in to Vercel, then try again.":n.includes("unexpected token '<'")||n.includes("<!doctype")||n.includes("vercel.com/sso-api")?"OpenPond received a web login page instead of account data. Restart after signing in to Vercel, then try again.":n.includes("401")||n.includes("unauthorized")||n.includes("could not authenticate")?"The API key could not authenticate. Check the key and account environment, then try again.":a.length>220?`${a.slice(0,217)}...`:a}function ms(s){const a=s.trim().toLowerCase();return!a||a==="production"?"Production":"Environment"}function ht(s){const a=s?.trim();return!a||a.toLowerCase()==="production"?"custom":a}function mt(s){const a=s?.trim().toLowerCase();return!!(a&&a!=="production")}function pt({advancedWorkspaceControls:s,defaultBranchPrefix:a,defaultNewProjectDirectory:n,preferences:t,saving:l,chooseDefaultProjectDirectory:i,saveDefaults:d,setAdvancedWorkspaceControls:c,setDefaultBranchPrefix:o,setDefaultNewProjectDirectory:f}){const x=Ye(a)===t.defaultBranchPrefix&&n.trim()===t.defaultNewProjectDirectory&&s===t.advancedWorkspaceControls;return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Defaults"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:h=>{d(h)},children:[e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s,disabled:l,onChange:h=>c(h.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:a,disabled:l,placeholder:"feat/",onChange:h=>o(h.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:n,disabled:l,placeholder:"~/Documents/OpenPond Projects",onChange:h=>f(h.target.value)})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:l,onClick:()=>{i()},children:[e.jsx(Us,{size:14}),e.jsx("span",{children:"Browse"})]})]}),e.jsx("button",{className:"settings-primary",disabled:l||x,children:e.jsx("span",{children:l?"Saving":"Save defaults"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Initial branch name"}),e.jsxs("strong",{children:[Ye(a),"example-project"]})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"New projects"}),e.jsx("strong",{children:n||t.defaultNewProjectDirectory})]})]})}function gt({diagnostics:s,diagnosticsAvailable:a,diagnosticsBusy:n,diagnosticsStatus:t,logDir:l,logLineLimit:i,logLines:d,logViewBusy:c,logViewSummary:o,logViewportRef:f,tailLogs:x,copyRecentLogs:h,exportDiagnosticsBundle:u,loadOlderLogs:m,openLogsFolder:j,refreshLogView:b,toggleTailLogs:S}){const C=s.filter(P=>P.name==="diagnostic"&&P.status==="failed").slice().reverse().map(ft),k=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:[C.length," saved"]})]}),e.jsx("div",{className:"diagnostics-error-list",role:"list",children:C.length===0?e.jsx("div",{className:"diagnostics-error-empty",children:"No saved errors"}):C.map(P=>e.jsxs("article",{className:"diagnostics-error-entry",role:"listitem",children:[e.jsx(Is,{size:15}),e.jsxs("div",{className:"diagnostics-error-body",children:[e.jsxs("div",{className:"diagnostics-error-title",children:[e.jsx("strong",{children:P.message}),e.jsx("time",{dateTime:P.timestamp,children:P.timeLabel})]}),e.jsxs("div",{className:"diagnostics-error-meta",children:[e.jsx("span",{children:P.surface}),P.status?e.jsx("span",{children:P.status}):null,P.sequence?e.jsxs("span",{children:["#",P.sequence]}):null]}),P.detail?e.jsxs("details",{className:"diagnostics-error-detail",children:[e.jsx("summary",{children:"Details"}),e.jsx("pre",{children:P.detail})]}):null]})]},P.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:a?"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:n!==null||!k?.openLogsFolder,onClick:()=>{j()},children:[e.jsx(Us,{size:15}),e.jsx("span",{children:n==="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:n!==null||!k?.exportDiagnostics,onClick:()=>{u()},children:[e.jsx(pa,{size:15}),e.jsx("span",{children:n==="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:n!==null||!k?.copyRecentLogs,onClick:()=>{h()},children:[e.jsx(Ja,{size:15}),e.jsx("span",{children:n==="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:o}),e.jsx("button",{type:"button",className:`settings-icon-button ${x?"active":""}`,title:x?"Pause tail":"Tail logs","aria-label":x?"Pause tail":"Tail logs",disabled:!k?.readRecentLogs,onClick:S,children:x?e.jsx(zs,{size:15}):e.jsx(Bs,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh logs","aria-label":"Refresh logs",disabled:c!==null||!k?.readRecentLogs,onClick:()=>{b(i,"refresh")},children:e.jsx(te,{size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:c!==null||!k?.readRecentLogs,onClick:m,children:[e.jsx(Ba,{size:15}),e.jsx("span",{children:c==="older"?"Loading":"Older"})]})]})]}),e.jsx("div",{ref:f,className:"diagnostics-log-viewer",role:"log","aria-live":x?"polite":"off",children:d.length===0?e.jsx("div",{className:"diagnostics-log-empty",children:c?"Loading logs":"No log lines"}):d.map((P,D)=>e.jsxs("div",{className:"diagnostics-log-entry",children:[e.jsx("span",{className:"diagnostics-log-source",children:P.file}),e.jsx("code",{children:P.line})]},`${P.file}:${P.timestamp}:${P.index}:${D}`))}),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 a=ps(s.data),n=ps(a.context),l=he(a.stack)??he(a.detail)??he(n.detail)??null;return{id:s.id,timestamp:s.timestamp,timeLabel:jt(s.timestamp),message:xt(s,a),surface:he(a.surface)??s.source??"diagnostic",status:s.status??null,sequence:s.sequence??null,detail:l}}function xt(s,a){return he(s.error)??he(s.output)??he(a.message)??he(a.error)??"Diagnostic event"}function jt(s){const a=new Date(s);return Number.isNaN(a.getTime())?s:a.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function ps(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function he(s){return typeof s=="string"&&s.trim()?s.trim():null}const gs=[{id:"typescript",label:"TypeScript",placeholder:"typescript-language-server"},{id:"python",label:"Python",placeholder:"pyright-langserver"},{id:"rust",label:"Rust",placeholder:"rust-analyzer"}];function vt({editorPreferences:s,lspStatus:a,preferences:n,restarting:t,saving:l,statusLoading:i,refreshLspStatus:d,restartLanguageServers:c,saveEditorSettings:o,setEditorPreferences:f,setLanguageCustomCommand:x,setLanguageMode:h}){const u=JSON.stringify(s)!==JSON.stringify(n.editor),m=new Map(a?.languages.map(j=>[j.language,j])??[]);return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Editor"}),e.jsxs("form",{className:"provider-settings-form editor-settings-form",onSubmit:j=>{o(j)},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(Se,{value:s.languageServers,disabled:l,label:"Language servers",options:ga,onChange:j=>f(b=>({...b,languageServers:j}))})]})}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:s.diagnosticsWhileEditing,disabled:l||s.languageServers==="off",onChange:j=>f(b=>({...b,diagnosticsWhileEditing:j.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:j=>f(b=>({...b,checkOnSave:j.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:gs.map(j=>{const b=s.languages[j.id];return e.jsxs("div",{className:"lsp-language-row",children:[e.jsxs("div",{className:"lsp-language-label",children:[e.jsx("strong",{children:j.label}),e.jsx("span",{children:fs(m.get(j.id),i)})]}),e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Mode"}),e.jsx(Se,{value:b.mode,disabled:l||s.languageServers==="off",label:`${j.label} language server mode`,options:fa,onChange:S=>h(j.id,S)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Custom executable"}),e.jsx("input",{value:b.customCommand,disabled:l||s.languageServers==="off"||b.mode!=="custom",placeholder:j.placeholder,onChange:S=>x(j.id,S.target.value)})]})]},j.id)})}),e.jsx("button",{className:"settings-primary",disabled:l||!u,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":a?"Current":"Not checked"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Refresh LSP status","aria-label":"Refresh LSP status",disabled:i||t,onClick:()=>{d()},children:e.jsx(te,{className:i?"settings-spin":void 0,size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:i||t,onClick:()=>{c()},children:[e.jsx(tt,{className:t?"settings-spin":void 0,size:15}),e.jsx("span",{children:t?"Restarting":"Restart"})]})]})]}),gs.map(j=>{const b=m.get(j.id);return e.jsxs("div",{className:"product-row lsp-status-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:j.label}),e.jsx("span",{title:b?.command??b?.message??void 0,children:b?.command??b?.message??"Not checked"})]}),e.jsx("span",{className:`lsp-status-pill ${b?.status??"missing"}`,children:fs(b,i)})]},j.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 fs(s,a){return a&&!s?"Checking":s?s.status==="found"?"Found":s.status==="disabled"?"Disabled":s.status==="error"?"Error":"Missing":"Not checked"}function bt({contextCompactionAutoEnabled:s,preferences:a,saving:n,saveDefaults:t,setContextCompactionAutoEnabled:l}){return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Context"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:i=>{t(i)},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:n,onChange:i=>l(i.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:n||s===a.contextCompaction.autoEnabled,children:e.jsx("span",{children:n?"Saving":"Save context"})})]})]})}function yt({subagentsEnabled:s,subagentDelegationMode:a,subagentsUseDefaultModel:n,subagentsProvider:t,subagentsModel:l,subagentRoles:i,subagentsMaxConcurrentRuns:d,subagentsMaxConcurrentRunsPerProvider:c,subagentsMaxConcurrentRunsPerWorkspaceTarget:o,preferences:f,providers:x,saving:h,saveDefaults:u,changeSubagentsProvider:m,setSubagentsEnabled:j,setSubagentDelegationMode:b,setSubagentsUseDefaultModel:S,setSubagentsModel:C,setSubagentsMaxConcurrentRuns:k,setSubagentsMaxConcurrentRunsPerProvider:P,setSubagentsMaxConcurrentRunsPerWorkspaceTarget:D,setSubagentRoleEnabled:g,setSubagentRoleIsolationMode:E,setSubagentRoleMaxConcurrentRuns:R,setSubagentRoleModel:z,setSubagentRolePeerMessages:p,setSubagentRoleToolPolicy:N,changeSubagentRoleProvider:y}){const v=Ms(x,{enabledOnly:!0}),M=n?f.defaultChatProvider:t,T=n?f.defaultChatModel:l,q=Gs(Le(M,x),T),V=n?null:{providerId:t,modelId:l.trim()},A=kt({enabled:s,delegationMode:a,defaultModelRef:V,roles:i,maxConcurrentRuns:d,maxConcurrentRunsPerProvider:c,maxConcurrentRunsPerWorkspaceTarget:o},f);return e.jsx("section",{className:"account-settings subagents-settings",children:e.jsxs("form",{className:"subagent-settings-form",onSubmit:w=>{u(w)},children:[e.jsxs("div",{className:"subagent-settings-title-row",children:[e.jsx("h1",{children:"Subagents"}),e.jsxs("div",{className:"subagent-settings-actions",children:[e.jsx("button",{className:`settings-primary subagent-save-button${A?"":" dirty"}`,disabled:h||A,children:e.jsx("span",{children:h?"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:h,onChange:w=>j(w.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:a,disabled:h||!s,onChange:w=>b(w.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:M,disabled:h||!s,onChange:w=>{S(!1),m(w.target.value)},children:v.map(w=>e.jsx("option",{value:w.value,children:w.label},w.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Model"}),e.jsx("select",{value:T,disabled:h||!s,onChange:w=>{S(!1),C(w.target.value)},children:q.map(w=>e.jsx("option",{value:w.value,children:w.label},w.value))})]})]})]}),e.jsx("div",{className:"subagent-role-list",children:i.map(w=>{const O=xa.find(U=>U.id===w.id),Q=w.modelRef?.providerId??M,J=w.modelRef?.modelId||ja(Q,x)||T,W=Ct(v,x,{providerId:Q,modelId:J}),Z=Ae(Q,J),K=h||!s||!w.enabled;return e.jsxs("section",{className:`subagent-role-row${w.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:O?.label??w.id}),e.jsx("small",{children:O?.description??"Custom subagent role."})]}),e.jsxs("label",{className:"provider-toggle subagent-card-toggle","aria-label":`${O?.label??w.id} enabled`,children:[e.jsx("input",{type:"checkbox",checked:w.enabled,disabled:h||!s,onChange:U=>g(w.id,U.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:Z,disabled:K,onChange:U=>{const se=W.find(ie=>ie.value===U.target.value);se&&(y(w.id,se.providerId),z(w.id,se.modelId))},children:W.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Isolation"}),e.jsx("select",{value:w.isolationMode,disabled:K,onChange:U=>E(w.id,U.target.value),children:Nt.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Tools"}),e.jsx("select",{value:w.toolPolicy,disabled:K,onChange:U=>N(w.id,U.target.value),children:wt.map(U=>e.jsx("option",{value:U.value,children:U.label},U.value))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Peer messages"}),e.jsx("select",{value:w.peerMessages,disabled:K,onChange:U=>p(w.id,U.target.value),children:St.map(U=>e.jsx("option",{value:U.value,children:U.label},U.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:w.maxConcurrentRuns,disabled:K,onChange:U=>R(w.id,xs(U.target.value,1))})]})})]},w.id)})}),e.jsxs("section",{className:"subagent-settings-section",children:[e.jsx("div",{className:"subagent-settings-card-header",children:e.jsxs("div",{children:[e.jsx("span",{children:"Limits"}),e.jsx("small",{children:"Controls child worker concurrency."})]})}),e.jsxs("div",{className:"subagent-field-grid four",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Total concurrency"}),e.jsx("input",{type:"number",min:1,max:32,value:d,disabled:h||!s,onChange:w=>k(xs(w.target.value,1))})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Per provider"}),e.jsx("input",{type:"number",min:1,max:32,value:c??"",placeholder:"No cap",disabled:h||!s,onChange:w=>P(ns(w.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:o??"",placeholder:"No cap",disabled:h||!s,onChange:w=>D(ns(w.target.value))})]})]})]})]})})}const Nt=[{value:"none",label:"Direct workspace"},{value:"copy_on_write",label:"Copy-on-write"},{value:"worktree",label:"Worktree"}],wt=[{value:"read_only",label:"Read only"},{value:"workspace_write",label:"Workspace write"},{value:"full_tools",label:"Full tools"}],St=[{value:"parent_scoped",label:"Parent-scoped handoffs"},{value:"disabled",label:"Disabled"}];function Gs(s,a){const n=a.trim();return!n||s.some(t=>t.value===n)?s:[{value:n,label:n},...s]}function Ae(s,a){return JSON.stringify([s,a])}function Ct(s,a,n){const t=[];for(const l of s){const i=Gs(Le(l.value,a),l.value===n.providerId?n.modelId:"");for(const d of i)t.push({value:Ae(l.value,d.value),label:`${l.label} / ${d.label}`,providerId:l.value,modelId:d.value})}return n.modelId&&!t.some(l=>l.value===Ae(n.providerId,n.modelId))&&t.unshift({value:Ae(n.providerId,n.modelId),label:`${Ee(n.providerId,a)} / ${n.modelId}`,providerId:n.providerId,modelId:n.modelId}),t}function ns(s){const a=s.trim();if(!a)return null;const n=Number(a);return Number.isFinite(n)?n:null}function xs(s,a){return ns(s)??a}function kt(s,a){const n=a.subagents;return s.enabled===n.enabled&&s.delegationMode===n.delegationMode&&Pt(s.defaultModelRef,n.defaultModelRef)&&s.maxConcurrentRuns===n.maxConcurrentRuns&&s.maxConcurrentRunsPerProvider===n.maxConcurrentRunsPerProvider&&s.maxConcurrentRunsPerWorkspaceTarget===n.maxConcurrentRunsPerWorkspaceTarget&&JSON.stringify(s.roles)===JSON.stringify(n.roles)}function Pt(s,a){return(s?.providerId??null)===(a?.providerId??null)&&(s?.modelId??null)===(a?.modelId??null)}const Rt=[{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 At({currentUserId:s,enabled:a,mode:n,threads:t,onModeChange:l,onThreadMuteChange:i}){const[d,c]=r.useState(null),[o,f]=r.useState(null);ls(o);const x=r.useMemo(()=>t.filter(m=>m.archivedAt===null).map(m=>({thread:m,label:Dt(m,s)})).sort((m,j)=>{const b=+!!j.thread.mutedAt-+!!m.thread.mutedAt;return b!==0?b:m.label.localeCompare(j.label)}),[s,t]),h=x.filter(({thread:m})=>!!m.mutedAt).length,u=r.useCallback(async m=>{c(m.id),f(null),await i(m.id,!m.mutedAt)||f("Could not update this conversation. Try again."),c(null)},[i]);return e.jsxs("section",{className:"account-settings notifications-settings",children:[e.jsx("h1",{children:"Notifications"}),e.jsxs("div",{className:"account-list notification-settings-card",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Team chat notifications"}),e.jsx("small",{children:"In-app alerts"})]}),e.jsx("div",{className:"notification-mode-list",role:"radiogroup","aria-label":"Notify me about",children:Rt.map(m=>e.jsxs("label",{className:`notification-mode-option${n===m.mode?" selected":""}`,children:[e.jsx("input",{type:"radio",name:"team-chat-notification-mode",checked:n===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:h===1?"1 muted":`${h} muted`})]}),a?x.length===0?e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:"Open a Team Chat conversation to manage it here."})}):x.map(({thread:m,label:j})=>{const b=!!m.mutedAt,S=d===m.id;return e.jsxs("div",{className:"notification-thread-row",children:[e.jsx("span",{className:`notification-thread-icon${b?" muted":""}`,children:b?e.jsx(_a,{size:15}):e.jsx(_s,{size:15})}),e.jsxs("span",{className:"notification-thread-copy",children:[e.jsx("strong",{children:j}),e.jsx("small",{children:b?"Muted":"Uses the team chat setting"})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:d!==null,onClick:()=>{u(m)},children:S?"Saving":b?"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 Dt(s,a){return s.kind==="general"||s.kind==="channel"?`#${s.title?.trim()||"general"}`:s.kind==="dm"?s.participants.find(n=>n.userId!==a)?.name??s.title?.trim()??"Direct message":s.title?.trim()||s.participants.filter(n=>n.userId!==a).map(n=>n.name).join(", ")||"Group conversation"}function Et({canSaveCurrentTemplate:s,personalizationTemplateId:a,personalizationTemplateOptions:n,saveAsNewOpen:t,saving:l,selectedPersonalizationTemplate:i,selectedTemplateIsCustom:d,soulDraft:c,templateNameDraft:o,changePersonalizationTemplate:f,changeSoulDraft:x,openSaveAsNew:h,resetPersonalizationDraft:u,savePersonalization:m,setSaveAsNewOpen:j,setTemplateNameDraft:b}){function S(C){C.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:S,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:o,onChange:C=>b(C.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:()=>j(!1),children:e.jsx(le,{size:15})}),e.jsx("button",{type:"button",className:"settings-icon-button primary",title:"Save new template","aria-label":"Save new template",disabled:l||!c.trim()||!o.trim(),onClick:()=>{m(!0)},children:e.jsx(Os,{size:15})})]}):e.jsxs(e.Fragment,{children:[e.jsx("small",{children:d?"Custom template":"Built-in template"}),e.jsx("button",{type:"button",className:"settings-icon-button",title:"Save as new","aria-label":"Save as new",disabled:l||!i||!c.trim(),onClick:h,children:e.jsx(me,{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(Se,{value:a,disabled:l||n.length===0,label:"Personalization template",options:n,onChange:C=>{f(C)}})]})}),e.jsxs("label",{className:"settings-select-field personalization-editor",children:[e.jsx("span",{children:"SOUL.md"}),e.jsx("textarea",{value:c,onChange:C=>x(C.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:u,children:e.jsx(Ie,{size:15})}),d&&e.jsx("button",{className:"settings-icon-button primary",title:"Save template","aria-label":"Save template",disabled:l||!s,children:e.jsx(is,{size:15})})]})]})]})}function $t({connection:s,profile:a,selectedDefaultTeamId:n}){const t=Ga(s),l=Ot(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(js,{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(It,{}),a.agents.map(i=>e.jsx(Mt,{agent:i,defaultAction:a.summary.defaultAction,profile:a,selectedDefaultTeamId:n},i.id)),l.paused.map(i=>e.jsx(js,{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 It(){return e.jsxs("tr",{className:"profile-agent-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:"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(Ce,{status:{state:"ready",label:"Ready"}})}),e.jsx("td",{children:e.jsx(Ce,{status:{state:"ready",label:"Built in"}})})]})}function Mt({agent:s,defaultAction:a,profile:n,selectedDefaultTeamId:t}){const l=zt(n,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(ze,{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:a??"None"})})}),e.jsx("td",{children:e.jsx(Ce,{status:l.check})}),e.jsx("td",{children:e.jsx(Ce,{status:l.sync})})]})}function js({pending:s,refreshing:a,schedule:n,onRefresh:t,onRun:l,onToggle:i}){const d=Tt(n),c=n.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(ze,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.localProjectName}),e.jsxs("span",{title:n.scheduleName,children:["schedule: ",n.scheduleName]})]})]})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{title:n.targetAction,children:n.targetAction})})}),e.jsx("td",{children:e.jsx(Ce,{status:d})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-schedule-actions",children:[e.jsx("span",{className:"profile-schedule-expression",title:Lt(n),children:n.enabled?n.scheduleExpression:"Paused"}),e.jsxs("div",{className:"profile-schedule-controls","aria-label":`${n.scheduleName} schedule controls`,children:[e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:a,type:"button",title:"Refresh local schedules","aria-label":"Refresh local schedules",onClick:t,children:e.jsx(te,{size:14,className:a?"settings-spin":void 0})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:"Run now","aria-label":`Run ${n.scheduleName} now`,onClick:l,children:e.jsx(Ie,{size:14})}),e.jsx("button",{className:"settings-icon-button profile-schedule-button",disabled:s,type:"button",title:c,"aria-label":`${c}: ${n.scheduleName}`,onClick:i,children:n.enabled?e.jsx(zs,{size:14}):e.jsx(Bs,{size:14})})]})]})})]})}function Ce({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function Ot(s){const a=[],n=[];for(const t of s)t.enabled?a.push(t):n.push(t);return a.sort((t,l)=>vs(t)-vs(l)),{active:a,paused:n}}function vs(s){return s.lastRunStatus==="running"?0:s.lastRunStatus==="queued"?1:2}function Tt(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 Lt(s){const a=[`${s.scheduleType}: ${s.scheduleExpression}`];return s.nextRunAt&&a.push(`next ${bs(s.nextRunAt)}`),s.lastRunAt&&a.push(`last ${bs(s.lastRunAt)}`),a.join(" - ")}function bs(s){const a=new Date(s);return Number.isFinite(a.getTime())?a.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):s}function zt(s,a,n){if(!a.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||Bt(s,a)>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(Ut(s,n))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 Ut(s,a){const n=s.hosted?.teamId?.trim()??"";return!!(n&&a&&n!==a)}function Bt(s,a){let n=0;s.diff.changedAgents.includes(a.id)&&(n+=1),s.diff.newAgents.includes(a.id)&&(n+=1),s.diff.deletedAgents.includes(a.id)&&(n+=1);const t=a.path.replace(/^profiles\/[^/]+\//,"");for(const l of s.diff.files){const i=l.path.replace(/^profiles\/[^/]+\//,"");(i===t||i.startsWith(`${t}/`)||i.startsWith(`agents/${a.id}/`))&&(n+=1)}return n}function _t({actions:s,busy:a,library:n,onSelect:t}){const l=n.profiles.find(d=>Qe(d.ref,n.lastUsed))??n.profiles[0]??null,i=l?_e(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:a||n.profiles.length===0,value:i,onChange:d=>{const c=va(n,d.currentTarget.value),o=n.profiles.find(f=>Qe(f.ref,c));o&&t(o)},children:n.profiles.length?n.profiles.map(d=>e.jsx("option",{value:_e(d.ref),children:d.name},_e(d.ref))):e.jsx("option",{value:"",children:"No profiles"})}),e.jsx(ba,{"aria-hidden":"true",size:14})]}),s]})}function Ht({addDisabled:s,commitDisabled:a,commitLabel:n,refreshDisabled:t,repoDisabled:l,syncDisabled:i,syncLabel:d,syncStatus:c,onAdd:o,onCommit:f,onRefresh:x,onRepo:h,onSync:u}){const[m,j]=r.useState(!1),b=r.useRef(null);r.useEffect(()=>{if(!m)return;function C(P){b.current?.contains(P.target)||j(!1)}function k(P){P.key==="Escape"&&j(!1)}return document.addEventListener("pointerdown",C),document.addEventListener("keydown",k),()=>{document.removeEventListener("pointerdown",C),document.removeEventListener("keydown",k)}},[m]);function S(C){j(!1),C()}return e.jsx("div",{className:"profile-selector-actions",children:e.jsxs("div",{className:"profile-settings-menu-root",ref:b,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:()=>j(C=>!C),children:e.jsx(ya,{size:15})}),m?e.jsxs("div",{className:"profile-settings-menu",role:"menu",children:[e.jsxs("button",{disabled:a,role:"menuitem",type:"button",onClick:()=>S(f),children:[e.jsx(Me,{size:14}),e.jsx("span",{children:n})]}),e.jsxs("button",{disabled:i,role:"menuitem",type:"button",onClick:()=>S(u),children:[e.jsx(pe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:d}),c?e.jsx("small",{children:c}):null]})]}),e.jsxs("button",{disabled:l,role:"menuitem",type:"button",onClick:()=>S(h),children:[e.jsx(ke,{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:()=>S(x),children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh profiles"})]}),e.jsxs("button",{disabled:s,role:"menuitem",type:"button",onClick:()=>S(o),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add profile"})]})]}):null]})})}const Ft=[{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 Gt({connection:s,entry:a,onClose:n,onPublished:t}){const[l,i]=r.useState("github"),[d,c]=r.useState(""),[o,f]=r.useState(`${a.name}-profile`),[x,h]=r.useState("public"),[u,m]=r.useState(()=>a.state.agents.filter(v=>v.enabled).map(v=>v.id)),[j,b]=r.useState(()=>a.state.skills.filter(v=>v.enabled).map(v=>v.name)),[S,C]=r.useState([]),[k,P]=r.useState(null),[D,g]=r.useState(null),[E,R]=r.useState(null),z=r.useMemo(()=>({ref:a.ref,selection:{agentIds:u,skillNames:j,optionalContent:S},target:{provider:l,owner:d.trim()||null,repository:o.trim(),visibility:l==="github"?"public":x}}),[u,a.ref,S,d,l,o,j,x]);function p(v,M,T){return T?[...new Set([...v,M])]:v.filter(q=>q!==M)}async function N(v){if(v.preventDefault(),!(!o.trim()||D)){g("preview"),R(null);try{P(await I.profilePublicationPreview(s,z))}catch(M){R(M instanceof Error?M.message:String(M))}finally{g(null)}}}async function y(){if(!(!k||k.blockedReasons.length>0||D)){g("publish"),R(null);try{const v=await I.profilePublicationPublish(s,{...z,expectedSourceHash:k.sourceHash,confirmed:!0});t(`Published ${a.name} to ${v.owner}/${v.repository}`),n()}catch(v){R(v instanceof Error?v.message:String(v))}finally{g(null)}}}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,children:e.jsxs("form",{className:"git-dialog profile-publication-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-publication-title",onMouseDown:v=>v.stopPropagation(),onSubmit:N,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!D,type:"button","aria-label":"Close",onClick:n,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{size:18})}),e.jsxs("h2",{id:"profile-publication-title",children:["Publish ",a.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."}),k?e.jsx(qt,{preview:k}):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"),h("public")}}),e.jsx(Ze,{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"),h("private")}}),e.jsx(Na,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"OpenPond Git"}),e.jsx("small",{children:"Private by default; uses the same repository format"})]})]})]}),e.jsxs("div",{className:"profile-publication-target-fields",children:[l==="github"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"GitHub owner (optional)"}),e.jsx("input",{value:d,placeholder:"Uses gh account",onChange:v=>c(v.currentTarget.value)})]}):null,e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Repository"}),e.jsx("input",{value:o,onChange:v=>f(v.currentTarget.value)})]}),l==="openpond_git"?e.jsxs("label",{className:"git-dialog-field",children:[e.jsx("span",{children:"Visibility"}),e.jsxs("select",{value:x,onChange:v=>h(v.currentTarget.value),children:[e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"public",children:"Public"})]})]}):null]}),e.jsx(We,{title:"Agents",empty:"No Agents in this Profile",children:a.state.agents.map(v=>e.jsx(Ve,{checked:u.includes(v.id),label:v.name,detail:v.path,onChange:M=>m(T=>p(T,v.id,M))},v.id))}),e.jsx(We,{title:"Skills",empty:"No Skills in this Profile",children:a.state.skills.map(v=>e.jsx(Ve,{checked:j.includes(v.name),label:v.name,detail:v.description||v.path,onChange:M=>b(T=>p(T,v.name,M))},v.name))}),e.jsx(We,{title:"Optional content",empty:"",children:Ft.map(v=>e.jsx(Ve,{checked:S.includes(v.id),label:v.label,detail:v.detail,onChange:M=>C(T=>p(T,v.id,M))},v.id))})]}),E?e.jsx("div",{className:"profile-dialog-warning",children:E}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!D,type:"button",onClick:k?()=>P(null):n,children:k?"Back":"Cancel"}),k?e.jsxs("button",{className:"git-dialog-primary",disabled:!!D||k.blockedReasons.length>0,type:"button",onClick:()=>{y()},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:D==="publish"?"Publishing":k.replacesExisting?"Confirm and replace":"Confirm and publish"})]}):e.jsx("button",{className:"git-dialog-primary",disabled:!!D||!o.trim(),type:"submit",children:D==="preview"?"Building preview":"Review exact files"})]})]})})}function We({title:s,empty:a,children:n}){const t=Array.isArray(n)?n.length:n?1:0;return e.jsxs("fieldset",{className:"profile-publication-fieldset",children:[e.jsx("legend",{children:s}),t?n:e.jsx("span",{className:"profile-publication-empty",children:a})]})}function Ve({checked:s,label:a,detail:n,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:a}),e.jsx("small",{children:n})]})]})}function qt({preview:s}){const a=s.files.reduce((n,t)=>n+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 · ",ys(a)]}),e.jsx("span",{children:s.sourceRevision?.slice(0,10)??"No source revision"})]}),s.blockedReasons.map(n=>e.jsx("div",{className:"profile-dialog-warning",children:n},n)),s.warnings.map(n=>e.jsx("div",{className:"profile-publication-warning",children:n},n)),e.jsx("div",{className:"profile-publication-file-list","aria-label":"Exact files to publish",children:s.files.map(n=>e.jsxs("div",{children:[e.jsx("span",{title:n.path,children:n.path}),e.jsxs("small",{children:[n.category," · ",ys(n.sizeBytes)]})]},n.path))}),s.excludedFiles.length?e.jsxs("details",{children:[e.jsxs("summary",{children:[s.excludedFiles.length," excluded sensitive/runtime files"]}),s.excludedFiles.map(n=>e.jsx("code",{children:n},n))]}):null]})}function ys(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function Wt({section:s="all",catalogPresentation:a="list",payload:n,connection:t,onPayload:l,onError:i,onToast:d,onSkillCommand:c,overviewContent:o}){const[f,x]=r.useState(""),[h,u]=r.useState(null),[m,j]=r.useState(!1),[b,S]=r.useState(null),[C,k]=r.useState(null),P=n?.profile??null,D=n?.preferences.defaultTeamId?.trim()||"",g=s==="all"||s==="profile"||s==="controls",E=s==="all"||s==="profile",R=s==="all"||s==="agents",z=s==="all"||s==="profile";async function p(O){t&&(l(await I.bootstrap(t)),d?.(O,"success"))}async function N(O,Q){if(!(!t||h)){u(O),i(null);try{await Q()}catch(J){i(J instanceof Error?J.message:String(J))}finally{u(null)}}}function y(){N("init",async()=>{await I.profileInit(t,{}),await p("Profile initialized")})}function v(){N("commit",async()=>{await I.profileCommit(t,{message:f.trim()||null}),x(""),await p("Profile commit complete")})}function M(){N("push",async()=>{if(!D)throw new Error("Select a default team before syncing a hosted profile.");await I.profileCheck(t,{kind:"all"}),await I.profilePush(t,{teamId:D,ensureHosted:!0,message:null}),await p("Profile synced to hosted profile repo")})}function T(O){N(`select:${O.ref.profileId}`,async()=>{await I.profileSelect(t,O.ref),await p(`Using ${O.name}`)})}function q(O){N("add",async()=>{O.source==="blank"?await I.profileInit(t,{path:O.path,profile:O.profile,template:"blank-profile"}):O.source==="local"?await I.profileLoad(t,O):await I.profileInstall(t,O),j(!1),await p(O.source==="blank"?`${O.profile} created`:"Profile added")})}function V(O){N("update",async()=>{await I.profileUpdate(t,O.ref),await p(`${O.name} updated`)})}function A(O){N("remove",async()=>{await I.profileRemove(t,O.ref),S(null),await p("Profile removed from this device")})}function w(){N("refresh",async()=>{await p("Profiles refreshed")})}return e.jsxs("section",{className:"account-settings profile-settings",children:[P?.mode==="local"?e.jsxs(e.Fragment,{children:[g?e.jsxs(e.Fragment,{children:[E&&a==="select"?e.jsx(_t,{actions:e.jsx(Ns,{connection:t,onAdd:()=>j(!0),onRefresh:w,presentation:"menu",profile:P,profileBusy:h,profileCommitMessage:f,selectedDefaultTeamId:D,syncDisabledReason:ws(P,D),setProfileCommitMessage:x,submitProfileCommit:v,submitProfilePush:M}),busy:!!h,library:n?.profileLibrary??{lastUsed:null,profiles:[]},onSelect:T}):e.jsxs(e.Fragment,{children:[E?e.jsx(Vt,{busy:!!h,library:n?.profileLibrary??{lastUsed:null,profiles:[]},onAdd:()=>j(!0),onRefresh:w,onRemove:S,onPublish:k,onUpdate:V,onSelect:T}):null,e.jsx(Ns,{connection:t,profile:P,profileBusy:h,profileCommitMessage:f,selectedDefaultTeamId:D,syncDisabledReason:ws(P,D),setProfileCommitMessage:x,submitProfileCommit:v,submitProfilePush:M})]}),o]}):null,R?e.jsx($t,{connection:t,profile:P,selectedDefaultTeamId:D}):null,z?e.jsx(Xt,{onSkillCommand:c,profile:P}):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:()=>j(!0),children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Create or add Profile"})]}),e.jsxs("button",{className:"settings-secondary",disabled:!t||!!h,type:"button",onClick:y,children:[e.jsx(me,{size:14}),e.jsx("span",{children:h==="init"?"Creating":"Create starter Profile"})]})]})]}),m?e.jsx(Kt,{busy:!!h,onClose:()=>j(!1),onSubmit:q}):null,b?e.jsx(Jt,{busy:!!h,entry:b,onClose:()=>S(null),onConfirm:()=>A(b)}):null,C&&t?e.jsx(Gt,{connection:t,entry:C,onClose:()=>k(null),onPublished:O=>d?.(O,"success")}):null]})}function Vt({busy:s,library:a,onAdd:n,onRefresh:t,onRemove:l,onPublish:i,onSelect:d,onUpdate:c}){return e.jsxs("div",{className:"account-list profile-catalog-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Profiles"}),e.jsxs("div",{className:"profile-skill-heading-actions",children:[e.jsxs("small",{children:[a.profiles.length," installed"]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:t,children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Refresh"})]}),e.jsxs("button",{className:"settings-secondary",disabled:s,type:"button",onClick:n,children:[e.jsx(me,{size:14}),e.jsx("span",{children:"Add"})]})]})]}),a.profiles.map(o=>{const f=Qe(o.ref,a.lastUsed);return e.jsxs("div",{className:`product-row profile-catalog-row ${f?"selected":""}`,role:"button",tabIndex:s?-1:0,"aria-disabled":s,onClick:()=>{s||d(o)},onKeyDown:x=>{s||x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),d(o))},children:[e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx(ke,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:o.name}),e.jsx("span",{title:o.repoPath,children:o.repoPath})]})]}),e.jsx(qs,{status:{state:o.state.error?"warning":"ready",label:o.state.error?"error":f?"current":"ready"}}),e.jsx("span",{className:"profile-catalog-source",children:o.ref.source.replace("_"," ")}),e.jsx("span",{className:"profile-catalog-summary",children:o.state.summary.message}),e.jsxs("span",{className:"profile-catalog-actions",children:[o.ref.source!=="local"?e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),c(o)},onKeyDown:x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),x.stopPropagation(),c(o))},children:[e.jsx(te,{size:14}),e.jsx("span",{children:"Update"})]}):null,e.jsxs("span",{className:"settings-secondary compact",role:"button",tabIndex:0,onClick:x=>{x.stopPropagation(),i(o)},onKeyDown:x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),x.stopPropagation(),i(o))},children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Publish"})]}),e.jsxs("span",{className:"settings-secondary compact profile-remove-button",role:"button",tabIndex:0,"aria-label":`Remove ${o.name}`,onClick:x=>{x.stopPropagation(),l(o)},onKeyDown:x=>{x.key!=="Enter"&&x.key!==" "||(x.preventDefault(),x.stopPropagation(),l(o))},children:[e.jsx(ve,{size:14}),e.jsx("span",{children:"Remove"})]})]})]},`${o.ref.source}:${o.ref.repositoryId}:${o.ref.profileId}`)})]})}function Kt({busy:s,onClose:a,onSubmit:n}){const[t,l]=r.useState("blank"),[i,d]=r.useState(""),[c,o]=r.useState(""),[f,x]=r.useState("");function h(u){if(u.preventDefault(),s)return;if(t==="blank"){const j=f.trim();if(!j)return;n({source:t,path:i.trim()||null,profile:j});return}if(t==="local"){const j=i.trim();if(!j)return;n({source:t,path:j,profile:f.trim()||null});return}const m=c.trim();m&&n({source:t,repositoryId:m,profile:f.trim()||null})}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:a,children:e.jsxs("form",{className:"git-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"add-profile-title",onMouseDown:u=>u.stopPropagation(),onSubmit:h,children:[e.jsx("button",{className:"git-dialog-close",disabled:s,type:"button","aria-label":"Close",onClick:a,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(ke,{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:u=>d(u.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:u=>d(u.currentTarget.value)})]}):e.jsxs("label",{className:"git-dialog-field",children:[e.jsxs("span",{children:[t==="github"?"GitHub":"OpenPond Git"," repository"]}),e.jsx("input",{autoFocus:!0,disabled:s,value:c,placeholder:"owner/repository",onChange:u=>o(u.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:f,placeholder:t==="blank"?"research":"Uses repository default",onChange:u=>x(u.currentTarget.value)})]}),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",disabled:s||!(t==="blank"?f:t==="local"?i:c).trim(),type:"submit",children:t==="blank"?"Create Profile":"Add Profile"})]})]})})}function Jt({busy:s,entry:a,onClose:n,onConfirm:t}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,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:n,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(ve,{size:18})}),e.jsxs("h2",{id:"remove-profile-title",children:["Remove ",a.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:a.name}),e.jsx("span",{children:a.repoPath})]}),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 danger",disabled:s,type:"button",onClick:t,children:"Remove"})]})]})})}function Ns({connection:s,onAdd:a,onRefresh:n,presentation:t="toolbar",profile:l,profileBusy:i,profileCommitMessage:d,selectedDefaultTeamId:c,syncDisabledReason:o,setProfileCommitMessage:f,submitProfileCommit:x,submitProfilePush:h}){const[u,m]=r.useState(!1),[j,b]=r.useState(!1),[S,C]=r.useState(!1),k=!s||!!i;return e.jsxs(e.Fragment,{children:[t==="menu"&&a&&n?e.jsx(Ht,{addDisabled:!!i,commitDisabled:k,commitLabel:i==="commit"?"Committing":"Commit",refreshDisabled:k,repoDisabled:!!i||!l,syncDisabled:k||!l,syncLabel:i==="push"?"Syncing":"Sync",syncStatus:l?Ke(l,c):null,onAdd:a,onCommit:()=>b(!0),onRefresh:n,onRepo:()=>m(!0),onSync:()=>C(!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:k,type:"button",onClick:()=>b(!0),children:[e.jsx(Me,{size:14}),e.jsx("span",{children:i==="commit"?"Committing":"Commit"})]}),e.jsxs("button",{className:"settings-secondary",disabled:k||!l,type:"button",onClick:()=>C(!0),children:[e.jsx(pe,{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(ke,{size:14}),e.jsx("span",{children:"Repo"})]}),l?e.jsxs("span",{className:"profile-hosted-status",title:`Profile sync status: ${Ke(l,c)}`,children:[e.jsx(pe,{size:14}),e.jsx("span",{children:"Profile sync"}),e.jsx("strong",{children:Ke(l,c)})]}):null]}),l?e.jsx("span",{className:`profile-local-status ${l.summary.state}`,title:l.summary.message,children:l.summary.message}):null]})}),u&&l?e.jsx(Zt,{profile:l,profileBusy:i,onClose:()=>m(!1)}):null,j?e.jsx(Yt,{disabled:k,profileBusy:i,profileCommitMessage:d,setProfileCommitMessage:f,submitProfileCommit:x,onClose:()=>b(!1)}):null,S&&l?e.jsx(Qt,{disabled:k,profile:l,profileBusy:i,selectedDefaultTeamId:c,syncDisabledReason:o,submitProfilePush:h,onClose:()=>C(!1)}):null]})}function Yt({disabled:s,profileBusy:a,profileCommitMessage:n,setProfileCommitMessage:t,submitProfileCommit:l,onClose:i}){function d(c){c.preventDefault(),!s&&(l(),i())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:i,children:e.jsxs("form",{className:"git-dialog profile-commit-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-commit-dialog-title",onMouseDown:c=>c.stopPropagation(),onSubmit:d,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!a,type:"button",title:"Close","aria-label":"Close",onClick:i,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Me,{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:n,disabled:!!a,placeholder:"Update OpenPond profile",onChange:c=>t(c.target.value)})]}),e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:i,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:s,type:"submit",children:[e.jsx(Me,{size:14}),e.jsx("span",{children:a==="commit"?"Committing":"Commit"})]})]})]})})}function Qt({disabled:s,profile:a,profileBusy:n,selectedDefaultTeamId:t,syncDisabledReason:l,submitProfilePush:i,onClose:d}){const c=sn(a,t),o=c.reduce((h,u)=>h+u.count,0),f=!s&&!l;function x(h){h.preventDefault(),f&&(i(),d())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("form",{className:"git-dialog profile-sync-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"profile-sync-dialog-title",onMouseDown:h=>h.stopPropagation(),onSubmit:x,children:[e.jsx("button",{className:"git-dialog-close",disabled:!!n,type:"button",title:"Close","aria-label":"Close",onClick:d,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(pe,{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:[o," ",o===1?"item":"items"," out of sync"]}),e.jsxs("span",{children:["Local ",be(a.summary.localHead??a.git?.head)," - Last pushed"," ",be(a.hosted?.lastPushedLocalHead)]})]}),c.length?e.jsx("div",{className:"profile-dialog-diff-list","aria-label":"Profile sync differences",children:c.map(h=>e.jsxs("div",{className:`profile-dialog-diff-row ${h.tone??""}`,children:[e.jsx("strong",{children:h.label}),e.jsx("span",{children:h.detail})]},h.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:!!n,type:"button",onClick:d,children:"Cancel"}),e.jsxs("button",{className:"git-dialog-primary",disabled:!f,type:"submit",children:[e.jsx(pe,{size:14}),e.jsx("span",{children:n==="push"?"Syncing":"Confirm sync"})]})]})]})})}function Zt({profile:s,profileBusy:a,onClose:n}){return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:n,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:!!a,type:"button",title:"Close","aria-label":"Close",onClick:n,children:e.jsx(le,{size:14})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(ke,{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"," · ",be(s.git?.head)]})]}),e.jsx("div",{className:"git-dialog-footer",children:e.jsx("button",{className:"git-dialog-secondary",disabled:!!a,type:"button",onClick:n,children:"Close"})})]})})}function Xt({onSkillCommand:s,profile:a}){const n=a.skills.slice().sort((i,d)=>i.name.localeCompare(d.name)),t=!s;function l(i){s?.(i)}return e.jsxs("div",{className:"account-list profile-skill-list",children:[e.jsxs("div",{className:"account-list-heading profile-agent-list-heading",children:[e.jsx("span",{children:"Skills"}),e.jsx("div",{className:"profile-skill-heading-actions",children:e.jsxs("small",{children:[a.skillCatalog.skillCount," tracked"]})})]}),n.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:n.map(i=>e.jsx(en,{commandDisabled:t,onSkillCommand:l,skill:i},i.name))})]})}):e.jsxs("div",{className:"empty-account-list",children:[e.jsx("strong",{children:"No profile skills found"}),e.jsx("span",{children:"Use /skill create to add reusable profile instructions."})]})]})}function en({commandDisabled:s,onSkillCommand:a,skill:n}){const t=n.validationStatus==="valid"?{state:"ready",label:"valid"}:{state:"warning",label:n.validationStatus};return e.jsxs("tr",{className:"profile-skill-row",children:[e.jsx("td",{children:e.jsxs("div",{className:"profile-agent-identity",children:[e.jsx($e,{size:18}),e.jsxs("div",{children:[e.jsx("strong",{children:n.name}),e.jsx("span",{title:n.path,children:n.path})]})]})}),e.jsx("td",{className:"profile-skill-description",title:n.description,children:n.description||"No description"}),e.jsx("td",{children:e.jsx(qs,{status:t})}),e.jsx("td",{children:e.jsx("div",{className:"profile-agent-action",children:e.jsx("span",{className:"profile-skill-source",title:n.sourcePath,children:n.sourcePath})})}),e.jsx("td",{children:e.jsxs("div",{className:"profile-skill-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:s||!n.enabled,type:"button",title:`Use ${n.name}`,onClick:()=>a(`$${n.name} `),children:e.jsx("span",{children:"Use"})}),e.jsx("button",{className:"settings-secondary compact",disabled:s,type:"button",title:`Edit ${n.name}`,onClick:()=>a(`/skill edit ${n.name} `),children:e.jsx("span",{children:"Edit"})})]})})]})}function qs({status:s}){return e.jsx("span",{className:`profile-status-text ${s.state}`,children:s.label})}function be(s){return s?s.slice(0,10):"None"}function Ke(s,a){return Ws(s,a)?"Sync this account":s.hosted?.sourceCommitSha?`${s.hosted.promotionStatus??"uploaded"} ${be(s.hosted.sourceCommitSha)}`:"Not pushed"}function ws(s,a){return a?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 sn(s,a){const n=[],t=s.summary.localHead??s.git?.head??null,l=s.hosted?.lastPushedLocalHead??null,i=s.summary.hostedHead??s.hosted?.sourceCommitSha??null;if(Ws(s,a)&&n.push({label:"Account",detail:"Hosted profile metadata was synced under a different default team.",count:1,tone:"warning"}),!i&&!l?n.push({label:"Hosted source",detail:"No hosted profile commit has been recorded.",count:1}):t&&l&&t!==l&&n.push({label:"Commit",detail:`Local ${be(t)} has not been pushed since ${be(l)}.`,count:1}),s.git?.dirty){const c=s.git.files.length||s.diff.files.length||1;n.push({label:"Uncommitted files",detail:`${c} local ${c===1?"file":"files"} changed.`,count:c,tone:"warning"})}const d=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length+s.diff.changedSkills.length+s.diff.changedActions.length+s.diff.changedExtensions.length+s.diff.setupChanges.length+s.diff.envRequirementChanges.length;return d>0&&n.push({label:"Profile changes",detail:an(s),count:d,tone:s.git?.dirty?"warning":void 0}),s.catalog.stale&&n.push({label:"Catalog",detail:"Action catalog artifacts are stale or missing.",count:1,tone:"warning"}),s.setupGate.blockingCount>0&&n.push({label:"Setup",detail:`${s.setupGate.blockingCount} blocking setup ${s.setupGate.blockingCount===1?"requirement":"requirements"}.`,count:s.setupGate.blockingCount,tone:"warning"}),n}function an(s){const a=[],n=s.diff.changedAgents.length+s.diff.newAgents.length+s.diff.deletedAgents.length;return n&&a.push(`${n} agent ${n===1?"change":"changes"}`),s.diff.changedActions.length&&a.push(`${s.diff.changedActions.length} action ${s.diff.changedActions.length===1?"change":"changes"}`),s.diff.changedSkills.length&&a.push(`${s.diff.changedSkills.length} skill ${s.diff.changedSkills.length===1?"change":"changes"}`),s.diff.changedExtensions.length&&a.push(`${s.diff.changedExtensions.length} extension ${s.diff.changedExtensions.length===1?"change":"changes"}`),s.diff.setupChanges.length&&a.push(`${s.diff.setupChanges.length} setup ${s.diff.setupChanges.length===1?"change":"changes"}`),s.diff.envRequirementChanges.length&&a.push(`${s.diff.envRequirementChanges.length} env ${s.diff.envRequirementChanges.length===1?"change":"changes"}`),a.join(", ")||"Profile source has local changes."}function Ws(s,a){const n=s.hosted?.teamId?.trim()??"";return!!(n&&a&&n!==a)}const tn=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],nn=120,ln=new Set(["openai","xai","zai"]),rn=new Set(["chatgpt-subscription"]),on="https://api.z.ai/api/coding/paas/v4";function Ss(s){return s.split(/[\n,]/).map(a=>a.trim()).filter(Boolean)}function Vs(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 Ks(s){return s?s.available?"ready":s.credential.connected?"configured":s.credential.lastError||s.lastError||s.id==="codex"?"warning":"muted":"unknown"}function Cs(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 cn(s){return s?.trim().replace(/\/+$/,"")??""}function Js(s,a){return s.id==="zai"&&cn(a.providers.zai?.baseUrl)===on}function dn(s,a){return!s.credential.connected||!s.routing.localByok?"":s.credential.source==="chatgpt_subscription"?"Subscription":Js(s,a)?"Coding Plan key":"API key"}function un(s,a){const n=a.modelCaches[s.id];if(s.routing.localByok&&s.enabled&&!s.credential.connected||!s.enabled&&s.id!=="openpond")return"";const t=Math.max(n?.models.length??0,s.modelIds.length),l=s.defaultModel?es(s.defaultModel,a,s.id):"",i=t===1?"1 model":`${t} models`,d=dn(s,a);return[Vs(s),d,n?i:"",l].filter(Boolean).join(" · ")}function hn(s){return s!=="openpond"&&Xe(s)}function rs(s){return s?ln.has(s.id)||s.credentialModes.some(a=>rn.has(a)):!1}function mn(s){return rs(s)?["api","subscription"]:["api"]}function ks(s,a){return!s||!a||!rs(s)?"api":s.credential.source==="chatgpt_subscription"||Js(s,a)?"subscription":"api"}function Ps(s,a){const n=wa.filter(t=>!!s?.statuses[t]);return a?n.filter(t=>rs(s?.statuses[t])):n}function pn(s){if(!s)return"Never";const a=new Date(s);return Number.isNaN(a.getTime())?s:a.toLocaleString()}function gn(s,a,n=nn){const t=[],l=new Set,i=new Set(a.map(c=>c.trim()).filter(Boolean)),d=c=>{l.has(c.value)||t.length>=n||(l.add(c.value),t.push(c))};for(const c of s)i.has(c.value)&&d(c);for(const c of s)d(c);return t}function fn({account:s,codex:a,providers:n,providerBusy:t,validationMessage:l,deleteProviderCredential:i,loadProviderModels:d,refreshProviderModels:c,saveProviderConfig:o,saveProviderCredential:f,startOpenAiSubscriptionAuth:x,validateProvider:h}){const[u,m]=r.useState(null),[j,b]=r.useState(!1),S=r.useMemo(()=>Ps(n,!1),[n]),C=r.useMemo(()=>Ps(n,j),[n,j]),k=u?n?.statuses[u]??null:null;function P(D,g){m(D),g&&d(D)}return e.jsxs("section",{className:"account-settings",children:[e.jsx("h1",{children:"Providers"}),n?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:j,onChange:D=>b(D.currentTarget.checked)}),e.jsx("span",{children:"Subscriptions"})]})]}),e.jsxs("small",{children:[C.length," of ",S.length," presets"]})]}),C.length>0?e.jsx("div",{className:"provider-manager-scroll",role:"list",children:C.map(D=>{const g=n.statuses[D],E=n.modelCaches[D],R=g.modelIds.length>0&&(E?.models.length??0)<g.modelIds.length,z=t?.startsWith(`${D}:`)??!1,p=hn(D),N=D==="openpond"||!!n.providers[D]?.enabled;return e.jsxs("div",{className:"provider-manager-row",role:"listitem",children:[e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${g.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:N,disabled:!p||z,onChange:y=>{P(D,!1),o(D,{enabled:y.currentTarget.checked})}}),e.jsx("span",{})]}),e.jsx("div",{className:"provider-row-main",children:e.jsx("strong",{children:g.displayName})}),e.jsxs("div",{className:`provider-row-status ${Ks(g)}`,children:[z?e.jsx(ae,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:un(g,n)})]}),e.jsx("button",{type:"button",className:"settings-secondary provider-details-button",onClick:()=>{P(D,R)},children:"Details"})]},D)})}):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,u&&k&&n?e.jsx(xn,{account:s,codex:a,providerId:u,providerBusy:t,settings:n,status:k,onClose:()=>m(null),onDeleteCredential:i,onRefreshModels:c,onSaveConfig:o,onSaveCredential:f,onStartOpenAiSubscriptionAuth:x,onValidate:h}):null]})}function xn({account:s,codex:a,providerId:n,providerBusy:t,settings:l,status:i,onClose:d,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:f,onSaveCredential:x,onStartOpenAiSubscriptionAuth:h,onValidate:u}){const m=l.providers[n],j=l.modelCaches[n],b=r.useId(),S=r.useRef(n),C=Math.max(j?.models.length??0,i.modelIds.length),k=i.routing.localByok&&Xe(n)&&n!=="codex",P=r.useMemo(()=>k?mn(i):[],[k,i]),D=P.includes("subscription"),[g,E]=r.useState(()=>ks(i,l)),R=k&&g==="subscription"&&D,z=N=>`${b}-${N}-panel`,p=n==="codex"?"Codex app server":m?.baseUrl??(n==="openpond"?s?.chatApiBaseUrl:null)??"Not set";return r.useEffect(()=>{if(S.current!==n){S.current=n,E(ks(i,l));return}k&&!P.includes(g)&&E("api")},[g,P,k,n,l,i]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:d,children:e.jsxs("section",{className:"git-dialog provider-details-dialog",role:"dialog","aria-modal":"true","aria-label":`${i.displayName} provider details`,onMouseDown:N=>N.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:d,children:e.jsx(le,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:i.displayName}),e.jsx("span",{children:Ee(n,l)})]}),e.jsx("div",{className:`provider-state-pill ${Ks(i)}`,children:Vs(i)})]}),k?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${i.displayName} mode`,children:P.map(N=>e.jsx("button",{type:"button",role:"tab",id:`${b}-${N}`,className:g===N?"active":void 0,"aria-selected":g===N,"aria-controls":z(N),onClick:()=>E(N),children:N==="api"?"API":"Subscription"},N))}):null,e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:Cs(i),children:Cs(i)})]}),R?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:p,children:p})]}),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:j?.lastError??void 0,children:[C," cached · ",pn(j?.fetchedAt)]})]})]}),n==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:a?.account?.email??void 0,children:a?.account?.label??a?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:a?.binaryPath??void 0,children:a?.binaryPath??"Not found"})]})]}):null,i.credential.lastError||j?.lastError||i.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:i.credential.lastError??j?.lastError??i.lastError??void 0,children:i.credential.lastError??j?.lastError??i.lastError})]}):null]}),n==="codex"?e.jsx(jn,{providerBusy:t,status:i,onValidate:u}):k&&m&&j?e.jsx(vn,{credentialTab:g,credentialTabsId:b,hasSubscriptionTab:D,providerId:n,providerBusy:t,settings:l,status:i,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:f,onSaveCredential:x,onStartOpenAiSubscriptionAuth:h,onValidate:u}):i.routing.localByok&&!Xe(n)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(Is,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]})})}function jn({providerBusy:s,status:a,onValidate:n}){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(ue,{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:()=>{n("codex",{modelId:a.defaultModel??void 0})},children:[t?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Ts,{size:14}),e.jsx("span",{children:t?"Testing":"Test Codex login"})]})})]})}function vn({credentialTab:s,credentialTabsId:a,hasSubscriptionTab:n,providerId:t,providerBusy:l,settings:i,status:d,onDeleteCredential:c,onRefreshModels:o,onSaveConfig:f,onSaveCredential:x,onStartOpenAiSubscriptionAuth:h,onValidate:u}){const m=i.providers[t],j=r.useMemo(()=>Le(t,i),[t,i]),b=`provider-models-${t}`,S=r.useRef(t),[C,k]=r.useState(m.baseUrl??""),[P,D]=r.useState(m.defaultModel??""),[g,E]=r.useState(m.modelOverrides.join(`
3
- `)),[R,z]=r.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[p,N]=r.useState("local_secret"),[y,v]=r.useState(""),[M,T]=r.useState(""),q=l===`${t}:config`,V=l===`${t}:credential`,A=l===`${t}:validate`,w=l===`${t}:models`,O=l==="openai:credential",Q=t==="openai",J=t==="xai",W=t==="zai",K=(B=>`${a}-${B}-panel`)(s),U=s==="subscription"&&n,se=s==="subscription"&&W?"coding-plan":"api",ie=se==="coding-plan"?"Coding Plan key":"API key",ce=d.credential.connected?se==="coding-plan"?"Replace saved plan key":"Replace saved key":ie,re=se==="coding-plan"?"Save plan key":"Save key",ne=r.useMemo(()=>gn(j,[P,...Ss(g)]),[P,j,g]),ee=Math.max(0,j.length-ne.length);r.useEffect(()=>{if(S.current!==t){S.current=t,z({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),k(m.baseUrl??""),D(m.defaultModel??""),E(m.modelOverrides.join(`
4
- `));return}R.baseUrl||k(m.baseUrl??""),R.defaultModel||D(m.defaultModel??""),R.modelOverrides||E(m.modelOverrides.join(`
5
- `))},[m.baseUrl,m.defaultModel,m.modelOverrides,R.baseUrl,R.defaultModel,R.modelOverrides,t]);const fe=p==="env"?!!M.trim():!!y.trim();async function oe(B){B.preventDefault(),await f(t,{enabled:!0,baseUrl:C.trim()||null,defaultModel:P.trim()||null,modelOverrides:Ss(g)}),z({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function L(B){if(B.preventDefault(),!!fe){if(p==="env"){await x(t,{source:"env",envVar:M.trim()});return}await x(t,{source:"local_secret",value:y}),v("")}}function _({panel:B=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:B?K:void 0,role:B?"tabpanel":void 0,"aria-labelledby":B?`${a}-${s}`:void 0,onSubmit:H=>{L(H)},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(Se,{value:p,disabled:V,label:"Credential source",options:tn,onChange:H=>N(H)})]}),p==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:M,disabled:V,placeholder:"PROVIDER_API_KEY",onChange:H=>T(H.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:ie}),e.jsx("input",{type:"password",value:y,disabled:V,placeholder:ce,autoComplete:"off",onChange:H=>v(H.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:V||!fe,children:[V?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:V?"Saving":re})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:V||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ve,{size:15})})]})]})}function F(){return Q?e.jsxs("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${a}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(ue,{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:O,onClick:()=>{h("browser")},children:[O?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:O?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:O,onClick:()=>{h("device")},children:[O?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(ue,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${d.displayName} credential`,disabled:O||!d.credential.connected,onClick:()=>{c(t)},children:e.jsx(ve,{size:15})})]})]}):J?e.jsx("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${a}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(ue,{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."})]})}):W?e.jsxs("div",{className:"provider-subscription-panel",id:K,role:"tabpanel","aria-labelledby":`${a}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(ue,{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."})]}),_({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[U?null:e.jsxs("form",{className:"provider-card-form",onSubmit:B=>{oe(B)},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:C,disabled:q,placeholder:"https://api.example.com/v1",onChange:B=>{z(H=>({...H,baseUrl:!0})),k(B.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:b,value:P,disabled:q,placeholder:"Model id",onChange:B=>{z(H=>({...H,defaultModel:!0})),D(B.currentTarget.value)}}),e.jsx("datalist",{id:b,children:ne.map(B=>e.jsx("option",{value:B.value,children:B.label},B.value))}),ee>0?e.jsxs("small",{children:[ee," 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(ae,{size:14,className:"settings-spin"}):e.jsx(is,{size:14}),e.jsx("span",{children:q?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:w,onClick:()=>{o(t)},children:[w?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(te,{size:14}),e.jsx("span",{children:w?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:A||!P.trim(),onClick:()=>{u(t,{baseUrl:C.trim()||void 0,modelId:P.trim()||void 0})},children:[A?e.jsx(ae,{size:14,className:"settings-spin"}):e.jsx(Ts,{size:14}),e.jsx("span",{children:A?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:U?F():_()})]})}function bn({status:s,busy:a,flashTailscaleUp:n,refresh:t,enableRemoteAccess:l,disableRemoteAccess:i,copyRemoteLink:d,copyTailscaleUpCommand:c,copyServeCommand:o,copyServeSetupUrl:f,copyOperatorCommand:x,createRemoteLink:h}){const u=s?.tailscale.installed??!1,m=s?.serve.enabled??!1,j=s?.serve.reachable??!1,b=!!(s?.webUiAvailable&&u),S=m?!!s?.remoteWebUrl:b,k=(s?.tailscale.peers??[]).filter(g=>!g.isSelf),P=!!s?.tailscale.error?.includes("set --operator"),D=!!(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 ${j?"online":m?"configured":""}`,children:u?e.jsx(Hs,{size:18}):e.jsx(Ha,{size:18})}),e.jsxs("div",{children:[e.jsx("strong",{children:j?"Tailscale Serve is reachable":m?"Tailscale Serve is configured":"Tailscale Serve is off"}),e.jsx("small",{children:s?wn(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:a!==null,onClick:()=>{t()},children:e.jsx(te,{className:a==="refresh"?"settings-spin":"",size:15})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:a!==null||!u||!m&&!b,onClick:()=>{m?i():l()},children:[e.jsx(et,{size:15}),e.jsx("span",{children:m?a==="disable"?"Turning off":"Turn off":a==="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:D?"Browser UI":"Tailscale + Serve"})]})}),D&&e.jsx(de,{label:"Remote URL",value:s?.remoteWebUrl??null,actionLabel:a==="copy-link"?"Copying":"Copy",disabled:!s?.remoteWebUrl||a!==null,onAction:d}),e.jsx(de,{label:"Tailscale up",value:s?.tailscaleUpCommand??null,flash:n,actionLabel:a==="copy-up-command"?"Copying":"Copy",disabled:!s?.tailscaleUpCommand||a!==null,onAction:c}),e.jsx(de,{label:"Serve command",value:s?.serveCommand??null,actionLabel:a==="copy-command"?"Copying":"Copy",disabled:!s?.serveCommand||a!==null,onAction:o}),s?.serve.setupUrl&&e.jsx(de,{label:"Enable Serve",value:s.serve.setupUrl,actionLabel:a==="copy-serve-setup"?"Copying":"Copy",disabled:a!==null,onAction:f}),P&&e.jsx(de,{label:"One-time setup",value:s?.operatorCommand??null,actionLabel:a==="copy-operator"?"Copying":"Copy",disabled:!s?.operatorCommand||a!==null,onAction:x}),e.jsx(de,{label:"Local target",value:s?.localUrl??null}),s?.tailscale.authUrl&&e.jsx(de,{label:"Tailscale login",value:s.tailscale.authUrl}),e.jsx(de,{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:[k.length," devices"]})]}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:a!==null||!S,onClick:()=>{h()},children:e.jsx("span",{children:m?"Copy link":"Create link"})})]}),s?k.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."})]}):k.map(g=>e.jsx(Nn,{peer:g},g.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(yn,{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 de({actionLabel:s,disabled:a,flash:n,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:n?"flash":void 0,children:t}),e.jsx("code",{children:i??"Not available"})]}),l&&e.jsx("button",{type:"button",className:"settings-secondary",disabled:a,onClick:()=>{l()},children:e.jsx("span",{children:s??"Copy"})})]})}function yn({status:s}){const a=[{label:"State",value:s?.tailscale.backendState??"Unknown"},{label:"Machine",value:s?.tailscale.machineName??"Unknown"},{label:"Tailnet",value:s?.tailscale.tailnetName??"Unknown"}],n=[{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:a.map(t=>e.jsx(Rs,{label:t.label,value:t.value},t.label))}),e.jsx("div",{className:"remote-access-environment-row two",children:n.map(t=>e.jsx(Rs,{label:t.label,value:t.value},t.label))})]})}function Rs({label:s,value:a}){return e.jsxs("div",{className:"remote-access-environment-cell",children:[e.jsx("strong",{children:s}),e.jsx("span",{children:a})]})}function Nn({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 wn(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 Sn=[{items:[{section:"account",label:"Account",Icon:it},{section:"notifications",label:"Notifications",Icon:_s},{section:"providers",label:"Providers",Icon:Ca},{section:"dataset-storage",label:"Dataset Storage",Icon:Qa},{section:"usage",label:"Activity",Icon:ka},{section:"defaults",label:"Defaults",Icon:Fs}]},{label:"Harness",items:[{section:"harness",label:"Harness",Icon:Fe},{section:"skills",label:"Skills",Icon:$e},{section:"context",label:"Context",Icon:Pa},{section:"training",label:"Training",Icon:Fe},{section:"subagents",label:"Subagents",Icon:Fe}]},{items:[{section:"profile",label:"Legacy Profiles",Icon:ze},{section:"editor",label:"Editor",Icon:Ua},{section:"remote",label:"Remote",Icon:Hs},{section:"personalization",label:"Personalization",Icon:Ra},{section:"diagnostics",label:"Diagnostics",Icon:Fa}]}];function Cn({section:s,onBack:a,onSectionChange:n}){return e.jsxs("aside",{className:"settings-sidebar",children:[e.jsxs("button",{className:"settings-back","aria-label":"Back to app",onClick:a,children:[e.jsx(Sa,{size:15}),e.jsx("span",{children:"Back to app"})]}),e.jsx("nav",{className:"settings-nav","aria-label":"Settings",children:Sn.map((t,l)=>e.jsxs("div",{className:"settings-nav-group",children:[t.label?e.jsx("div",{className:"settings-nav-heading",children:t.label}):null,t.items.map(({section:i,label:d,Icon:c})=>e.jsxs("button",{className:`settings-nav-item ${s===i?"active":""}`,onClick:()=>n(i),children:[e.jsx(c,{size:16}),e.jsx("span",{children:d})]},i))]},t.label??`settings-${l}`))})]})}function kn({catalog:s,connection:a,onCatalog:n,onError:t,onOpenExtension:l,onToast:i}){const[d,c]=r.useState(""),[o,f]=r.useState(""),[x,h]=r.useState(null),[u,m]=r.useState(null),[j,b]=r.useState(null),S=r.useCallback(p=>{const N=p instanceof Error?p.message:String(p);b(N),t(N),i?.(N,"error")},[t,i]),C=r.useCallback(()=>{b(null),t(null)},[t]),k=r.useCallback(async p=>{if(p?.preventDefault(),!(!a||!d.trim()||u)){C(),m("preview");try{const N=await I.extensionPreview(a,{source:d.trim(),...o.trim()?{ref:o.trim()}:{}});h(N)}catch(N){h(null),S(N)}finally{m(null)}}},[u,C,a,S,o,d]),P=r.useCallback(async()=>{if(!(!a||!x||u)){C(),m("install");try{const p=await I.extensionAdd(a,{source:x.repositoryUrl,ref:x.requestedRef});n(p.catalog),c(""),f(""),h(null),i?.(`Installed ${p.extension.owner}/${p.extension.repo}.`,"success")}catch(p){S(p)}finally{m(null)}}},[u,C,a,n,i,x,S]),D=r.useCallback(async p=>{if(!(!a||u)){C(),m(`update:${p.id}`);try{const N=await I.extensionUpdate(a,p);n(N.catalog);const y=N.extension.resolvedCommit===p.resolvedCommit&&N.extension.packageHash===p.packageHash;i?.(y?`${p.owner}/${p.repo} is already current.`:`Updated ${p.owner}/${p.repo}.`,"success")}catch(N){S(N)}finally{m(null)}}},[u,C,a,n,i,S]),g=r.useCallback(async()=>{if(!(!a||u||s.extensions.length===0)){C(),m("update-all");try{const p=await I.extensionUpdateAll(a);n(p.catalog);const N=`Updated ${p.updated.length}; ${p.unchanged.length} already current${p.failed.length?`; ${p.failed.length} failed`:""}.`;i?.(N,p.failed.length?"error":"success"),p.failed.length&&b(p.failed.map(y=>y.error).join(" "))}catch(p){S(p)}finally{m(null)}}},[u,s.extensions.length,C,a,n,i,S]),E=r.useCallback(async p=>{if(!(!a||u)&&window.confirm(`Remove ${p.owner}/${p.repo} and its ${p.skills.length} installed skill${p.skills.length===1?"":"s"}? Profile and built-in skills will not be changed.`)){C(),m(`remove:${p.id}`);try{const N=await I.extensionRemove(a,p);n(N.catalog),i?.(`Removed ${p.owner}/${p.repo}.`,"success")}catch(N){S(N)}finally{m(null)}}},[u,C,a,n,i,S]),R=r.useCallback(p=>{c(p),h(null),b(null)},[]),z=r.useCallback(p=>{f(p),h(null),b(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:!a||u!==null||s.extensions.length===0,type:"button",onClick:()=>{g()},children:[u==="update-all"?e.jsx(ae,{className:"settings-spin",size:13}):e.jsx(te,{size:13}),"Update all"]})]})]}),e.jsxs("form",{className:"github-extension-add",onSubmit:p=>{k(p)},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:!a||u!==null,placeholder:"owner/repo",value:d,onChange:p=>R(p.target.value)})]}),e.jsxs("label",{className:"github-extension-ref-input",children:[e.jsx("span",{children:"Branch, tag, or SHA"}),e.jsx("input",{disabled:!a||u!==null,placeholder:"Default branch",value:o,onChange:p=>z(p.target.value)})]}),e.jsxs("button",{className:"settings-secondary",disabled:!a||!d.trim()||u!==null,type:"submit",children:[u==="preview"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(Ze,{size:14}),u==="preview"?"Checking":"Preview"]})]}),j||s.error?e.jsx("div",{className:"github-extension-message error",role:"alert",children:j??s.error}):null,x?e.jsxs("div",{className:"github-extension-preview",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[x.owner,"/",x.repo]}),e.jsxs("span",{children:[x.skills.length," skill",x.skills.length===1?"":"s"," at ",x.resolvedCommit.slice(0,12)]})]}),e.jsx("div",{className:"github-extension-preview-skills",children:x.skills.map(p=>e.jsx("span",{children:p.name},p.relativePath))}),e.jsxs("button",{className:"settings-secondary",disabled:u!==null,type:"button",onClick:()=>{P()},children:[u==="install"?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(me,{size:14}),u==="install"?"Installing":"Install extension"]})]}):null,s.extensions.length?s.extensions.map(p=>{const N=u===`update:${p.id}`,y=u===`remove:${p.id}`;return e.jsxs("div",{className:"github-extension-row",children:[e.jsxs("button",{"aria-label":`Open ${p.owner}/${p.repo} extension source`,className:"github-extension-open",disabled:!a||u!==null,type:"button",onClick:()=>l(p),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.jsxs("strong",{children:[p.owner,"/",p.repo]}),e.jsx("span",{children:p.skills.map(v=>v.name).join(", ")})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsxs("strong",{children:[p.skills.length," skill",p.skills.length===1?"":"s"]}),e.jsxs("span",{children:[p.requestedRef," · ",p.resolvedCommit.slice(0,12)]})]}),e.jsx("span",{className:`native-skill-status ${p.validationStatus==="valid"?"":"invalid"}`,children:p.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx(Ls,{size:16,"aria-hidden":"true"})]}),e.jsxs("span",{className:"github-extension-row-actions",children:[e.jsx("button",{"aria-label":`Update ${p.owner}/${p.repo}`,className:"settings-icon-button ghost",disabled:u!==null,title:"Update extension",type:"button",onClick:()=>{D(p)},children:N?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(te,{size:14})}),e.jsx("button",{"aria-label":`Remove ${p.owner}/${p.repo}`,className:"settings-icon-button ghost danger",disabled:u!==null,title:"Remove extension",type:"button",onClick:()=>{E(p)},children:y?e.jsx(ae,{className:"settings-spin",size:14}):e.jsx(ve,{size:14})})]})]},p.id)}):e.jsx("div",{className:"skills-settings-empty",children:"No third-party extensions installed."})]})}function Pn({onOpenSkill:s,onOpenExtension:a,personalSkills:n,extensionCatalog:t,connection:l,onExtensionCatalog:i,onError:d,onToast:c}){return e.jsxs("section",{className:"account-settings skills-settings","aria-labelledby":"skills-settings-title",children:[e.jsx("header",{className:"skills-settings-header",children:e.jsxs("div",{children:[e.jsx("h1",{id:"skills-settings-title",children:"Skills"}),e.jsx("p",{children:"Install third-party GitHub packs, inspect personal Codex skills, and view instructions bundled with OpenPond."})]})}),e.jsx(kn,{catalog:t,connection:l,onCatalog:i,onError:d,onOpenExtension:a,onToast:c}),e.jsxs("div",{className:"account-list native-skills-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Personal Codex skills"}),e.jsx("small",{children:"Discovered from your local Codex skills folder"})]}),n.length?n.map(o=>e.jsxs("div",{className:"native-skill-row personal-skill-row",children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx($e,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description||"Packaged Codex skill"})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:o.resourceFiles.length?`${o.resourceFiles.length} packaged resource${o.resourceFiles.length===1?"":"s"}`:"Instructions only"}),e.jsx("span",{children:o.sourcePath})]}),e.jsx("span",{className:`native-skill-status ${o.validationStatus==="valid"?"":"invalid"}`,children:o.validationStatus==="valid"?"Ready":"Needs attention"}),e.jsx("span",{"aria-hidden":"true"})]},o.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"})]}),Aa.map(o=>{const f=Da(o.provider)?.label??o.provider;return e.jsxs("button",{className:"native-skill-row",type:"button",onClick:()=>s(o),children:[e.jsx("span",{className:"native-skill-icon","aria-hidden":"true",children:e.jsx($e,{size:17})}),e.jsxs("span",{className:"native-skill-identity",children:[e.jsx("strong",{children:o.name}),e.jsx("span",{children:o.description})]}),e.jsxs("span",{className:"native-skill-provider",children:[e.jsx("strong",{children:f}),e.jsx("span",{children:o.path})]}),e.jsx("span",{className:"native-skill-status",children:"Built in"}),e.jsx(Ls,{size:16,"aria-hidden":"true"})]},o.name)})]})]})}const os="default";function Rn({connection:s,embedded:a=!1,onError:n,onPreferences:t,preferences:l,providers:i}){const d=l.training,[c,o]=r.useState(Je(d.defaultModelRef)),[f,x]=r.useState(d.creationMode),[h,u]=r.useState(d.autoApproveEvidence),[m,j]=r.useState(!1),b=r.useMemo(()=>Ms(i,{includeUnavailable:!0}),[i]),S=r.useMemo(()=>b.map(g=>({provider:g,models:Le(g.value,i)})).filter(g=>g.models.length>0),[b,i]),C=An(c),k=Ea(l.defaultChatProvider,l.defaultChatModel,i)?` · ${Dn(l.codexReasoningEffort)} reasoning`:"",P=En(C,d.defaultModelRef??null)&&f===d.creationMode&&h===d.autoApproveEvidence;r.useEffect(()=>{o(Je(d.defaultModelRef)),x(d.creationMode),u(d.autoApproveEvidence)},[l.defaultChatModel,l.defaultChatProvider,d.autoApproveEvidence,d.creationMode,d.defaultModelRef]);async function D(g){if(g.preventDefault(),!!s){j(!0),n(null);try{t(await I.savePreferences(s,{training:{defaultModelRef:C,creationMode:f,autoApproveEvidence:h}}))}catch(E){n(E instanceof Error?E.message:String(E))}finally{j(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${a?" embedded":""}`,children:[a?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:g=>{D(g)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:c,disabled:m,onChange:g=>o(g.target.value),children:[e.jsxs("option",{value:os,children:["Use chat default — ",Ee(l.defaultChatProvider,i)," · ",es(l.defaultChatModel,i,l.defaultChatProvider),k]}),S.map(g=>e.jsx("optgroup",{label:g.provider.label,children:g.models.map(E=>e.jsx("option",{value:Je({providerId:g.provider.value,modelId:E.value}),children:E.label},E.value))},g.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:f,disabled:m,onChange:g=>x(g.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:h,disabled:m,onChange:g=>u(g.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||P,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:C?`${Ee(C.providerId,i)} / ${es(C.modelId,i,C.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 Je(s){return s?JSON.stringify([s.providerId,s.modelId]):os}function An(s){if(s===os)return null;try{const a=JSON.parse(s);return!Array.isArray(a)||a.length!==2||typeof a[0]!="string"||typeof a[1]!="string"?null:{providerId:a[0],modelId:a[1]}}catch{return null}}function Dn(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function En(s,a){return s?.providerId===a?.providerId&&s?.modelId===a?.modelId}function $n({disabled:s,onChange:a,storageRoots:n,value:t}){const l=r.useId(),[i,d]=r.useState(!1),c=As(t),o=h=>h.datasetStorePath,f="Dataset",x=n.find(h=>As(o(h))===c)??null;return e.jsxs("div",{className:"model-storage-picker",children:[e.jsxs("label",{className:"model-storage-label",htmlFor:l,children:[f," storage"]}),e.jsxs("div",{className:"model-storage-control-row",children:[e.jsxs("select",{"aria-label":`${f} storage drive`,className:"model-storage-select",disabled:s,id:l,title:t??"No Dataset storage configured",value:t??"",onChange:h=>a(h.target.value||null),children:[e.jsx("option",{value:"",children:"Not configured"}),t&&!x?e.jsx("option",{value:t,children:"Manual location"}):null,n.map(h=>e.jsxs("option",{disabled:!h.mounted||!h.writable,title:o(h),value:o(h),children:[h.label," · ",Tn(h.kind)," · ",Ln(h)]},h.id))]}),e.jsx("button",{className:"settings-icon-button model-storage-add",disabled:s,type:"button",title:"Add manual location","aria-label":"Add manual Dataset storage location",onClick:()=>d(!0),children:e.jsx(me,{size:15})})]}),i?In(e.jsx(Mn,{initialPath:t??"",purpose:"dataset",onClose:()=>d(!1),onUse:h=>{a(h),d(!1)}})):null]})}function In(s){return typeof document>"u"?s:qa.createPortal(s,document.body)}function Mn({initialPath:s,onClose:a,onUse:n,purpose:t="model"}){const l=r.useId(),[i,d]=r.useState(s),c=On(i);r.useEffect(()=>{const f=x=>{x.key==="Escape"&&a()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[a]);function o(f){f.preventDefault(),f.stopPropagation(),!c&&n(i.trim())}return e.jsx("div",{className:"git-dialog-backdrop",role:"presentation",onMouseDown:f=>{f.target===f.currentTarget&&a()},children:e.jsxs("form",{className:"git-dialog model-storage-dialog",role:"dialog","aria-modal":"true","aria-labelledby":l,onSubmit:o,children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":`Close manual ${t} storage`,onClick:a,children:e.jsx(le,{size:15})}),e.jsx("div",{className:"git-dialog-icon",children:e.jsx(Wa,{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:f=>d(f.target.value)})]}),e.jsx("div",{className:"model-storage-dialog-note",children:"For SMB, connect the share in Files or Finder first, then paste its mounted folder path. OpenPond uses your operating system’s existing connection and credentials."}),i.trim()&&c?e.jsx("div",{className:"profile-dialog-warning",children:c}):null,e.jsxs("div",{className:"git-dialog-footer",children:[e.jsx("button",{className:"git-dialog-secondary",type:"button",onClick:a,children:"Cancel"}),e.jsx("button",{className:"git-dialog-primary",disabled:!!c,type:"submit",children:"Use location"})]})]})})}function On(s){const a=s.trim();return a?/^[a-z][a-z\d+.-]*:\/\//i.test(a)?"Use the mounted folder path, not an smb:// or other network URL.":a==="~"||a.startsWith("~/")||a.startsWith("/")||a.startsWith("\\\\")||/^[a-z]:[\\/]/i.test(a)?null:"Enter an absolute mounted folder path.":"Enter a mounted folder path."}function Tn(s){return s==="network"?"Network":s==="removable"?"Removable":s==="cache"?"Cache":"Local"}function Ln(s){return s.mounted?s.writable?`${zn(s.freeBytes)} free`:"Read only":"Not mounted"}function As(s){const a=(s??"").trim().replace(/[\\/]+$/,"");return/^(?:[a-z]:[\\/]|\\\\)/i.test(a)?a.toLowerCase():a}function zn(s){if(s==null)return"Unknown";if(s<1024)return`${s} B`;const a=["KB","MB","GB","TB"];let n=s,t=-1;do n/=1024,t+=1;while(n>=1024&&t<a.length-1);return`${n>=10?n.toFixed(0):n.toFixed(1)} ${a[t]}`}function Un({state:s,catalog:a,busy:n,catalogLoading:t,onRefresh:l,onSave:i}){const[d,c]=r.useState(s?.settings.datasetStorePath??null);r.useEffect(()=>{c(s?.settings.datasetStorePath??null)},[s?.settings.datasetStorePath]);const o=r.useMemo(()=>s?.storageRoots.find(u=>Ds(u.datasetStorePath)===Ds(d))??null,[d,s?.storageRoots]),f=d===(s?.settings.datasetStorePath??null),x=a?.datasets??[];async function h(u){u.preventDefault(),await i(d)}return e.jsxs("section",{className:"account-settings compute-settings dataset-storage-settings",children:[e.jsxs("div",{className:"compute-title-row",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Dataset Storage"}),e.jsx("p",{className:"dataset-storage-intro",children:"Choose where Dataset artifacts are saved and review registered Datasets without loading their rows."})]}),e.jsx("button",{"aria-label":"Refresh Dataset storage",className:"settings-icon-button",disabled:n!==null||t,onClick:()=>{l()},title:"Refresh Dataset storage",type:"button",children:e.jsx(te,{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:o?.label??(d?"Manual location":"Not configured")}),e.jsx("small",{children:d??"Choose a writable local or mounted location before importing a Dataset."}),o?e.jsxs("small",{children:[Fn(o.kind)," · ",o.freeBytes==null?"Free space unknown":`${Ys(o.freeBytes)} free`]}):null]})})}),e.jsxs("form",{className:"provider-settings-form",onSubmit:u=>{h(u)},children:[e.jsx("div",{className:"account-list-heading",children:e.jsx("span",{children:"Location"})}),e.jsx($n,{disabled:n!==null,onChange:c,storageRoots:s?.storageRoots??[],value:d}),e.jsx("button",{className:"settings-primary",disabled:n!==null||f,children:n==="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:x.length})]}),x.length?x.map(u=>e.jsx(Bn,{dataset:u},u.tasksetId)):e.jsx("div",{className:"empty-account-list",children:e.jsx("span",{children:t?"Loading registered Datasets":"No registered Datasets"})})]})]})}function Bn({dataset:s}){const a=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:[Qs(s.rowCount)," rows"," · ",_n(s)," · ",a," · ",s.sizeBytes==null?"Size unavailable":Ys(s.sizeBytes)]}),!s.available&&s.unavailableReason?e.jsx("small",{className:"dataset-storage-error",children:s.unavailableReason}):null]}),e.jsx("span",{children:s.available?Hn(s.status):"Unavailable"})]})}function _n(s){return[["train",s.splitCounts.train],["validation",s.splitCounts.validation],["test",s.splitCounts.test],["frozen eval",s.splitCounts.frozen_eval]].filter(([,n])=>Number(n)>0).map(([n,t])=>`${Qs(Number(t))} ${n}`).join(" · ")||"No split rows"}function Ys(s){if(s<1024)return`${s} B`;const a=["KB","MB","GB","TB"];let n=s,t=-1;do n/=1024,t+=1;while(n>=1024&&t<a.length-1);return`${n>=10?n.toFixed(0):n.toFixed(1)} ${a[t]}`}function Qs(s){return new Intl.NumberFormat().format(s)}function Ds(s){return s?.replace(/[\\/]+$/,"")??""}function Hn(s){return s.replaceAll("_"," ").replace(/^./,a=>a.toUpperCase())}function Fn(s){return s.replace(/^./,a=>a.toUpperCase())}function we(s){if(!s)return"Not yet";const a=new Date(s);return Number.isNaN(a.valueOf())?s:a.toLocaleString()}function De(s){return s?s.slice(0,10):"none"}function Oe(s){const a=s.replaceAll("_"," ");return`${a.charAt(0).toUpperCase()}${a.slice(1)}`}function Gn({review:s}){const a=[["Taskset",s.tasksetProposal],["Baseline evaluation",s.evaluation],["Training qualification",s.trainingQualification]];return e.jsx("div",{className:"harness-review-lineage","aria-label":"Review lineage",children:a.map(([n,t])=>e.jsxs("div",{className:t?"linked":"pending",children:[e.jsx("span",{children:n}),e.jsx("code",{children:t?De(t.contentHash):"Not created"})]},n))})}function qn({accepting:s,onAcceptTasksetReview:a,review:n}){const t=n.classification==="taskset"&&n.nextAuthority==="human_review"&&n.tasksetProposal===null;return e.jsxs("article",{className:"harness-history-card harness-evaluation-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-${n.classification}`,children:Oe(n.classification)}),e.jsx("span",{children:Oe(n.nextAuthority)})]}),e.jsx("h2",{children:n.claim?.statement??n.reason})]}),e.jsx("time",{children:we(n.createdAt)})]}),e.jsx("p",{children:n.reason}),e.jsxs("div",{className:"harness-review-metrics",children:[e.jsxs("span",{children:[e.jsx("strong",{children:n.selectedEvidence.length})," selected"]}),e.jsxs("span",{children:[e.jsx("strong",{children:n.excludedEvidence.length})," excluded"]}),e.jsxs("span",{children:[e.jsx("strong",{children:n.claim?.independentOccurrences??0})," independent occurrences"]})]}),e.jsx(Gn,{review:n}),t?e.jsx("div",{className:"harness-history-actions",children:e.jsx("button",{className:"settings-primary compact",disabled:s,onClick:()=>a(n),type:"button",children:s?"Opening Taskset review…":"Build training Taskset"})}):null]})}function Wn({receipt:s}){return e.jsxs("article",{className:"harness-route-card harness-qualification-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:`harness-status harness-status-${s.decision}`,children:Oe(s.decision)}),e.jsxs("strong",{children:[s.model.provider,"/",s.model.model]}),e.jsx("time",{children:we(s.createdAt)})]}),e.jsx("p",{children:s.reasons.join(" ")}),e.jsxs("small",{children:["Review ",De(s.review.contentHash)," · Taskset ",De(s.tasksetRelease?.contentHash)," · Baseline ",De(s.baselineEvaluation?.contentHash)]})]})}function Vn({acceptingReviewId:s,backgroundReviewBusy:a,backgroundReviewEnabled:n,busy:t,onBackgroundReviewChange:l,onAcceptTasksetReview:i,reviews:d,candidates:c,qualifications:o,schedule:f,onReview:x,onSaveSchedule:h}){const[u,m]=r.useState(f.cadence),[j,b]=r.useState(f.enabled),[S,C]=r.useState(f.activityEnabled),[k,P]=r.useState(f.activityBatchSize);r.useEffect(()=>{m(f.cadence),b(f.enabled),C(f.activityEnabled),P(f.activityBatchSize)},[f.activityBatchSize,f.activityEnabled,f.cadence,f.enabled]);const D=u!==f.cadence||j!==f.enabled||S!==f.activityEnabled||k!==f.activityBatchSize;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:"Continuous learning"}),e.jsx("p",{children:"Review each completed turn, and separately look across Work for recurring evidence when you choose."})]}),e.jsxs("div",{className:"harness-section-actions",children:[e.jsx("button",{className:"settings-secondary compact",disabled:t,onClick:()=>x(f.maxEstimatedCostUsd),type:"button",children:"Review now"}),e.jsx("button",{className:"settings-primary compact",disabled:t||!D,onClick:()=>h({enabled:j,activityEnabled:S,activityBatchSize:k,cadence:u,maxEstimatedCostUsd:f.maxEstimatedCostUsd}),type:"button",children:"Update schedule"})]})]}),e.jsxs("section",{className:"harness-learning-card","aria-label":"Continuous learning controls",children:[e.jsxs("label",{className:"harness-learning-setting",children:[e.jsxs("span",{className:"harness-learning-copy",children:[e.jsx("strong",{children:"Refiner"}),e.jsx("small",{children:"Review each completed turn for reusable improvements. This is enabled by default for new users."})]}),e.jsxs("span",{className:"provider-toggle harness-learning-toggle",children:[e.jsx("input",{checked:n,disabled:a,onChange:g=>l(g.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsxs("label",{className:"harness-learning-setting",children:[e.jsxs("span",{className:"harness-learning-copy",children:[e.jsx("strong",{children:"Activity review"}),e.jsx("small",{children:"Review after a bounded batch of new outcomes. Unchanged evidence does not call the model."})]}),e.jsxs("span",{className:"provider-toggle harness-learning-toggle",children:[e.jsx("input",{checked:S,disabled:t,onChange:g=>C(g.target.checked),type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("div",{className:"harness-learning-schedule",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Activity batch"}),e.jsxs("select",{disabled:t||!S,onChange:g=>P(Number(g.target.value)),value:k,children:[e.jsx("option",{value:5,children:"5 new outcomes"}),e.jsx("option",{value:10,children:"10 new outcomes"}),e.jsx("option",{value:20,children:"20 new outcomes"}),e.jsx("option",{value:50,children:"50 new outcomes"})]})]})}),e.jsxs("label",{className:"harness-learning-setting",children:[e.jsxs("span",{className:"harness-learning-copy",children:[e.jsx("strong",{children:"Scheduled backstop"}),e.jsx("small",{children:"Optionally review daily or weekly when activity is low. This is the same cross-Work reviewer, not another learning loop."})]}),e.jsxs("span",{className:"provider-toggle harness-learning-toggle",children:[e.jsx("input",{checked:j,disabled:t,onChange:g=>{b(g.target.checked),g.target.checked&&u==="manual"&&m("daily")},type:"checkbox"}),e.jsx("span",{"aria-hidden":"true"})]})]}),e.jsx("div",{className:"harness-learning-schedule",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Cadence"}),e.jsxs("select",{disabled:t||!j,onChange:g=>{const E=g.target.value;m(E)},value:u==="manual"?"daily":u,children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"})]})]})}),e.jsxs("dl",{className:"harness-learning-run-times",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Last run"}),e.jsx("dd",{children:we(f.lastRunAt)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Next scheduled run"}),e.jsx("dd",{children:f.enabled?we(f.nextRunAt):"Off"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Activity trigger"}),e.jsx("dd",{children:f.activityEnabled?`${f.activityBatchSize} new outcomes`:"Off"})]})]})]})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Cross-Work candidates"}),e.jsx("p",{children:"Persistent patterns carried across review windows until confirmed, resolved, rejected, or expired."})]}),e.jsx("span",{children:c.length})]}),c.length?c.map(g=>e.jsxs("article",{className:"harness-history-card harness-evaluation-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-${g.status}`,children:Oe(g.status)}),e.jsxs("span",{children:[g.occurrences.length," occurrences"]})]}),e.jsx("h2",{children:g.statement})]}),e.jsx("time",{children:we(g.updatedAt)})]}),e.jsx("p",{children:g.resolution?.reason??g.recurrenceFamily})]},`${g.id}:${g.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No cross-Work candidates yet."})]}),e.jsxs("section",{className:"harness-history-section",children:[e.jsxs("div",{className:"harness-section-heading",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Evaluation reviews"}),e.jsx("p",{children:"Immutable review receipts and their downstream lineage."})]}),e.jsx("span",{children:d.length})]}),d.length?d.map(g=>e.jsx(qn,{accepting:s===g.id,onAcceptTasksetReview:i,review:g},`${g.id}:${g.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No model improvement reviews have run."})]}),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 qualifications"}),e.jsx("p",{children:"Evidence-bound decisions that permit a specific training method or record why training is not warranted."})]}),e.jsx("span",{children:o.length})]}),o.length?o.map(g=>e.jsx(Wn,{receipt:g},`${g.id}:${g.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No review has reached training qualification."})]})]})}const Kn={enabled:!0,activityEnabled:!0,activityBatchSize:10,cadence:"daily",maxEstimatedCostUsd:.1,nextRunAt:null,lastRunAt:null,lastResult:null,lastError:null,updatedAt:null};function Pe(s){const a=new Date(s);return Number.isNaN(a.valueOf())?s:a.toLocaleString()}function Te(s){return s?s.slice(0,10):"none"}function Es(s,a,n){return{workspaceId:s,baseRelease:a?{id:a.id,contentHash:a.contentHash}:null,targetRelease:{id:n.id,contentHash:n.contentHash},title:n.current?"Current Harness release":`Harness release ${Te(n.contentHash)}`}}function Jn({change:s,onOpenDiff:a,onOpenSourceSession:n}){const t=s.trigger?.runRef??null,l=s.proposal;return e.jsxs("article",{className:"harness-history-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-${s.receipt.decision}`,children:s.receipt.decision.replaceAll("_"," ")}),e.jsx("span",{children:l?.route??(s.receipt.rollbackOf?"rollback":"workspace")})]}),e.jsx("h2",{children:l?.expectedOutcome??s.receipt.reason})]}),e.jsx("time",{children:Pe(s.receipt.createdAt)})]}),e.jsxs("div",{className:"harness-history-release-flow",children:[e.jsx("code",{children:Te(s.receipt.previousRelease?.contentHash)}),e.jsx("span",{"aria-hidden":"true",children:"→"}),e.jsx("code",{children:Te(s.receipt.nextRelease?.contentHash)}),e.jsxs("span",{children:["channel ",s.receipt.previousChannelRevision," → ",s.receipt.nextChannelRevision]})]}),e.jsx("p",{children:s.receipt.reason}),a||t&&n?e.jsxs("div",{className:"harness-history-actions",children:[a?e.jsx("button",{className:"settings-secondary compact",onClick:a,type:"button",children:"View release diff"}):null,t&&n?e.jsx("button",{className:"settings-secondary compact",onClick:()=>n(t),type:"button",children:"Open source conversation"}):null]}):null,l?e.jsxs("details",{className:"harness-history-details",children:[e.jsxs("summary",{children:["Review ",l.edits.length," exact edit",l.edits.length===1?"":"s"]}),e.jsx("div",{className:"harness-edit-list",children:l.edits.map(i=>e.jsxs("section",{className:"harness-edit",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[i.operation," · ",i.target]}),e.jsx("span",{children:i.summary})]}),i.content!==null?e.jsx("pre",{children:i.content}):e.jsx("p",{children:"File deleted."})]},i.id))})]}):null,s.validations.length?e.jsx("div",{className:"harness-validation-list",children:s.validations.map(i=>e.jsxs("div",{children:[e.jsx("span",{className:`harness-validation-status ${i.status}`,children:i.status}),e.jsx("strong",{children:i.kind.replaceAll("_"," ")}),e.jsx("span",{children:i.summary})]},i.id))}):null,s.outcome?e.jsxs("footer",{children:[e.jsxs("span",{children:["Refiner: ",s.outcome.decision.replaceAll("_"," ")]}),e.jsxs("span",{children:["Estimated cost $",s.outcome.estimatedCostUsd.toFixed(4)]})]}):null]})}function Yn({route:s}){return e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("span",{className:"harness-status harness-status-retained",children:"recommendation"}),e.jsx("strong",{children:s.decision.route}),e.jsx("time",{children:Pe(s.decision.createdAt)})]}),e.jsx("p",{children:s.decision.reason}),s.trigger?e.jsxs("small",{children:["Triggered by ",s.trigger.reason]}):null]})}function Qn({review:s,busy:a,onReview:n}){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",open:!0,children:[e.jsxs("summary",{children:["Review ",s.proposal.edits.length," exact edit",s.proposal.edits.length===1?"":"s"]}),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))})]}),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))}),e.jsxs("footer",{className:"harness-review-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:a,onClick:()=>n(s,"decline"),type:"button",children:[e.jsx(le,{size:13})," Decline"]}),e.jsxs("button",{className:"settings-primary compact",disabled:a||s.validations.some(t=>t.status!=="passed"),onClick:()=>n(s,"approve"),type:"button",children:[e.jsx(Os,{size:13})," Approve and release"]})]})]})}function Zn({baseRelease:s,release:a,busy:n,onOpenDiff:t,onRollback:l}){const[i,d]=r.useState(!1);return e.jsxs("div",{className:"harness-release-row",children:[e.jsxs("div",{children:[e.jsx("strong",{children:a.current?"Current release":a.id}),e.jsxs("span",{children:[Te(a.contentHash)," · ",a.files.length," files · ",Pe(a.createdAt)]})]}),i?e.jsxs("div",{className:"harness-inline-actions",children:[e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>d(!1),type:"button",children:[e.jsx(le,{size:13})," Cancel"]}),e.jsxs("button",{className:"settings-primary compact",disabled:n,onClick:()=>{d(!1),l(a)},type:"button",children:[e.jsx(Ie,{size:13})," Confirm rollback"]})]}):e.jsxs("div",{className:"harness-inline-actions",children:[a.current?e.jsx("span",{className:"harness-current-pill",children:"current"}):null,e.jsx("button",{className:"settings-secondary compact",onClick:()=>t(s,a),type:"button",children:"View changes"}),a.current?null:e.jsxs("button",{className:"settings-secondary compact",disabled:n,onClick:()=>d(!0),type:"button",children:[e.jsx(Ie,{size:13})," Roll back"]})]})]})}function Xn({connection:s,enabled:a,onAcceptEvaluationReview:n,onError:t,onDefaultReleaseDiff:l,onOpenReleaseDiff:i,onOpenSourceSession:d,onToast:c}){const[o,f]=r.useState(null),[x,h]=r.useState(!1),[u,m]=r.useState(null),[j,b]=r.useState(null),[S,C]=r.useState(!1),[k,P]=r.useState(!1),[D,g]=r.useState(null),[E,R]=r.useState(!1),z=r.useCallback(async()=>{if(s){h(!0);try{const A=await I.harnessHistory(s);f(A);const w=A.releases.findIndex(Q=>Q.current),O=w>=0?A.releases[w]:null;A.workspace&&O&&l(Es(A.workspace.id,A.releases[w+1]??null,O)),t(null)}catch(A){t(A instanceof Error?A.message:String(A))}finally{h(!1)}}},[s,l,t]);r.useEffect(()=>{a&&z()},[a,z]);const p=r.useCallback(async A=>{if(!(!s||!o?.workspace)){C(!0);try{const w=await I.updateHarnessBackgroundReview(s,{workspaceId:o.workspace.id,enabled:A});f(w.history),t(null),c?.(A?"Harness background review enabled.":"Harness background review disabled.","info")}catch(w){t(w instanceof Error?w.message:String(w))}finally{C(!1)}}},[s,o?.workspace,t,c]),N=r.useCallback(async A=>{if(!(!s||!o?.workspace)){P(!0);try{const w=await I.reviewHarnessEvaluation(s,{workspaceId:o.workspace.id,maxEstimatedCostUsd:A});f(w.history),t(null),c?.(`Harness review completed: ${w.receipt.classification.replaceAll("_"," ")}.`,"success")}catch(w){t(w instanceof Error?w.message:String(w))}finally{P(!1)}}},[s,o?.workspace,t,c]),y=r.useCallback(async A=>{if(!(!s||!o?.workspace)){R(!0);try{const w=await I.updateHarnessEvaluationReviewSchedule(s,{workspaceId:o.workspace.id,...A});f(w.history),t(null),c?.(A.enabled?"Harness review schedule saved.":"Harness review schedule disabled.","info")}catch(w){t(w instanceof Error?w.message:String(w))}finally{R(!1)}}},[s,o?.workspace,t,c]),v=r.useCallback(async A=>{if(o?.workspace){g(A.id);try{await n(o.workspace.id,{id:A.id,contentHash:A.contentHash})&&(t(null),c?.("Taskset review opened in Models.","success"))}catch(w){t(w instanceof Error?w.message:String(w))}finally{g(null)}}},[o?.workspace,n,t,c]),M=r.useCallback((A,w)=>{o?.workspace&&i(Es(o.workspace.id,A,w))},[o?.workspace,i]),T=r.useCallback(A=>{!o?.workspace||!A.receipt.nextRelease||i({workspaceId:o.workspace.id,baseRelease:A.receipt.previousRelease,targetRelease:A.receipt.nextRelease,title:A.proposal?.expectedOutcome??A.receipt.reason})},[o?.workspace,i]),q=r.useCallback(async A=>{if(!(!s||!o?.workspace)){m(A.contentHash);try{const w=await I.rollbackHarness(s,{workspaceId:o.workspace.id,targetRelease:{id:A.id,contentHash:A.contentHash}});f(w.history),t(null),c?.("Personal Harness rolled back. Existing runs remain pinned.","success")}catch(w){t(w instanceof Error?w.message:String(w))}finally{m(null)}}},[s,o?.workspace,t,c]),V=r.useCallback(async(A,w)=>{if(!(!s||!o?.workspace)){b(A.proposal.id);try{const O=await I.reviewHarnessProposal(s,{workspaceId:o.workspace.id,proposal:{id:A.proposal.id,contentHash:A.proposal.contentHash},decision:w});f(O.history),t(null),c?.(w==="approve"?"Harness proposal approved and released.":"Harness proposal declined.",w==="approve"?"success":"info")}catch(O){t(O instanceof Error?O.message:String(O))}finally{b(null)}}},[s,o?.workspace,t,c]);return e.jsxs("section",{className:"account-settings harness-history-settings","aria-labelledby":"harness-history-title",children:[e.jsxs("div",{className:"account-settings-title",children:[e.jsxs("div",{children:[e.jsx("h1",{id:"harness-history-title",children:"Harness"}),e.jsx("p",{children:"Immutable releases, Refiner changes, validation evidence, and rollback history."})]}),e.jsxs("button",{className:"settings-secondary",disabled:x,onClick:()=>{z()},type:"button",children:[e.jsx(te,{className:x?"settings-spin":void 0,size:14})," Refresh"]})]}),s?null:e.jsx("div",{className:"harness-empty",children:"Connect to the Local OpenPond server to inspect the Harness."}),s&&x&&!o?e.jsx("div",{className:"harness-empty",children:"Loading Harness history…"}):null,o&&!o.workspace?e.jsx("div",{className:"harness-empty",children:"No Personal Harness workspace has been created yet."}):null,o?.workspace?e.jsxs(e.Fragment,{children:[e.jsx(Vn,{acceptingReviewId:D,backgroundReviewBusy:S,backgroundReviewEnabled:o.backgroundReview.enabled,busy:k||E,onBackgroundReviewChange:A=>{p(A)},onAcceptTasksetReview:A=>{v(A)},onReview:A=>{N(A)},onSaveSchedule:A=>{y(A)},qualifications:o.modelImprovementQualifications,candidates:o.refinementCandidates,reviews:o.evaluationReviews,schedule:o.evaluationReviewSchedule??Kn}),e.jsxs("section",{className:"account-list",children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Releases"}),e.jsx("small",{children:"New runs use current; active runs stay pinned."})]}),o.releases.map((A,w)=>e.jsx(Zn,{baseRelease:o.releases[w+1]??null,busy:u!==null,onOpenDiff:M,onRollback:q,release:A},`${A.id}:${A.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:"Needs review"}),e.jsx("p",{children:"Executable, Agent, destructive, and sensitive changes never advance without your approval."})]}),e.jsx("span",{children:o.pendingReviews.length})]}),o.pendingReviews.length?o.pendingReviews.map(A=>e.jsx(Qn,{busy:j!==null,onReview:V,review:A},`${A.proposal.id}:${A.proposal.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No Harness proposals need 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:"Applied history"}),e.jsx("p",{children:"Every release transition with its exact change and validation receipts."})]}),e.jsx("span",{children:o.changes.length})]}),o.changes.length?o.changes.map(A=>e.jsx(Jn,{change:A,onOpenDiff:A.receipt.nextRelease?()=>T(A):void 0,onOpenSourceSession:d},`${A.receipt.id}:${A.receipt.contentHash}`)):e.jsx("div",{className:"harness-empty",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:"Runtime, memory, product, Taskset, and training observations that did not mutate the Harness."})]}),e.jsx("span",{children:o.routes.length})]}),o.routes.length?o.routes.map(A=>e.jsx(Yn,{route:A},`${A.decision.id}:${A.decision.contentHash}`)):e.jsx("div",{className:"harness-empty",children:"No external recommendations have been routed."})]}),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 external memory available through search; it is not copied into every Agent prompt or sandbox."})]}),e.jsx("span",{children:o.memories.length})]}),o.memories.length?o.memories.map(A=>e.jsxs("article",{className:"harness-route-card",children:[e.jsxs("div",{children:[e.jsx("strong",{children:A.key}),e.jsxs("span",{children:["revision ",A.revision]}),e.jsx("time",{children:Pe(A.updatedAt)})]}),e.jsx("p",{children:A.content}),A.tags.length?e.jsx("small",{children:A.tags.join(" · ")}):null]},`${A.id}:${A.revision}`)):e.jsx("div",{className:"harness-empty",children:"No Harness memory has been saved."})]})]}):null]})}function $s(s){return s?s.slice(0,10):"initial"}function el({connection:s,expanded:a,onResizeStart:n,onToggleExpanded:t,selection:l}){const[i,d]=r.useState(null),[c,o]=r.useState(null),[f,x]=r.useState(!0),h=r.useCallback(async()=>{o(null),x(!0);try{d(await I.harnessReleaseDiff(s,l))}catch(j){d(null),o(j instanceof Error?j.message:String(j))}finally{x(!1)}},[s,l]);r.useEffect(()=>{h()},[h]);const u=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(j=>j.path),files:i.files,error:null,updatedAt:""}:null,[i,l.title,l.workspaceId]),m=`${l.title} · ${$s(l.baseRelease?.contentHash)} → ${$s(l.targetRelease.contentHash)}`;return e.jsx(Va,{appId:`harness:${l.workspaceId}`,workspaceId:`harness:${l.targetRelease.contentHash}`,workspaceKind:"local_project",connection:s,diff:u,editorPreferences:null,expanded:a,filesWithPreview:!0,loading:f,onOpenBrowserUrl:()=>{},onRefresh:h,onResizeStart:n,onToggleExpanded:t,readOnly:!0,workspaceError:c,workspaceInitialized:!0,workspaceName:m})}function sl({connection:s,onError:a,onPayload:n}){const[t,l]=r.useState(!1),[i,d]=r.useState(!1);async function c(h,u){if(s){l(!0),a(null);try{const m=await I.switchOpenPondAccount(s,{handle:h,baseUrl:u??null}),j=await I.savePreferences(s,{defaultTeamId:null});n({...m,preferences:j.preferences})}catch(m){a(m instanceof Error?m.message:String(m))}finally{l(!1)}}}async function o(h,u){if(!s)return!1;l(!0),a(null);try{return n(await I.removeOpenPondAccount(s,{handle:h,baseUrl:u??null})),!0}catch(m){return a(m instanceof Error?m.message:String(m)),!1}finally{l(!1)}}async function f(h){if(!(!s||!h.apiKey.trim())){l(!0),a(null);try{const u=h.handle?.trim(),m=h.environment?.trim(),j=await I.saveOpenPondAccount(s,{apiKey:h.apiKey.trim(),handle:u||void 0,baseUrl:h.baseUrl,apiBaseUrl:h.apiBaseUrl,environment:m||"custom",setActive:!0}),b=await I.savePreferences(s,{defaultTeamId:null});n({...j,preferences:b.preferences})}catch(u){throw a(u instanceof Error?u.message:String(u)),u}finally{l(!1)}}}async function x(){if(s){d(!0),a(null);try{n(await I.refreshOpenPondAccounts(s))}catch(h){a(h instanceof Error?h.message:String(h))}finally{d(!1)}}}return{refreshingAccounts:i,saving:t,refreshAccounts:x,removeAccount:o,saveAccount:f,switchAccount:c}}function al({connection:s,onError:a,onPreferences:n,preferences:t,providers:l}){const[i,d]=r.useState(t.defaultBranchPrefix),[c,o]=r.useState(t.defaultNewProjectDirectory),[f,x]=r.useState(t.advancedWorkspaceControls),[h,u]=r.useState(t.contextCompaction.autoEnabled),[m,j]=r.useState(t.subagents.enabled),[b,S]=r.useState(t.subagents.delegationMode),[C,k]=r.useState(!t.subagents.defaultModelRef),[P,D]=r.useState(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),[g,E]=r.useState(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),[R,z]=r.useState(t.subagents.roles),[p,N]=r.useState(t.subagents.maxConcurrentRuns),[y,v]=r.useState(t.subagents.maxConcurrentRunsPerProvider),[M,T]=r.useState(t.subagents.maxConcurrentRunsPerWorkspaceTarget),[q,V]=r.useState(!1),A=C?null:{providerId:P,modelId:g.trim()},w=m!==t.subagents.enabled||b!==t.subagents.delegationMode||!tl(A,t.subagents.defaultModelRef)||p!==t.subagents.maxConcurrentRuns||y!==t.subagents.maxConcurrentRunsPerProvider||M!==t.subagents.maxConcurrentRunsPerWorkspaceTarget||JSON.stringify(R)!==JSON.stringify(t.subagents.roles);r.useEffect(()=>{d(t.defaultBranchPrefix),o(t.defaultNewProjectDirectory),x(t.advancedWorkspaceControls),u(t.contextCompaction.autoEnabled),j(t.subagents.enabled),S(t.subagents.delegationMode),k(!t.subagents.defaultModelRef),D(t.subagents.defaultModelRef?.providerId??t.defaultChatProvider),E(t.subagents.defaultModelRef?.modelId??t.defaultChatModel),z(t.subagents.roles),N(t.subagents.maxConcurrentRuns),v(t.subagents.maxConcurrentRunsPerProvider),T(t.subagents.maxConcurrentRunsPerWorkspaceTarget)},[t.defaultChatProvider,t.defaultChatModel,t.defaultBranchPrefix,t.defaultNewProjectDirectory,t.advancedWorkspaceControls,t.contextCompaction.autoEnabled,t.subagents]);function O(L){D(L),E(_=>ss(L,_,l))}function Q(){return C?t.defaultChatProvider:P}function J(){return C?t.defaultChatModel:g}function W(L,_){z(F=>F.map(B=>B.id===L?_(B):B))}function Z(L,_){W(L,F=>({...F,enabled:_}))}function K(L,_){W(L,F=>({...F,background:_}))}function U(L,_){W(L,F=>{if(_)return{...F,modelRef:null};const B=F.modelRef?.providerId??Q(),H=F.modelRef?.modelId??J();return{...F,modelRef:He(B,H,l)??null}})}function se(L,_){W(L,F=>({...F,modelRef:He(_,F.modelRef?.modelId??J(),l)??null}))}function ie(L,_){W(L,F=>{const B=F.modelRef?.providerId??Q(),H=_.trim();return{...F,modelRef:H?{providerId:B,modelId:H}:null}})}function ce(L,_){W(L,F=>({...F,isolationMode:_}))}function re(L,_){W(L,F=>({...F,toolPolicy:_}))}function ne(L,_){W(L,F=>({...F,peerMessages:_}))}function ee(L,_){W(L,F=>({...F,maxConcurrentRuns:xe(_,1,16)}))}async function fe(){let L=null;if(window.openpond?.selectFolder){const _=await window.openpond.selectFolder();if(_.canceled)return;L=_.path}else L=window.prompt("Default new project directory",c);L?.trim()&&o(L.trim())}async function oe(L){if(L.preventDefault(),!!s){V(!0),a(null);try{n(await I.savePreferences(s,{defaultBranchPrefix:Ye(i),defaultNewProjectDirectory:c.trim(),advancedWorkspaceControls:f,contextCompaction:{...t.contextCompaction,autoEnabled:h},subagents:{enabled:m,workspaceDefaultsVersion:t.subagents.workspaceDefaultsVersion,toolDefaultsVersion:t.subagents.toolDefaultsVersion,delegationMode:b,defaultModelRef:C?null:He(P,g,l)??null,roles:R,maxConcurrentRuns:xe(p,1,32),maxConcurrentRunsPerProvider:y===null?null:xe(y,1,32),maxConcurrentRunsPerWorkspaceTarget:M===null?null:xe(M,1,32)}}))}catch(_){a(_ instanceof Error?_.message:String(_))}finally{V(!1)}}}return{advancedWorkspaceControls:f,contextCompactionAutoEnabled:h,defaultBranchPrefix:i,defaultNewProjectDirectory:c,subagentsEnabled:m,subagentDelegationMode:b,subagentsUseDefaultModel:C,subagentsProvider:P,subagentsModel:g,subagentRoles:R,subagentsMaxConcurrentRuns:p,subagentsMaxConcurrentRunsPerProvider:y,subagentsMaxConcurrentRunsPerWorkspaceTarget:M,subagentsDirty:w,saving:q,chooseDefaultProjectDirectory:fe,saveDefaults:oe,changeSubagentsProvider:O,changeSubagentRoleProvider:se,setAdvancedWorkspaceControls:x,setContextCompactionAutoEnabled:u,setDefaultBranchPrefix:d,setDefaultNewProjectDirectory:o,setSubagentsUseDefaultModel:k,setSubagentsModel:E,setSubagentsEnabled:j,setSubagentDelegationMode:L=>S(L),setSubagentsMaxConcurrentRuns:L=>N(xe(L,1,32)),setSubagentsMaxConcurrentRunsPerProvider:L=>v(L===null?null:xe(L,1,32)),setSubagentsMaxConcurrentRunsPerWorkspaceTarget:L=>T(L===null?null:xe(L,1,32)),setSubagentRoleBackground:K,setSubagentRoleEnabled:Z,setSubagentRoleIsolationMode:ce,setSubagentRoleMaxConcurrentRuns:ee,setSubagentRoleModel:ie,setSubagentRolePeerMessages:ne,setSubagentRoleToolPolicy:re,setSubagentRoleUseDefaultModel:U}}function xe(s,a,n){return Number.isFinite(s)?Math.min(n,Math.max(a,Math.trunc(s))):a}function tl(s,a){return(s?.providerId??null)===(a?.providerId??null)&&(s?.modelId??null)===(a?.modelId??null)}const nl=15e3,ll=100,il=100,rl=2500;function ol({onError:s,section:a}){const[n,t]=r.useState(null),[l,i]=r.useState(null),[d,c]=r.useState(ll),[o,f]=r.useState([]),[x,h]=r.useState(null),[u,m]=r.useState(!0),j=r.useRef(null),[b,S]=r.useState(null),C=!!(window.openpond?.openLogsFolder||window.openpond?.readRecentLogs||window.openpond?.copyRecentLogs||window.openpond?.exportDiagnostics),P=!!window.openpond?.readRecentLogs?`${o.length} of ${d} line${d===1?"":"s"}${u?" tailing":""}`:"Unavailable";r.useEffect(()=>{a==="diagnostics"&&D(d,"refresh",{quiet:!0})},[a]),r.useEffect(()=>{if(a!=="diagnostics"||!u||!window.openpond?.readRecentLogs)return;let N=!1;const y=window.setInterval(()=>{N||(N=!0,D(d,"refresh",{quiet:!0}).finally(()=>{N=!1}))},rl);return()=>window.clearInterval(y)},[a,u,d]),r.useEffect(()=>{if(a!=="diagnostics"||!u)return;const N=j.current;N&&(N.scrollTop=N.scrollHeight)},[a,u,o]);async function D(N=d,y="refresh",v={}){const M=window.openpond?.readRecentLogs;if(!M){const T="Log view is not available in this runtime.";v.quiet||(S({label:"Logs",value:T,warning:!0}),s(T));return}v.quiet||i(y);try{const T=await Re(M(N),"Read logs");if(!T.ok)throw new Error(T.error);c(T.lineLimit),h(T.logDir),f(T.lines),v.quiet?S(q=>q?.label==="Logs"?null:q):S(null)}catch(T){const q=T instanceof Error?T.message:String(T);S({label:"Logs",value:q,warning:!0}),v.quiet||s(q)}finally{v.quiet||i(null)}}function g(){m(!1),D(d+il,"older")}function E(){const N=!u;m(N),N&&D(d,"refresh",{quiet:!0})}async function R(){const N=window.openpond?.openLogsFolder;if(!N){const y="Desktop logs are not available in this runtime.";S({label:"Logs",value:y,warning:!0}),s(y);return}t("logs"),s(null);try{const y=await Re(N(),"Open logs");if(!y.ok)throw new Error(y.error??"Could not open the logs folder.");S(null)}catch(y){const v=y instanceof Error?y.message:String(y);S({label:"Logs",value:v,warning:!0}),s(v)}finally{t(null)}}async function z(){const N=window.openpond?.copyRecentLogs;if(!N){const y="Recent log copy is not available in this runtime.";S({label:"Copy",value:y,warning:!0}),s(y);return}t("copy"),s(null);try{const y=await Re(N(1e3),"Copy recent logs");if(!y.ok)throw new Error(y.error??"Could not copy recent logs.");S({label:"Copy",value:y.lines?`Copied ${y.lines} recent log lines.`:"Copied recent logs."})}catch(y){const v=y instanceof Error?y.message:String(y);S({label:"Copy",value:v,warning:!0}),s(v)}finally{t(null)}}async function p(){const N=window.openpond?.exportDiagnostics;if(!N){const y="Diagnostics export is not available in this runtime.";S({label:"Export",value:y,warning:!0}),s(y);return}t("export"),s(null);try{const y=await Re(N(),"Export diagnostics");if(!y.ok)throw new Error(y.error??"Could not export diagnostics.");S({label:"Export",value:y.path?`Saved to ${y.path}`:"Diagnostics exported."})}catch(y){const v=y instanceof Error?y.message:String(y);S({label:"Export",value:v,warning:!0}),s(v)}finally{t(null)}}return{diagnosticsAvailable:C,diagnosticsBusy:n,diagnosticsStatus:b,logDir:x,logLineLimit:d,logLines:o,logViewBusy:l,logViewSummary:P,logViewportRef:j,tailLogs:u,copyRecentLogs:z,exportDiagnosticsBundle:p,loadOlderLogs:g,openLogsFolder:R,refreshLogView:D,toggleTailLogs:E}}async function Re(s,a){let n;try{return await Promise.race([s,new Promise((t,l)=>{n=window.setTimeout(()=>{l(new Error(`${a} did not receive a desktop response.`))},nl)})])}finally{n!==void 0&&window.clearTimeout(n)}}function cl({connection:s,enabled:a,onError:n,onPreferences:t,onToast:l,preferences:i}){const[d,c]=r.useState(i.editor),[o,f]=r.useState(null),[x,h]=r.useState(!1),[u,m]=r.useState(!1),[j,b]=r.useState(!1);r.useEffect(()=>{c(i.editor)},[i.editor]);const S=r.useCallback(async()=>{if(s){m(!0);try{f(await I.workspaceLspSettingsStatus(s))}catch(g){n(g instanceof Error?g.message:String(g))}finally{m(!1)}}},[s,n]);r.useEffect(()=>{!a||!s||S()},[s,a,S]);function C(g,E){c(R=>({...R,languages:{...R.languages,[g]:{...R.languages[g],mode:E}}}))}function k(g,E){c(R=>({...R,languages:{...R.languages,[g]:{...R.languages[g],customCommand:E}}}))}async function P(g){if(g.preventDefault(),!!s){h(!0),n(null);try{const E=await I.savePreferences(s,{editor:d});t(E),f(await I.workspaceLspSettingsStatus(s))}catch(E){n(E instanceof Error?E.message:String(E))}finally{h(!1)}}}async function D(){if(s){b(!0),n(null);try{await I.restartWorkspaceLsp(s),f(await I.workspaceLspSettingsStatus(s)),l?.("Language servers restarted.","success")}catch(g){n(g instanceof Error?g.message:String(g))}finally{b(!1)}}}return{editorPreferences:d,lspStatus:o,restarting:j,saving:x,statusLoading:u,refreshLspStatus:S,restartLanguageServers:D,saveEditorSettings:P,setEditorPreferences:c,setLanguageCustomCommand:k,setLanguageMode:C}}function dl({connection:s,onError:a,onPayload:n,personalization:t}){const l=r.useMemo(()=>t.templates.map(p=>({value:p.id,label:p.name,description:p.id===t.activeTemplateId?"Selected":p.source==="built_in"?p.description:void 0})),[t.activeTemplateId,t.templates]),[i,d]=r.useState(t.activeTemplateId),[c,o]=r.useState(t.soul),[f,x]=r.useState(""),[h,u]=r.useState(!1),[m,j]=r.useState(!1),b=t.templates.find(p=>p.id===i)??t.templates[0],S=b?.source==="custom",C=b?c!==b.content:!0,k=i!==t.activeTemplateId||c!==t.soul||C,P=!!(S&&c.trim()&&b&&k);r.useEffect(()=>{d(t.activeTemplateId),o(t.soul);const p=t.templates.find(N=>N.id===t.activeTemplateId);x(p?`${p.name} Copy`:""),u(!1)},[t.activeTemplateId,t.soul,t.templates]);async function D(p=!1){if(!p&&!S)return;const N=p?f:b?.name;if(!(!s||!c.trim()||!N?.trim())){j(!0),a(null);try{n(await I.savePersonalization(s,{activeTemplateId:i,templateName:N,soul:c,saveAsNew:p})),u(!1)}catch(y){a(y instanceof Error?y.message:String(y))}finally{j(!1)}}}async function g(p){const N=t.templates.find(y=>y.id===p);if(N&&(d(N.id),x(`${N.name} Copy`),o(N.content),u(!1),!!s)){j(!0),a(null);try{n(await I.savePersonalization(s,{activeTemplateId:N.id,templateName:N.name,soul:N.content,saveAsNew:!1}))}catch(y){a(y instanceof Error?y.message:String(y))}finally{j(!1)}}}function E(){b&&(x(`${b.name} Copy`),o(b.content),u(!1))}function R(p){o(p),b&&!S&&p!==b.content&&u(!0)}function z(){b&&(x(`${b.name} Copy`),u(!0))}return{canSaveCurrentTemplate:P,personalizationTemplateId:i,personalizationTemplateOptions:l,saveAsNewOpen:h,saving:m,selectedPersonalizationTemplate:b,selectedTemplateIsCustom:S,soulDraft:c,templateNameDraft:f,changePersonalizationTemplate:g,changeSoulDraft:R,openSaveAsNew:z,resetPersonalizationDraft:E,savePersonalization:D,setSaveAsNewOpen:u,setTemplateNameDraft:x}}function ul({connection:s,onError:a,onPreferences:n,onProviders:t,preferences:l,providers:i}){const[d,c]=r.useState(l.defaultChatProvider),[o,f]=r.useState(l.defaultChatModel),[x,h]=r.useState(!1),[u,m]=r.useState(null),[j,b]=r.useState(null);r.useEffect(()=>{c(l.defaultChatProvider),f(l.defaultChatModel)},[l.defaultChatProvider,l.defaultChatModel]);async function S(y){if(y.preventDefault(),!!s){h(!0),a(null);try{n(await I.savePreferences(s,{defaultChatProvider:d,defaultChatModel:ss(d,o,i)}))}catch(v){a(v instanceof Error?v.message:String(v))}finally{h(!1)}}}function C(y){c(y),f(v=>ss(y,v,i))}async function k(y,v,M){if(!s)return null;m(`${y}:${v}`),b(null),a(null);try{return await M()}catch(T){return a(T instanceof Error?T.message:String(T)),null}finally{m(null)}}async function P(y,v){await k(y,"config",async()=>{const M=await I.saveProviderSettings(s,{providers:{[y]:v}});return t(M),M})}async function D(y,v){await k(y,"credential",async()=>{const M=await I.saveProviderCredential(s,y,v);return t(M),M})}async function g(y){await k(y,"credential",async()=>{const v=await I.deleteProviderCredential(s,y,{});return t(v),v})}async function E(y){return k("openai","credential",async()=>{const v=await I.startOpenAiSubscriptionAuth(s,{method:y});return v.method==="browser"?(window.open(v.url,"_blank","noopener,noreferrer"),b("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(v.url,"_blank","noopener,noreferrer"),b(`OpenAI device login started. Enter code ${v.userCode}.`)),R(v.expiresAt),v})}async function R(y){if(s)for(;Date.now()<y;){await new Promise(v=>setTimeout(v,2500));try{const v=await I.providerSettings(s);t(v);const M=v.statuses.openai?.credential;if(M?.connected&&M.source==="chatgpt_subscription"){b("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function z(y){await k(y,"models",async()=>{const v=await I.refreshProviderModels(s,y,{force:!0});return t(v.providers),v})}async function p(y){await k(y,"models",async()=>{const v=await I.loadProviderModels(s,y,{limit:500});return t(v.providers),v})}async function N(y,v={}){await k(y,"validate",async()=>{const M=await I.validateProviderCredential(s,y,v);return b(M.ok?`${y} validated${M.modelId?` with ${M.modelId}`:""}.`:M.errors.join(`
6
- `)||`${y} validation failed.`),t(M.providers),M})}return{defaultModel:o,defaultProvider:d,providerBusy:u,saving:x,validationMessage:j,changeDefaultProvider:C,deleteProviderCredential:g,loadProviderModels:p,refreshProviderModels:z,saveProviderConfig:P,saveProviderCredential:D,saveProviders:S,setDefaultModel:f,startOpenAiSubscriptionAuth:E,validateProvider:N}}function hl({connection:s,enabled:a,onError:n,onToast:t}){const[l,i]=r.useState(null),[d,c]=r.useState(null),[o,f]=r.useState(!1),x=r.useRef(null),h=r.useCallback(async(E={})=>{if(s){E.quiet||c("refresh");try{const R=await I.remoteAccess(s);i(R),n(null)}catch(R){n(R instanceof Error?R.message:String(R))}finally{E.quiet||c(null)}}},[s,n]);r.useEffect(()=>{!a||!s||h({quiet:!0})},[s,a,h]),r.useEffect(()=>()=>{x.current!==null&&window.clearTimeout(x.current)},[]);function u(){x.current!==null&&window.clearTimeout(x.current),f(!1),window.setTimeout(()=>{f(!0),x.current=window.setTimeout(()=>{f(!1),x.current=null},1500)},0)}async function m(){if(n(null),!!s)try{i(await I.remoteAccess(s))}catch{}}async function j(){if(!s)return null;l&&!l.tailscale.running&&u(),c("enable");try{const E=await I.enableRemoteAccess(s);return i(E.status),n(null),E.status.tailscale.running?!E.status.serve.enabled&&E.status.serve.error&&t?.(E.status.serve.setupUrl?"Tailscale Serve needs to be enabled for this tailnet. Copy the Enable Serve link.":E.message||E.status.serve.error,"error"):(u(),t?.(E.message||"Tailscale is not running. Run Tailscale up first.","error")),E.status}catch{return await m(),u(),t?.("Unable to turn on remote access. Run Tailscale up first.","error"),null}finally{c(null)}}async function b(){if(s&&window.confirm("Turn off remote access? This runs tailscale serve reset and clears Tailscale Serve config on this device.")){c("disable");try{const E=await I.disableRemoteAccess(s);i(E.status),n(null)}catch{await m()}finally{c(null)}}}async function S(){l?.remoteWebUrl&&(c("copy-link"),await je(l.remoteWebUrl),c(null))}async function C(){l?.serveCommand&&(c("copy-command"),await je(l.serveCommand),c(null))}async function k(){l?.serve.setupUrl&&(c("copy-serve-setup"),await je(l.serve.setupUrl),c(null))}async function P(){l?.tailscaleUpCommand&&(c("copy-up-command"),await je(l.tailscaleUpCommand),c(null))}async function D(){l?.operatorCommand&&(c("copy-operator"),await je(l.operatorCommand),c(null))}async function g(){if(!l?.serve.enabled){const E=await j();E?.serve.enabled&&E.remoteWebUrl&&await je(E.remoteWebUrl);return}await S()}return{status:l,busy:d,flashTailscaleUp:o,refresh:h,enableRemoteAccess:j,disableRemoteAccess:b,copyRemoteLink:S,copyTailscaleUpCommand:P,copyServeCommand:C,copyServeSetupUrl:k,copyOperatorCommand:D,createRemoteLink:g}}function ml(s){const[a,n]=r.useState(null),[t,l]=r.useState(null),i=r.useCallback(async()=>{if(s.connection){l("load");try{n(await I.datasetStorageState(s.connection)),s.onError(null)}catch(c){s.onError(c instanceof Error?c.message:String(c))}finally{l(null)}}},[s.connection,s.onError]),d=r.useCallback(async c=>{if(!s.connection||!c)return!1;l("save");try{return n(await I.updateDatasetStorage(s.connection,c)),s.onError(null),!0}catch(o){return s.onError(o instanceof Error?o.message:String(o)),!1}finally{l(null)}},[s.connection,s.onError]);return r.useEffect(()=>{s.enabled&&i()},[s.enabled,i]),{state:a,busy:t,refresh:i,save:d}}function pl(s){const{connection:a,enabled:n,onError:t,profileId:l}=s,[i,d]=r.useState(null),[c,o]=r.useState(!1),f=r.useCallback(async()=>{if(a){o(!0);try{d(await I.datasetCatalog(a,l)),t(null)}catch(x){t(gl(x))}finally{o(!1)}}},[a,t,l]);return r.useEffect(()=>{n&&f()},[n,f]),{catalog:i,loading:c,refresh:f}}function gl(s){return s instanceof Error?s.message:String(s)}const fl=r.lazy(()=>za(()=>import("./UsageSettingsSection-WBtxLhBx.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url).then(s=>({default:s.UsageSettingsSection})));function Ml({payload:s,connection:a,diagnostics:n,onPayload:t,onError:l,onToast:i,onBack:d,onOpenSourceSession:c,onAcceptEvaluationReview:o,onOpenSkill:f,onOpenExtension:x,teamChatCurrentUserId:h,teamChatEnabled:u,teamChatNotificationMode:m,teamChatThreads:j,onTeamChatNotificationModeChange:b,onTeamChatThreadMuteChange:S,diffPanelWidth:C,diffPanelResizing:k,diffPanelExpanded:P,onDiffPanelResizeStart:D,onDiffPanelExpandedChange:g,initialSection:E="account"}){const[R,z]=r.useState(E),[p,N]=r.useState(null),[y,v]=r.useState(!1),M=s?.codex??null,T=r.useMemo(()=>$a(s?.preferences),[s?.preferences]),q=s?.personalization??Ia,V=n??s?.diagnostics??[],A=Ma()&&Oa(a?.platform),w=r.useCallback(H=>{s&&t({...s,providers:H})},[t,s]),O=r.useCallback(H=>{s&&t({...s,preferences:H.preferences})},[t,s]),Q=r.useCallback(H=>{s&&t({...s,extensionCatalog:H})},[t,s]),J=sl({connection:a,onError:l,onPayload:t}),W=ul({connection:a,onError:l,onPayload:t,onPreferences:O,onProviders:w,preferences:T,providers:s?.providers??null}),Z=al({connection:a,onError:l,onPayload:t,onPreferences:O,preferences:T,providers:s?.providers??null}),K=cl({connection:a,enabled:R==="editor",onError:l,onPayload:t,onPreferences:O,onToast:i,preferences:T}),U=dl({connection:a,onError:l,onPayload:t,personalization:q}),se=ol({onError:l,section:R}),ie=hl({connection:a,enabled:R==="remote",onError:l,onToast:i}),ce=R==="dataset-storage",re=ml({connection:a,enabled:ce,onError:l}),ne=pl({connection:a,enabled:ce,onError:l,profileId:s?.profile.activeProfile??"default"}),ee=re.save,fe=r.useCallback(async()=>{await Promise.all([re.refresh(),ne.refresh()])},[re.refresh,ne.refresh]),oe=r.useCallback(()=>R!=="subagents"||!Z.subagentsDirty?!0:window.confirm("You have unsaved changes. Leave Subagents without saving?"),[Z.subagentsDirty,R]),L=r.useCallback(H=>{H!==R&&oe()&&(v(!1),g(!1),z(H))},[oe,g,R]),_=r.useCallback(()=>{oe()&&(v(!1),g(!1),d())},[oe,d,g]);r.useEffect(()=>{z(E)},[E]),r.useEffect(()=>{if(R!=="subagents"||!Z.subagentsDirty)return;const H=ye=>{ye.preventDefault(),ye.returnValue="You have unsaved changes."};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[Z.subagentsDirty,R]);const F={"--diff-panel-width":`${C}px`},B=R==="harness"&&y&&p;return e.jsxs("div",{className:`settings-shell ${A?"platform-macos":""} ${B?"harness-diff-open":""} ${P?"harness-diff-expanded":""} ${k?"diff-panel-resizing":""}`,style:F,children:[e.jsx("div",{className:"settings-drag-region","aria-hidden":"true"}),e.jsxs("div",{className:"settings-window-controls",children:[R==="harness"?e.jsx("button",{type:"button",className:`topbar-diff-button ${B?"active":""}`,title:`${B?"Hide":"Show"} sidebar`,"aria-label":`${B?"Hide":"Show"} sidebar`,"aria-pressed":!!B,disabled:!p,onClick:()=>v(H=>!H),children:e.jsx(Ta,{size:16})}):null,e.jsx(La,{platform:a?.platform})]}),e.jsx(Cn,{section:R,onBack:_,onSectionChange:L}),e.jsx("main",{className:`settings-content ${R==="profile"||R==="harness"?"settings-content-wide":""}`,children:R==="account"?e.jsx(dt,{payload:s,connection:a,onPayload:t,onPreferences:O,onError:l,onToast:i,...J}):R==="notifications"?e.jsx(At,{currentUserId:h,enabled:u,mode:m,threads:j,onModeChange:b,onThreadMuteChange:S}):R==="harness"?e.jsx(Xn,{connection:a,enabled:R==="harness",onAcceptEvaluationReview:o,onError:l,onDefaultReleaseDiff:N,onOpenSourceSession:c,onOpenReleaseDiff:H=>{N(H),v(!0)},onToast:i}):R==="profile"?e.jsx(Wt,{payload:s,connection:a,onPayload:t,onError:l,onToast:i}):R==="skills"?e.jsx(Pn,{personalSkills:s?.codexPersonalSkills??[],extensionCatalog:s?.extensionCatalog??{rootPath:"",registryPath:"",extensions:[],error:null},connection:a,onExtensionCatalog:Q,onError:l,onToast:i,onOpenSkill:f,onOpenExtension:x}):R==="providers"?e.jsx(fn,{account:s?.account??null,codex:M,providers:s?.providers??null,...W}):R==="dataset-storage"?e.jsx(Un,{state:re.state,catalog:ne.catalog,busy:re.busy,catalogLoading:ne.loading,onRefresh:fe,onSave:ee}):R==="defaults"?e.jsx(pt,{preferences:T,...Z}):R==="context"?e.jsx(bt,{preferences:T,...Z}):R==="training"?e.jsx(Rn,{connection:a,onError:l,onPreferences:O,preferences:T,providers:s?.providers??null}):R==="subagents"?e.jsx(yt,{preferences:T,providers:s?.providers??null,...Z}):R==="editor"?e.jsx(vt,{preferences:T,...K}):R==="remote"?e.jsx(bn,{...ie}):R==="usage"?e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"usage-load-state",children:"Loading activity…"}),children:e.jsx(fl,{account:s?.account??null,connection:a,enabled:R==="usage",onError:l,onOpenSourceSession:c})}):R==="personalization"?e.jsx(Et,{...U}):e.jsx(gt,{diagnostics:V,...se})}),R==="harness"&&a&&B?e.jsx(el,{connection:a,expanded:P,onResizeStart:D,onToggleExpanded:()=>g(!P),selection:B}):null]})}export{Ml as SettingsView};
@@ -1,3 +0,0 @@
1
- import{j as t,cf as H,X as R,r as o,cg as le,ch as K,as as re,a2 as N,p as ce,ay as de,az as me,ci as ue,cj as ge,ck as he,aF as fe,cl as xe,cm as ve}from"./index--lwjVZXT.js";/* empty css */import{R as E,f as L}from"./MainPane-B2kcZpM0.js";import{T as Ce,B as T,b as k}from"./MarkdownText-C4Ixpl-i.js";import{R as X}from"./refresh-cw-DRJJ-X1U.js";import{r as ye}from"./index-C9-OtZl8.js";import"./cloud-upload-ZGHLWEn3.js";import"./arrow-up-right-3TbyK1ec.js";import"./square-BV-Vgh5a.js";import"./folder-open-C4WG_lDr.js";function be(e,l){const s=new Set(Array.from(e.matchAll(/(?:^|\s)@([a-zA-Z0-9_-]+)/g),n=>(n[1]??"").toLowerCase()));return l.filter(n=>{const c=n.handle?.toLowerCase(),r=n.name.toLowerCase().replace(/[^a-z0-9_-]+/g,"-");return c&&s.has(c)||s.has(r)}).map(n=>n.userId)}function je(e){return t.jsxs("div",{className:"team-chat-composer-reply",role:"status",children:[t.jsx(E,{size:15,"aria-hidden":"true"}),t.jsxs("button",{type:"button",className:"team-chat-composer-reply-target","aria-label":`Jump to message from ${e.authorLabel}`,onClick:e.onJump,children:[t.jsxs("strong",{children:["Replying to ",e.authorLabel]}),t.jsx("span",{children:H(e.target)})]}),t.jsx("button",{type:"button",className:"team-chat-icon-button","aria-label":"Cancel reply","data-tooltip":"Cancel reply",onClick:e.onCancel,children:t.jsx(R,{size:14})})]})}function we(e){return t.jsxs("button",{type:"button",className:"team-chat-message-reply-quote","aria-label":`Jump to replied message from ${e.authorLabel}`,onClick:e.onJump,children:[t.jsx("strong",{children:e.authorLabel}),t.jsx("span",{children:H(e.target)})]})}function Te(e){const l=o.useRef(null);if(o.useEffect(()=>{if(!e.menu)return;l.current?.focus();const n=()=>e.onClose(),c=r=>{r.key==="Escape"&&n()};return window.addEventListener("click",n),window.addEventListener("blur",n),window.addEventListener("keydown",c),window.addEventListener("scroll",n,!0),()=>{window.removeEventListener("click",n),window.removeEventListener("blur",n),window.removeEventListener("keydown",c),window.removeEventListener("scroll",n,!0)}},[e.menu,e.onClose]),!e.menu||typeof document>"u")return null;const s=t.jsx("div",{className:"team-chat-message-context-menu",role:"menu","aria-label":"Message actions",style:{left:e.menu.x,top:e.menu.y},onClick:n=>n.stopPropagation(),children:t.jsxs("button",{ref:l,type:"button",role:"menuitem",onClick:()=>{e.onReply(e.menu.message),e.onClose()},children:[t.jsx(E,{size:14}),"Reply"]})});return ye.createPortal(s,document.body)}function Me(e){const c=e.clientX||e.fallbackX,r=e.clientY||e.fallbackY;return{x:Math.max(8,Math.min(c,e.viewportWidth-150-8)),y:Math.max(8,Math.min(r,e.viewportHeight-42-8))}}function Y(e){return`team-chat-message-${encodeURIComponent(e)}`}function Re(e){const[l,s]=o.useState(!1),[n,c]=o.useState(e.message.body),r=e.message.refs.find(a=>a.refType==="hosted_ai_thread"),m=e.message.refs.find(a=>a.refType==="agent_run"),v=typeof r?.preview.status=="string"?r.preview.status:null,h=typeof e.message.metadata.deliveryStatus=="string"?e.message.metadata.deliveryStatus:null,C=typeof e.message.metadata.uploadProgress=="string"?e.message.metadata.uploadProgress:null,d=!e.message.deletedAt&&!h,g=le(e.message,e.messagesById),b=g?K(g,e.membersById):null;return t.jsxs("article",{id:Y(e.message.id),className:`team-chat-message${e.own?" own":""}`,tabIndex:-1,onContextMenu:a=>{if(!d)return;a.preventDefault();const y=a.currentTarget.getBoundingClientRect();e.onOpenReplyMenu(e.message,{clientX:a.clientX,clientY:a.clientY,fallbackX:y.right-12,fallbackY:y.top+24})},children:[t.jsx(Ie,{member:e.author}),t.jsxs("div",{className:"team-chat-message-content",children:[t.jsxs("header",{children:[t.jsx("strong",{children:e.author?.name??"Team member"}),t.jsx("time",{children:Se(e.message.createdAt)}),e.message.editedAt?t.jsx("span",{children:"edited"}):null,h==="sending"?t.jsx("span",{children:"sending"}):null,h==="sending"&&C?t.jsxs("span",{children:["uploaded ",C]}):null,h==="failed"?t.jsx("span",{className:"failed",children:"not sent"}):null,h==="failed"?t.jsxs("div",{className:"team-chat-message-actions visible",children:[t.jsx("button",{type:"button","data-tooltip":"Retry message","aria-label":"Retry message",onClick:()=>{e.onRetry(e.message)},children:t.jsx(X,{size:13})}),t.jsx("button",{type:"button","data-tooltip":"Remove failed message","aria-label":"Remove failed message",onClick:()=>e.onDismissFailed(e.message),children:t.jsx(R,{size:13})})]}):d||e.own&&!e.message.deletedAt?t.jsxs("div",{className:"team-chat-message-actions",children:[d?t.jsx("button",{type:"button","data-tooltip":"Reply","aria-label":"Reply to message",onClick:()=>e.onReply(e.message),children:t.jsx(E,{size:13})}):null,e.own&&!r?t.jsx("button",{type:"button","data-tooltip":"Edit message","aria-label":"Edit message",onClick:()=>s(!0),children:t.jsx(re,{size:13})}):null,e.own?t.jsx("button",{type:"button","data-tooltip":"Delete message","aria-label":"Delete message",onClick:()=>{e.onDelete(e.message)},children:t.jsx(Ce,{size:13})}):null]}):null]}),g&&b?t.jsx(we,{authorLabel:b,target:g,onJump:()=>e.onJumpToMessage(g.id)}):null,l?t.jsxs("form",{className:"team-chat-message-edit",onSubmit:a=>{a.preventDefault(),e.onEdit(e.message,n).then(y=>{y&&s(!1)})},children:[t.jsx("textarea",{autoFocus:!0,value:n,onChange:a=>c(a.currentTarget.value),onKeyDown:a=>{a.key==="Escape"&&(a.preventDefault(),s(!1),c(e.message.body))}}),t.jsxs("div",{children:[t.jsx("button",{type:"button",onClick:()=>s(!1),children:"Cancel"}),t.jsx("button",{type:"submit",disabled:!n.trim(),children:"Save"})]})]}):t.jsx("div",{className:e.message.deletedAt?"deleted":"",children:e.message.deletedAt?"Message deleted":e.message.body}),!e.message.deletedAt&&e.message.attachments.length>0?t.jsx(Ae,{message:e.message,connection:e.connection}):null,r?t.jsxs("button",{type:"button",className:"team-chat-thread-link",onClick:()=>{e.onOpenAiThread(r.refId)},children:[t.jsx(N,{size:14}),t.jsx("span",{children:"Thread"}),v&&v!=="completed"?t.jsx("small",{children:J(v)}):null,t.jsx("span",{"aria-hidden":"true",children:"›"})]}):null,m?t.jsxs("button",{type:"button",className:"team-chat-thread-link",onClick:()=>{e.onOpenAgentConversation(m.refId)},children:[t.jsx(T,{size:14}),t.jsx("span",{children:"Agent run"}),t.jsx("small",{children:J(String(m.preview.status??"queued"))}),t.jsx("span",{"aria-hidden":"true",children:"›"})]}):null]})]})}function Ae(e){const l=new Map(Array.isArray(e.message.metadata.localAttachmentPreviews)?e.message.metadata.localAttachmentPreviews.flatMap(s=>{if(!s||typeof s!="object")return[];const n=s;return typeof n.id=="string"&&typeof n.url=="string"?[[n.id,n.url]]:[]}):[]);return t.jsx("div",{className:"team-chat-message-images",children:e.message.attachments.map(s=>t.jsx(Pe,{attachmentId:s.id,alt:s.name,teamId:e.message.teamId,connection:e.connection,localUrl:l.get(s.clientAttachmentId)??null},s.id))})}function Pe(e){const[l,s]=o.useState(e.localUrl),[n,c]=o.useState(!1),r=o.useRef(0);async function m(){if(!e.connection||e.localUrl){e.localUrl||c(!0);return}c(!1);try{const v=await ce.teamChatAttachmentDownload(e.connection,e.teamId,e.attachmentId);s(v.url)}catch{s(null),c(!0)}}return o.useEffect(()=>{s(e.localUrl),c(!1),r.current=0,e.localUrl||m()},[e.attachmentId,e.connection,e.localUrl,e.teamId]),l?t.jsx("a",{href:l,target:"_blank",rel:"noreferrer","aria-label":`Open ${e.alt}`,children:t.jsx("img",{src:l,alt:e.alt,loading:"lazy",onError:()=>{if(!e.localUrl&&r.current<1){r.current+=1,m();return}s(null),c(!0)}})}):n?t.jsx("button",{type:"button",className:"team-chat-message-image-retry","aria-label":`Retry ${e.alt}`,"data-tooltip":"Retry image",onClick:()=>{r.current=0,e.localUrl?(c(!1),s(e.localUrl)):m()},children:t.jsx(X,{size:18})}):t.jsx("div",{className:"team-chat-message-image-loading",role:"status","aria-label":`Loading ${e.alt}`})}function J(e){return e==="pending"?"Starting":e==="running"?"Responding":e==="failed"?"Failed":e==="interrupted"?"Interrupted":e==="cancelled"?"Cancelled":e}function Ie({member:e}){if(e?.image)return t.jsx("img",{className:"team-chat-avatar",src:e.image,alt:""});const l=(e?.name??"T").split(/\s+/).slice(0,2).map(s=>s[0]?.toUpperCase()??"").join("");return t.jsx("span",{className:"team-chat-avatar fallback",children:l})}function Se(e){const l=new Date(e);return Number.isFinite(l.getTime())?l.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):""}const U={value:"none",label:"No project",detail:"Team conversation",options:[],busy:!1},z={value:"local",label:"Local",detail:"Local execution",options:[],action:{value:"local",label:"Local",detail:"Local execution",disabled:!1},busy:!1},G=new Set(["codex","openai","xai","openrouter","deepseek","zai","moonshot","together","groq","custom-openai-compatible"]);function ke(e,l){return!l||e===l?e:e?`${l}
2
-
3
- ${e}`:l}function Fe(){return t.jsx("section",{className:"team-chat-view team-chat-pro-view","aria-label":"Team Chat",children:t.jsxs("div",{className:"team-chat-pro-content",children:[t.jsx("span",{className:"team-chat-pro-icon","aria-hidden":"true",children:t.jsx(N,{size:22})}),t.jsx("h1",{children:"Team Chat"}),t.jsx("p",{children:"Team Chat is available with Pro mode."}),t.jsx("small",{children:"Create or join a Pro team to chat with teammates, coordinate work, and share agents."})]})})}function We(e){de(e.error);const[l,s]=o.useState(""),[n,c]=o.useState(!1),[r,m]=o.useState(null),[v,h]=o.useState(null),[C,d]=o.useState(0),g=o.useRef(null),b=o.useRef(!0),a=o.useRef(e.detail?.thread.id??null);a.current=e.detail?.thread.id??null;const{confirmAction:y,confirmDialog:V,resolveConfirmDialog:Q}=me(),A=o.useMemo(()=>new Map(e.members.map(i=>[i.userId,i])),[e.members]),D=o.useMemo(()=>new Map((e.detail?.messages??[]).map(i=>[i.id,i])),[e.detail?.messages]),Z=e.detail?.thread.id??null,O=r?.threadId===Z?D.get(r.message.id)??r.message:null,M=O?.deletedAt?null:O,j=M?ue(M):null,q=j?K(j,A):null,p=e.detail?ge(e.detail.thread,e.currentUserId):"Team",P=G.has(e.provider)?e.provider:"codex",B=P===e.provider?e.model:"gpt-5.6-sol",ee=o.useMemo(()=>he({hostedActions:e.agents,profile:e.profile,teamId:e.teamId}),[e.agents,e.profile,e.teamId]),te=e.detail?.messages.at(-1)?.sequence??0;o.useEffect(()=>{if(!b.current)return;const i=g.current;i&&(i.scrollTop=i.scrollHeight)},[te,e.detail?.thread.id]);const $=o.useCallback(i=>{i.deletedAt||i.id.startsWith("pending:")||typeof i.metadata.deliveryStatus=="string"||(m({threadId:i.threadId,message:i}),c(!1),h(null),d(f=>f+1))},[]),ne=o.useCallback(()=>h(null),[]),ae=o.useCallback((i,f)=>{const x=Me({...f,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight});h({message:i,...x})},[]),F=o.useCallback(i=>{const f=document.getElementById(Y(i));f&&(f.scrollIntoView({behavior:"smooth",block:"center"}),f.focus({preventScroll:!0}))},[]);async function se(i=[],f=null){if(i.some(u=>u.kind!=="image"||!["image/png","image/jpeg","image/webp","image/gif"].includes(u.mediaType)))return e.showToast("Team chat supports PNG, JPEG, WebP, and GIF images.","error"),!1;let x=f;if(M&&x)return e.showToast("Remove the agent action before replying to a message.","error"),!1;if(xe(x)){const u=ve(x);if(!u)throw new Error("The selected profile agent is missing its profile id.");if(!await y({title:`Publish ${x.label??x.name??"agent"} to Team?`,body:`This will upload the committed agent source to ${e.teamName??"this Team"}, create its hosted runtime, and then send your message.`,confirmLabel:"Publish and send",tone:"default"}))return!1;x=await e.onPublishProfileAgent(u)}const I=x?.approvalPolicy?.risk;let W=null;if(x?.approvalPolicy?.required&&I&&I!=="read"){const u=I==="destructive";if(!await y({title:u?"Approve destructive action?":"Approve external write?",body:`${x.label??x.name??"This agent action"} will use the workspace connection to ${u?"perform a destructive operation":"write external data"}. Approve this run only?`,confirmLabel:u?"Approve destructive action":"Approve write",tone:u?"danger":"default"}))return!1;W=crypto.randomUUID()}const S=l,oe=e.detail?.thread.id??null,w=M,_=()=>{a.current===oe&&(s(u=>ke(u,S)),w&&m(u=>u??{threadId:w.threadId,message:w}))};s(""),w&&m(null);try{const u=await e.onSendMessage({body:S,useModel:n,providerId:P,modelId:B,mentionUserIds:be(S,e.members),attachments:i,replyToMessage:w,selectedActionKey:x?.id??null,approvalId:W});return u?n&&c(!1):_(),u}catch(u){throw _(),u}}return t.jsxs("section",{className:"team-chat-view",children:[t.jsxs("div",{className:"team-chat-main conversation-surface-main",children:[t.jsxs("div",{className:"team-chat-messages conversation-message-scroll",role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":e.loading,"aria-label":p,tabIndex:0,ref:g,onScroll:i=>{const f=i.currentTarget;b.current=f.scrollHeight-f.scrollTop-f.clientHeight<72},children:[e.detail?.hasMoreBefore?t.jsx("button",{type:"button",className:"team-chat-load-older",disabled:e.loading,onClick:()=>{e.onLoadMoreMessages()},children:e.loading?"Loading...":"Load older messages"}):null,e.loading&&!e.detail?t.jsx("div",{className:"team-chat-empty",children:"Loading messages..."}):e.detail?.messages.length?e.detail.messages.map(i=>t.jsx(Re,{message:i,author:i.authorUserId?A.get(i.authorUserId)??null:null,own:i.authorUserId===e.currentUserId,onOpenAiThread:e.onOpenAiThread,onOpenAgentConversation:e.onOpenAgentConversation,onEdit:e.onEditMessage,onDelete:e.onDeleteMessage,onRetry:e.onRetryMessage,onDismissFailed:e.onDismissFailedMessage,membersById:A,messagesById:D,onReply:$,onOpenReplyMenu:ae,onJumpToMessage:F,connection:e.connection},i.id)):t.jsx("div",{className:"team-chat-empty",children:"No messages yet"})]}),t.jsxs("div",{className:"team-chat-composer-shell conversation-composer-shell",children:[j&&q?t.jsx(je,{authorLabel:q,target:j,onCancel:()=>m(null),onJump:()=>F(j.id)}):null,t.jsx(L,{mode:"dock",surface:"team",teamUseModel:n,teamUseModelLocked:!!j,teamMentionMembers:e.members.filter(i=>i.userId!==e.currentUserId),actionCatalog:ee,onTeamUseModelChange:c,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:e.busy,running:!1,focusRequestId:C,submissionScopeKey:`team:${e.detail?.thread.id??"none"}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:P,model:B,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:s,showToast:e.showToast,onSubmit:async(i,f)=>se(i??[],f??null),onStop:()=>!1})]})]}),t.jsx(Te,{menu:v,onClose:ne,onReply:$}),t.jsx(fe,{state:V,onResolve:Q})]})}function _e(e){const[l,s]=o.useState(""),n=e.agentConversation,c=o.useRef(null),r=o.useRef(null),m=o.useRef(null),v=n.messages.at(-1)?.sequence??0,h=["pending","queued","running"].includes(n.run.status);o.useEffect(()=>{const d=c.current;d&&(d.scrollTop=d.scrollHeight)},[v,n.run.status]),o.useEffect(()=>{r.current?.focus();const d=g=>{g.key==="Escape"&&(g.preventDefault(),e.onCloseAgentConversation())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e.onCloseAgentConversation]);async function C(){const d=m.current??crypto.randomUUID();m.current=d;const g=await e.onSendAgentTurn({body:l,clientRequestId:d});return g&&(m.current=null,s("")),g}return t.jsxs("aside",{className:"workspace-diff-panel team-ai-thread-panel","aria-label":`${n.agent.name} run`,children:[e.onResizeStart?t.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agent run panel",onPointerDown:e.onResizeStart}):null,t.jsxs("header",{children:[t.jsxs("div",{children:[t.jsx(T,{size:15}),t.jsx("strong",{children:n.agent.name}),t.jsx("span",{children:n.run.status})]}),t.jsx("button",{ref:r,type:"button",className:"team-chat-icon-button","aria-label":"Close agent run",onClick:e.onCloseAgentConversation,children:t.jsx(R,{size:16})})]}),t.jsxs("div",{className:"team-ai-thread-messages",ref:c,role:"log","aria-live":"polite","aria-relevant":"additions text",tabIndex:0,children:[n.messages.map(d=>t.jsxs("article",{className:`team-ai-message ${d.role}`,children:[t.jsxs("div",{className:"team-ai-message-author",children:[d.role==="assistant"?t.jsx(T,{size:14}):null,t.jsx("strong",{children:d.role==="user"?"Team member":n.agent.name})]}),t.jsx(k,{connection:e.connection,content:d.body})]},d.id)),n.messages.length===0?t.jsx("div",{className:"team-chat-empty",children:"The agent run is starting."}):null]}),t.jsx("div",{className:"team-ai-thread-composer",children:t.jsx(L,{mode:"dock",surface:"team",teamUseModel:!1,teamUseModelLocked:!0,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:e.busy||h,running:h,submissionScopeKey:`team-agent:${n.conversationId}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:e.provider,model:e.model,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:d=>{m.current=null,s(d)},showToast:e.showToast,onSubmit:C,onStop:()=>!1})})]})}function Je(e){const[l,s]=o.useState(""),n=e.aiThread,c=new Map(e.members.map(a=>[a.userId,a])),r=n.turns.at(-1)??null,m=o.useRef(null),v=n.messages.at(-1)?.sequence??0,h=o.useRef(null),C=G.has(e.provider)?e.provider:"codex",d=C===e.provider?e.model:"gpt-5.6-sol",g=!!(n.activeTurn&&(n.activeTurn.status==="pending"||n.activeTurn.status==="running"));o.useEffect(()=>{const a=m.current;a&&(a.scrollTop=a.scrollHeight)},[v,n.activeTurn?.partialBody]),o.useEffect(()=>{h.current?.focus();const a=y=>{y.key==="Escape"&&(y.preventDefault(),e.onCloseAiThread())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e.onCloseAiThread]);async function b(){const a=await e.onSendAiTurn({body:l,providerId:C,modelId:d});return a&&s(""),a}return t.jsxs("aside",{className:"workspace-diff-panel team-ai-thread-panel","aria-label":"AI thread",children:[e.onResizeStart?t.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-label":"Resize AI thread panel","aria-orientation":"vertical",onPointerDown:e.onResizeStart}):null,t.jsxs("header",{children:[t.jsxs("div",{children:[t.jsx(N,{size:15}),t.jsx("strong",{children:"AI thread"}),t.jsxs("span",{children:[n.messages.length," messages"]})]}),t.jsx("button",{ref:h,type:"button",className:"team-chat-icon-button","data-tooltip":"Close thread","aria-label":"Close thread",onClick:e.onCloseAiThread,children:t.jsx(R,{size:16})})]}),t.jsxs("div",{className:"team-ai-thread-messages",ref:m,role:"log","aria-live":"polite","aria-relevant":"additions text",tabIndex:0,children:[n.messages.map(a=>t.jsxs("article",{className:`team-ai-message ${a.role}`,children:[t.jsxs("div",{className:"team-ai-message-author",children:[a.role==="assistant"?t.jsx(T,{size:14}):null,t.jsx("strong",{children:a.role==="assistant"?"Model":a.createdByUserId?c.get(a.createdByUserId)?.name??"Team member":"Team member"})]}),t.jsx(k,{connection:e.connection,content:a.body})]},a.id)),n.activeTurn?.partialBody?t.jsxs("article",{className:"team-ai-message assistant streaming",children:[t.jsxs("div",{className:"team-ai-message-author",children:[t.jsx(T,{size:14}),t.jsx("strong",{children:"Model"}),t.jsx("span",{children:n.activeTurn.status})]}),t.jsx(k,{connection:e.connection,content:n.activeTurn.partialBody})]}):n.activeTurn?t.jsx("div",{className:"team-ai-running",children:n.activeTurn.status==="pending"?"Starting model...":"Model is responding..."}):r&&["failed","interrupted","cancelled"].includes(r.status)?t.jsx("div",{className:`team-ai-turn-state ${r.status}`,children:r.status==="failed"?"Model response failed":r.status==="interrupted"?"Model response was interrupted":"Model response was cancelled"}):null]}),t.jsx("div",{className:"team-ai-thread-composer",children:t.jsx(L,{mode:"dock",surface:"team",teamUseModel:!0,teamUseModelLocked:!0,prompt:l,contextWindowStatus:e.contextWindowStatus,busy:g,running:g,submissionScopeKey:`team-ai:${n.conversationId}`,showProjectFooter:!1,connection:e.connection,providerSettings:e.providerSettings,provider:C,model:d,projectTarget:U,workspaceTarget:z,codexPermissionMode:e.codexPermissionMode,codexReasoningEffort:e.codexReasoningEffort,openPondCommandAccessMode:e.openPondCommandAccessMode,onProviderChange:e.onProviderChange,onProviderSetupOpen:e.onOpenProviderSettings,onProjectTargetChange:()=>{},onWorkspaceTargetChange:()=>{},onModelChange:e.onModelChange,onCodexPermissionModeChange:e.onCodexPermissionModeChange,onCodexReasoningEffortChange:e.onCodexReasoningEffortChange,onOpenPondCommandAccessModeChange:e.onOpenPondCommandAccessModeChange,onPromptChange:s,showToast:e.showToast,onSubmit:b,onStop:e.onStopAiTurn})})]})}export{_e as TeamAgentConversationPanel,Je as TeamAiThreadPanel,Fe as TeamChatProView,We as TeamChatView,ke as restoreFailedTeamChatPrompt};
@@ -1 +0,0 @@
1
- import{cn as r}from"./index--lwjVZXT.js";var a=r();export{a as r};