openpond 0.2.65 → 0.2.66

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 (157) hide show
  1. package/dist/app-server.js +1 -1
  2. package/dist/chunks/{acp-PHMBLRCV.js → acp-YYZ3ZO3Q.js} +1 -1
  3. package/dist/chunks/{acp-agent-A7GK2VSH.js → acp-agent-T26S7TU2.js} +1 -1
  4. package/dist/chunks/{app-layer-J66CQ2QN.js → app-layer-5XUMNHDO.js} +1 -1
  5. package/dist/chunks/{app-server-runtime-OMR2VE6L.js → app-server-runtime-TH56EG2Z.js} +1 -1
  6. package/dist/chunks/{apps-IHUFERZO.js → apps-MNT3KXIY.js} +1 -1
  7. package/dist/chunks/chunk-2ZNW6GUU.js +2 -0
  8. package/dist/chunks/{chunk-E2S2EMYQ.js → chunk-BQVB2SPF.js} +5 -5
  9. package/dist/chunks/{chunk-UM6EQOT2.js → chunk-JKI53ED7.js} +1 -1
  10. package/dist/chunks/{chunk-FGOTSCSE.js → chunk-NABPZ7AK.js} +1 -1
  11. package/dist/chunks/{chunk-KGUPAPGR.js → chunk-PLVWARB7.js} +1 -1
  12. package/dist/chunks/chunk-SBQ6KLXB.js +33 -0
  13. package/dist/chunks/{chunk-N2AV7PHV.js → chunk-UXPO3ZV7.js} +2 -2
  14. package/dist/chunks/{command-NDHFZAKA.js → command-NW6BGKOM.js} +3 -3
  15. package/dist/chunks/{configuration-command-465ODYTC.js → configuration-command-4WTS2MZS.js} +1 -1
  16. package/dist/chunks/{connected-evidence-XPAZQRFQ.js → connected-evidence-D7C45HYD.js} +1 -1
  17. package/dist/chunks/{connected-starting-assets-2YX3QVDB.js → connected-starting-assets-4LDXQVLN.js} +1 -1
  18. package/dist/chunks/{core-commands-PJOGRBHJ.js → core-commands-RXPXOYOP.js} +1 -1
  19. package/dist/chunks/{datasets-OTE2I4VT.js → datasets-LBLEKLCS.js} +1 -1
  20. package/dist/chunks/{desktop-test-Q6REQJ7K.js → desktop-test-INJPZ5VP.js} +1 -1
  21. package/dist/chunks/{evaluation-coordination-KRCY2H4C.js → evaluation-coordination-3ARLJAFH.js} +1 -1
  22. package/dist/chunks/{experiment-improvements-7MI2VYBR.js → experiment-improvements-UB4C5CSP.js} +1 -1
  23. package/dist/chunks/{experiments-CNUQKJZE.js → experiments-AHHKFJD6.js} +1 -1
  24. package/dist/chunks/{experiments-signal-4N344D4Y.js → experiments-signal-MTR475QV.js} +1 -1
  25. package/dist/chunks/{help-ZUKVY6RO.js → help-JQA3YMCX.js} +1 -1
  26. package/dist/chunks/{hosted-app-server-composition-DWSU6ASL.js → hosted-app-server-composition-GPXH3BOG.js} +1 -1
  27. package/dist/chunks/{human-review-HOBGC6RC.js → human-review-DVHVJXBA.js} +1 -1
  28. package/dist/chunks/{import-Q3YRFVY7.js → import-CLWTKDG6.js} +1 -1
  29. package/dist/chunks/{opchat-2LLDIWEJ.js → opchat-LMKH3OWR.js} +1 -1
  30. package/dist/chunks/{opchat-bounded-chat-FLDS36LU.js → opchat-bounded-chat-PPOWO7H4.js} +1 -1
  31. package/dist/chunks/{organizations-VIFSOY6P.js → organizations-T6ZUSHNJ.js} +1 -1
  32. package/dist/chunks/{profile-KIHMW2WB.js → profile-RIDNU2I5.js} +1 -1
  33. package/dist/chunks/{project-agent-TJLQNMLA.js → project-agent-GBMVDJY3.js} +1 -1
  34. package/dist/chunks/{sandbox-command-CQO6BEMQ.js → sandbox-command-L5VQ2T6C.js} +1 -1
  35. package/dist/chunks/{sandbox-template-MU33IILL.js → sandbox-template-NN3XQI7M.js} +1 -1
  36. package/dist/chunks/{setup-HSRCZ3WR.js → setup-TXEM2QSG.js} +1 -1
  37. package/dist/chunks/{src-CHQVWHV7.js → src-HJHIBDFX.js} +1 -1
  38. package/dist/chunks/{teams-bot-D3LWA4S5.js → teams-bot-FXMCOCPP.js} +1 -1
  39. package/dist/chunks/{tool-learning-NGO7QHYK.js → tool-learning-O7QTTEDB.js} +1 -1
  40. package/dist/cli.js +1 -1
  41. package/dist/skills/manifest.json +1 -1
  42. package/dist/web/assets/{App-BZuSv1XM.js → App-CNQi3RlI.js} +4 -4
  43. package/dist/web/assets/{AppDialog-BILEK4np.js → AppDialog-DuSd0wk6.js} +1 -1
  44. package/dist/web/assets/{AppTerminalPanel-BvxZ8bwD.js → AppTerminalPanel-DLz34eSs.js} +2 -2
  45. package/dist/web/assets/{AppToastContext-C-FsCKXW.js → AppToastContext-Dklk6CaG.js} +1 -1
  46. package/dist/web/assets/{AppsView-BMaq5oxx.js → AppsView-DkCMr67-.js} +1 -1
  47. package/dist/web/assets/{AttachmentTypeIcon-Bh7Ft_UL.js → AttachmentTypeIcon-DipNT6Tj.js} +1 -1
  48. package/dist/web/assets/{BrowserSidebar-BG2MLJ9I.js → BrowserSidebar-BBaaanMS.js} +1 -1
  49. package/dist/web/assets/{CartesianChart-CS6ES_XT.js → CartesianChart-UU1sdoUO.js} +1 -1
  50. package/dist/web/assets/{ChatTimelineEntry-Dr5X_XyN.js → ChatTimelineEntry-Ct59FKw1.js} +1 -1
  51. package/dist/web/assets/{CollaborationTabs-CPJ2w67F.js → CollaborationTabs-BWYRQ1PE.js} +1 -1
  52. package/dist/web/assets/{CommandMenu-Fe1V7NJd.js → CommandMenu-B08F9x5g.js} +1 -1
  53. package/dist/web/assets/{CommunityView-DHTcmOnI.js → CommunityView-BLTlSxyb.js} +1 -1
  54. package/dist/web/assets/{ComposerAttachments-Ck9VWD6o.js → ComposerAttachments-srWBKvCv.js} +1 -1
  55. package/dist/web/assets/{ComposerCreateImproveStrip-yiXO7cf8.js → ComposerCreateImproveStrip-DqTpU5cO.js} +1 -1
  56. package/dist/web/assets/{ConversationImportsSettings-_VLzUnHQ.js → ConversationImportsSettings-2KC-KQvu.js} +1 -1
  57. package/dist/web/assets/{FilePagePreview-BpcM1DfE.js → FilePagePreview-B-iUVPhh.js} +2 -2
  58. package/dist/web/assets/{GetStartedView-BH-WJ-rW.js → GetStartedView-5v0vBWXy.js} +1 -1
  59. package/dist/web/assets/{GettingStartedDialog-CdQfj7RA.js → GettingStartedDialog-Bn4072K-.js} +1 -1
  60. package/dist/web/assets/{HostedModelLearningReview-C3GsOlu9.js → HostedModelLearningReview-DWF6WPao.js} +1 -1
  61. package/dist/web/assets/{HostedModelLearningSettings-SSMst6dl.js → HostedModelLearningSettings-BYl-2j7B.js} +1 -1
  62. package/dist/web/assets/{HtmlVisual-CH0tb3fv.js → HtmlVisual-C2WsMj90.js} +1 -1
  63. package/dist/web/assets/{LabModelVersionDetailPage-J2t9yILv.js → LabModelVersionDetailPage-CQz29DwD.js} +1 -1
  64. package/dist/web/assets/{LabSkillSidebar-DdDYvfj2.js → LabSkillSidebar-C50P74LI.js} +1 -1
  65. package/dist/web/assets/{LabsRoute-MJwIjSKg.js → LabsRoute-DJRgF1kQ.js} +6 -6
  66. package/dist/web/assets/{MainChatThread-BcwtaTDZ.js → MainChatThread-gwmhe1Nw.js} +2 -2
  67. package/dist/web/assets/{MainPane-DDO6diPt.js → MainPane-CqtgV9rU.js} +5 -5
  68. package/dist/web/assets/{NativeSetupTerminal-BPSUFpRm.js → NativeSetupTerminal-DrQldDsG.js} +2 -2
  69. package/dist/web/assets/{NativeSkillSidebar-DPYavzau.js → NativeSkillSidebar-Clv0IWyn.js} +1 -1
  70. package/dist/web/assets/{NewProjectDialog-BtmvE9Sp.js → NewProjectDialog-Cw_F5Eaa.js} +1 -1
  71. package/dist/web/assets/{OutputsPage-BMRY7RK2.js → OutputsPage-Btyiie4B.js} +1 -1
  72. package/dist/web/assets/{PageChrome-5VRxH6Rp.js → PageChrome-BLLw_cEA.js} +1 -1
  73. package/dist/web/assets/{ProjectsPage-1LHqxOMo.js → ProjectsPage-BpSHWQgj.js} +1 -1
  74. package/dist/web/assets/{RightChatPanelStack-D_7KgExz.js → RightChatPanelStack-xW5rKbp0.js} +1 -1
  75. package/dist/web/assets/RightSidebarHomePanel-BDmIxvIm.js +1 -0
  76. package/dist/web/assets/{ScheduledWorkPage-Dtz4zJ0T.js → ScheduledWorkPage-WytWGQgw.js} +1 -1
  77. package/dist/web/assets/{SettingsView-BeDYNPcD.js → SettingsView-BJq5zNkv.js} +3 -3
  78. package/dist/web/assets/{TasksetDraftEditorPrimitives-CcvKO3YA.js → TasksetDraftEditorPrimitives-BxFEWI9W.js} +1 -1
  79. package/dist/web/assets/{TeamChatView-DaXxOkTe.js → TeamChatView-BisSMAXy.js} +1 -1
  80. package/dist/web/assets/{TerminalOverlay-CF8uB4qA.js → TerminalOverlay-C7OM2F0-.js} +1 -1
  81. package/dist/web/assets/{TrainingCreationPanel-DmMO7x5T.js → TrainingCreationPanel-KH5GFacT.js} +1 -1
  82. package/dist/web/assets/{TrainingDraftPanel-DCHbXjSx.js → TrainingDraftPanel-DzOw13Md.js} +1 -1
  83. package/dist/web/assets/{TrainingRunLineage-CwisTWs_.js → TrainingRunLineage-B2WBOchk.js} +1 -1
  84. package/dist/web/assets/{UsageSettingsSection-Drt7gwRb.js → UsageSettingsSection-nZHno_4P.js} +1 -1
  85. package/dist/web/assets/WorkSidebarPanel-D3Ub_jVj.js +1 -0
  86. package/dist/web/assets/{WorkspaceDiffPanel-Dmbrg0-y.js → WorkspaceDiffPanel-CyTa8Cjs.js} +3 -3
  87. package/dist/web/assets/{WorkspaceEnvironmentMenu-KEZm1gdb.js → WorkspaceEnvironmentMenu-CtZzxQ1e.js} +1 -1
  88. package/dist/web/assets/{WorkspaceFileLocation-ChbOKrPO.js → WorkspaceFileLocation-1U8DDj1J.js} +1 -1
  89. package/dist/web/assets/{WorkspaceGitDialogs-BS2JQKNQ.js → WorkspaceGitDialogs-BO1EUA3G.js} +1 -1
  90. package/dist/web/assets/{WorkspaceMonacoEditor-CN1hE_C4.js → WorkspaceMonacoEditor-Rqq_sKW_.js} +3 -3
  91. package/dist/web/assets/{WorkspacePdfPreview-Clb4m0le.js → WorkspacePdfPreview-zmmMp09R.js} +2 -2
  92. package/dist/web/assets/{WorkspacePresentationPreview-CwQsdvAR.js → WorkspacePresentationPreview-DNbhGjkE.js} +1 -1
  93. package/dist/web/assets/{bot-BNFltD5O.js → bot-D-eTQib6.js} +1 -1
  94. package/dist/web/assets/{chevron-down-BnnT0tnM.js → chevron-down-75im8nFF.js} +1 -1
  95. package/dist/web/assets/chevron-right-CpbCIUFo.js +1 -0
  96. package/dist/web/assets/{chevron-up-BAnwJJN3.js → chevron-up-BD8jg0bQ.js} +1 -1
  97. package/dist/web/assets/{client-choice-storage-Iuzoszas.js → client-choice-storage-CXlWJW5g.js} +1 -1
  98. package/dist/web/assets/{cloud-upload-CdSXJ7ms.js → cloud-upload-4lP-5zmp.js} +1 -1
  99. package/dist/web/assets/{copy-CBFg6m0d.js → copy-DRnATDDY.js} +1 -1
  100. package/dist/web/assets/{createLucideIcon-DF2VR6WA.js → createLucideIcon-CmkSm39S.js} +1 -1
  101. package/dist/web/assets/{cssMode-BSQUZhUO.js → cssMode-Cps-05f3.js} +1 -1
  102. package/dist/web/assets/{external-link-Cql9bKdv.js → external-link-D_nBEDFO.js} +1 -1
  103. package/dist/web/assets/{folder-open-BXdVB5J1.js → folder-open-tD5Lle1M.js} +1 -1
  104. package/dist/web/assets/{folder-plus-Cma2HulC.js → folder-plus-DlZ4hM48.js} +1 -1
  105. package/dist/web/assets/{git-commit-horizontal-eF--16ps.js → git-commit-horizontal-g8KBhvfr.js} +1 -1
  106. package/dist/web/assets/{htmlMode-aLPlQtyU.js → htmlMode-Do72TyNy.js} +1 -1
  107. package/dist/web/assets/icons-B8_Rkg-l.js +1 -0
  108. package/dist/web/assets/{image-CqKPwnBn.js → image-CUZMnZYi.js} +1 -1
  109. package/dist/web/assets/{index-CM0IRu1U.js → index-D7igQSAg.js} +2 -2
  110. package/dist/web/assets/{info-CqeYEqG0.js → info-SmuBZiE5.js} +1 -1
  111. package/dist/web/assets/{jsonMode-fu7bEcHB.js → jsonMode-B2N7W15Y.js} +1 -1
  112. package/dist/web/assets/loader-circle-D_KVxLLz.js +1 -0
  113. package/dist/web/assets/{lspLanguageFeatures-DraXQA4w.js → lspLanguageFeatures-DPmyOFVA.js} +1 -1
  114. package/dist/web/assets/{maximize-2-yMp8X9ts.js → maximize-2-B8HN3jsA.js} +1 -1
  115. package/dist/web/assets/{message-square-DbIMQqfj.js → message-square-CrDvzn66.js} +1 -1
  116. package/dist/web/assets/{monaco.contribution-Bd8EqYGR.js → monaco.contribution-BfOxF9PJ.js} +2 -2
  117. package/dist/web/assets/{monaco.contribution-BQhp1CJs.js → monaco.contribution-CRdTg0FH.js} +2 -2
  118. package/dist/web/assets/{monaco.contribution-CYWKnVxQ.js → monaco.contribution-DNONXznc.js} +2 -2
  119. package/dist/web/assets/{monaco.contribution-CmbWO0tB.js → monaco.contribution-DqqJBDzF.js} +2 -2
  120. package/dist/web/assets/{monitor-DFE2fTkT.js → monitor-CW-M_aaj.js} +1 -1
  121. package/dist/web/assets/{paperclip-D_qsKbVs.js → paperclip-DL449Io5.js} +1 -1
  122. package/dist/web/assets/{pdf-DkQRsi4n.js → pdf-BCq2Oosd.js} +1 -1
  123. package/dist/web/assets/play-DYLqBrwg.js +1 -0
  124. package/dist/web/assets/plus-DXZIpQuY.js +1 -0
  125. package/dist/web/assets/{presentation-BN_kIBPL.js → presentation-CupIXaYv.js} +1 -1
  126. package/dist/web/assets/{python-DB9pj5Hr.js → python-DuGMr666.js} +1 -1
  127. package/dist/web/assets/{refresh-cw-B27ohHfn.js → refresh-cw-CzVf5_oo.js} +1 -1
  128. package/dist/web/assets/{save-D-rwjKop.js → save-DatjrYPV.js} +1 -1
  129. package/dist/web/assets/{settings-lists-DgSaJQA4.js → settings-lists-D2ol3uNK.js} +1 -1
  130. package/dist/web/assets/square-BWB1nbZF.js +1 -0
  131. package/dist/web/assets/{square-terminal-CeoK51wH.js → square-terminal-Buj-s-fz.js} +1 -1
  132. package/dist/web/assets/{submit-issue-command-DZNW7Evj.js → submit-issue-command-wfngGS6Y.js} +1 -1
  133. package/dist/web/assets/{toggleHighContrast-Bs8L1gx0.js → toggleHighContrast-cl0cw2QK.js} +1 -1
  134. package/dist/web/assets/{training-model-data-wHvE7xL1.js → training-model-data-CWnu1bz9.js} +1 -1
  135. package/dist/web/assets/{tsMode-C7EqshxC.js → tsMode-DLEc0PYL.js} +1 -1
  136. package/dist/web/assets/{upload-BWgjC2Jf.js → upload-DaFVH6R1.js} +1 -1
  137. package/dist/web/assets/{useAccountSettings-Dva1MpsJ.js → useAccountSettings-ByxjI9BG.js} +1 -1
  138. package/dist/web/assets/{useAgentInventory-CrjIOmvb.js → useAgentInventory-Df64T07n.js} +1 -1
  139. package/dist/web/assets/{useLocalAgentSchedules-P-UaUKMb.js → useLocalAgentSchedules-DNh_x9gQ.js} +1 -1
  140. package/dist/web/assets/{useQuery-Bn3KqR4r.js → useQuery-yUz7Ui8g.js} +1 -1
  141. package/dist/web/assets/{wifi-off--mKrSPFc.js → wifi-off-CtNwnIJc.js} +1 -1
  142. package/dist/web/assets/{workers-p0Kn2KMK.js → workers-CnqrOtic.js} +1 -1
  143. package/dist/web/assets/x-Bhl-4Zlt.js +1 -0
  144. package/dist/web/assets/{yaml-BeIdC4tu.js → yaml-C9vtYV4w.js} +1 -1
  145. package/dist/web/index.html +1 -1
  146. package/package.json +1 -1
  147. package/dist/chunks/chunk-LOIYNRBC.js +0 -33
  148. package/dist/chunks/chunk-MMJU6PZV.js +0 -2
  149. package/dist/web/assets/RightSidebarHomePanel-iznJwDMf.js +0 -1
  150. package/dist/web/assets/WorkSidebarPanel-BrIIRtGW.js +0 -1
  151. package/dist/web/assets/chevron-right-C8K5PZj7.js +0 -1
  152. package/dist/web/assets/icons-c3vt7y6n.js +0 -1
  153. package/dist/web/assets/loader-circle-pxp89T5x.js +0 -1
  154. package/dist/web/assets/play-BtlX2stU.js +0 -1
  155. package/dist/web/assets/plus-DbASL_gy.js +0 -1
  156. package/dist/web/assets/square-C2caJ3NG.js +0 -1
  157. package/dist/web/assets/x-D9GTV9ke.js +0 -1
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-CM0IRu1U.js";import{n as r}from"./PageChrome-5VRxH6Rp.js";var i=e(t(),1),a=n(),o=[],s=new WeakMap,c=[`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`summary`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable='true']`].join(`,`);function l({ariaLabel:e,backdropClassName:t=`training-dialog-backdrop`,children:n,className:s,contained:c=!1,dismissDisabled:l=!1,initialFocusKey:u,inertExclusionSelector:p,onClose:m}){let h=(0,i.useRef)(null),g=(0,i.useRef)(Symbol(`app-dialog`)),_=(0,i.useRef)(null),v=(0,i.useRef)(l),y=(0,i.useRef)(m);v.current=l,y.current=m,(0,i.useEffect)(()=>{let e=g.current;_.current=document.activeElement instanceof HTMLElement?document.activeElement:null,o.push(e);let t=c?h.current?.closest(`.main-pane`)??null:null,n=f(h.current,t,p);function r(t){o.at(-1)===e&&(p&&t.target instanceof Element&&t.target.closest(p)||(t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),v.current||y.current()):t.key!==`Tab`||c||d(t,h.current)))}return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0);let t=o.lastIndexOf(e);t>=0&&o.splice(t,1),n();let i=_.current;i?.isConnected&&i.focus()}},[c,p]),(0,i.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=h.current;(e?.querySelector(`[data-autofocus]`)??e)?.focus()});return()=>window.cancelAnimationFrame(e)},[u]);function b(e){e.target===e.currentTarget&&!l&&m()}function x(e){e.key===`Escape`&&e.stopPropagation()}return(0,a.jsx)(`div`,{className:t,role:`presentation`,onMouseDown:b,children:(0,a.jsx)(`section`,{ref:h,"aria-busy":l||void 0,"aria-label":e,"aria-modal":c?void 0:`true`,className:s,role:`dialog`,tabIndex:-1,onKeyDown:x,onMouseDown:e=>e.stopPropagation(),children:(0,a.jsx)(r,{children:n})})})}function u(e){return e?Array.from(e.querySelectorAll(c)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`&&e.getClientRects().length>0):[]}function d(e,t){if(!t)return;let n=u(t);if(n.length===0){e.preventDefault(),t.focus();return}let r=n.indexOf(document.activeElement),i=e.shiftKey?r<=0?n.length-1:r-1:r<0||r===n.length-1?0:r+1;e.preventDefault(),n[i]?.focus()}function f(e,t=null,n){if(!e)return()=>void 0;let r=[],i=e.parentElement??e;for(;i.parentElement&&i!==document.body;){let e=i.parentElement;for(let t of Array.from(e.children)){if(t===i||!(t instanceof HTMLElement)||n&&t.matches(n))continue;let e=s.get(t)??{count:0,ariaHidden:t.getAttribute(`aria-hidden`),inert:t.inert};e.count+=1,s.set(t,e),r.push(t),t.inert=!0,t.setAttribute(`aria-hidden`,`true`)}if(i=e,t&&i===t)break}return()=>{for(let e of r.reverse()){let t=s.get(e);!t||--t.count>0||(s.delete(e),e.inert=t.inert,t.ariaHidden===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,t.ariaHidden))}}}export{l as t};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-D7igQSAg.js";import{n as r}from"./PageChrome-BLLw_cEA.js";var i=e(t(),1),a=n(),o=[],s=new WeakMap,c=[`button:not([disabled])`,`[href]`,`input:not([disabled])`,`select:not([disabled])`,`textarea:not([disabled])`,`summary`,`[tabindex]:not([tabindex='-1'])`,`[contenteditable='true']`].join(`,`);function l({ariaLabel:e,backdropClassName:t=`training-dialog-backdrop`,children:n,className:s,contained:c=!1,dismissDisabled:l=!1,initialFocusKey:u,inertExclusionSelector:p,onClose:m}){let h=(0,i.useRef)(null),g=(0,i.useRef)(Symbol(`app-dialog`)),_=(0,i.useRef)(null),v=(0,i.useRef)(l),y=(0,i.useRef)(m);v.current=l,y.current=m,(0,i.useEffect)(()=>{let e=g.current;_.current=document.activeElement instanceof HTMLElement?document.activeElement:null,o.push(e);let t=c?h.current?.closest(`.main-pane`)??null:null,n=f(h.current,t,p);function r(t){o.at(-1)===e&&(p&&t.target instanceof Element&&t.target.closest(p)||(t.key===`Escape`?(t.preventDefault(),t.stopPropagation(),v.current||y.current()):t.key!==`Tab`||c||d(t,h.current)))}return document.addEventListener(`keydown`,r,!0),()=>{document.removeEventListener(`keydown`,r,!0);let t=o.lastIndexOf(e);t>=0&&o.splice(t,1),n();let i=_.current;i?.isConnected&&i.focus()}},[c,p]),(0,i.useEffect)(()=>{let e=window.requestAnimationFrame(()=>{let e=h.current;(e?.querySelector(`[data-autofocus]`)??e)?.focus()});return()=>window.cancelAnimationFrame(e)},[u]);function b(e){e.target===e.currentTarget&&!l&&m()}function x(e){e.key===`Escape`&&e.stopPropagation()}return(0,a.jsx)(`div`,{className:t,role:`presentation`,onMouseDown:b,children:(0,a.jsx)(`section`,{ref:h,"aria-busy":l||void 0,"aria-label":e,"aria-modal":c?void 0:`true`,className:s,role:`dialog`,tabIndex:-1,onKeyDown:x,onMouseDown:e=>e.stopPropagation(),children:(0,a.jsx)(r,{children:n})})})}function u(e){return e?Array.from(e.querySelectorAll(c)).filter(e=>!e.hidden&&e.getAttribute(`aria-hidden`)!==`true`&&e.getClientRects().length>0):[]}function d(e,t){if(!t)return;let n=u(t);if(n.length===0){e.preventDefault(),t.focus();return}let r=n.indexOf(document.activeElement),i=e.shiftKey?r<=0?n.length-1:r-1:r<0||r===n.length-1?0:r+1;e.preventDefault(),n[i]?.focus()}function f(e,t=null,n){if(!e)return()=>void 0;let r=[],i=e.parentElement??e;for(;i.parentElement&&i!==document.body;){let e=i.parentElement;for(let t of Array.from(e.children)){if(t===i||!(t instanceof HTMLElement)||n&&t.matches(n))continue;let e=s.get(t)??{count:0,ariaHidden:t.getAttribute(`aria-hidden`),inert:t.inert};e.count+=1,s.set(t,e),r.push(t),t.inert=!0,t.setAttribute(`aria-hidden`,`true`)}if(i=e,t&&i===t)break}return()=>{for(let e of r.reverse()){let t=s.get(e);!t||--t.count>0||(s.delete(e),e.inert=t.inert,t.ariaHidden===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,t.ariaHidden))}}}export{l as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOverlay-CF8uB4qA.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/index-CM0IRu1U.js","assets/index-g7UqJhnX.css","assets/api-client-Dgz-fOMl.js","assets/icons-c3vt7y6n.js","assets/chevron-down-BnnT0tnM.js","assets/createLucideIcon-DF2VR6WA.js","assets/plus-DbASL_gy.js","assets/x-D9GTV9ke.js","assets/AppToastContext-C-FsCKXW.js","assets/ui-theme.generated-D-mc26qt.js","assets/App-BZuSv1XM.js","assets/useQuery-Bn3KqR4r.js","assets/schemas-lO3MoWQr.js","assets/common-BMjyKlX-.js","assets/settings-D7C-Auyi.js","assets/client-choice-storage-Iuzoszas.js","assets/requests-BCbaFiqV.js","assets/create-pipeline-CyUZrbbO.js","assets/profile-ref-DSNkG6Ol.js","assets/chunk-H3JZ3P5T-B0SCoPw4.js","assets/work-outputs-CK0nHe4g.js","assets/contracts-BLiqJxBv.js","assets/training-DCdoHJ0Y.js","assets/chunk-GJRXJL6G-pJp1DyJd.js","assets/reward-checks-Bcq9ETCA.js","assets/intake-contracts-BW0Y0C2R.js","assets/chat-resources-CTN4f6KC.js","assets/ponder-desktop-Dm7tOkKo.js","assets/app-models-Cz3yxq4x.js","assets/model-display-zPvC4L2B.js","assets/submit-issue-command-DZNW7Evj.js","assets/connected-app-mentions-D3wRZLwI.js","assets/profile-agent-labels-Duh96b8x.js","assets/browser-sidebar-links-ZyYiYBBd.js","assets/browser-url-LACq2Ngu.js","assets/query-scope-BRpcgljO.js","assets/bot-BNFltD5O.js","assets/chevron-right-C8K5PZj7.js","assets/copy-CBFg6m0d.js","assets/external-link-Cql9bKdv.js","assets/loader-circle-pxp89T5x.js","assets/maximize-2-yMp8X9ts.js","assets/message-square-DbIMQqfj.js","assets/refresh-cw-B27ohHfn.js","assets/square-terminal-CeoK51wH.js","assets/models-route-CWcJuOd0.js","assets/NativeSetupTerminal-BPSUFpRm.js","assets/AppDialog-BILEK4np.js","assets/PageChrome-5VRxH6Rp.js","assets/NativeSetupTerminal-3eR9D_R3.css","assets/organization-types-PP-yuR2J.js","assets/App-DpFKLxuA.css","assets/TerminalOverlay-DoUFGstN.css"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n,t as r}from"./index-CM0IRu1U.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./TerminalOverlay-CF8uB4qA.js`).then(e=>({default:e.TerminalOverlay})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54])));function s({open:e,connection:t,scope:n,tabs:r,onTabsChange:s,cwd:c,appId:l,workspaceName:u,queuedCommand:d,onClose:f}){let[p,m]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{e&&m(!0)},[e]),p?(0,a.jsx)(i.Suspense,{fallback:null,children:(0,a.jsx)(o,{open:e,connection:t,scope:n,tabs:r,onTabsChange:s,cwd:c,appId:l,workspaceName:u,queuedCommand:d,onClose:f})}):null}export{s as AppTerminalPanel};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalOverlay-C7OM2F0-.js","assets/rolldown-runtime-Dd_uD5pT.js","assets/index-D7igQSAg.js","assets/index-g7UqJhnX.css","assets/api-client-Dgz-fOMl.js","assets/icons-B8_Rkg-l.js","assets/chevron-down-75im8nFF.js","assets/createLucideIcon-CmkSm39S.js","assets/plus-DXZIpQuY.js","assets/x-Bhl-4Zlt.js","assets/AppToastContext-Dklk6CaG.js","assets/ui-theme.generated-D-mc26qt.js","assets/App-CNQi3RlI.js","assets/useQuery-yUz7Ui8g.js","assets/schemas-lO3MoWQr.js","assets/common-BMjyKlX-.js","assets/settings-D7C-Auyi.js","assets/client-choice-storage-CXlWJW5g.js","assets/requests-BCbaFiqV.js","assets/create-pipeline-CyUZrbbO.js","assets/profile-ref-DSNkG6Ol.js","assets/chunk-H3JZ3P5T-B0SCoPw4.js","assets/work-outputs-CK0nHe4g.js","assets/contracts-BLiqJxBv.js","assets/training-DCdoHJ0Y.js","assets/chunk-GJRXJL6G-pJp1DyJd.js","assets/reward-checks-Bcq9ETCA.js","assets/intake-contracts-BW0Y0C2R.js","assets/chat-resources-CTN4f6KC.js","assets/ponder-desktop-Dm7tOkKo.js","assets/app-models-Cz3yxq4x.js","assets/model-display-zPvC4L2B.js","assets/submit-issue-command-wfngGS6Y.js","assets/connected-app-mentions-D3wRZLwI.js","assets/profile-agent-labels-Duh96b8x.js","assets/browser-sidebar-links-ZyYiYBBd.js","assets/browser-url-LACq2Ngu.js","assets/query-scope-BRpcgljO.js","assets/bot-D-eTQib6.js","assets/chevron-right-CpbCIUFo.js","assets/copy-DRnATDDY.js","assets/external-link-D_nBEDFO.js","assets/loader-circle-D_KVxLLz.js","assets/maximize-2-B8HN3jsA.js","assets/message-square-CrDvzn66.js","assets/refresh-cw-CzVf5_oo.js","assets/square-terminal-Buj-s-fz.js","assets/models-route-CWcJuOd0.js","assets/NativeSetupTerminal-DrQldDsG.js","assets/AppDialog-DuSd0wk6.js","assets/PageChrome-BLLw_cEA.js","assets/NativeSetupTerminal-3eR9D_R3.css","assets/organization-types-PP-yuR2J.js","assets/App-DpFKLxuA.css","assets/TerminalOverlay-DoUFGstN.css"])))=>i.map(i=>d[i]);
2
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n,t as r}from"./index-D7igQSAg.js";var i=e(t(),1),a=n(),o=(0,i.lazy)(()=>r(()=>import(`./TerminalOverlay-C7OM2F0-.js`).then(e=>({default:e.TerminalOverlay})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54])));function s({open:e,connection:t,scope:n,tabs:r,onTabsChange:s,cwd:c,appId:l,workspaceName:u,queuedCommand:d,onClose:f}){let[p,m]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{e&&m(!0)},[e]),p?(0,a.jsx)(i.Suspense,{fallback:null,children:(0,a.jsx)(o,{open:e,connection:t,scope:n,tabs:r,onTabsChange:s,cwd:c,appId:l,workspaceName:u,queuedCommand:d,onClose:f})}):null}export{s as AppTerminalPanel};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-CM0IRu1U.js";var r=e(t(),1),i=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i,/^(?:ConnectionRequestError:\s*)?Couldn[’']t connect to OpenPond\.?$/i,/^Event stream disconnected$/i];function a(e,t=`Something went wrong.`){let n=(e instanceof Error?e.message:String(e??``)).trim();return n?o(n)?`Couldn’t connect to OpenPond.`:n:t}function o(e){let t=e.trim();return i.some(e=>e.test(t))||/(?:^|:\s*)(?:ConnectionRequestError:\s*)?Couldn[’']t connect to OpenPond\.?$/i.test(t)}var s=n(),c=(0,r.createContext)(null);function l({children:e,showToast:t}){return(0,s.jsx)(c.Provider,{value:t,children:e})}function u(){return(0,r.useContext)(c)}function d(e,t={}){let n=u(),i=(0,r.useRef)(null),s=t.enabled??!0,c=t.fallback??`Something went wrong.`,l=t.prefix?.trim()??``,d=e instanceof Error?e.message:String(e??``),f=e==null||e===``||o(d)?null:`${l}${l?`: `:``}${a(e,c)}`;(0,r.useEffect)(()=>{!s||!f?i.current=null:i.current!==f&&(i.current=f,n?.(f,`error`,{dedupeKey:`error:${f}`}))},[s,f,n])}export{o as a,a as i,u as n,d as r,l as t};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-D7igQSAg.js";var r=e(t(),1),i=[/^(?:(?:type)?error:\s*)?failed to fetch\.?$/i,/^networkerror when attempting to fetch resource\.?$/i,/^load failed\.?$/i,/^(?:ConnectionRequestError:\s*)?Couldn[’']t connect to OpenPond\.?$/i,/^Event stream disconnected$/i];function a(e,t=`Something went wrong.`){let n=(e instanceof Error?e.message:String(e??``)).trim();return n?o(n)?`Couldn’t connect to OpenPond.`:n:t}function o(e){let t=e.trim();return i.some(e=>e.test(t))||/(?:^|:\s*)(?:ConnectionRequestError:\s*)?Couldn[’']t connect to OpenPond\.?$/i.test(t)}var s=n(),c=(0,r.createContext)(null);function l({children:e,showToast:t}){return(0,s.jsx)(c.Provider,{value:t,children:e})}function u(){return(0,r.useContext)(c)}function d(e,t={}){let n=u(),i=(0,r.useRef)(null),s=t.enabled??!0,c=t.fallback??`Something went wrong.`,l=t.prefix?.trim()??``,d=e instanceof Error?e.message:String(e??``),f=e==null||e===``||o(d)?null:`${l}${l?`: `:``}${a(e,c)}`;(0,r.useEffect)(()=>{!s||!f?i.current=null:i.current!==f&&(i.current=f,n?.(f,`error`,{dedupeKey:`error:${f}`}))},[s,f,n])}export{o as a,a as i,u as n,d as r,l as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,l as n,m as r,s as i}from"./index-CM0IRu1U.js";import{T as a,t as o}from"./useQuery-Bn3KqR4r.js";import{a as s,c,d as l,m as u,o as d,p as f,r as p,v as m}from"./schemas-lO3MoWQr.js";import{d as h,h as g,i as _,p as v}from"./chunk-H3JZ3P5T-B0SCoPw4.js";import{C as y}from"./app-models-Cz3yxq4x.js";import{n as b}from"./api-client-Dgz-fOMl.js";import"./icons-c3vt7y6n.js";import{t as x}from"./chevron-right-C8K5PZj7.js";import{t as S}from"./external-link-Cql9bKdv.js";import{a as C,i as w,n as T,t as E}from"./settings-lists-DgSaJQA4.js";import{t as D}from"./plus-DbASL_gy.js";import{t as O}from"./refresh-cw-B27ohHfn.js";import{t as k}from"./x-D9GTV9ke.js";import{t as A}from"./NativeSetupTerminal-BPSUFpRm.js";import{At as j,Bt as M,Gt as N,Mn as P,Nn as F,Nt as I,Rt as L,bn as R,kt as z,un as ee}from"./App-BZuSv1XM.js";import{D as B,O as te}from"./MainPane-DDO6diPt.js";import{n as V,r as H,t as ne}from"./useAgentInventory-CrjIOmvb.js";/* empty css */var U=e(t(),1),W=r();function re({agent:e,account:t,native:n,inventory:r,projects:i,teamId:a,learningControl:o,connected:s,onHide:c,onManage:l}){let u=r?.collector.connections.filter(t=>t.source===e.id)??[],d=r?.sources.some(t=>t.source===e.id&&t.available&&t.capabilities.history);return(0,W.jsxs)(`article`,{className:`agent-connection-card`,"aria-label":e.name,children:[(0,W.jsxs)(`div`,{className:`agent-card-title`,children:[(0,W.jsx)(`img`,{src:e.icon,alt:``}),(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`agent-hide`,"aria-label":`Hide ${e.name}`,onClick:c,children:(0,W.jsx)(k,{size:14})})]}),e.id===`openpond_chat`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`small`,{children:t?.state===`signed_in`?`Connected to OpenPond`:`Sign in to OpenPond`}),(0,W.jsx)(`p`,{children:`Use Pal from the sidebar.`}),(0,W.jsx)(`button`,{type:`button`,className:`agent-account-link`,onClick:()=>void I({kind:`settings`,section:`account`}),children:`Account setup`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`small`,{children:n?n.available?n.enabled?`Ready to chat`:`Installed · chat disabled`:n.lastError??`Check installation`:`Conversation import`}),(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:!s,onClick:l,children:n?.available||u.length?`Manage`:`Connect`}),(0,W.jsx)(`div`,{className:`agent-card-sync`,children:u.length?u.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:H(e,r.collector)}),(0,W.jsxs)(`small`,{children:[i.find(t=>t.id===e.projectId&&e.teamId===a)?.content.name??e.projectId,` `,`· `,e.admitted,` tasks`]}),e.teamId===a?null:(0,W.jsxs)(`small`,{children:[`Team: `,e.teamId]}),e.queued?(0,W.jsxs)(`small`,{children:[e.queued,` updates queued`]}):null,e.lastAdmissionAt?(0,W.jsxs)(`small`,{children:[`Last sync: `,new Date(e.lastAdmissionAt).toLocaleString()]}):null,e.error?(0,W.jsx)(M,{error:e.error}):null]},e.id)):(0,W.jsx)(`small`,{children:r?d?`History available · sync not connected`:`No local history found`:`Reading local setup…`})})]}),o]})}function ie(e,t,n,r){let i=(0,U.useRef)({providers:t,onProvider:n});i.current={providers:t,onProvider:n};let a=JSON.stringify([`claude-code`,`opencode`,`grok-build`].map(e=>{let n=t?.providers[e];return[e,n?.binaryPath,n?.sourceHome,n?.enabled]}));(0,U.useEffect)(()=>{if(!e||!i.current.providers)return;let t=!1,n=[`claude-code`,`opencode`,`grok-build`].map(n=>{let a=i.current.providers?.providers[n],o=new AbortController,s=r>0?{promise:b(e,`/v1/providers/${n}/native-setup`,{method:`POST`,body:JSON.stringify({action:`check`}),signal:o.signal}),release:()=>o.abort()}:B(e,n,i.current.providers?.providers[n]);return s.promise.then(o=>{t||(r>0&&o.session&&!o.error&&te(e,n,o,a),i.current.onProvider(n,o.settings))},()=>{}),s});return()=>{t=!0,n.forEach(e=>e.release())}},[e,a,r])}var G=m().trim().min(1).max(240),K=f().int().positive(),q=p([`dataset`,`evaluator`,`model`,`training_configuration`,`training_run`,`harness`,`environment`,`experiment`,`learning_policy`,`deployment`]),J=u({kind:q,resourceId:G,release:_.nullable(),role:p([`training`,`validation`,`holdout`,`target`,`reward`,`evaluation`,`serving`,`source`])}).strict(),ae=c(`kind`,[u({kind:l(`model`),providerId:G,modelId:G,artifact:_.nullable(),messages:s(u({role:p([`system`,`user`,`assistant`]),content:m().max(1e5)}).strict()).max(100)}).strict(),u({kind:l(`harness`),profileRepositoryId:G,source:g}).strict(),u({kind:l(`agent`),source:v}).strict(),u({kind:l(`suite`),profileRepositoryId:G,suiteId:G,sources:s(g).min(1).max(1e3)}).strict().superRefine((e,t)=>{let n=e.sources[0],r=new Set;for(let[i,a]of e.sources.entries())r.has(a.definitionId)&&t.addIssue({code:`custom`,path:[`sources`,i],message:`Suite definitions must be unique.`}),r.add(a.definitionId),(a.profileId!==n.profileId||a.sourceRevision!==n.sourceRevision||a.catalogHash!==n.catalogHash||h(a.harnessRelease)!==h(n.harnessRelease))&&t.addIssue({code:`custom`,path:[`sources`,i],message:`Suite checks must belong to the same pinned Profile source and Harness release.`})})]),oe=u({name:m().trim().min(1).max(200),description:m().max(1e4),targets:s(u({id:G,name:m().trim().min(1).max(200),target:ae}).strict()).max(100),defaultTargetId:G.nullable(),resources:s(J).max(1e3)}).strict().superRefine((e,t)=>{new Set(e.targets.map(e=>e.id)).size!==e.targets.length&&t.addIssue({code:`custom`,path:[`targets`],message:`Target identities must be unique.`}),e.defaultTargetId&&!e.targets.some(t=>t.id===e.defaultTargetId)&&t.addIssue({code:`custom`,path:[`defaultTargetId`],message:`Default target must belong to this Project.`}),new Set(e.resources.map(e=>h(e))).size!==e.resources.length&&t.addIssue({code:`custom`,path:[`resources`],message:`Resource links must be unique.`})}),se=u({schemaVersion:l(`openpond.trainingProject.v1`),id:G,teamId:G,creatorUserId:G,ownerScope:p([`workspace`,`personal`]).optional(),revision:K,content:oe,archived:d(),createdAt:m().datetime(),updatedAt:m().datetime()}).strict();u({operationId:G,id:G,expectedRevision:f().int().nonnegative(),content:oe,ownerScope:p([`workspace`,`personal`]).optional()}).strict(),u({operationId:G,expectedRevision:K,archived:d()}).strict();var ce=u({teamId:G,projects:s(se).max(100),nextCursor:G.nullable()}).strict();u({operation:p([`evaluate`,`train`,`enable_learning`,`accept_candidate`,`serve`]),support:p([`supported`,`unsupported`]),state:p([`ready`,`needs_setup`,`blocked`]),reasons:s(u({code:G,message:m().min(1).max(2e3),field:m().nullable(),action:p([`choose_target`,`choose_data`,`choose_evaluator`,`configure_runtime`,`request_access`,`configure_budget`,`wait`,`review_evidence`]).nullable()}).strict()).max(100)}).strict().superRefine((e,t)=>{e.state===`ready`&&(e.support!==`supported`||e.reasons.length)&&t.addIssue({code:`custom`,message:`Ready operations must be supported with no blockers.`}),e.state!==`ready`&&!e.reasons.length&&t.addIssue({code:`custom`,message:`Unavailable operations must explain the next step.`})});var Y=new WeakMap;function le(e,t,n){let r=JSON.stringify([t?.activeProfile,t?.profile?.id,n]),i=e?Y.get(e)?.get(r):void 0,[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(0),p=t?.state===`signed_in`?a?.key===r&&a.connection===e?a.value:i:void 0;(0,U.useEffect)(()=>{if(!e||!n||t?.state!==`signed_in`)return;let i=new AbortController;u(!0),c(null);async function a(){let t=[],a=new Set,s;do{let r=ce.parse(await b(e,`/v1/training/evaluation-workspace`,{method:`POST`,body:JSON.stringify({teamId:n,operation:`projects`,value:{cursor:s}}),signal:i.signal}));if(r.teamId!==n)throw Error(`The hosted project workspace changed. Refresh connections.`);if(t.push(...r.projects.filter(e=>!e.archived)),s=r.nextCursor??void 0,s&&a.has(s))throw Error(`Project pagination stalled. Refresh connections.`);s&&a.add(s)}while(s&&!i.signal.aborted);if(i.signal.aborted)return;let c=Y.get(e);c||(c=new Map,Y.set(e,c));let l=c.get(r)?.selected,u={projects:t,selected:l&&t.some(e=>e.id===l)?l:t.length===1?t[0].id:``};c.set(r,u),o({key:r,connection:e,value:u})}return a().catch(e=>{i.signal.aborted||c(e instanceof Error?e.message:`Unable to list hosted projects.`)}).finally(()=>{i.signal.aborted||u(!1)}),()=>i.abort()},[e,r,n,t?.state,d]);let m=(0,U.useCallback)(t=>{if(!e)return;let n=Y.get(e)?.get(r);if(!n||!n.projects.some(e=>e.id===t))return;let i={...n,selected:t};Y.get(e).set(r,i),o({key:r,connection:e,value:i})},[e,r]);return{projects:p?.projects??[],projectId:p?.selected??``,select:m,error:s,loading:l,refresh:()=>f(e=>e+1)}}var ue=e(j(),1),de=e(z(),1);function fe({connection:e,connectionId:t,disabled:n,projectName:r,onUpload:i,onClose:a}){let[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(`all`),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(()=>new Map),[m,h]=(0,U.useState)(!0),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(0);w(e,g,()=>y(e=>e+1));let x=(0,U.useRef)(null),S=(0,U.useRef)(0);(0,U.useEffect)(()=>{let n=new AbortController;x.current?.abort(),x.current=n,h(!0),d(null),_(null);let r=window.setTimeout(()=>{let r=v!==S.current;S.current=v,b(e,`/v1/native-history/collector`,{method:`POST`,signal:n.signal,body:JSON.stringify({command:`conversations`,connectionId:t,query:o,range:c,refresh:r})}).then(e=>{n.signal.aborted||d(e)}).catch(e=>{n.signal.aborted||_(e instanceof Error?e.message:`Unable to list conversations.`)}).finally(()=>{n.signal.aborted||h(!1)})},200);return()=>{window.clearTimeout(r),n.abort(),x.current?.abort()}},[e,t,o,c,v]);async function C(){if(m||u?.nextOffset==null)return;let n=new AbortController;x.current=n,h(!0),_(null);try{let r=await b(e,`/v1/native-history/collector`,{method:`POST`,signal:n.signal,body:JSON.stringify({command:`conversations`,connectionId:t,query:o,range:c,offset:u.nextOffset})});n.signal.aborted||d(e=>({...r,items:[...new Map([...e?.items??[],...r.items].map(e=>[e.key,e])).values()]}))}catch(e){n.signal.aborted||_(e instanceof Error?e.message:`Unable to load more conversations.`)}finally{n.signal.aborted||h(!1)}}function T(e,t){p(n=>{let r=new Map(n);return t?r.set(e.key,e):r.delete(e.key),r})}let E=u?.items??[],D=E.filter(e=>!e.issue),O=D.length>0&&D.every(e=>f.has(e.key)),k=new Set(E.map(e=>e.key)),A=[...f.keys()].filter(e=>!k.has(e)).length;return(0,W.jsxs)(`section`,{className:`conversation-upload-picker`,"aria-label":`Choose conversations to upload`,children:[(0,W.jsx)(`h3`,{children:`Choose conversations`}),(0,W.jsxs)(`p`,{children:[`Upload to `,(0,W.jsx)(`strong`,{children:r}),`. This selection also sets which conversations later syncs update. Previously uploaded data stays in the project.`]}),(0,W.jsxs)(`div`,{className:`conversation-upload-toolbar`,children:[(0,W.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`Search conversations`,placeholder:`Search title, folder, or session ID`,value:o,disabled:n,onChange:e=>s(e.target.value)}),(0,W.jsx)(L,{label:`Conversation activity`,value:c,disabled:n,onChange:l,options:[{value:`all`,label:`All dates`},{value:`week`,label:`Active last week`},{value:`day`,label:`Active last day`}]})]}),(0,W.jsxs)(`div`,{className:`conversation-upload-selection`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[f.size,` selected`,A?` · ${A} outside this view`:``,u?` · ${u.total} matching`:``]}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>y(e=>e+1),children:`Refresh`}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||!f.size,onClick:()=>p(new Map),children:`Clear selection`})]}),(0,W.jsx)(`div`,{className:`evaluation-table-scroll evaluation-table-frame conversation-upload-table`,children:(0,W.jsxs)(`table`,{className:`training-data-table evaluation-workspace-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{children:(0,W.jsx)(`input`,{type:`checkbox`,className:`training-chat-checkbox`,"aria-label":`Select visible conversations`,checked:O,disabled:n||m||!D.length,onChange:e=>{let t=e.target.checked;p(e=>{let n=new Map(e);return D.forEach(e=>{t?n.set(e.key,e):n.delete(e.key)}),n})}})}),(0,W.jsx)(`th`,{children:`Conversation`}),(0,W.jsx)(`th`,{children:`Last activity`})]})}),(0,W.jsxs)(`tbody`,{children:[E.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{children:(0,W.jsx)(`input`,{type:`checkbox`,className:`training-chat-checkbox`,"aria-label":`Select ${e.title}`,checked:f.has(e.key),disabled:n||!!e.issue,onChange:t=>T(e,t.target.checked)})}),(0,W.jsxs)(`td`,{children:[(0,W.jsx)(`span`,{className:`conversation-upload-title`,title:e.title,children:e.title}),(0,W.jsx)(`small`,{title:e.cwd??e.nativeSessionId,children:e.cwd??e.nativeSessionId}),e.issue?(0,W.jsx)(`small`,{role:`status`,children:e.issue}):e.approved?(0,W.jsx)(`small`,{children:`Already approved for sync`}):null]}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`time`,{dateTime:e.updatedAt,children:new Date(e.updatedAt).toLocaleDateString()})})]},e.key)),m?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:3,role:`status`,children:`Loading conversations…`})}):!E.length&&!g?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:3,children:o.trim()||c!==`all`?`No conversations match these filters.`:`No saved conversations found in this installation.`})}):null]})]})}),g?(0,W.jsx)(M,{error:g,children:(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>y(e=>e+1),children:`Retry`})}):null,u?.nextOffset==null?null:(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>void C(),children:`Load more conversations`}),(0,W.jsx)(`p`,{children:`The complete selected conversations are uploaded, including their prompts, responses, and tool history. Date filters help you find conversations; they do not trim their contents.`}),(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:n||!f.size,onClick:()=>void i([...f.keys()]),children:`Upload ${f.size} conversation${f.size===1?``:`s`}`}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n,onClick:a,children:`Cancel`})]})]})}ue.default.extend(de.default);function pe({agent:e,inventory:t,connection:n,account:r,teamId:i,projects:a,projectId:o,onRefresh:s,learningUrl:c}){let l=t?.sources.filter(t=>t.source===e.id)??[],[u,d]=(0,U.useState)(l.length===1?l[0].instanceId:``),[f,p]=(0,U.useState)(o),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(null),C=l.find(e=>e.instanceId===u)??(!u&&l.length===1?l[0]:void 0),w=t?.collector.connections.filter(t=>t.source===e.id)??[],T=r?.baseUrl??r?.activeProfile?.baseUrl,E=r?.apiBaseUrl;async function D(e,t,r){if(!(!n||v||g)){y(!0),S(null);try{let a=await b(n,`/v1/native-history/collector`,{method:`POST`,body:JSON.stringify({command:e,...t?{connectionId:t}:{},...r?{sessionKeys:r}:{},...e===`connect`?{setup:{sourceInstanceId:C?.instanceId,teamId:i,projectId:f,accountBaseUrl:T,apiBaseUrl:E,range:`all`}}:{}})});a.command?_(a.command):await s()}catch(e){S(e instanceof Error?e.message:`Unable to update this connection.`)}finally{y(!1)}}}let O=v||g!==null,k=w.find(e=>e.id===m),j=g&&n?(0,W.jsx)(A,{connection:n,command:g,onComplete:()=>{_(null),h(null),s()},onClose:()=>{_(null),s()}}):null;return k&&n?(0,W.jsxs)(`div`,{className:`agent-conversation-setup provider-dialog-body`,children:[(0,W.jsx)(fe,{connection:n,connectionId:k.id,projectName:a.find(e=>e.id===k.projectId&&k.teamId===i)?.content.name??k.projectId,disabled:O||!!t?.collector.running,onClose:()=>h(null),onUpload:e=>D(`upload`,k.id,e)},k.id),x?(0,W.jsx)(M,{error:x}):null,j]}):(0,W.jsxs)(`div`,{className:`agent-conversation-setup provider-dialog-body`,children:[(0,W.jsxs)(`p`,{children:[`Sync saved `,e.name,` conversations to an existing OpenPond project. Connecting authorizes the destination. Choose conversations and confirm an upload when ready.`]}),w.map(n=>(0,W.jsxs)(`section`,{className:`agent-retained-connection`,"aria-label":`${e.name} sync connection`,children:[(0,W.jsx)(`strong`,{children:H(n,t.collector)}),(0,W.jsxs)(`span`,{children:[`Project:`,` `,n.teamId===i?a.find(e=>e.id===n.projectId)?.content.name??n.projectId:n.projectId,` `,`· Team: `,n.teamId]}),(0,W.jsx)(`small`,{children:n.accountBaseUrl??`Hosted destination`}),(0,W.jsx)(`small`,{className:`agent-source-path`,children:n.sourceRoot}),(0,W.jsxs)(`span`,{children:[n.admitted,` tasks imported · `,n.queued,` updates queued`]}),(0,W.jsx)(`small`,{children:n.selectedConversations===null?`All history approved for sync`:`${n.selectedConversations} conversations approved for sync`}),n.backfill.total>0&&n.backfill.stage!==`complete`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`progress`,{"aria-label":`History import progress`,value:n.backfill.admitted+n.backfill.skipped,max:n.backfill.total}),(0,W.jsxs)(`small`,{children:[n.backfill.admitted+n.backfill.skipped,` of`,` `,n.backfill.total,` conversations processed`]})]}):null,(0,W.jsx)(`small`,{children:n.lastAdmissionAt?`Last synced ${(0,ue.default)(n.lastAdmissionAt).fromNow()}`:`No uploads acknowledged yet`}),n.error?(0,W.jsx)(M,{error:n.error}):null,(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:O||n.state!==`active`||t?.collector.running,onClick:()=>h(n.id),children:`Choose conversations…`}),n.state===`disconnected`?(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void D(`reconnect`,n.id),children:`Reconnect`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void D(n.state===`paused`?`resume`:`pause`,n.id),children:n.state===`paused`?`Resume`:`Pause`}),(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>{window.confirm(`Disconnect this conversation source? Imported data stays in its project.`)&&D(`disconnect`,n.id)},children:`Disconnect`})]}),n.destinationLinks.tasks?(0,W.jsx)(`a`,{href:n.destinationLinks.tasks,target:`_blank`,rel:`noreferrer`,children:`View tasks`}):null,n.destinationLinks.conversations?(0,W.jsx)(`a`,{href:n.destinationLinks.conversations,target:`_blank`,rel:`noreferrer`,children:`View conversations`}):null]})]},n.id)),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),D(`connect`)},className:`agent-sync-form`,children:[(0,W.jsx)(`h3`,{children:w.length?`Add another connection`:`Connect conversations`}),(0,W.jsxs)(`label`,{className:`agent-source-field`,children:[`Source installation`,(0,W.jsx)(L,{label:`Source installation`,value:C?.instanceId??``,disabled:O,onChange:d,options:[{value:``,label:`Select installation`},...l.map(e=>({value:e.instanceId,label:e.root,disabled:!e.available||!e.capabilities.history}))]})]}),C?.reason?(0,W.jsx)(`small`,{children:C.reason}):null,l.some(e=>e.available&&e.capabilities.history)?null:(0,W.jsxs)(`small`,{children:[`No readable conversation history found.`,` `,e.provider?`Use Agent setup to check the installation, or create a conversation in this agent first.`:`Open this agent and create a conversation, then refresh connections.`]}),(0,W.jsxs)(`label`,{children:[`Project`,(0,W.jsx)(L,{label:`Upload destination project`,value:f,disabled:O||!i,onChange:p,searchable:!0,options:[{value:``,label:`Select project`},...a.map(e=>({value:e.id,label:e.content.name}))]})]}),(0,W.jsx)(`p`,{children:`No conversations are uploaded during setup. Continual imports are off by default and can be scheduled after choosing conversations.`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>I({kind:`settings`,section:`conversation-imports`}),children:`Manage continual imports in Settings`}),r?.state!==`signed_in`||!i?(0,W.jsx)(`small`,{children:`Sign in and select a default team in Account settings to choose a hosted project.`}):null,(0,W.jsx)(`button`,{type:`submit`,className:`agent-connect-button`,disabled:O||!C?.available||!C.capabilities.history||!a.some(e=>e.id===f)||!i||!T||!E||r?.state!==`signed_in`,children:v?`Opening setup…`:`Connect conversations`})]}),c?(0,W.jsx)(`a`,{className:`agent-learning-link`,href:c,target:`_blank`,rel:`noreferrer`,children:`Configure continual learning in Console`}):null,t?(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`CLI setup`}),(0,W.jsxs)(`small`,{className:`agent-source-path`,children:[`Importer directory: `,t.directory]}),(0,W.jsx)(`code`,{children:t.statusCommand})]}):null,x?(0,W.jsx)(M,{error:x}):null,j]})}var X=e=>JSON.stringify([e.origin,e.sourceInstanceId]),me=e=>({id:e.id,revision:e.revision,contentHash:e.contentHash});function Z(e,t,n,r,i){return b(e,`/v1/conversation-learning/${n}?${new URLSearchParams({teamId:t})}`,{method:r===void 0?`GET`:`POST`,...r===void 0?{}:{body:JSON.stringify(r)},signal:i})}function he(e,t,n,r){let i=a(),s=[`native-conversation-learning`,e?.serverUrl,n,t];return{...o({queryKey:s,enabled:!!(e&&t&&r),queryFn:({signal:n})=>Z(e,t,`options`,void 0,n),staleTime:15e3,refetchInterval:3e4}),refresh:()=>i.invalidateQueries({queryKey:s})}}function ge(e,t,n,r,i){return Z(e,t,`policies`,{...n?{id:n.id}:{},expectedRevision:n?.revision??0,configuration:r,enabled:i})}function Q(e,t,n=[]){let r=t?.configuration;return{projectId:e,name:r?.name??`Continuous learning`,mode:r?.mode??`activate`,definition:r?.definition??null,configurationId:r?.configuration?.id??``,trainingPolicyId:r?.learningPolicy?.id??``,graderIds:[],sourceKeys:[...new Set([...r?.sources.filter(e=>e.enabled).map(X)??[],...n.map(X)])],adapter:r?.adapter??{kind:`complete_text`,qualitativeOnly:!0},generator:r?.generator??null,graderSelection:r?.graderSelection??(t?{mode:`manual`}:{mode:`auto`,modelId:`gpt-6-luna`,sampleSize:8,maximumOutputTokens:2048,maximumSpendUsd:1}),schedule:r?.schedule??{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,hour:2,minute:0,endHour:6,endMinute:0},limits:r?.limits??{perCycleUsd:5,dailyUsd:5,monthlyUsd:25,gradeUsd:.2,maximumTasks:10,minimumExamples:5,maxGpuSeconds:10800,maximumAttempts:2,lookbackDays:30},exceptions:r?.exceptions??`block`,minimumScore:r?.minimumScore??.8,selection:r?.selection??{maximumSourceShare:1,maximumFailureShare:1,maximumLengthShare:1,replayFraction:.2,auditFraction:.1},acceptance:r?.acceptance??{minimumCasesPerCheck:20,minimumImprovement:.05,windowCasesPerCheck:20},failurePolicy:r?.failurePolicy??{pauseAfterConsecutiveFailures:3},...r?.serving?{serving:r.serving}:{serving:{targetId:``,canarySeconds:120,rollbackOnRuntimeFailure:!0}}}}function _e(e,t){let n=e?.configurations.find(e=>e.id===t);return e?.trainingPolicies.filter(e=>e.modelProjectId===n?.portableProjectId&&e.training.recipe.id===`model-recipe-${n?.etag}`&&!e.id.startsWith(`conversation-training-`))??[]}async function ve(e,t,n,r,i,a){let o=r.configurations.find(e=>e.id===n.configurationId),s=_e(r,n.configurationId).find(e=>e.id===n.trainingPolicyId);if(!n.name.trim())throw Error(`Enter a policy name.`);if(!r.projects.some(e=>e.id===n.projectId))throw Error(`This owned Project is unavailable for continuous learning.`);if(n.configurationId&&(!o||!r.projects.find(e=>e.id===n.projectId)?.configurationIds.includes(o.id)))throw Error(`Choose a model configuration attached to this Project.`);if(n.mode!==`evaluate`&&(!o||!s))throw Error(`Choose an owned model and its reviewed training setup.`);if(n.limits.perCycleUsd>n.limits.dailyUsd||n.limits.dailyUsd>n.limits.monthlyUsd)throw Error(`Daily and monthly spending limits must cover the run limit.`);if(n.limits.minimumExamples>n.limits.maximumTasks-Math.floor(n.limits.maximumTasks*(n.selection?.replayFraction??0)))throw Error(`Leave capacity for the minimum new examples after replay.`);let c=r.sources.filter(e=>e.projectId===n.projectId&&n.sourceKeys.includes(X(e)));if(!c.length)throw Error(`Select a source agent for this Project.`);let l=[...(i?.configuration.sources??[]).filter(e=>!c.some(t=>X(t)===X(e))).map(e=>({...e,enabled:!1})),...c.map(e=>({origin:e.origin,sourceInstanceId:e.sourceInstanceId,enabled:!0}))],u=n.definition;if(o&&(i?.configuration.configuration?.id!==o.id||i.configuration.configuration.expectedEtag!==o.etag))u=await Z(e,t,`definitions`,{projectId:n.projectId,configuration:{id:o.id,expectedRevision:o.revision,expectedEtag:o.etag}});else if(n.graderIds.length){let i=r.graders.flatMap(e=>e&&n.graderIds.includes(e.id)?[me(e)]:[]);u=await Z(e,t,`definitions`,{projectId:n.projectId,graders:i})}if(!u)throw Error(`Select evaluation rubrics or an existing task definition.`);let d=n.serving,f=r.servingTargets.find(e=>e.id===d?.targetId);if(n.mode===`activate`&&d?.targetId&&(!f||!f.enabled||f.projectId!==n.projectId))throw Error(`Select an available serving target in this Project.`);if(n.mode===`activate`&&(!d?.targetId||f?.hostedPonder)&&(d={targetId:(await Z(e,t,`serving-targets`,{action:`ensure_hosted_ponder`,projectId:n.projectId,bindingId:r.ponderBindingId})).id,canarySeconds:d?.canarySeconds??120,rollbackOnRuntimeFailure:!0}),n.mode===`activate`&&!d?.targetId)throw Error(`Choose a serving target, or enable the policy to register hosted Pal.`);let{sourceKeys:p,configurationId:m,trainingPolicyId:h,graderIds:g,..._}=n,v={..._,name:n.name.trim(),definition:u,sources:l,configuration:o?{id:o.id,expectedRevision:o.revision,expectedEtag:o.etag}:null,learningPolicy:s?me(s):null,...n.mode===`activate`?{serving:d}:{}};return n.mode!==`activate`&&delete v.serving,n.mode===`evaluate`&&delete v.acceptance,ge(e,t,i,v,a)}function ye({draft:e,options:t,loading:n,onChange:r}){let i=t?.sources.filter(t=>t.projectId===e.projectId)??[],a=i.filter(e=>[`active`,`paused`].includes(e.state)),o=a.length>0&&a.every(t=>e.sourceKeys.includes(X(t))),s=t=>r({...e,sourceKeys:t}),c=t?.graders.flatMap(e=>e?[e]:[])??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Source agents`}),(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,disabled:!a.length,ref:t=>{t&&(t.indeterminate=!o&&a.some(t=>e.sourceKeys.includes(X(t))))},onChange:t=>s(t.target.checked?[...new Set([...e.sourceKeys,...a.map(X)])]:e.sourceKeys.filter(e=>!a.some(t=>X(t)===e)))}),`Select all`,` `,(0,W.jsxs)(`small`,{children:[`(`,i.filter(t=>e.sourceKeys.includes(X(t))).length,` selected)`]})]}),(0,W.jsxs)(`div`,{className:`agent-learning-options`,"aria-label":`Source agents`,children:[i.map(t=>{let n=X(t),r=e.sourceKeys.includes(n),i=V.find(e=>e.id===(t.origin.startsWith(`native_`)?`openpond_chat`:t.origin)),a=t.origin===`native_chat`?`Pal Chat`:t.origin===`native_work`?`Pal Work`:i?.name??t.name;return(0,W.jsxs)(`label`,{className:`agent-learning-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:r,disabled:!r&&![`active`,`paused`].includes(t.state),onChange:t=>s(t.target.checked?[...new Set([...e.sourceKeys,n])]:e.sourceKeys.filter(e=>e!==n))}),i?(0,W.jsx)(`img`,{src:i.icon,alt:``}):null,(0,W.jsxs)(`span`,{children:[a,(0,W.jsx)(`small`,{children:t.sourceInstanceId?t.name===t.origin?`Local connection`:t.name:t.origin.startsWith(`native_`)?`Hosted conversations`:`Uploaded history`})]}),(0,W.jsx)(`small`,{children:t.state})]},n)}),i.length?null:(0,W.jsx)(`p`,{role:`status`,children:n?`Fetching source agents…`:`Connect or import an agent into this Project first.`})]}),(0,W.jsx)(`p`,{children:`Paused agents can use uploaded conversations. Selecting them leaves collection paused.`})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Evaluation rubrics`}),e.configurationId?(0,W.jsx)(`p`,{children:`The training configuration pins the task definition and its rubrics. Choose grader selection in Preparation.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:!c.length,checked:c.length>0&&c.every(t=>e.graderIds.includes(t.id)),onChange:t=>r({...e,graderIds:t.target.checked?c.map(e=>e.id):[]})}),`Select all `,(0,W.jsxs)(`small`,{children:[`(`,e.graderIds.length,` selected)`]})]}),(0,W.jsxs)(`div`,{className:`agent-learning-options`,"aria-label":`Evaluation rubrics`,children:[c.map(t=>(0,W.jsxs)(`label`,{className:`agent-learning-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.graderIds.includes(t.id),onChange:n=>r({...e,graderIds:n.target.checked?[...e.graderIds,t.id]:e.graderIds.filter(e=>e!==t.id)})}),(0,W.jsxs)(`span`,{children:[t.name,(0,W.jsxs)(`small`,{children:[`Version `,t.revision]})]})]},`${t.id}:${t.revision}`)),c.length?null:(0,W.jsx)(`p`,{role:`status`,children:n?`Fetching evaluation rubrics…`:`No owned evaluation rubrics are available.`})]}),e.definition&&!e.graderIds.length?(0,W.jsx)(`p`,{children:`The saved task definition and rubrics remain unchanged.`}):null,(0,W.jsxs)(`label`,{children:[`Existing task definition`,(0,W.jsxs)(`select`,{value:e.definition?.id??``,onChange:n=>{let i=t?.definitions.find(e=>e.id===n.target.value);r({...e,definition:i?{id:i.id,revision:i.revision,contentHash:i.contentHash}:null,graderIds:[]})},children:[(0,W.jsx)(`option`,{value:``,children:`Select a definition or choose rubrics above`}),e.definition&&!t?.definitions.some(t=>t.id===e.definition?.id)?(0,W.jsx)(`option`,{value:e.definition.id,children:`Saved task definition`}):null,t?.definitions.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.name,` (version `,e.revision,`)`]},e.id))]})]})]}),(0,W.jsxs)(`label`,{children:[`Minimum verified score`,(0,W.jsx)(`input`,{type:`number`,min:0,max:1,step:.01,value:e.minimumScore,onChange:t=>r({...e,minimumScore:Number(t.target.value)})})]})]})]})}function be({draft:e,options:t,loading:n,onChange:r}){let i=t?.projects.find(t=>t.id===e.projectId)?.configurationIds??[],a=_e(t,e.configurationId),o=e.graderSelection??{mode:`manual`};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Mode`,(0,W.jsxs)(`select`,{value:e.mode,onChange:t=>r({...e,mode:t.target.value}),children:[(0,W.jsx)(`option`,{value:`evaluate`,children:`Evaluate only`}),(0,W.jsx)(`option`,{value:`train`,children:`Train automatically, approve candidate`}),(0,W.jsx)(`option`,{value:`activate`,children:`Train and activate automatically`})]})]}),(0,W.jsxs)(`label`,{children:[`Model to train`,(0,W.jsxs)(`select`,{value:e.configurationId,onChange:n=>{let i=n.target.value,a=_e(t,i);r({...e,configurationId:i,trainingPolicyId:a.length===1?a[0].id:``,adapter:i?{kind:`reference_text`,inputPointer:`/prompt`,match:`contained`}:{kind:`complete_text`,qualitativeOnly:!0}})},children:[(0,W.jsx)(`option`,{value:``,children:n?`Fetching configurations…`:`Select configuration`}),t?.configurations.filter(e=>i.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),e.mode===`evaluate`?null:(0,W.jsxs)(`label`,{children:[`Reviewed training setup`,(0,W.jsxs)(`select`,{value:e.trainingPolicyId,onChange:t=>r({...e,trainingPolicyId:t.target.value}),children:[(0,W.jsx)(`option`,{value:``,children:`Select reviewed setup`}),a.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[`Reviewed setup (version `,e.revision,`)`]},e.id))]})]}),e.configurationId?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Task construction`,(0,W.jsxs)(`select`,{value:e.adapter.kind,onChange:t=>r({...e,adapter:t.target.value===`reference_text`?{kind:`reference_text`,inputPointer:`/prompt`,match:`contained`}:{kind:`complete_text`,qualitativeOnly:!0}}),children:[(0,W.jsx)(`option`,{value:`reference_text`,children:`Match a published executable task`}),(0,W.jsx)(`option`,{value:`complete_text`,children:`Complete text context and calibrated judges`})]})]}),e.adapter.kind===`reference_text`?(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`Public task input field`,(0,W.jsx)(`input`,{value:e.adapter.inputPointer,onChange:t=>r({...e,adapter:{kind:`reference_text`,inputPointer:t.target.value,match:e.adapter.kind===`reference_text`?e.adapter.match:`contained`}})})]}),(0,W.jsxs)(`label`,{children:[`Reference matching`,(0,W.jsxs)(`select`,{value:e.adapter.match,onChange:t=>r({...e,adapter:{kind:`reference_text`,inputPointer:e.adapter.kind===`reference_text`?e.adapter.inputPointer:`/prompt`,match:t.target.value}}),children:[(0,W.jsx)(`option`,{value:`contained`,children:`Contained`}),(0,W.jsx)(`option`,{value:`exact`,children:`Exact`})]})]})]}):null,(0,W.jsxs)(`label`,{children:[`Grader selection`,(0,W.jsxs)(`select`,{value:o.mode,onChange:t=>r({...e,graderSelection:t.target.value===`auto`?{mode:`auto`,modelId:`gpt-6-luna`,sampleSize:8,maximumOutputTokens:2048,maximumSpendUsd:1}:{mode:`manual`}}),children:[(0,W.jsx)(`option`,{value:`auto`,children:`Choose compatible rubrics automatically`}),(0,W.jsx)(`option`,{value:`manual`,children:`Use the pinned rubrics`})]})]}),o.mode===`auto`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Selection model`,(0,W.jsxs)(`select`,{value:o.modelId,onChange:t=>r({...e,graderSelection:{...o,modelId:t.target.value}}),children:[t?.generators.some(e=>e.id===o.modelId)?null:(0,W.jsx)(`option`,{value:o.modelId,children:o.modelId}),t?.generators.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`sampleSize`,`Sample examples`,1,30],[`maximumOutputTokens`,`Output token limit`,256,4096],[`maximumSpendUsd`,`Selection spending limit ($)`,.01,1e5]].map(([t,n,i,a])=>(0,W.jsxs)(`label`,{children:[n,(0,W.jsx)(`input`,{type:`number`,min:i,max:a,step:t===`maximumSpendUsd`?.01:1,value:o[t],onChange:n=>r({...e,graderSelection:{...o,[t]:Number(n.target.value)}})})]},t))})]}):null]}):null,(0,W.jsxs)(`label`,{children:[`Answer improvement model`,(0,W.jsxs)(`select`,{value:e.generator?.modelId??``,onChange:t=>r({...e,generator:t.target.value?{modelId:t.target.value,maximumOutputTokens:e.generator?.maximumOutputTokens??2048,maximumSpendUsd:e.generator?.maximumSpendUsd??.1}:null}),children:[(0,W.jsx)(`option`,{value:``,children:`Use recorded answers only`}),t?.generators.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),e.generator?(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`Per improved answer limit ($)`,(0,W.jsx)(`input`,{type:`number`,min:.01,step:.01,value:e.generator.maximumSpendUsd,onChange:t=>r({...e,generator:{...e.generator,maximumSpendUsd:Number(t.target.value)}})})]}),(0,W.jsxs)(`label`,{children:[`Output token limit`,(0,W.jsx)(`input`,{type:`number`,min:256,max:16384,value:e.generator.maximumOutputTokens,onChange:t=>r({...e,generator:{...e.generator,maximumOutputTokens:Number(t.target.value)}})})]})]}):null,e.mode===`activate`?(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Serving authorization`}),(0,W.jsxs)(`label`,{children:[`Serving target`,(0,W.jsxs)(`select`,{value:e.serving?.targetId??``,onChange:t=>r({...e,serving:{targetId:t.target.value,canarySeconds:e.serving?.canarySeconds??120,rollbackOnRuntimeFailure:!0}}),children:[(0,W.jsx)(`option`,{value:``,children:`Pal in this Project`}),t?.servingTargets.filter(t=>t.projectId===e.projectId&&t.enabled).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.hostedPonder?`Hosted Pal`:`${e.role} / ${e.roleTargetId}`},e.id))]})]}),(0,W.jsxs)(`label`,{children:[`Runtime canary (seconds)`,(0,W.jsx)(`input`,{type:`number`,min:30,max:600,value:e.serving?.canarySeconds??120,onChange:t=>r({...e,serving:{targetId:e.serving?.targetId??``,canarySeconds:Number(t.target.value),rollbackOnRuntimeFailure:!0}})})]}),(0,W.jsx)(`p`,{children:`Saving authorizes the selected target. Failed runtime checks restore its prior model. Training runs only within the saved policy's schedule and limits.`})]}):null]})}var xe=(e,t)=>e===void 0||t===void 0?``:`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`;function Se({draft:e,onChange:t}){let n=(n,r)=>t({...e,limits:{...e.limits,[n]:r}});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Run window`}),(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`From`,(0,W.jsx)(`input`,{type:`time`,required:!0,value:xe(e.schedule.hour,e.schedule.minute),onChange:n=>{let[r,i]=n.target.value.split(`:`).map(Number);t({...e,schedule:{...e.schedule,hour:r,minute:i}})}})]}),(0,W.jsxs)(`label`,{children:[`Until`,(0,W.jsx)(`input`,{type:`time`,value:xe(e.schedule.endHour,e.schedule.endMinute),onChange:n=>{let[r,i]=n.target.value.split(`:`).map(Number),{endHour:a,endMinute:o,...s}=e.schedule;t({...e,schedule:n.target.value?{...s,endHour:r,endMinute:i}:s})}})]})]}),(0,W.jsxs)(`label`,{children:[`Timezone`,(0,W.jsx)(`input`,{required:!0,value:e.schedule.timezone,onChange:n=>t({...e,schedule:{...e.schedule,timezone:n.target.value}})})]}),(0,W.jsx)(`p`,{children:`Queued learning starts within this window. A run already started may finish afterward.`})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Maximum spending`}),(0,W.jsx)(`p`,{children:`These are limits, not prices. Evaluation, answer improvements and training count toward them.`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`perCycleUsd`,`Per run ($)`],[`dailyUsd`,`Per day ($)`],[`monthlyUsd`,`Per month ($)`]].map(([t,r])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,required:!0,min:.01,max:1e5,step:.01,value:e.limits[t],onChange:e=>n(t,Number(e.target.value))})]},t))})]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Advanced limits`}),(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[[[`gradeUsd`,`Per evaluation ceiling ($)`,0,1e3,.01],[`maximumTasks`,`Maximum tasks`,1,200,1],[`minimumExamples`,`Minimum training examples`,1,200,1],[`maximumAttempts`,`Maximum correction attempts`,1,5,1],[`lookbackDays`,`Uploaded history window (days)`,1,30,1]].map(([t,r,i,a,o])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,required:!0,min:i,max:a,step:o,value:e.limits[t],onChange:e=>n(t,Number(e.target.value))})]},t)),(0,W.jsxs)(`label`,{children:[`Maximum GPU session (hours)`,(0,W.jsx)(`input`,{type:`number`,required:!0,min:.01,max:3,step:.01,value:e.limits.maxGpuSeconds/3600,onChange:e=>n(`maxGpuSeconds`,Math.round(Number(e.target.value)*3600))})]}),(0,W.jsxs)(`label`,{children:[`Pause after failed cycles`,(0,W.jsx)(`input`,{type:`number`,required:!0,min:1,max:20,value:e.failurePolicy?.pauseAfterConsecutiveFailures??3,onChange:n=>t({...e,failurePolicy:{pauseAfterConsecutiveFailures:Number(n.target.value)}})})]})]}),(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.exceptions===`eligible_remainder`,onChange:n=>t({...e,exceptions:n.target.checked?`eligible_remainder`:`block`})}),`Use the independently verified remainder when exceptions occur`]})]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Training data balance`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`maximumSourceShare`,`Maximum from one agent`,100],[`maximumFailureShare`,`Maximum from one error type`,100],[`maximumLengthShare`,`Maximum from one conversation length`,100],[`replayFraction`,`Previously learned examples`,50],[`auditFraction`,`Examples checked for quality`,100]].map(([n,r,i])=>(0,W.jsxs)(`label`,{children:[r,` (%)`,(0,W.jsx)(`input`,{type:`number`,min:+!!n.startsWith(`maximum`),max:i,value:Math.round((e.selection?.[n]??0)*100),onChange:r=>t({...e,selection:{maximumSourceShare:1,maximumFailureShare:1,maximumLengthShare:1,replayFraction:.2,auditFraction:.1,...e.selection,[n]:Number(r.target.value)/100}})})]},n))})]}),e.mode===`evaluate`?null:(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Checks before using the trained model`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`windowCasesPerCheck`,`New examples per quality check`,2,1e4],[`minimumCasesPerCheck`,`Minimum paired examples`,2,1e4],[`minimumImprovement`,`Required improvement`,1e-4,1]].map(([n,r,i,a])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,min:i,max:a,step:n===`minimumImprovement`?.01:1,value:e.acceptance?.[n]??i,onChange:r=>t({...e,acceptance:{minimumCasesPerCheck:20,windowCasesPerCheck:20,minimumImprovement:.05,...e.acceptance,[n]:Number(r.target.value)}})})]},n))}),(0,W.jsx)(`p`,{children:`Current and trained models use the same unseen examples. Insufficient evidence keeps the current model active.`})]})]})}function Ce({connection:e,teamId:t,projectId:n,projectName:r,initialPolicy:i,bindings:a,query:o,onClose:s}){let[c,l]=(0,U.useState)(i),[u,d]=(0,U.useState)(()=>Q(n,i,i?[]:a)),[f,p]=(0,U.useState)(!!o.data),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(i?.status===`enabled`||!i),[S,w]=(0,U.useState)(`sources`),[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(null),A=(0,U.useRef)(f);A.current=f;let j=o.data?.policies.filter(e=>e.configuration.projectId===n)??[];(0,U.useEffect)(()=>{if(!o.data||A.current)return;let e=o.data.policies.find(e=>e.configuration.projectId===n&&e.status===`enabled`)??o.data.policies.find(e=>e.configuration.projectId===n);l(e),d(Q(n,e,e?[]:a)),x(e?.status===`enabled`||!e),p(!0)},[o.data,n,a]);let N=()=>{g||(m?E(!0):s())},P=C(N);function F(e){let t=j.find(t=>t.id===e);t&&(l(t),d(Q(n,t)),x(t.status===`enabled`),h(!1),O(null),E(!1),y(null))}function I(e){d(e),h(!0)}async function L(){if(o.data&&f&&!g&&!o.isError){_(!0),y(null);try{await ve(e,t,u,o.data,c,b),await o.refresh(),h(!1),s()}catch(e){y(e instanceof Error?e.message:`Unable to save continuous learning.`)}finally{_(!1)}}}let R={draft:u,options:o.data,loading:o.isPending,onChange:I};return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:N,children:(0,W.jsxs)(`section`,{ref:P,className:`git-dialog provider-details-dialog agent-learning-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Continuous learning`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,"aria-label":`Close continuous learning`,disabled:g,onClick:N,children:(0,W.jsx)(k,{size:16})}),(0,W.jsx)(`div`,{className:`provider-dialog-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`Continuous learning`}),(0,W.jsx)(`span`,{children:r})]})}),T?(0,W.jsxs)(`div`,{className:`agent-learning-discard`,role:`alert`,children:[(0,W.jsx)(`p`,{children:`Discard unsaved policy changes?`}),(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>{E(!1),O(null)},children:`Keep editing`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>D?F(D):s(),children:`Discard changes`})]})]}):null,j.length>1?(0,W.jsxs)(`label`,{className:`agent-learning-policy-picker`,children:[`Learning policy`,(0,W.jsx)(`select`,{disabled:g,value:c?.id??``,onChange:e=>{m?(O(e.target.value),E(!0)):F(e.target.value)},children:j.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.configuration.name,` (`,e.status,`)`]},e.id))})]}):null,(0,W.jsx)(`div`,{className:`surface-tabs provider-agent-tabs`,role:`tablist`,"aria-label":`Continuous learning settings`,children:[[`sources`,`Sources & rubrics`],[`preparation`,`Preparation`],[`schedule`,`Run window & budget`]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,id:`learning-tab-${e}`,role:`tab`,"aria-selected":S===e,"aria-controls":`learning-panel-${e}`,tabIndex:S===e?0:-1,onClick:()=>w(e),onKeyDown:t=>{let n=[`sources`,`preparation`,`schedule`],r=n.indexOf(e);if([`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(t.key)){t.preventDefault();let e=n[t.key===`Home`?0:t.key===`End`?2:(r+(t.key===`ArrowRight`?1:2))%3];w(e),document.getElementById(`learning-tab-${e}`)?.focus()}},children:t},e))}),(0,W.jsxs)(`form`,{className:`agent-learning-form`,onSubmit:e=>{e.preventDefault(),L()},children:[(0,W.jsx)(`fieldset`,{disabled:!f||g,children:(0,W.jsxs)(`label`,{children:[`Policy name`,(0,W.jsx)(`input`,{required:!0,maxLength:200,value:u.name,onChange:e=>I({...u,name:e.target.value})})]})}),(0,W.jsx)(`div`,{id:`learning-panel-${S}`,role:`tabpanel`,"aria-labelledby":`learning-tab-${S}`,children:(0,W.jsx)(`fieldset`,{disabled:!f||g,children:S===`sources`?(0,W.jsx)(ye,{...R}):S===`preparation`?(0,W.jsx)(be,{...R}):(0,W.jsx)(Se,{...R})})}),o.isPending?(0,W.jsx)(`p`,{role:`status`,children:`Fetching available sources, rubrics and models…`}):null,o.isError?(0,W.jsx)(M,{error:o.error.message,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void o.refetch(),children:`Retry settings`})}):null,v?(0,W.jsx)(M,{error:v}):null,(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:b,disabled:!f||g,onChange:e=>{x(e.target.checked),h(!0)}}),`Enable this policy after saving`]}),(0,W.jsx)(`p`,{children:`Saving enables only the reviewed sources, schedule and limits. No training is dispatched by opening this dialog.`}),(0,W.jsxs)(`div`,{className:`settings-button-row agent-learning-footer`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:g,onClick:N,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!f||!o.data||o.isError||g||!u.sourceKeys.length,children:g?`Saving…`:b?`Save and enable`:`Save paused`})]})]})]})})}function we({agent:e,inventory:t,connection:n,teamId:r,projectId:i,projectName:a,query:o,signedIn:s}){let[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(``),v=(0,U.useMemo)(()=>new Set(t?.collector.connections.filter(t=>t.source===e.id&&t.teamId===r&&t.projectId===i&&t.state!==`disconnected`).map(e=>e.sourceInstanceId)??[]),[t,e.id,r,i]),y=o.data?.sources.filter(t=>t.projectId===i&&(e.id===`openpond_chat`?[`native_chat`,`native_work`].includes(t.origin)&&t.sourceInstanceId===null:t.origin===e.id&&t.sourceInstanceId!==null&&v.has(t.sourceInstanceId)))??[],b=[...new Set(y.flatMap(e=>e.sourceInstanceId?[e.sourceInstanceId]:[]))],x=b.includes(g)?g:b[0],S=y.filter(e=>e.sourceInstanceId===null||e.sourceInstanceId===x).map(e=>({origin:e.origin,sourceInstanceId:e.sourceInstanceId,enabled:!0})),C=o.data?.policies.filter(e=>e.configuration.projectId===i)??[],w=C.filter(e=>e.status===`enabled`&&e.configuration.sources.some(e=>e.enabled&&S.some(t=>X(t)===X(e)))),T=w[0]??C.find(e=>e.status===`enabled`)??C[0],E=!!(n&&r&&i&&s&&o.data?.projects.some(e=>e.id===i));async function D(e,t){if(!n||!r||!o.data)return;let a={...e.configuration,sources:e.configuration.sources.map(e=>S.some(t=>X(t)===X(e))?{...e,enabled:t}:e)};if(t)for(let e of S)a.sources.some(t=>X(t)===X(e))||a.sources.push(e);let s=o.data.servingTargets.find(e=>e.id===a.serving?.targetId);if(t&&a.mode===`activate`&&a.serving?.targetId&&(!s||!s.enabled||s.projectId!==i))throw Error(`Review the policy's serving target before adding a source.`);if(t&&a.mode===`activate`&&(!a.serving?.targetId||s?.hostedPonder)){let e=await Z(n,r,`serving-targets`,{action:`ensure_hosted_ponder`,projectId:i,bindingId:o.data.ponderBindingId});a={...a,serving:{targetId:e.id,canarySeconds:a.serving?.canarySeconds??120,rollbackOnRuntimeFailure:!0}}}return ge(n,r,e,a,a.sources.some(e=>e.enabled))}async function O(e){if(!f){p(!0),h(null);try{if(e){let e=C.find(e=>e.id===u);if(!e)throw Error(`Refresh the learning policy before joining.`);await D(e,!0),d(null)}else for(let e of w)await D(e,!1);await o.refresh()}catch(e){h(e instanceof Error?e.message:`Unable to update this learning source.`),await o.refresh()}finally{p(!1)}}}return(0,W.jsxs)(`div`,{className:`agent-learning-control`,children:[b.length>1?(0,W.jsxs)(`label`,{children:[`Learning connection`,(0,W.jsx)(`select`,{"aria-label":`${e.name} learning connection`,value:x,disabled:f,onChange:e=>_(e.target.value),children:b.map(e=>(0,W.jsx)(`option`,{value:e,children:y.find(t=>t.sourceInstanceId===e)?.name??`Local connection`},e))})]}):null,(0,W.jsxs)(`div`,{className:`agent-learning-control-row`,children:[(0,W.jsxs)(`label`,{className:`provider-toggle`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.name} continuous learning`,checked:w.length>0,disabled:!E||!S.length||o.isPending||o.isError||f,onChange:e=>{if(e.target.checked){let e=C.find(e=>e.status===`enabled`);e?d(e.id):l(!0)}else O(!1)}}),(0,W.jsx)(`span`,{"aria-hidden":`true`})]}),(0,W.jsx)(`button`,{type:`button`,className:`agent-learning-settings`,disabled:!n||!r||!i||!s||f,onClick:()=>l(!0),children:`Continuous learning`}),(0,W.jsx)(`small`,{children:o.isError?`Needs attention`:o.isPending?`Loading…`:w.length?`On schedule`:C.length?`Paused`:`Off`})]}),i&&!S.length&&o.data?(0,W.jsx)(`small`,{children:`Sync this agent to the selected Project to use its local connection.`}):null,m?(0,W.jsx)(M,{error:m}):null,c&&n&&r?(0,W.jsx)(Ce,{connection:n,teamId:r,projectId:i,projectName:a,initialPolicy:T,bindings:S,query:o,onClose:()=>l(!1)},i):null,u?(0,W.jsx)(Te,{policies:C.filter(e=>e.status===`enabled`),policyId:u,agentName:e.name,busy:f,error:m,onChoose:d,onClose:()=>{f||d(null)},onJoin:()=>void O(!0)}):null]})}function Te({policies:e,policyId:t,agentName:n,busy:r,error:i,onChoose:a,onClose:o,onJoin:s}){let c=C(o),l=e.find(e=>e.id===t);return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:o,children:(0,W.jsxs)(`section`,{ref:c,className:`git-dialog agent-learning-join`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add learning source`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,disabled:r,"aria-label":`Cancel`,onClick:o,children:(0,W.jsx)(k,{size:16})}),(0,W.jsxs)(`h2`,{children:[`Add `,n,` to `,l?.configuration.name??`continuous learning`,`?`]}),(0,W.jsx)(`p`,{children:`This agent will contribute conversations to the existing model, schedule and spending limits. Collection settings stay unchanged.`}),e.length>1?(0,W.jsxs)(`label`,{children:[`Existing policy`,(0,W.jsx)(`select`,{value:t,disabled:r,onChange:e=>a(e.target.value),children:e.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.configuration.name},e.id))})]}):null,i?(0,W.jsx)(M,{error:i}):null,(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:r,onClick:o,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,className:`primary`,disabled:r||!l,onClick:s,children:r?`Adding…`:`Add agent`})]})]})})}function Ee({connection:e,payload:t,onPayload:n,onToast:r}){let{inventory:i,error:a,loading:o,refresh:s}=ne(e),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(0),m=`openpond-agent-cards:${JSON.stringify(t?.account.activeProfile??null)}`,[h,g]=(0,U.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(m)??`null`);return Array.isArray(e)?e.filter(e=>typeof e==`string`&&V.some(t=>t.id===e)):[`oh_my_pi`]}catch{return[`oh_my_pi`]}});(0,U.useEffect)(()=>{try{localStorage.setItem(m,JSON.stringify(h))}catch{}},[m,h]);let[_,v]=(0,U.useState)(!1),b=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!_)return;let e=e=>{b.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&(v(!1),b.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[_]);let x=(0,U.useRef)({payload:t,onPayload:n});x.current={payload:t,onPayload:n};let S=(0,U.useRef)(!0);(0,U.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let C=t?.account??null,w=t?.preferences.defaultTeamId??C?.accounts.find(e=>e.isActive)?.apiKeyAccess?.teamId??null,k=(0,U.useCallback)(e=>{l(e),e&&r?.(e,`error`)},[r]),A=(0,U.useCallback)(e=>{let t=x.current;S.current&&t.payload&&t.onPayload({...t.payload,providers:e})},[]),j=(0,U.useCallback)((e,t)=>{let n=x.current;if(!S.current||!n.payload)return;let r=n.payload.providers,i={...n.payload,providers:{...r,statuses:{...r.statuses,[e]:t.statuses[e]},modelCaches:{...r.modelCaches,[e]:t.modelCaches[e]}}};x.current={...n,payload:i},n.onPayload(i)},[]);ie(e,t?.providers,j,f);let N=(0,U.useCallback)(e=>{let t=x.current;t.payload&&t.onPayload({...t.payload,preferences:e.preferences})},[]),P=E({connection:e,onError:k,onPayload:n,onPreferences:N,onProviders:A,preferences:y(t?.preferences),providers:t?.providers}),F=le(e,C,w),{projects:R,projectId:z,loading:ee,error:B}=F,te=he(e,w,JSON.stringify([C?.activeProfile??null,C?.profile?.id??null]),C?.state===`signed_in`),H=C?.baseUrl??C?.activeProfile?.baseUrl,G=H&&w?`${H.replace(/\/$/u,``)}/console/connections?${new URLSearchParams({teamId:w,...z?{project:z}:{}})}`:null,K=u?.provider,q=K?t?.providers.statuses[K]:null,J=u?(0,W.jsx)(pe,{agent:u,inventory:i,connection:e,account:C,teamId:w,projects:R,projectId:z,onRefresh:s,learningUrl:G},u.id):null;return(0,W.jsxs)(`section`,{className:`connected-agents-view`,"aria-label":`Continuous learning`,children:[(0,W.jsxs)(`div`,{className:`agent-connections-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`Continuous learning`}),(0,W.jsx)(`p`,{children:`Sync conversations from your installed agents and configure continuous learning.`})]}),(0,W.jsxs)(`div`,{className:`agent-connections-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o||!e,"aria-label":`Refresh agent connections`,onClick:()=>{s(),F.refresh(),p(e=>e+1)},children:(0,W.jsx)(O,{size:15})}),(0,W.jsxs)(`div`,{className:`agent-more`,ref:b,children:[(0,W.jsx)(`button`,{type:`button`,"aria-expanded":_,onClick:()=>v(e=>!e),children:`More agents`}),_?(0,W.jsxs)(`div`,{className:`agent-more-menu`,children:[V.filter(e=>h.includes(e.id)).map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{g(t=>t.filter(t=>t!==e.id)),v(!1)},children:[(0,W.jsx)(D,{size:14}),(0,W.jsx)(`span`,{children:e.name})]},e.id)),h.length===0?(0,W.jsx)(`span`,{children:`All agents shown`}):null]}):null]})]})]}),(0,W.jsxs)(`label`,{className:`agent-project-scope`,children:[`Project`,(0,W.jsx)(L,{label:`Connections project`,value:z,disabled:!R.length,onChange:F.select,searchable:!0,options:[{value:``,label:ee&&!R.length?`Fetching projects…`:`Select project`},...R.map(e=>({value:e.id,label:e.content.name}))]})]}),B?(0,W.jsx)(M,{error:B}):null,a?(0,W.jsx)(M,{error:a}):null,c?(0,W.jsx)(M,{error:c}):null,(0,W.jsx)(`div`,{className:`agent-connections-grid`,children:V.filter(e=>!h.includes(e.id)).map(n=>(0,W.jsx)(re,{agent:n,account:C,native:n.provider?t?.providers.statuses[n.provider]:null,inventory:i,projects:R,teamId:w,learningControl:(0,W.jsx)(we,{agent:n,inventory:i,connection:e,teamId:w,projectId:z,projectName:R.find(e=>e.id===z)?.content.name??`Selected Project`,query:te,signedIn:C?.state===`signed_in`}),connected:!!e,onHide:()=>g(e=>[...e,n.id]),onManage:()=>d(n)},`${JSON.stringify([C?.activeProfile,C?.profile?.id])}:${w}:${z}:${n.id}`))}),i?(0,W.jsxs)(`div`,{className:`agent-importer-footer`,children:[(0,W.jsx)(`span`,{children:i.collector.running?`Import in progress`:`No import running`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>I({kind:`settings`,section:`conversation-imports`}),children:`Conversation import settings`})]}):null,u&&K&&q&&t?(0,W.jsx)(T,{checkNativeProvider:P.checkNativeProvider,connection:e,account:C,codex:t.codex,providerId:K,providerBusy:P.providerBusy,settings:t.providers,status:q,onClose:()=>d(null),onDeleteCredential:P.deleteProviderCredential,onRefreshModels:P.refreshProviderModels,onSaveConfig:P.saveProviderConfig,onSaveCredential:P.saveProviderCredential,onStartOpenAiSubscriptionAuth:P.startOpenAiSubscriptionAuth,onValidate:P.validateProvider,conversationPanel:J}):u?(0,W.jsx)(De,{agent:u,onClose:()=>d(null),children:J}):null]})}function De({agent:e,onClose:t,children:n}){let r=C(t);return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:t,children:(0,W.jsxs)(`section`,{ref:r,className:`git-dialog provider-details-dialog agent-setup-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`${e.name} connection`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,"aria-label":`Close`,onClick:t,children:(0,W.jsx)(k,{size:16})}),(0,W.jsx)(`div`,{className:`provider-dialog-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:e.name}),(0,W.jsx)(`span`,{children:`Conversation syncing`})]})}),n]})})}var Oe=[`For agents`,`Featured`,`Productivity`,`Developer tools`],ke=new Set([`slack`,`google`,`github`,`mcp`]);function Ae({account:e,connection:t,defaultTeamId:n,onToast:r,payload:i,onPayload:a}){let[o,s]=(0,U.useState)(`apps`),c=(0,U.useId)(),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(`For agents`),[h,g]=(0,U.useState)(()=>F()),[_,v]=(0,U.useState)(null),y=e?.baseUrl??e?.activeProfile?.baseUrl??null,b=je(n,_),x=(0,U.useMemo)(()=>h.filter(e=>Pe(e,p)).filter(e=>Fe(e,d)),[p,d,h]);(0,U.useEffect)(()=>{let e=!0;return!t||o!==`apps`?(g(F()),v(null),()=>{e=!1}):(R.connectedAppStatus(t,{status:`all`}).then(t=>{e&&(g(t.apps),v(t.teamId?.trim()||null))}).catch(t=>{e&&(console.warn(`Unable to load connected app status.`,t),g(F()),v(null))}),()=>{e=!1})},[t,o]);function S(e){Le(P({appId:e.id,baseUrl:y,teamId:b})).catch(e=>{r?.(e instanceof Error?e.message:String(e),`error`)})}return(0,W.jsxs)(`div`,{className:`apps-workspace-view`,children:[(0,W.jsx)(`div`,{className:`apps-page-tabs`,role:`tablist`,"aria-label":`Apps pages`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=e.key===`Home`?`apps`:e.key===`End`?`agents`:o===`agents`?`apps`:`agents`;s(t),e.currentTarget.querySelector(`#${CSS.escape(`${c}-${t}`)}`)?.focus()},children:[{value:`apps`,label:`Apps`},{value:`agents`,label:`Continuous learning`}].map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,id:`${c}-${e.value}`,"aria-controls":`${c}-${e.value}-panel`,tabIndex:o===e.value?0:-1,"aria-selected":o===e.value,onClick:()=>s(e.value),children:e.label},e.value))}),(0,W.jsx)(`div`,{role:`tabpanel`,id:`${c}-${o}-panel`,"aria-labelledby":`${c}-${o}`,children:o===`agents`?(0,W.jsx)(Ee,{connection:t,payload:i,onPayload:a,onToast:r},JSON.stringify([e?.activeProfile,n])):(0,W.jsxs)(`section`,{className:`connected-apps-view`,"aria-label":`Apps`,children:[(0,W.jsxs)(`div`,{className:`connected-apps-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`Apps`}),(0,W.jsx)(`p`,{children:`Connect apps that agents can use for chat, knowledge, files, and workflow actions.`})]}),(0,W.jsxs)(`label`,{className:`connected-apps-search`,children:[(0,W.jsx)(N,{size:15}),(0,W.jsx)(`input`,{"aria-label":`Search apps`,onChange:e=>f(e.target.value),placeholder:`Search apps`,type:`search`,value:d})]})]}),(0,W.jsxs)(`section`,{className:`connected-apps-hero`,"aria-label":`App context`,children:[(0,W.jsxs)(`div`,{className:`connected-apps-hero-copy`,children:[(0,W.jsx)(`span`,{className:`connected-apps-hero-icon`,children:(0,W.jsx)($,{appId:`github`})}),(0,W.jsx)(`h2`,{children:`Work with your apps`}),(0,W.jsx)(`p`,{children:`Bring repositories, documents, chat, calendars, and custom MCP tools into OpenPond.`})]}),(0,W.jsxs)(`div`,{className:`connected-apps-context-card`,"aria-hidden":`true`,children:[(0,W.jsx)(`strong`,{children:`Agent context`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`files`,children:`Files`}),(0,W.jsx)(`span`,{className:`chat`,children:`Chat`}),(0,W.jsx)(`span`,{className:`oauth`,children:`OAuth`}),(0,W.jsx)(`span`,{className:`mcp`,children:`MCP`})]})]})]}),(0,W.jsx)(`div`,{className:`connected-apps-filters`,role:`tablist`,"aria-label":`App categories`,children:Oe.map(e=>(0,W.jsx)(`button`,{"aria-selected":p===e,className:p===e?`active`:``,onClick:()=>m(e),role:`tab`,type:`button`,children:e},e))}),(0,W.jsxs)(`div`,{className:`connected-apps-list`,children:[x.map(e=>(0,W.jsx)(Me,{app:e,onSelect:()=>u(e)},e.id)),x.length===0?(0,W.jsx)(`div`,{className:`connected-apps-empty`,children:`No apps match the current search.`}):null]}),l?(0,W.jsx)(Ne,{app:l,onClose:()=>u(null),onInstall:()=>S(l)}):null]})})]})}function je(e,t){return e?.trim()||t?.trim()||null}function Me({app:e,onSelect:t}){return(0,W.jsxs)(`button`,{className:`connected-app-row`,onClick:t,type:`button`,children:[(0,W.jsxs)(`span`,{className:`connected-app-row-main`,children:[(0,W.jsx)($,{appId:e.id}),(0,W.jsxs)(`span`,{className:`connected-app-copy`,children:[(0,W.jsxs)(`span`,{className:`connected-app-title`,children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsxs)(`span`,{children:[e.shortLabel===e.label?e.category:e.shortLabel,` / `,e.setupSurfaceLabel]})]}),(0,W.jsx)(`span`,{children:e.description}),(0,W.jsxs)(`span`,{className:`connected-app-capability-row`,children:[e.capabilityLabels.slice(0,2).map(e=>(0,W.jsx)(`span`,{children:e},e)),e.capabilityLabels.length>2?(0,W.jsxs)(`span`,{children:[`+`,e.capabilityLabels.length-2]}):null]})]})]}),(0,W.jsx)(`span`,{className:`connected-app-status-pill ${e.status}`,children:e.statusLabel}),(0,W.jsx)(x,{size:16})]})}function Ne({app:e,onClose:t,onInstall:n}){let r=e.connections.filter(e=>e.status===`active`);return(0,W.jsx)(`div`,{className:`connected-app-dialog-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`section`,{className:`connected-app-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`connected-app-dialog-title`,children:[(0,W.jsx)(`button`,{className:`connected-app-dialog-close`,type:`button`,"aria-label":`Close app details`,onClick:t,children:(0,W.jsx)(k,{size:17})}),(0,W.jsxs)(`div`,{className:`connected-app-dialog-identity`,children:[(0,W.jsx)(`span`,{className:`openpond-mark`,children:(0,W.jsx)(`img`,{alt:``,src:i})}),(0,W.jsxs)(`span`,{className:`connection-dots`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{})]}),(0,W.jsx)($,{appId:e.id})]}),(0,W.jsxs)(`h2`,{id:`connected-app-dialog-title`,children:[`Connect `,e.label]}),(0,W.jsxs)(`div`,{className:`connected-app-approval`,children:[(0,W.jsx)(ee,{size:16}),(0,W.jsx)(`span`,{children:e.statusLabel})]}),(0,W.jsxs)(`div`,{className:`connected-app-dialog-body`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:e.setupSurfaceLabel}),(0,W.jsx)(`p`,{children:`The web flow shows the provider account, workspace, and requested access before anything is connected.`})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Connected account`}),(0,W.jsx)(`p`,{children:Re(r)})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Available capabilities`}),(0,W.jsx)(`div`,{className:`connected-app-dialog-capabilities`,children:e.capabilities.map(e=>(0,W.jsx)(`span`,{children:e.label},e.id))})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Sandbox lease policy`}),(0,W.jsx)(`p`,{children:e.leasePolicy.leaseable?`Leaseable for ${e.leasePolicy.defaultTtlSeconds??0} seconds with scoped proxy access.`:`Managed as setup or tool discovery; no OAuth lease is required.`})]})]}),(0,W.jsxs)(`button`,{className:`connected-app-dialog-primary`,type:`button`,onClick:n,children:[(0,W.jsx)(`span`,{children:e.installLabel}),(0,W.jsx)(S,{size:15})]})]})})}function $({appId:e}){return(0,W.jsx)(`span`,{className:`connected-app-icon app-${e}`,children:(0,W.jsx)(`img`,{alt:``,src:Ie(e)})})}function Pe(e,t){return t===`For agents`?!0:t===`Featured`?ke.has(e.id):t===`Productivity`?e.category===`Productivity`||e.category===`Chat`:e.category===`Developer tools`||e.id===`mcp`}function Fe(e,t){let n=t.trim().toLowerCase();return!n||[e.id,e.label,e.shortLabel,e.category,e.description,e.providerFamily,e.setupSurface].some(e=>e.toLowerCase().includes(n))}function Ie(e){return n(e)}async function Le(e){let t=window.openpond?.browser;if(t){let n=await t.openExternal({conversationId:`connected-apps`,url:e});if(!n.ok)throw Error(n.error??`Unable to open app setup.`)}else window.open(e,`_blank`,`noopener,noreferrer`)}function Re(e){return e.length===0?`No active OAuth connection for this setup surface.`:e.map(e=>{let t=e.accountLabel??`Connected account`;return e.workspaceLabel?`${t} / ${e.workspaceLabel}`:t}).join(`, `)}export{Ae as AppsView};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,l as n,m as r,s as i}from"./index-D7igQSAg.js";import{T as a,t as o}from"./useQuery-yUz7Ui8g.js";import{a as s,c,d as l,m as u,o as d,p as f,r as p,v as m}from"./schemas-lO3MoWQr.js";import{d as h,h as g,i as _,p as v}from"./chunk-H3JZ3P5T-B0SCoPw4.js";import{C as y}from"./app-models-Cz3yxq4x.js";import{n as b}from"./api-client-Dgz-fOMl.js";import"./icons-B8_Rkg-l.js";import{t as x}from"./chevron-right-CpbCIUFo.js";import{t as S}from"./external-link-D_nBEDFO.js";import{a as C,i as w,n as T,t as E}from"./settings-lists-D2ol3uNK.js";import{t as D}from"./plus-DXZIpQuY.js";import{t as O}from"./refresh-cw-CzVf5_oo.js";import{t as k}from"./x-Bhl-4Zlt.js";import{t as A}from"./NativeSetupTerminal-DrQldDsG.js";import{At as j,Bt as M,Gt as N,Mn as P,Nn as F,Nt as I,Rt as L,bn as R,kt as z,un as ee}from"./App-CNQi3RlI.js";import{D as B,O as te}from"./MainPane-CqtgV9rU.js";import{n as V,r as H,t as ne}from"./useAgentInventory-Df64T07n.js";/* empty css */var U=e(t(),1),W=r();function re({agent:e,account:t,native:n,inventory:r,projects:i,teamId:a,learningControl:o,connected:s,onHide:c,onManage:l}){let u=r?.collector.connections.filter(t=>t.source===e.id)??[],d=r?.sources.some(t=>t.source===e.id&&t.available&&t.capabilities.history);return(0,W.jsxs)(`article`,{className:`agent-connection-card`,"aria-label":e.name,children:[(0,W.jsxs)(`div`,{className:`agent-card-title`,children:[(0,W.jsx)(`img`,{src:e.icon,alt:``}),(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`button`,{type:`button`,className:`agent-hide`,"aria-label":`Hide ${e.name}`,onClick:c,children:(0,W.jsx)(k,{size:14})})]}),e.id===`openpond_chat`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`small`,{children:t?.state===`signed_in`?`Connected to OpenPond`:`Sign in to OpenPond`}),(0,W.jsx)(`p`,{children:`Use Pal from the sidebar.`}),(0,W.jsx)(`button`,{type:`button`,className:`agent-account-link`,onClick:()=>void I({kind:`settings`,section:`account`}),children:`Account setup`})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`small`,{children:n?n.available?n.enabled?`Ready to chat`:`Installed · chat disabled`:n.lastError??`Check installation`:`Conversation import`}),(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:!s,onClick:l,children:n?.available||u.length?`Manage`:`Connect`}),(0,W.jsx)(`div`,{className:`agent-card-sync`,children:u.length?u.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:H(e,r.collector)}),(0,W.jsxs)(`small`,{children:[i.find(t=>t.id===e.projectId&&e.teamId===a)?.content.name??e.projectId,` `,`· `,e.admitted,` tasks`]}),e.teamId===a?null:(0,W.jsxs)(`small`,{children:[`Team: `,e.teamId]}),e.queued?(0,W.jsxs)(`small`,{children:[e.queued,` updates queued`]}):null,e.lastAdmissionAt?(0,W.jsxs)(`small`,{children:[`Last sync: `,new Date(e.lastAdmissionAt).toLocaleString()]}):null,e.error?(0,W.jsx)(M,{error:e.error}):null]},e.id)):(0,W.jsx)(`small`,{children:r?d?`History available · sync not connected`:`No local history found`:`Reading local setup…`})})]}),o]})}function ie(e,t,n,r){let i=(0,U.useRef)({providers:t,onProvider:n});i.current={providers:t,onProvider:n};let a=JSON.stringify([`claude-code`,`opencode`,`grok-build`].map(e=>{let n=t?.providers[e];return[e,n?.binaryPath,n?.sourceHome,n?.enabled]}));(0,U.useEffect)(()=>{if(!e||!i.current.providers)return;let t=!1,n=[`claude-code`,`opencode`,`grok-build`].map(n=>{let a=i.current.providers?.providers[n],o=new AbortController,s=r>0?{promise:b(e,`/v1/providers/${n}/native-setup`,{method:`POST`,body:JSON.stringify({action:`check`}),signal:o.signal}),release:()=>o.abort()}:B(e,n,i.current.providers?.providers[n]);return s.promise.then(o=>{t||(r>0&&o.session&&!o.error&&te(e,n,o,a),i.current.onProvider(n,o.settings))},()=>{}),s});return()=>{t=!0,n.forEach(e=>e.release())}},[e,a,r])}var G=m().trim().min(1).max(240),K=f().int().positive(),q=p([`dataset`,`evaluator`,`model`,`training_configuration`,`training_run`,`harness`,`environment`,`experiment`,`learning_policy`,`deployment`]),J=u({kind:q,resourceId:G,release:_.nullable(),role:p([`training`,`validation`,`holdout`,`target`,`reward`,`evaluation`,`serving`,`source`])}).strict(),ae=c(`kind`,[u({kind:l(`model`),providerId:G,modelId:G,artifact:_.nullable(),messages:s(u({role:p([`system`,`user`,`assistant`]),content:m().max(1e5)}).strict()).max(100)}).strict(),u({kind:l(`harness`),profileRepositoryId:G,source:g}).strict(),u({kind:l(`agent`),source:v}).strict(),u({kind:l(`suite`),profileRepositoryId:G,suiteId:G,sources:s(g).min(1).max(1e3)}).strict().superRefine((e,t)=>{let n=e.sources[0],r=new Set;for(let[i,a]of e.sources.entries())r.has(a.definitionId)&&t.addIssue({code:`custom`,path:[`sources`,i],message:`Suite definitions must be unique.`}),r.add(a.definitionId),(a.profileId!==n.profileId||a.sourceRevision!==n.sourceRevision||a.catalogHash!==n.catalogHash||h(a.harnessRelease)!==h(n.harnessRelease))&&t.addIssue({code:`custom`,path:[`sources`,i],message:`Suite checks must belong to the same pinned Profile source and Harness release.`})})]),oe=u({name:m().trim().min(1).max(200),description:m().max(1e4),targets:s(u({id:G,name:m().trim().min(1).max(200),target:ae}).strict()).max(100),defaultTargetId:G.nullable(),resources:s(J).max(1e3)}).strict().superRefine((e,t)=>{new Set(e.targets.map(e=>e.id)).size!==e.targets.length&&t.addIssue({code:`custom`,path:[`targets`],message:`Target identities must be unique.`}),e.defaultTargetId&&!e.targets.some(t=>t.id===e.defaultTargetId)&&t.addIssue({code:`custom`,path:[`defaultTargetId`],message:`Default target must belong to this Project.`}),new Set(e.resources.map(e=>h(e))).size!==e.resources.length&&t.addIssue({code:`custom`,path:[`resources`],message:`Resource links must be unique.`})}),se=u({schemaVersion:l(`openpond.trainingProject.v1`),id:G,teamId:G,creatorUserId:G,ownerScope:p([`workspace`,`personal`]).optional(),revision:K,content:oe,archived:d(),createdAt:m().datetime(),updatedAt:m().datetime()}).strict();u({operationId:G,id:G,expectedRevision:f().int().nonnegative(),content:oe,ownerScope:p([`workspace`,`personal`]).optional()}).strict(),u({operationId:G,expectedRevision:K,archived:d()}).strict();var ce=u({teamId:G,projects:s(se).max(100),nextCursor:G.nullable()}).strict();u({operation:p([`evaluate`,`train`,`enable_learning`,`accept_candidate`,`serve`]),support:p([`supported`,`unsupported`]),state:p([`ready`,`needs_setup`,`blocked`]),reasons:s(u({code:G,message:m().min(1).max(2e3),field:m().nullable(),action:p([`choose_target`,`choose_data`,`choose_evaluator`,`configure_runtime`,`request_access`,`configure_budget`,`wait`,`review_evidence`]).nullable()}).strict()).max(100)}).strict().superRefine((e,t)=>{e.state===`ready`&&(e.support!==`supported`||e.reasons.length)&&t.addIssue({code:`custom`,message:`Ready operations must be supported with no blockers.`}),e.state!==`ready`&&!e.reasons.length&&t.addIssue({code:`custom`,message:`Unavailable operations must explain the next step.`})});var Y=new WeakMap;function le(e,t,n){let r=JSON.stringify([t?.activeProfile,t?.profile?.id,n]),i=e?Y.get(e)?.get(r):void 0,[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)(null),[l,u]=(0,U.useState)(!1),[d,f]=(0,U.useState)(0),p=t?.state===`signed_in`?a?.key===r&&a.connection===e?a.value:i:void 0;(0,U.useEffect)(()=>{if(!e||!n||t?.state!==`signed_in`)return;let i=new AbortController;u(!0),c(null);async function a(){let t=[],a=new Set,s;do{let r=ce.parse(await b(e,`/v1/training/evaluation-workspace`,{method:`POST`,body:JSON.stringify({teamId:n,operation:`projects`,value:{cursor:s}}),signal:i.signal}));if(r.teamId!==n)throw Error(`The hosted project workspace changed. Refresh connections.`);if(t.push(...r.projects.filter(e=>!e.archived)),s=r.nextCursor??void 0,s&&a.has(s))throw Error(`Project pagination stalled. Refresh connections.`);s&&a.add(s)}while(s&&!i.signal.aborted);if(i.signal.aborted)return;let c=Y.get(e);c||(c=new Map,Y.set(e,c));let l=c.get(r)?.selected,u={projects:t,selected:l&&t.some(e=>e.id===l)?l:t.length===1?t[0].id:``};c.set(r,u),o({key:r,connection:e,value:u})}return a().catch(e=>{i.signal.aborted||c(e instanceof Error?e.message:`Unable to list hosted projects.`)}).finally(()=>{i.signal.aborted||u(!1)}),()=>i.abort()},[e,r,n,t?.state,d]);let m=(0,U.useCallback)(t=>{if(!e)return;let n=Y.get(e)?.get(r);if(!n||!n.projects.some(e=>e.id===t))return;let i={...n,selected:t};Y.get(e).set(r,i),o({key:r,connection:e,value:i})},[e,r]);return{projects:p?.projects??[],projectId:p?.selected??``,select:m,error:s,loading:l,refresh:()=>f(e=>e+1)}}var ue=e(j(),1),de=e(z(),1);function fe({connection:e,connectionId:t,disabled:n,projectName:r,onUpload:i,onClose:a}){let[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(`all`),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(()=>new Map),[m,h]=(0,U.useState)(!0),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(0);w(e,g,()=>y(e=>e+1));let x=(0,U.useRef)(null),S=(0,U.useRef)(0);(0,U.useEffect)(()=>{let n=new AbortController;x.current?.abort(),x.current=n,h(!0),d(null),_(null);let r=window.setTimeout(()=>{let r=v!==S.current;S.current=v,b(e,`/v1/native-history/collector`,{method:`POST`,signal:n.signal,body:JSON.stringify({command:`conversations`,connectionId:t,query:o,range:c,refresh:r})}).then(e=>{n.signal.aborted||d(e)}).catch(e=>{n.signal.aborted||_(e instanceof Error?e.message:`Unable to list conversations.`)}).finally(()=>{n.signal.aborted||h(!1)})},200);return()=>{window.clearTimeout(r),n.abort(),x.current?.abort()}},[e,t,o,c,v]);async function C(){if(m||u?.nextOffset==null)return;let n=new AbortController;x.current=n,h(!0),_(null);try{let r=await b(e,`/v1/native-history/collector`,{method:`POST`,signal:n.signal,body:JSON.stringify({command:`conversations`,connectionId:t,query:o,range:c,offset:u.nextOffset})});n.signal.aborted||d(e=>({...r,items:[...new Map([...e?.items??[],...r.items].map(e=>[e.key,e])).values()]}))}catch(e){n.signal.aborted||_(e instanceof Error?e.message:`Unable to load more conversations.`)}finally{n.signal.aborted||h(!1)}}function T(e,t){p(n=>{let r=new Map(n);return t?r.set(e.key,e):r.delete(e.key),r})}let E=u?.items??[],D=E.filter(e=>!e.issue),O=D.length>0&&D.every(e=>f.has(e.key)),k=new Set(E.map(e=>e.key)),A=[...f.keys()].filter(e=>!k.has(e)).length;return(0,W.jsxs)(`section`,{className:`conversation-upload-picker`,"aria-label":`Choose conversations to upload`,children:[(0,W.jsx)(`h3`,{children:`Choose conversations`}),(0,W.jsxs)(`p`,{children:[`Upload to `,(0,W.jsx)(`strong`,{children:r}),`. This selection also sets which conversations later syncs update. Previously uploaded data stays in the project.`]}),(0,W.jsxs)(`div`,{className:`conversation-upload-toolbar`,children:[(0,W.jsx)(`input`,{autoFocus:!0,type:`search`,"aria-label":`Search conversations`,placeholder:`Search title, folder, or session ID`,value:o,disabled:n,onChange:e=>s(e.target.value)}),(0,W.jsx)(L,{label:`Conversation activity`,value:c,disabled:n,onChange:l,options:[{value:`all`,label:`All dates`},{value:`week`,label:`Active last week`},{value:`day`,label:`Active last day`}]})]}),(0,W.jsxs)(`div`,{className:`conversation-upload-selection`,role:`status`,children:[(0,W.jsxs)(`span`,{children:[f.size,` selected`,A?` · ${A} outside this view`:``,u?` · ${u.total} matching`:``]}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>y(e=>e+1),children:`Refresh`}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||!f.size,onClick:()=>p(new Map),children:`Clear selection`})]}),(0,W.jsx)(`div`,{className:`evaluation-table-scroll evaluation-table-frame conversation-upload-table`,children:(0,W.jsxs)(`table`,{className:`training-data-table evaluation-workspace-table`,children:[(0,W.jsx)(`thead`,{children:(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`th`,{children:(0,W.jsx)(`input`,{type:`checkbox`,className:`training-chat-checkbox`,"aria-label":`Select visible conversations`,checked:O,disabled:n||m||!D.length,onChange:e=>{let t=e.target.checked;p(e=>{let n=new Map(e);return D.forEach(e=>{t?n.set(e.key,e):n.delete(e.key)}),n})}})}),(0,W.jsx)(`th`,{children:`Conversation`}),(0,W.jsx)(`th`,{children:`Last activity`})]})}),(0,W.jsxs)(`tbody`,{children:[E.map(e=>(0,W.jsxs)(`tr`,{children:[(0,W.jsx)(`td`,{children:(0,W.jsx)(`input`,{type:`checkbox`,className:`training-chat-checkbox`,"aria-label":`Select ${e.title}`,checked:f.has(e.key),disabled:n||!!e.issue,onChange:t=>T(e,t.target.checked)})}),(0,W.jsxs)(`td`,{children:[(0,W.jsx)(`span`,{className:`conversation-upload-title`,title:e.title,children:e.title}),(0,W.jsx)(`small`,{title:e.cwd??e.nativeSessionId,children:e.cwd??e.nativeSessionId}),e.issue?(0,W.jsx)(`small`,{role:`status`,children:e.issue}):e.approved?(0,W.jsx)(`small`,{children:`Already approved for sync`}):null]}),(0,W.jsx)(`td`,{children:(0,W.jsx)(`time`,{dateTime:e.updatedAt,children:new Date(e.updatedAt).toLocaleDateString()})})]},e.key)),m?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:3,role:`status`,children:`Loading conversations…`})}):!E.length&&!g?(0,W.jsx)(`tr`,{children:(0,W.jsx)(`td`,{colSpan:3,children:o.trim()||c!==`all`?`No conversations match these filters.`:`No saved conversations found in this installation.`})}):null]})]})}),g?(0,W.jsx)(M,{error:g,children:(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>y(e=>e+1),children:`Retry`})}):null,u?.nextOffset==null?null:(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n||m,onClick:()=>void C(),children:`Load more conversations`}),(0,W.jsx)(`p`,{children:`The complete selected conversations are uploaded, including their prompts, responses, and tool history. Date filters help you find conversations; they do not trim their contents.`}),(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:n||!f.size,onClick:()=>void i([...f.keys()]),children:`Upload ${f.size} conversation${f.size===1?``:`s`}`}),(0,W.jsx)(`button`,{type:`button`,className:`settings-secondary`,disabled:n,onClick:a,children:`Cancel`})]})]})}ue.default.extend(de.default);function pe({agent:e,inventory:t,connection:n,account:r,teamId:i,projects:a,projectId:o,onRefresh:s,learningUrl:c}){let l=t?.sources.filter(t=>t.source===e.id)??[],[u,d]=(0,U.useState)(l.length===1?l[0].instanceId:``),[f,p]=(0,U.useState)(o),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(null),[v,y]=(0,U.useState)(!1),[x,S]=(0,U.useState)(null),C=l.find(e=>e.instanceId===u)??(!u&&l.length===1?l[0]:void 0),w=t?.collector.connections.filter(t=>t.source===e.id)??[],T=r?.baseUrl??r?.activeProfile?.baseUrl,E=r?.apiBaseUrl;async function D(e,t,r){if(!(!n||v||g)){y(!0),S(null);try{let a=await b(n,`/v1/native-history/collector`,{method:`POST`,body:JSON.stringify({command:e,...t?{connectionId:t}:{},...r?{sessionKeys:r}:{},...e===`connect`?{setup:{sourceInstanceId:C?.instanceId,teamId:i,projectId:f,accountBaseUrl:T,apiBaseUrl:E,range:`all`}}:{}})});a.command?_(a.command):await s()}catch(e){S(e instanceof Error?e.message:`Unable to update this connection.`)}finally{y(!1)}}}let O=v||g!==null,k=w.find(e=>e.id===m),j=g&&n?(0,W.jsx)(A,{connection:n,command:g,onComplete:()=>{_(null),h(null),s()},onClose:()=>{_(null),s()}}):null;return k&&n?(0,W.jsxs)(`div`,{className:`agent-conversation-setup provider-dialog-body`,children:[(0,W.jsx)(fe,{connection:n,connectionId:k.id,projectName:a.find(e=>e.id===k.projectId&&k.teamId===i)?.content.name??k.projectId,disabled:O||!!t?.collector.running,onClose:()=>h(null),onUpload:e=>D(`upload`,k.id,e)},k.id),x?(0,W.jsx)(M,{error:x}):null,j]}):(0,W.jsxs)(`div`,{className:`agent-conversation-setup provider-dialog-body`,children:[(0,W.jsxs)(`p`,{children:[`Sync saved `,e.name,` conversations to an existing OpenPond project. Connecting authorizes the destination. Choose conversations and confirm an upload when ready.`]}),w.map(n=>(0,W.jsxs)(`section`,{className:`agent-retained-connection`,"aria-label":`${e.name} sync connection`,children:[(0,W.jsx)(`strong`,{children:H(n,t.collector)}),(0,W.jsxs)(`span`,{children:[`Project:`,` `,n.teamId===i?a.find(e=>e.id===n.projectId)?.content.name??n.projectId:n.projectId,` `,`· Team: `,n.teamId]}),(0,W.jsx)(`small`,{children:n.accountBaseUrl??`Hosted destination`}),(0,W.jsx)(`small`,{className:`agent-source-path`,children:n.sourceRoot}),(0,W.jsxs)(`span`,{children:[n.admitted,` tasks imported · `,n.queued,` updates queued`]}),(0,W.jsx)(`small`,{children:n.selectedConversations===null?`All history approved for sync`:`${n.selectedConversations} conversations approved for sync`}),n.backfill.total>0&&n.backfill.stage!==`complete`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`progress`,{"aria-label":`History import progress`,value:n.backfill.admitted+n.backfill.skipped,max:n.backfill.total}),(0,W.jsxs)(`small`,{children:[n.backfill.admitted+n.backfill.skipped,` of`,` `,n.backfill.total,` conversations processed`]})]}):null,(0,W.jsx)(`small`,{children:n.lastAdmissionAt?`Last synced ${(0,ue.default)(n.lastAdmissionAt).fromNow()}`:`No uploads acknowledged yet`}),n.error?(0,W.jsx)(M,{error:n.error}):null,(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,className:`agent-connect-button`,disabled:O||n.state!==`active`||t?.collector.running,onClick:()=>h(n.id),children:`Choose conversations…`}),n.state===`disconnected`?(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void D(`reconnect`,n.id),children:`Reconnect`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>void D(n.state===`paused`?`resume`:`pause`,n.id),children:n.state===`paused`?`Resume`:`Pause`}),(0,W.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>{window.confirm(`Disconnect this conversation source? Imported data stays in its project.`)&&D(`disconnect`,n.id)},children:`Disconnect`})]}),n.destinationLinks.tasks?(0,W.jsx)(`a`,{href:n.destinationLinks.tasks,target:`_blank`,rel:`noreferrer`,children:`View tasks`}):null,n.destinationLinks.conversations?(0,W.jsx)(`a`,{href:n.destinationLinks.conversations,target:`_blank`,rel:`noreferrer`,children:`View conversations`}):null]})]},n.id)),(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),D(`connect`)},className:`agent-sync-form`,children:[(0,W.jsx)(`h3`,{children:w.length?`Add another connection`:`Connect conversations`}),(0,W.jsxs)(`label`,{className:`agent-source-field`,children:[`Source installation`,(0,W.jsx)(L,{label:`Source installation`,value:C?.instanceId??``,disabled:O,onChange:d,options:[{value:``,label:`Select installation`},...l.map(e=>({value:e.instanceId,label:e.root,disabled:!e.available||!e.capabilities.history}))]})]}),C?.reason?(0,W.jsx)(`small`,{children:C.reason}):null,l.some(e=>e.available&&e.capabilities.history)?null:(0,W.jsxs)(`small`,{children:[`No readable conversation history found.`,` `,e.provider?`Use Agent setup to check the installation, or create a conversation in this agent first.`:`Open this agent and create a conversation, then refresh connections.`]}),(0,W.jsxs)(`label`,{children:[`Project`,(0,W.jsx)(L,{label:`Upload destination project`,value:f,disabled:O||!i,onChange:p,searchable:!0,options:[{value:``,label:`Select project`},...a.map(e=>({value:e.id,label:e.content.name}))]})]}),(0,W.jsx)(`p`,{children:`No conversations are uploaded during setup. Continual imports are off by default and can be scheduled after choosing conversations.`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>I({kind:`settings`,section:`conversation-imports`}),children:`Manage continual imports in Settings`}),r?.state!==`signed_in`||!i?(0,W.jsx)(`small`,{children:`Sign in and select a default team in Account settings to choose a hosted project.`}):null,(0,W.jsx)(`button`,{type:`submit`,className:`agent-connect-button`,disabled:O||!C?.available||!C.capabilities.history||!a.some(e=>e.id===f)||!i||!T||!E||r?.state!==`signed_in`,children:v?`Opening setup…`:`Connect conversations`})]}),c?(0,W.jsx)(`a`,{className:`agent-learning-link`,href:c,target:`_blank`,rel:`noreferrer`,children:`Configure continual learning in Console`}):null,t?(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`CLI setup`}),(0,W.jsxs)(`small`,{className:`agent-source-path`,children:[`Importer directory: `,t.directory]}),(0,W.jsx)(`code`,{children:t.statusCommand})]}):null,x?(0,W.jsx)(M,{error:x}):null,j]})}var X=e=>JSON.stringify([e.origin,e.sourceInstanceId]),me=e=>({id:e.id,revision:e.revision,contentHash:e.contentHash});function Z(e,t,n,r,i){return b(e,`/v1/conversation-learning/${n}?${new URLSearchParams({teamId:t})}`,{method:r===void 0?`GET`:`POST`,...r===void 0?{}:{body:JSON.stringify(r)},signal:i})}function he(e,t,n,r){let i=a(),s=[`native-conversation-learning`,e?.serverUrl,n,t];return{...o({queryKey:s,enabled:!!(e&&t&&r),queryFn:({signal:n})=>Z(e,t,`options`,void 0,n),staleTime:15e3,refetchInterval:3e4}),refresh:()=>i.invalidateQueries({queryKey:s})}}function ge(e,t,n,r,i){return Z(e,t,`policies`,{...n?{id:n.id}:{},expectedRevision:n?.revision??0,configuration:r,enabled:i})}function Q(e,t,n=[]){let r=t?.configuration;return{projectId:e,name:r?.name??`Continuous learning`,mode:r?.mode??`activate`,definition:r?.definition??null,configurationId:r?.configuration?.id??``,trainingPolicyId:r?.learningPolicy?.id??``,graderIds:[],sourceKeys:[...new Set([...r?.sources.filter(e=>e.enabled).map(X)??[],...n.map(X)])],adapter:r?.adapter??{kind:`complete_text`,qualitativeOnly:!0},generator:r?.generator??null,graderSelection:r?.graderSelection??(t?{mode:`manual`}:{mode:`auto`,modelId:`gpt-6-luna`,sampleSize:8,maximumOutputTokens:2048,maximumSpendUsd:1}),schedule:r?.schedule??{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,hour:2,minute:0,endHour:6,endMinute:0},limits:r?.limits??{perCycleUsd:5,dailyUsd:5,monthlyUsd:25,gradeUsd:.2,maximumTasks:10,minimumExamples:5,maxGpuSeconds:10800,maximumAttempts:2,lookbackDays:30},exceptions:r?.exceptions??`block`,minimumScore:r?.minimumScore??.8,selection:r?.selection??{maximumSourceShare:1,maximumFailureShare:1,maximumLengthShare:1,replayFraction:.2,auditFraction:.1},acceptance:r?.acceptance??{minimumCasesPerCheck:20,minimumImprovement:.05,windowCasesPerCheck:20},failurePolicy:r?.failurePolicy??{pauseAfterConsecutiveFailures:3},...r?.serving?{serving:r.serving}:{serving:{targetId:``,canarySeconds:120,rollbackOnRuntimeFailure:!0}}}}function _e(e,t){let n=e?.configurations.find(e=>e.id===t);return e?.trainingPolicies.filter(e=>e.modelProjectId===n?.portableProjectId&&e.training.recipe.id===`model-recipe-${n?.etag}`&&!e.id.startsWith(`conversation-training-`))??[]}async function ve(e,t,n,r,i,a){let o=r.configurations.find(e=>e.id===n.configurationId),s=_e(r,n.configurationId).find(e=>e.id===n.trainingPolicyId);if(!n.name.trim())throw Error(`Enter a policy name.`);if(!r.projects.some(e=>e.id===n.projectId))throw Error(`This owned Project is unavailable for continuous learning.`);if(n.configurationId&&(!o||!r.projects.find(e=>e.id===n.projectId)?.configurationIds.includes(o.id)))throw Error(`Choose a model configuration attached to this Project.`);if(n.mode!==`evaluate`&&(!o||!s))throw Error(`Choose an owned model and its reviewed training setup.`);if(n.limits.perCycleUsd>n.limits.dailyUsd||n.limits.dailyUsd>n.limits.monthlyUsd)throw Error(`Daily and monthly spending limits must cover the run limit.`);if(n.limits.minimumExamples>n.limits.maximumTasks-Math.floor(n.limits.maximumTasks*(n.selection?.replayFraction??0)))throw Error(`Leave capacity for the minimum new examples after replay.`);let c=r.sources.filter(e=>e.projectId===n.projectId&&n.sourceKeys.includes(X(e)));if(!c.length)throw Error(`Select a source agent for this Project.`);let l=[...(i?.configuration.sources??[]).filter(e=>!c.some(t=>X(t)===X(e))).map(e=>({...e,enabled:!1})),...c.map(e=>({origin:e.origin,sourceInstanceId:e.sourceInstanceId,enabled:!0}))],u=n.definition;if(o&&(i?.configuration.configuration?.id!==o.id||i.configuration.configuration.expectedEtag!==o.etag))u=await Z(e,t,`definitions`,{projectId:n.projectId,configuration:{id:o.id,expectedRevision:o.revision,expectedEtag:o.etag}});else if(n.graderIds.length){let i=r.graders.flatMap(e=>e&&n.graderIds.includes(e.id)?[me(e)]:[]);u=await Z(e,t,`definitions`,{projectId:n.projectId,graders:i})}if(!u)throw Error(`Select evaluation rubrics or an existing task definition.`);let d=n.serving,f=r.servingTargets.find(e=>e.id===d?.targetId);if(n.mode===`activate`&&d?.targetId&&(!f||!f.enabled||f.projectId!==n.projectId))throw Error(`Select an available serving target in this Project.`);if(n.mode===`activate`&&(!d?.targetId||f?.hostedPonder)&&(d={targetId:(await Z(e,t,`serving-targets`,{action:`ensure_hosted_ponder`,projectId:n.projectId,bindingId:r.ponderBindingId})).id,canarySeconds:d?.canarySeconds??120,rollbackOnRuntimeFailure:!0}),n.mode===`activate`&&!d?.targetId)throw Error(`Choose a serving target, or enable the policy to register hosted Pal.`);let{sourceKeys:p,configurationId:m,trainingPolicyId:h,graderIds:g,..._}=n,v={..._,name:n.name.trim(),definition:u,sources:l,configuration:o?{id:o.id,expectedRevision:o.revision,expectedEtag:o.etag}:null,learningPolicy:s?me(s):null,...n.mode===`activate`?{serving:d}:{}};return n.mode!==`activate`&&delete v.serving,n.mode===`evaluate`&&delete v.acceptance,ge(e,t,i,v,a)}function ye({draft:e,options:t,loading:n,onChange:r}){let i=t?.sources.filter(t=>t.projectId===e.projectId)??[],a=i.filter(e=>[`active`,`paused`].includes(e.state)),o=a.length>0&&a.every(t=>e.sourceKeys.includes(X(t))),s=t=>r({...e,sourceKeys:t}),c=t?.graders.flatMap(e=>e?[e]:[])??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Source agents`}),(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:o,disabled:!a.length,ref:t=>{t&&(t.indeterminate=!o&&a.some(t=>e.sourceKeys.includes(X(t))))},onChange:t=>s(t.target.checked?[...new Set([...e.sourceKeys,...a.map(X)])]:e.sourceKeys.filter(e=>!a.some(t=>X(t)===e)))}),`Select all`,` `,(0,W.jsxs)(`small`,{children:[`(`,i.filter(t=>e.sourceKeys.includes(X(t))).length,` selected)`]})]}),(0,W.jsxs)(`div`,{className:`agent-learning-options`,"aria-label":`Source agents`,children:[i.map(t=>{let n=X(t),r=e.sourceKeys.includes(n),i=V.find(e=>e.id===(t.origin.startsWith(`native_`)?`openpond_chat`:t.origin)),a=t.origin===`native_chat`?`Pal Chat`:t.origin===`native_work`?`Pal Work`:i?.name??t.name;return(0,W.jsxs)(`label`,{className:`agent-learning-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:r,disabled:!r&&![`active`,`paused`].includes(t.state),onChange:t=>s(t.target.checked?[...new Set([...e.sourceKeys,n])]:e.sourceKeys.filter(e=>e!==n))}),i?(0,W.jsx)(`img`,{src:i.icon,alt:``}):null,(0,W.jsxs)(`span`,{children:[a,(0,W.jsx)(`small`,{children:t.sourceInstanceId?t.name===t.origin?`Local connection`:t.name:t.origin.startsWith(`native_`)?`Hosted conversations`:`Uploaded history`})]}),(0,W.jsx)(`small`,{children:t.state})]},n)}),i.length?null:(0,W.jsx)(`p`,{role:`status`,children:n?`Fetching source agents…`:`Connect or import an agent into this Project first.`})]}),(0,W.jsx)(`p`,{children:`Paused agents can use uploaded conversations. Selecting them leaves collection paused.`})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Evaluation rubrics`}),e.configurationId?(0,W.jsx)(`p`,{children:`The training configuration pins the task definition and its rubrics. Choose grader selection in Preparation.`}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,disabled:!c.length,checked:c.length>0&&c.every(t=>e.graderIds.includes(t.id)),onChange:t=>r({...e,graderIds:t.target.checked?c.map(e=>e.id):[]})}),`Select all `,(0,W.jsxs)(`small`,{children:[`(`,e.graderIds.length,` selected)`]})]}),(0,W.jsxs)(`div`,{className:`agent-learning-options`,"aria-label":`Evaluation rubrics`,children:[c.map(t=>(0,W.jsxs)(`label`,{className:`agent-learning-option`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.graderIds.includes(t.id),onChange:n=>r({...e,graderIds:n.target.checked?[...e.graderIds,t.id]:e.graderIds.filter(e=>e!==t.id)})}),(0,W.jsxs)(`span`,{children:[t.name,(0,W.jsxs)(`small`,{children:[`Version `,t.revision]})]})]},`${t.id}:${t.revision}`)),c.length?null:(0,W.jsx)(`p`,{role:`status`,children:n?`Fetching evaluation rubrics…`:`No owned evaluation rubrics are available.`})]}),e.definition&&!e.graderIds.length?(0,W.jsx)(`p`,{children:`The saved task definition and rubrics remain unchanged.`}):null,(0,W.jsxs)(`label`,{children:[`Existing task definition`,(0,W.jsxs)(`select`,{value:e.definition?.id??``,onChange:n=>{let i=t?.definitions.find(e=>e.id===n.target.value);r({...e,definition:i?{id:i.id,revision:i.revision,contentHash:i.contentHash}:null,graderIds:[]})},children:[(0,W.jsx)(`option`,{value:``,children:`Select a definition or choose rubrics above`}),e.definition&&!t?.definitions.some(t=>t.id===e.definition?.id)?(0,W.jsx)(`option`,{value:e.definition.id,children:`Saved task definition`}):null,t?.definitions.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.name,` (version `,e.revision,`)`]},e.id))]})]})]}),(0,W.jsxs)(`label`,{children:[`Minimum verified score`,(0,W.jsx)(`input`,{type:`number`,min:0,max:1,step:.01,value:e.minimumScore,onChange:t=>r({...e,minimumScore:Number(t.target.value)})})]})]})]})}function be({draft:e,options:t,loading:n,onChange:r}){let i=t?.projects.find(t=>t.id===e.projectId)?.configurationIds??[],a=_e(t,e.configurationId),o=e.graderSelection??{mode:`manual`};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Mode`,(0,W.jsxs)(`select`,{value:e.mode,onChange:t=>r({...e,mode:t.target.value}),children:[(0,W.jsx)(`option`,{value:`evaluate`,children:`Evaluate only`}),(0,W.jsx)(`option`,{value:`train`,children:`Train automatically, approve candidate`}),(0,W.jsx)(`option`,{value:`activate`,children:`Train and activate automatically`})]})]}),(0,W.jsxs)(`label`,{children:[`Model to train`,(0,W.jsxs)(`select`,{value:e.configurationId,onChange:n=>{let i=n.target.value,a=_e(t,i);r({...e,configurationId:i,trainingPolicyId:a.length===1?a[0].id:``,adapter:i?{kind:`reference_text`,inputPointer:`/prompt`,match:`contained`}:{kind:`complete_text`,qualitativeOnly:!0}})},children:[(0,W.jsx)(`option`,{value:``,children:n?`Fetching configurations…`:`Select configuration`}),t?.configurations.filter(e=>i.includes(e.id)).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),e.mode===`evaluate`?null:(0,W.jsxs)(`label`,{children:[`Reviewed training setup`,(0,W.jsxs)(`select`,{value:e.trainingPolicyId,onChange:t=>r({...e,trainingPolicyId:t.target.value}),children:[(0,W.jsx)(`option`,{value:``,children:`Select reviewed setup`}),a.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[`Reviewed setup (version `,e.revision,`)`]},e.id))]})]}),e.configurationId?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Task construction`,(0,W.jsxs)(`select`,{value:e.adapter.kind,onChange:t=>r({...e,adapter:t.target.value===`reference_text`?{kind:`reference_text`,inputPointer:`/prompt`,match:`contained`}:{kind:`complete_text`,qualitativeOnly:!0}}),children:[(0,W.jsx)(`option`,{value:`reference_text`,children:`Match a published executable task`}),(0,W.jsx)(`option`,{value:`complete_text`,children:`Complete text context and calibrated judges`})]})]}),e.adapter.kind===`reference_text`?(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`Public task input field`,(0,W.jsx)(`input`,{value:e.adapter.inputPointer,onChange:t=>r({...e,adapter:{kind:`reference_text`,inputPointer:t.target.value,match:e.adapter.kind===`reference_text`?e.adapter.match:`contained`}})})]}),(0,W.jsxs)(`label`,{children:[`Reference matching`,(0,W.jsxs)(`select`,{value:e.adapter.match,onChange:t=>r({...e,adapter:{kind:`reference_text`,inputPointer:e.adapter.kind===`reference_text`?e.adapter.inputPointer:`/prompt`,match:t.target.value}}),children:[(0,W.jsx)(`option`,{value:`contained`,children:`Contained`}),(0,W.jsx)(`option`,{value:`exact`,children:`Exact`})]})]})]}):null,(0,W.jsxs)(`label`,{children:[`Grader selection`,(0,W.jsxs)(`select`,{value:o.mode,onChange:t=>r({...e,graderSelection:t.target.value===`auto`?{mode:`auto`,modelId:`gpt-6-luna`,sampleSize:8,maximumOutputTokens:2048,maximumSpendUsd:1}:{mode:`manual`}}),children:[(0,W.jsx)(`option`,{value:`auto`,children:`Choose compatible rubrics automatically`}),(0,W.jsx)(`option`,{value:`manual`,children:`Use the pinned rubrics`})]})]}),o.mode===`auto`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`label`,{children:[`Selection model`,(0,W.jsxs)(`select`,{value:o.modelId,onChange:t=>r({...e,graderSelection:{...o,modelId:t.target.value}}),children:[t?.generators.some(e=>e.id===o.modelId)?null:(0,W.jsx)(`option`,{value:o.modelId,children:o.modelId}),t?.generators.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`sampleSize`,`Sample examples`,1,30],[`maximumOutputTokens`,`Output token limit`,256,4096],[`maximumSpendUsd`,`Selection spending limit ($)`,.01,1e5]].map(([t,n,i,a])=>(0,W.jsxs)(`label`,{children:[n,(0,W.jsx)(`input`,{type:`number`,min:i,max:a,step:t===`maximumSpendUsd`?.01:1,value:o[t],onChange:n=>r({...e,graderSelection:{...o,[t]:Number(n.target.value)}})})]},t))})]}):null]}):null,(0,W.jsxs)(`label`,{children:[`Answer improvement model`,(0,W.jsxs)(`select`,{value:e.generator?.modelId??``,onChange:t=>r({...e,generator:t.target.value?{modelId:t.target.value,maximumOutputTokens:e.generator?.maximumOutputTokens??2048,maximumSpendUsd:e.generator?.maximumSpendUsd??.1}:null}),children:[(0,W.jsx)(`option`,{value:``,children:`Use recorded answers only`}),t?.generators.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),e.generator?(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`Per improved answer limit ($)`,(0,W.jsx)(`input`,{type:`number`,min:.01,step:.01,value:e.generator.maximumSpendUsd,onChange:t=>r({...e,generator:{...e.generator,maximumSpendUsd:Number(t.target.value)}})})]}),(0,W.jsxs)(`label`,{children:[`Output token limit`,(0,W.jsx)(`input`,{type:`number`,min:256,max:16384,value:e.generator.maximumOutputTokens,onChange:t=>r({...e,generator:{...e.generator,maximumOutputTokens:Number(t.target.value)}})})]})]}):null,e.mode===`activate`?(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Serving authorization`}),(0,W.jsxs)(`label`,{children:[`Serving target`,(0,W.jsxs)(`select`,{value:e.serving?.targetId??``,onChange:t=>r({...e,serving:{targetId:t.target.value,canarySeconds:e.serving?.canarySeconds??120,rollbackOnRuntimeFailure:!0}}),children:[(0,W.jsx)(`option`,{value:``,children:`Pal in this Project`}),t?.servingTargets.filter(t=>t.projectId===e.projectId&&t.enabled).map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.hostedPonder?`Hosted Pal`:`${e.role} / ${e.roleTargetId}`},e.id))]})]}),(0,W.jsxs)(`label`,{children:[`Runtime canary (seconds)`,(0,W.jsx)(`input`,{type:`number`,min:30,max:600,value:e.serving?.canarySeconds??120,onChange:t=>r({...e,serving:{targetId:e.serving?.targetId??``,canarySeconds:Number(t.target.value),rollbackOnRuntimeFailure:!0}})})]}),(0,W.jsx)(`p`,{children:`Saving authorizes the selected target. Failed runtime checks restore its prior model. Training runs only within the saved policy's schedule and limits.`})]}):null]})}var xe=(e,t)=>e===void 0||t===void 0?``:`${String(e).padStart(2,`0`)}:${String(t).padStart(2,`0`)}`;function Se({draft:e,onChange:t}){let n=(n,r)=>t({...e,limits:{...e.limits,[n]:r}});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Run window`}),(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[(0,W.jsxs)(`label`,{children:[`From`,(0,W.jsx)(`input`,{type:`time`,required:!0,value:xe(e.schedule.hour,e.schedule.minute),onChange:n=>{let[r,i]=n.target.value.split(`:`).map(Number);t({...e,schedule:{...e.schedule,hour:r,minute:i}})}})]}),(0,W.jsxs)(`label`,{children:[`Until`,(0,W.jsx)(`input`,{type:`time`,value:xe(e.schedule.endHour,e.schedule.endMinute),onChange:n=>{let[r,i]=n.target.value.split(`:`).map(Number),{endHour:a,endMinute:o,...s}=e.schedule;t({...e,schedule:n.target.value?{...s,endHour:r,endMinute:i}:s})}})]})]}),(0,W.jsxs)(`label`,{children:[`Timezone`,(0,W.jsx)(`input`,{required:!0,value:e.schedule.timezone,onChange:n=>t({...e,schedule:{...e.schedule,timezone:n.target.value}})})]}),(0,W.jsx)(`p`,{children:`Queued learning starts within this window. A run already started may finish afterward.`})]}),(0,W.jsxs)(`fieldset`,{children:[(0,W.jsx)(`legend`,{children:`Maximum spending`}),(0,W.jsx)(`p`,{children:`These are limits, not prices. Evaluation, answer improvements and training count toward them.`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`perCycleUsd`,`Per run ($)`],[`dailyUsd`,`Per day ($)`],[`monthlyUsd`,`Per month ($)`]].map(([t,r])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,required:!0,min:.01,max:1e5,step:.01,value:e.limits[t],onChange:e=>n(t,Number(e.target.value))})]},t))})]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Advanced limits`}),(0,W.jsxs)(`div`,{className:`agent-learning-columns`,children:[[[`gradeUsd`,`Per evaluation ceiling ($)`,0,1e3,.01],[`maximumTasks`,`Maximum tasks`,1,200,1],[`minimumExamples`,`Minimum training examples`,1,200,1],[`maximumAttempts`,`Maximum correction attempts`,1,5,1],[`lookbackDays`,`Uploaded history window (days)`,1,30,1]].map(([t,r,i,a,o])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,required:!0,min:i,max:a,step:o,value:e.limits[t],onChange:e=>n(t,Number(e.target.value))})]},t)),(0,W.jsxs)(`label`,{children:[`Maximum GPU session (hours)`,(0,W.jsx)(`input`,{type:`number`,required:!0,min:.01,max:3,step:.01,value:e.limits.maxGpuSeconds/3600,onChange:e=>n(`maxGpuSeconds`,Math.round(Number(e.target.value)*3600))})]}),(0,W.jsxs)(`label`,{children:[`Pause after failed cycles`,(0,W.jsx)(`input`,{type:`number`,required:!0,min:1,max:20,value:e.failurePolicy?.pauseAfterConsecutiveFailures??3,onChange:n=>t({...e,failurePolicy:{pauseAfterConsecutiveFailures:Number(n.target.value)}})})]})]}),(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:e.exceptions===`eligible_remainder`,onChange:n=>t({...e,exceptions:n.target.checked?`eligible_remainder`:`block`})}),`Use the independently verified remainder when exceptions occur`]})]}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Training data balance`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`maximumSourceShare`,`Maximum from one agent`,100],[`maximumFailureShare`,`Maximum from one error type`,100],[`maximumLengthShare`,`Maximum from one conversation length`,100],[`replayFraction`,`Previously learned examples`,50],[`auditFraction`,`Examples checked for quality`,100]].map(([n,r,i])=>(0,W.jsxs)(`label`,{children:[r,` (%)`,(0,W.jsx)(`input`,{type:`number`,min:+!!n.startsWith(`maximum`),max:i,value:Math.round((e.selection?.[n]??0)*100),onChange:r=>t({...e,selection:{maximumSourceShare:1,maximumFailureShare:1,maximumLengthShare:1,replayFraction:.2,auditFraction:.1,...e.selection,[n]:Number(r.target.value)/100}})})]},n))})]}),e.mode===`evaluate`?null:(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:`Checks before using the trained model`}),(0,W.jsx)(`div`,{className:`agent-learning-columns`,children:[[`windowCasesPerCheck`,`New examples per quality check`,2,1e4],[`minimumCasesPerCheck`,`Minimum paired examples`,2,1e4],[`minimumImprovement`,`Required improvement`,1e-4,1]].map(([n,r,i,a])=>(0,W.jsxs)(`label`,{children:[r,(0,W.jsx)(`input`,{type:`number`,min:i,max:a,step:n===`minimumImprovement`?.01:1,value:e.acceptance?.[n]??i,onChange:r=>t({...e,acceptance:{minimumCasesPerCheck:20,windowCasesPerCheck:20,minimumImprovement:.05,...e.acceptance,[n]:Number(r.target.value)}})})]},n))}),(0,W.jsx)(`p`,{children:`Current and trained models use the same unseen examples. Insufficient evidence keeps the current model active.`})]})]})}function Ce({connection:e,teamId:t,projectId:n,projectName:r,initialPolicy:i,bindings:a,query:o,onClose:s}){let[c,l]=(0,U.useState)(i),[u,d]=(0,U.useState)(()=>Q(n,i,i?[]:a)),[f,p]=(0,U.useState)(!!o.data),[m,h]=(0,U.useState)(!1),[g,_]=(0,U.useState)(!1),[v,y]=(0,U.useState)(null),[b,x]=(0,U.useState)(i?.status===`enabled`||!i),[S,w]=(0,U.useState)(`sources`),[T,E]=(0,U.useState)(!1),[D,O]=(0,U.useState)(null),A=(0,U.useRef)(f);A.current=f;let j=o.data?.policies.filter(e=>e.configuration.projectId===n)??[];(0,U.useEffect)(()=>{if(!o.data||A.current)return;let e=o.data.policies.find(e=>e.configuration.projectId===n&&e.status===`enabled`)??o.data.policies.find(e=>e.configuration.projectId===n);l(e),d(Q(n,e,e?[]:a)),x(e?.status===`enabled`||!e),p(!0)},[o.data,n,a]);let N=()=>{g||(m?E(!0):s())},P=C(N);function F(e){let t=j.find(t=>t.id===e);t&&(l(t),d(Q(n,t)),x(t.status===`enabled`),h(!1),O(null),E(!1),y(null))}function I(e){d(e),h(!0)}async function L(){if(o.data&&f&&!g&&!o.isError){_(!0),y(null);try{await ve(e,t,u,o.data,c,b),await o.refresh(),h(!1),s()}catch(e){y(e instanceof Error?e.message:`Unable to save continuous learning.`)}finally{_(!1)}}}let R={draft:u,options:o.data,loading:o.isPending,onChange:I};return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:N,children:(0,W.jsxs)(`section`,{ref:P,className:`git-dialog provider-details-dialog agent-learning-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`Continuous learning`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,"aria-label":`Close continuous learning`,disabled:g,onClick:N,children:(0,W.jsx)(k,{size:16})}),(0,W.jsx)(`div`,{className:`provider-dialog-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`Continuous learning`}),(0,W.jsx)(`span`,{children:r})]})}),T?(0,W.jsxs)(`div`,{className:`agent-learning-discard`,role:`alert`,children:[(0,W.jsx)(`p`,{children:`Discard unsaved policy changes?`}),(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:()=>{E(!1),O(null)},children:`Keep editing`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>D?F(D):s(),children:`Discard changes`})]})]}):null,j.length>1?(0,W.jsxs)(`label`,{className:`agent-learning-policy-picker`,children:[`Learning policy`,(0,W.jsx)(`select`,{disabled:g,value:c?.id??``,onChange:e=>{m?(O(e.target.value),E(!0)):F(e.target.value)},children:j.map(e=>(0,W.jsxs)(`option`,{value:e.id,children:[e.configuration.name,` (`,e.status,`)`]},e.id))})]}):null,(0,W.jsx)(`div`,{className:`surface-tabs provider-agent-tabs`,role:`tablist`,"aria-label":`Continuous learning settings`,children:[[`sources`,`Sources & rubrics`],[`preparation`,`Preparation`],[`schedule`,`Run window & budget`]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,id:`learning-tab-${e}`,role:`tab`,"aria-selected":S===e,"aria-controls":`learning-panel-${e}`,tabIndex:S===e?0:-1,onClick:()=>w(e),onKeyDown:t=>{let n=[`sources`,`preparation`,`schedule`],r=n.indexOf(e);if([`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(t.key)){t.preventDefault();let e=n[t.key===`Home`?0:t.key===`End`?2:(r+(t.key===`ArrowRight`?1:2))%3];w(e),document.getElementById(`learning-tab-${e}`)?.focus()}},children:t},e))}),(0,W.jsxs)(`form`,{className:`agent-learning-form`,onSubmit:e=>{e.preventDefault(),L()},children:[(0,W.jsx)(`fieldset`,{disabled:!f||g,children:(0,W.jsxs)(`label`,{children:[`Policy name`,(0,W.jsx)(`input`,{required:!0,maxLength:200,value:u.name,onChange:e=>I({...u,name:e.target.value})})]})}),(0,W.jsx)(`div`,{id:`learning-panel-${S}`,role:`tabpanel`,"aria-labelledby":`learning-tab-${S}`,children:(0,W.jsx)(`fieldset`,{disabled:!f||g,children:S===`sources`?(0,W.jsx)(ye,{...R}):S===`preparation`?(0,W.jsx)(be,{...R}):(0,W.jsx)(Se,{...R})})}),o.isPending?(0,W.jsx)(`p`,{role:`status`,children:`Fetching available sources, rubrics and models…`}):null,o.isError?(0,W.jsx)(M,{error:o.error.message,children:(0,W.jsx)(`button`,{type:`button`,onClick:()=>void o.refetch(),children:`Retry settings`})}):null,v?(0,W.jsx)(M,{error:v}):null,(0,W.jsxs)(`label`,{className:`agent-learning-check`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:b,disabled:!f||g,onChange:e=>{x(e.target.checked),h(!0)}}),`Enable this policy after saving`]}),(0,W.jsx)(`p`,{children:`Saving enables only the reviewed sources, schedule and limits. No training is dispatched by opening this dialog.`}),(0,W.jsxs)(`div`,{className:`settings-button-row agent-learning-footer`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:g,onClick:N,children:`Cancel`}),(0,W.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!f||!o.data||o.isError||g||!u.sourceKeys.length,children:g?`Saving…`:b?`Save and enable`:`Save paused`})]})]})]})})}function we({agent:e,inventory:t,connection:n,teamId:r,projectId:i,projectName:a,query:o,signedIn:s}){let[c,l]=(0,U.useState)(!1),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),[g,_]=(0,U.useState)(``),v=(0,U.useMemo)(()=>new Set(t?.collector.connections.filter(t=>t.source===e.id&&t.teamId===r&&t.projectId===i&&t.state!==`disconnected`).map(e=>e.sourceInstanceId)??[]),[t,e.id,r,i]),y=o.data?.sources.filter(t=>t.projectId===i&&(e.id===`openpond_chat`?[`native_chat`,`native_work`].includes(t.origin)&&t.sourceInstanceId===null:t.origin===e.id&&t.sourceInstanceId!==null&&v.has(t.sourceInstanceId)))??[],b=[...new Set(y.flatMap(e=>e.sourceInstanceId?[e.sourceInstanceId]:[]))],x=b.includes(g)?g:b[0],S=y.filter(e=>e.sourceInstanceId===null||e.sourceInstanceId===x).map(e=>({origin:e.origin,sourceInstanceId:e.sourceInstanceId,enabled:!0})),C=o.data?.policies.filter(e=>e.configuration.projectId===i)??[],w=C.filter(e=>e.status===`enabled`&&e.configuration.sources.some(e=>e.enabled&&S.some(t=>X(t)===X(e)))),T=w[0]??C.find(e=>e.status===`enabled`)??C[0],E=!!(n&&r&&i&&s&&o.data?.projects.some(e=>e.id===i));async function D(e,t){if(!n||!r||!o.data)return;let a={...e.configuration,sources:e.configuration.sources.map(e=>S.some(t=>X(t)===X(e))?{...e,enabled:t}:e)};if(t)for(let e of S)a.sources.some(t=>X(t)===X(e))||a.sources.push(e);let s=o.data.servingTargets.find(e=>e.id===a.serving?.targetId);if(t&&a.mode===`activate`&&a.serving?.targetId&&(!s||!s.enabled||s.projectId!==i))throw Error(`Review the policy's serving target before adding a source.`);if(t&&a.mode===`activate`&&(!a.serving?.targetId||s?.hostedPonder)){let e=await Z(n,r,`serving-targets`,{action:`ensure_hosted_ponder`,projectId:i,bindingId:o.data.ponderBindingId});a={...a,serving:{targetId:e.id,canarySeconds:a.serving?.canarySeconds??120,rollbackOnRuntimeFailure:!0}}}return ge(n,r,e,a,a.sources.some(e=>e.enabled))}async function O(e){if(!f){p(!0),h(null);try{if(e){let e=C.find(e=>e.id===u);if(!e)throw Error(`Refresh the learning policy before joining.`);await D(e,!0),d(null)}else for(let e of w)await D(e,!1);await o.refresh()}catch(e){h(e instanceof Error?e.message:`Unable to update this learning source.`),await o.refresh()}finally{p(!1)}}}return(0,W.jsxs)(`div`,{className:`agent-learning-control`,children:[b.length>1?(0,W.jsxs)(`label`,{children:[`Learning connection`,(0,W.jsx)(`select`,{"aria-label":`${e.name} learning connection`,value:x,disabled:f,onChange:e=>_(e.target.value),children:b.map(e=>(0,W.jsx)(`option`,{value:e,children:y.find(t=>t.sourceInstanceId===e)?.name??`Local connection`},e))})]}):null,(0,W.jsxs)(`div`,{className:`agent-learning-control-row`,children:[(0,W.jsxs)(`label`,{className:`provider-toggle`,children:[(0,W.jsx)(`input`,{type:`checkbox`,"aria-label":`${e.name} continuous learning`,checked:w.length>0,disabled:!E||!S.length||o.isPending||o.isError||f,onChange:e=>{if(e.target.checked){let e=C.find(e=>e.status===`enabled`);e?d(e.id):l(!0)}else O(!1)}}),(0,W.jsx)(`span`,{"aria-hidden":`true`})]}),(0,W.jsx)(`button`,{type:`button`,className:`agent-learning-settings`,disabled:!n||!r||!i||!s||f,onClick:()=>l(!0),children:`Continuous learning`}),(0,W.jsx)(`small`,{children:o.isError?`Needs attention`:o.isPending?`Loading…`:w.length?`On schedule`:C.length?`Paused`:`Off`})]}),i&&!S.length&&o.data?(0,W.jsx)(`small`,{children:`Sync this agent to the selected Project to use its local connection.`}):null,m?(0,W.jsx)(M,{error:m}):null,c&&n&&r?(0,W.jsx)(Ce,{connection:n,teamId:r,projectId:i,projectName:a,initialPolicy:T,bindings:S,query:o,onClose:()=>l(!1)},i):null,u?(0,W.jsx)(Te,{policies:C.filter(e=>e.status===`enabled`),policyId:u,agentName:e.name,busy:f,error:m,onChoose:d,onClose:()=>{f||d(null)},onJoin:()=>void O(!0)}):null]})}function Te({policies:e,policyId:t,agentName:n,busy:r,error:i,onChoose:a,onClose:o,onJoin:s}){let c=C(o),l=e.find(e=>e.id===t);return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:o,children:(0,W.jsxs)(`section`,{ref:c,className:`git-dialog agent-learning-join`,role:`dialog`,"aria-modal":`true`,"aria-label":`Add learning source`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,disabled:r,"aria-label":`Cancel`,onClick:o,children:(0,W.jsx)(k,{size:16})}),(0,W.jsxs)(`h2`,{children:[`Add `,n,` to `,l?.configuration.name??`continuous learning`,`?`]}),(0,W.jsx)(`p`,{children:`This agent will contribute conversations to the existing model, schedule and spending limits. Collection settings stay unchanged.`}),e.length>1?(0,W.jsxs)(`label`,{children:[`Existing policy`,(0,W.jsx)(`select`,{value:t,disabled:r,onChange:e=>a(e.target.value),children:e.map(e=>(0,W.jsx)(`option`,{value:e.id,children:e.configuration.name},e.id))})]}):null,i?(0,W.jsx)(M,{error:i}):null,(0,W.jsxs)(`div`,{className:`settings-button-row`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:r,onClick:o,children:`Cancel`}),(0,W.jsx)(`button`,{type:`button`,className:`primary`,disabled:r||!l,onClick:s,children:r?`Adding…`:`Add agent`})]})]})})}function Ee({connection:e,payload:t,onPayload:n,onToast:r}){let{inventory:i,error:a,loading:o,refresh:s}=ne(e),[c,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(0),m=`openpond-agent-cards:${JSON.stringify(t?.account.activeProfile??null)}`,[h,g]=(0,U.useState)(()=>{try{let e=JSON.parse(localStorage.getItem(m)??`null`);return Array.isArray(e)?e.filter(e=>typeof e==`string`&&V.some(t=>t.id===e)):[`oh_my_pi`]}catch{return[`oh_my_pi`]}});(0,U.useEffect)(()=>{try{localStorage.setItem(m,JSON.stringify(h))}catch{}},[m,h]);let[_,v]=(0,U.useState)(!1),b=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!_)return;let e=e=>{b.current?.contains(e.target)||v(!1)},t=e=>{e.key===`Escape`&&(v(!1),b.current?.querySelector(`button`)?.focus())};return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[_]);let x=(0,U.useRef)({payload:t,onPayload:n});x.current={payload:t,onPayload:n};let S=(0,U.useRef)(!0);(0,U.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let C=t?.account??null,w=t?.preferences.defaultTeamId??C?.accounts.find(e=>e.isActive)?.apiKeyAccess?.teamId??null,k=(0,U.useCallback)(e=>{l(e),e&&r?.(e,`error`)},[r]),A=(0,U.useCallback)(e=>{let t=x.current;S.current&&t.payload&&t.onPayload({...t.payload,providers:e})},[]),j=(0,U.useCallback)((e,t)=>{let n=x.current;if(!S.current||!n.payload)return;let r=n.payload.providers,i={...n.payload,providers:{...r,statuses:{...r.statuses,[e]:t.statuses[e]},modelCaches:{...r.modelCaches,[e]:t.modelCaches[e]}}};x.current={...n,payload:i},n.onPayload(i)},[]);ie(e,t?.providers,j,f);let N=(0,U.useCallback)(e=>{let t=x.current;t.payload&&t.onPayload({...t.payload,preferences:e.preferences})},[]),P=E({connection:e,onError:k,onPayload:n,onPreferences:N,onProviders:A,preferences:y(t?.preferences),providers:t?.providers}),F=le(e,C,w),{projects:R,projectId:z,loading:ee,error:B}=F,te=he(e,w,JSON.stringify([C?.activeProfile??null,C?.profile?.id??null]),C?.state===`signed_in`),H=C?.baseUrl??C?.activeProfile?.baseUrl,G=H&&w?`${H.replace(/\/$/u,``)}/console/connections?${new URLSearchParams({teamId:w,...z?{project:z}:{}})}`:null,K=u?.provider,q=K?t?.providers.statuses[K]:null,J=u?(0,W.jsx)(pe,{agent:u,inventory:i,connection:e,account:C,teamId:w,projects:R,projectId:z,onRefresh:s,learningUrl:G},u.id):null;return(0,W.jsxs)(`section`,{className:`connected-agents-view`,"aria-label":`Continuous learning`,children:[(0,W.jsxs)(`div`,{className:`agent-connections-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:`Continuous learning`}),(0,W.jsx)(`p`,{children:`Sync conversations from your installed agents and configure continuous learning.`})]}),(0,W.jsxs)(`div`,{className:`agent-connections-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:o||!e,"aria-label":`Refresh agent connections`,onClick:()=>{s(),F.refresh(),p(e=>e+1)},children:(0,W.jsx)(O,{size:15})}),(0,W.jsxs)(`div`,{className:`agent-more`,ref:b,children:[(0,W.jsx)(`button`,{type:`button`,"aria-expanded":_,onClick:()=>v(e=>!e),children:`More agents`}),_?(0,W.jsxs)(`div`,{className:`agent-more-menu`,children:[V.filter(e=>h.includes(e.id)).map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>{g(t=>t.filter(t=>t!==e.id)),v(!1)},children:[(0,W.jsx)(D,{size:14}),(0,W.jsx)(`span`,{children:e.name})]},e.id)),h.length===0?(0,W.jsx)(`span`,{children:`All agents shown`}):null]}):null]})]})]}),(0,W.jsxs)(`label`,{className:`agent-project-scope`,children:[`Project`,(0,W.jsx)(L,{label:`Connections project`,value:z,disabled:!R.length,onChange:F.select,searchable:!0,options:[{value:``,label:ee&&!R.length?`Fetching projects…`:`Select project`},...R.map(e=>({value:e.id,label:e.content.name}))]})]}),B?(0,W.jsx)(M,{error:B}):null,a?(0,W.jsx)(M,{error:a}):null,c?(0,W.jsx)(M,{error:c}):null,(0,W.jsx)(`div`,{className:`agent-connections-grid`,children:V.filter(e=>!h.includes(e.id)).map(n=>(0,W.jsx)(re,{agent:n,account:C,native:n.provider?t?.providers.statuses[n.provider]:null,inventory:i,projects:R,teamId:w,learningControl:(0,W.jsx)(we,{agent:n,inventory:i,connection:e,teamId:w,projectId:z,projectName:R.find(e=>e.id===z)?.content.name??`Selected Project`,query:te,signedIn:C?.state===`signed_in`}),connected:!!e,onHide:()=>g(e=>[...e,n.id]),onManage:()=>d(n)},`${JSON.stringify([C?.activeProfile,C?.profile?.id])}:${w}:${z}:${n.id}`))}),i?(0,W.jsxs)(`div`,{className:`agent-importer-footer`,children:[(0,W.jsx)(`span`,{children:i.collector.running?`Import in progress`:`No import running`}),(0,W.jsx)(`button`,{type:`button`,onClick:()=>I({kind:`settings`,section:`conversation-imports`}),children:`Conversation import settings`})]}):null,u&&K&&q&&t?(0,W.jsx)(T,{checkNativeProvider:P.checkNativeProvider,connection:e,account:C,codex:t.codex,providerId:K,providerBusy:P.providerBusy,settings:t.providers,status:q,onClose:()=>d(null),onDeleteCredential:P.deleteProviderCredential,onRefreshModels:P.refreshProviderModels,onSaveConfig:P.saveProviderConfig,onSaveCredential:P.saveProviderCredential,onStartOpenAiSubscriptionAuth:P.startOpenAiSubscriptionAuth,onValidate:P.validateProvider,conversationPanel:J}):u?(0,W.jsx)(De,{agent:u,onClose:()=>d(null),children:J}):null]})}function De({agent:e,onClose:t,children:n}){let r=C(t);return(0,W.jsx)(`div`,{className:`git-dialog-backdrop provider-dialog-backdrop`,onMouseDown:t,children:(0,W.jsxs)(`section`,{ref:r,className:`git-dialog provider-details-dialog agent-setup-dialog`,role:`dialog`,"aria-modal":`true`,"aria-label":`${e.name} connection`,onMouseDown:e=>e.stopPropagation(),children:[(0,W.jsx)(`button`,{type:`button`,className:`git-dialog-close`,"aria-label":`Close`,onClick:t,children:(0,W.jsx)(k,{size:16})}),(0,W.jsx)(`div`,{className:`provider-dialog-header`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{children:e.name}),(0,W.jsx)(`span`,{children:`Conversation syncing`})]})}),n]})})}var Oe=[`For agents`,`Featured`,`Productivity`,`Developer tools`],ke=new Set([`slack`,`google`,`github`,`mcp`]);function Ae({account:e,connection:t,defaultTeamId:n,onToast:r,payload:i,onPayload:a}){let[o,s]=(0,U.useState)(`apps`),c=(0,U.useId)(),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(``),[p,m]=(0,U.useState)(`For agents`),[h,g]=(0,U.useState)(()=>F()),[_,v]=(0,U.useState)(null),y=e?.baseUrl??e?.activeProfile?.baseUrl??null,b=je(n,_),x=(0,U.useMemo)(()=>h.filter(e=>Pe(e,p)).filter(e=>Fe(e,d)),[p,d,h]);(0,U.useEffect)(()=>{let e=!0;return!t||o!==`apps`?(g(F()),v(null),()=>{e=!1}):(R.connectedAppStatus(t,{status:`all`}).then(t=>{e&&(g(t.apps),v(t.teamId?.trim()||null))}).catch(t=>{e&&(console.warn(`Unable to load connected app status.`,t),g(F()),v(null))}),()=>{e=!1})},[t,o]);function S(e){Le(P({appId:e.id,baseUrl:y,teamId:b})).catch(e=>{r?.(e instanceof Error?e.message:String(e),`error`)})}return(0,W.jsxs)(`div`,{className:`apps-workspace-view`,children:[(0,W.jsx)(`div`,{className:`apps-page-tabs`,role:`tablist`,"aria-label":`Apps pages`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=e.key===`Home`?`apps`:e.key===`End`?`agents`:o===`agents`?`apps`:`agents`;s(t),e.currentTarget.querySelector(`#${CSS.escape(`${c}-${t}`)}`)?.focus()},children:[{value:`apps`,label:`Apps`},{value:`agents`,label:`Continuous learning`}].map(e=>(0,W.jsx)(`button`,{type:`button`,role:`tab`,id:`${c}-${e.value}`,"aria-controls":`${c}-${e.value}-panel`,tabIndex:o===e.value?0:-1,"aria-selected":o===e.value,onClick:()=>s(e.value),children:e.label},e.value))}),(0,W.jsx)(`div`,{role:`tabpanel`,id:`${c}-${o}-panel`,"aria-labelledby":`${c}-${o}`,children:o===`agents`?(0,W.jsx)(Ee,{connection:t,payload:i,onPayload:a,onToast:r},JSON.stringify([e?.activeProfile,n])):(0,W.jsxs)(`section`,{className:`connected-apps-view`,"aria-label":`Apps`,children:[(0,W.jsxs)(`div`,{className:`connected-apps-header`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{children:`Apps`}),(0,W.jsx)(`p`,{children:`Connect apps that agents can use for chat, knowledge, files, and workflow actions.`})]}),(0,W.jsxs)(`label`,{className:`connected-apps-search`,children:[(0,W.jsx)(N,{size:15}),(0,W.jsx)(`input`,{"aria-label":`Search apps`,onChange:e=>f(e.target.value),placeholder:`Search apps`,type:`search`,value:d})]})]}),(0,W.jsxs)(`section`,{className:`connected-apps-hero`,"aria-label":`App context`,children:[(0,W.jsxs)(`div`,{className:`connected-apps-hero-copy`,children:[(0,W.jsx)(`span`,{className:`connected-apps-hero-icon`,children:(0,W.jsx)($,{appId:`github`})}),(0,W.jsx)(`h2`,{children:`Work with your apps`}),(0,W.jsx)(`p`,{children:`Bring repositories, documents, chat, calendars, and custom MCP tools into OpenPond.`})]}),(0,W.jsxs)(`div`,{className:`connected-apps-context-card`,"aria-hidden":`true`,children:[(0,W.jsx)(`strong`,{children:`Agent context`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{className:`files`,children:`Files`}),(0,W.jsx)(`span`,{className:`chat`,children:`Chat`}),(0,W.jsx)(`span`,{className:`oauth`,children:`OAuth`}),(0,W.jsx)(`span`,{className:`mcp`,children:`MCP`})]})]})]}),(0,W.jsx)(`div`,{className:`connected-apps-filters`,role:`tablist`,"aria-label":`App categories`,children:Oe.map(e=>(0,W.jsx)(`button`,{"aria-selected":p===e,className:p===e?`active`:``,onClick:()=>m(e),role:`tab`,type:`button`,children:e},e))}),(0,W.jsxs)(`div`,{className:`connected-apps-list`,children:[x.map(e=>(0,W.jsx)(Me,{app:e,onSelect:()=>u(e)},e.id)),x.length===0?(0,W.jsx)(`div`,{className:`connected-apps-empty`,children:`No apps match the current search.`}):null]}),l?(0,W.jsx)(Ne,{app:l,onClose:()=>u(null),onInstall:()=>S(l)}):null]})})]})}function je(e,t){return e?.trim()||t?.trim()||null}function Me({app:e,onSelect:t}){return(0,W.jsxs)(`button`,{className:`connected-app-row`,onClick:t,type:`button`,children:[(0,W.jsxs)(`span`,{className:`connected-app-row-main`,children:[(0,W.jsx)($,{appId:e.id}),(0,W.jsxs)(`span`,{className:`connected-app-copy`,children:[(0,W.jsxs)(`span`,{className:`connected-app-title`,children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsxs)(`span`,{children:[e.shortLabel===e.label?e.category:e.shortLabel,` / `,e.setupSurfaceLabel]})]}),(0,W.jsx)(`span`,{children:e.description}),(0,W.jsxs)(`span`,{className:`connected-app-capability-row`,children:[e.capabilityLabels.slice(0,2).map(e=>(0,W.jsx)(`span`,{children:e},e)),e.capabilityLabels.length>2?(0,W.jsxs)(`span`,{children:[`+`,e.capabilityLabels.length-2]}):null]})]})]}),(0,W.jsx)(`span`,{className:`connected-app-status-pill ${e.status}`,children:e.statusLabel}),(0,W.jsx)(x,{size:16})]})}function Ne({app:e,onClose:t,onInstall:n}){let r=e.connections.filter(e=>e.status===`active`);return(0,W.jsx)(`div`,{className:`connected-app-dialog-backdrop`,role:`presentation`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,W.jsxs)(`section`,{className:`connected-app-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`connected-app-dialog-title`,children:[(0,W.jsx)(`button`,{className:`connected-app-dialog-close`,type:`button`,"aria-label":`Close app details`,onClick:t,children:(0,W.jsx)(k,{size:17})}),(0,W.jsxs)(`div`,{className:`connected-app-dialog-identity`,children:[(0,W.jsx)(`span`,{className:`openpond-mark`,children:(0,W.jsx)(`img`,{alt:``,src:i})}),(0,W.jsxs)(`span`,{className:`connection-dots`,"aria-hidden":`true`,children:[(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{}),(0,W.jsx)(`span`,{})]}),(0,W.jsx)($,{appId:e.id})]}),(0,W.jsxs)(`h2`,{id:`connected-app-dialog-title`,children:[`Connect `,e.label]}),(0,W.jsxs)(`div`,{className:`connected-app-approval`,children:[(0,W.jsx)(ee,{size:16}),(0,W.jsx)(`span`,{children:e.statusLabel})]}),(0,W.jsxs)(`div`,{className:`connected-app-dialog-body`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:e.setupSurfaceLabel}),(0,W.jsx)(`p`,{children:`The web flow shows the provider account, workspace, and requested access before anything is connected.`})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Connected account`}),(0,W.jsx)(`p`,{children:Re(r)})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Available capabilities`}),(0,W.jsx)(`div`,{className:`connected-app-dialog-capabilities`,children:e.capabilities.map(e=>(0,W.jsx)(`span`,{children:e.label},e.id))})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{children:`Sandbox lease policy`}),(0,W.jsx)(`p`,{children:e.leasePolicy.leaseable?`Leaseable for ${e.leasePolicy.defaultTtlSeconds??0} seconds with scoped proxy access.`:`Managed as setup or tool discovery; no OAuth lease is required.`})]})]}),(0,W.jsxs)(`button`,{className:`connected-app-dialog-primary`,type:`button`,onClick:n,children:[(0,W.jsx)(`span`,{children:e.installLabel}),(0,W.jsx)(S,{size:15})]})]})})}function $({appId:e}){return(0,W.jsx)(`span`,{className:`connected-app-icon app-${e}`,children:(0,W.jsx)(`img`,{alt:``,src:Ie(e)})})}function Pe(e,t){return t===`For agents`?!0:t===`Featured`?ke.has(e.id):t===`Productivity`?e.category===`Productivity`||e.category===`Chat`:e.category===`Developer tools`||e.id===`mcp`}function Fe(e,t){let n=t.trim().toLowerCase();return!n||[e.id,e.label,e.shortLabel,e.category,e.description,e.providerFamily,e.setupSurface].some(e=>e.toLowerCase().includes(n))}function Ie(e){return n(e)}async function Le(e){let t=window.openpond?.browser;if(t){let n=await t.openExternal({conversationId:`connected-apps`,url:e});if(!n.ok)throw Error(n.error??`Unable to open app setup.`)}else window.open(e,`_blank`,`noopener,noreferrer`)}function Re(e){return e.length===0?`No active OAuth connection for this setup surface.`:e.map(e=>{let t=e.accountLabel??`Connected account`;return e.workspaceLabel?`${t} / ${e.workspaceLabel}`:t}).join(`, `)}export{Ae as AppsView};
@@ -1 +1 @@
1
- import{m as e}from"./index-CM0IRu1U.js";import"./icons-c3vt7y6n.js";import{H as t,R as n,z as r}from"./training-model-data-wHvE7xL1.js";import{i,n as a,r as o,t as s}from"./presentation-BN_kIBPL.js";import{t as c}from"./image-CqKPwnBn.js";import{an as l}from"./App-BZuSv1XM.js";var u=e(),d=new Set([`c`,`cc`,`cpp`,`css`,`go`,`h`,`html`,`java`,`js`,`json`,`jsx`,`mdx`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`toml`,`ts`,`tsx`,`xml`,`yaml`,`yml`]),f=new Set([`csv`,`ods`,`tsv`,`xls`,`xlsm`,`xlsx`]),p=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`xz`,`zip`]),m=new Set([`doc`,`docx`,`epub`,`md`,`odt`,`pdf`,`rtf`,`txt`]),h=new Set([`key`,`odp`,`ppt`,`pptx`]);function g(e){let t=e.mediaType.toLowerCase(),n=e.name.split(`.`).pop()?.toLowerCase()??``;return e.kind===`image`||t.startsWith(`image/`)?`image`:t.startsWith(`audio/`)?`audio`:t.startsWith(`video/`)?`video`:f.has(n)||t.includes(`spreadsheet`)||t.includes(`excel`)?`spreadsheet`:p.has(n)||t.includes(`zip`)||t.includes(`compressed`)?`archive`:h.has(n)||t.includes(`presentation`)||t.includes(`powerpoint`)?`presentation`:d.has(n)?`code`:e.kind===`text`||m.has(n)||t.startsWith(`text/`)||t===`application/pdf`||t.includes(`document`)||t.includes(`msword`)?`document`:`file`}function _(e){if(e.mediaType.toLowerCase()===`application/pdf`)return`PDF`;let t=g(e);return t===`spreadsheet`?`Spreadsheet`:t.charAt(0).toUpperCase()+t.slice(1)}function v(e){return`${e.toLocaleString()} ${e===1?`line`:`lines`}`}var y={archive:t,audio:i,code:r,document:l,file:n,image:c,presentation:s,spreadsheet:o,video:a};function b({attachment:e,...t}){let n=y[g(e)];return(0,u.jsx)(n,{...t})}export{_ as n,v as r,b as t};
1
+ import{m as e}from"./index-D7igQSAg.js";import"./icons-B8_Rkg-l.js";import{H as t,R as n,z as r}from"./training-model-data-CWnu1bz9.js";import{i,n as a,r as o,t as s}from"./presentation-CupIXaYv.js";import{t as c}from"./image-CUZMnZYi.js";import{an as l}from"./App-CNQi3RlI.js";var u=e(),d=new Set([`c`,`cc`,`cpp`,`css`,`go`,`h`,`html`,`java`,`js`,`json`,`jsx`,`mdx`,`php`,`py`,`rb`,`rs`,`sh`,`sql`,`toml`,`ts`,`tsx`,`xml`,`yaml`,`yml`]),f=new Set([`csv`,`ods`,`tsv`,`xls`,`xlsm`,`xlsx`]),p=new Set([`7z`,`bz2`,`gz`,`rar`,`tar`,`tgz`,`xz`,`zip`]),m=new Set([`doc`,`docx`,`epub`,`md`,`odt`,`pdf`,`rtf`,`txt`]),h=new Set([`key`,`odp`,`ppt`,`pptx`]);function g(e){let t=e.mediaType.toLowerCase(),n=e.name.split(`.`).pop()?.toLowerCase()??``;return e.kind===`image`||t.startsWith(`image/`)?`image`:t.startsWith(`audio/`)?`audio`:t.startsWith(`video/`)?`video`:f.has(n)||t.includes(`spreadsheet`)||t.includes(`excel`)?`spreadsheet`:p.has(n)||t.includes(`zip`)||t.includes(`compressed`)?`archive`:h.has(n)||t.includes(`presentation`)||t.includes(`powerpoint`)?`presentation`:d.has(n)?`code`:e.kind===`text`||m.has(n)||t.startsWith(`text/`)||t===`application/pdf`||t.includes(`document`)||t.includes(`msword`)?`document`:`file`}function _(e){if(e.mediaType.toLowerCase()===`application/pdf`)return`PDF`;let t=g(e);return t===`spreadsheet`?`Spreadsheet`:t.charAt(0).toUpperCase()+t.slice(1)}function v(e){return`${e.toLocaleString()} ${e===1?`line`:`lines`}`}var y={archive:t,audio:i,code:r,document:l,file:n,image:c,presentation:s,spreadsheet:o,video:a};function b({attachment:e,...t}){let n=y[g(e)];return(0,u.jsx)(n,{...t})}export{_ as n,v as r,b as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-CM0IRu1U.js";import"./icons-c3vt7y6n.js";import{t as r}from"./createLucideIcon-DF2VR6WA.js";import{N as i}from"./training-model-data-wHvE7xL1.js";import{t as a}from"./copy-CBFg6m0d.js";import{t as o}from"./x-D9GTV9ke.js";import{n as s}from"./AppToastContext-C-FsCKXW.js";import{Bt as c,en as l,on as u}from"./App-BZuSv1XM.js";import{t as d}from"./HtmlVisual-CH0tb3fv.js";import{S as f,t as p,x as m}from"./MainPane-DDO6diPt.js";var h=r(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),g=e(t(),1),_=n();function v({active:e,onBounds:t}){let n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useCallback)(e=>{let n=e?`${e.x}:${e.y}:${e.width}:${e.height}`:`null`;r.current!==n&&(r.current=n,t(e))},[t]),o=(0,g.useCallback)(()=>{let t=n.current;if(!e||!t){a(null);return}let r=t.getBoundingClientRect(),i=Math.max(0,Math.round(r.width)),o=Math.max(0,Math.round(r.height));a(i===0||o===0?null:{x:Math.round(r.left),y:Math.round(r.top),width:i,height:o})},[e,a]),s=(0,g.useCallback)(()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,o()}))},[o]);return(0,g.useLayoutEffect)(()=>{r.current=null,o();let t=n.current;if(!e||!t)return a(null),()=>a(null);let c=new ResizeObserver(s);return c.observe(t),window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),()=>{i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null),c.disconnect(),window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0),a(null)}},[e,a,o,s]),(0,_.jsx)(`div`,{className:`browser-viewport`,ref:n,hidden:!e})}function y({available:e,busy:t,onCapture:n,onCancel:r}){let[i,a]=(0,g.useState)(!1),s=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!i)return;let e=e=>{s.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,_.jsxs)(`div`,{className:`browser-menu-anchor`,ref:s,children:[(0,_.jsx)(`button`,{type:`button`,title:t?`Cancel snapshot`:`Take snapshot`,"aria-label":t?`Cancel snapshot`:`Take snapshot`,disabled:!e&&!t,"aria-haspopup":t?void 0:`menu`,"aria-expanded":i,onClick:()=>t?r():a(e=>!e),children:t?(0,_.jsx)(o,{size:15}):(0,_.jsx)(h,{size:15})}),i?(0,_.jsxs)(`div`,{className:`browser-options-menu browser-snapshot-menu`,role:`menu`,"aria-label":`Snapshot options`,children:[(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),n(`page`)},children:`Full page snapshot`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),n(`node`)},children:`Select an element…`})]}):null]})}function b({image:e,onClose:t}){let n=s(),r=e.source?.length===64e3?`HTML excerpt`:`HTML`;async function c(){let t=`${e.selector.replace(/[^a-z0-9._-]+/gi,`-`).slice(0,80)||`snapshot`}.png`;if(window.openpond?.files?.saveImage){let r=await window.openpond.files.saveImage({url:e.dataUrl,suggestedName:t});!r.ok&&!r.canceled&&n?.(r.error??`Snapshot could not be saved.`,`error`)}else{let n=document.createElement(`a`);n.href=e.dataUrl,n.download=t,n.click()}}return(0,_.jsxs)(`section`,{className:`browser-snapshot-preview`,"aria-label":`Snapshot preview`,children:[(0,_.jsxs)(`div`,{className:`html-visual-toolbar`,children:[(0,_.jsxs)(`span`,{children:[e.selector,` · `,e.width,` × `,e.height]}),e.source?(0,_.jsx)(`button`,{type:`button`,"aria-label":`Copy ${r}`,title:`Copy ${r}`,onClick:()=>void i(e.source),children:(0,_.jsx)(a,{size:15})}):null,(0,_.jsx)(`button`,{type:`button`,"aria-label":`Save snapshot PNG`,title:`Save snapshot PNG`,onClick:()=>void c(),children:(0,_.jsx)(u,{size:15})}),(0,_.jsx)(`button`,{type:`button`,"aria-label":`Close snapshot`,title:`Close snapshot`,onClick:t,children:(0,_.jsx)(o,{size:15})})]}),(0,_.jsx)(`div`,{className:`browser-snapshot-image`,children:(0,_.jsx)(`img`,{src:e.dataUrl,alt:`Snapshot of ${e.selector}`})}),e.source?(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:r}),(0,_.jsx)(`pre`,{children:e.source})]}):null]})}function x(e,t,n,r){let[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(0),d=(0,g.useRef)(null),f=(0,g.useCallback)(()=>{u.current++,d.current?.(),d.current=null,a(null)},[]);return(0,g.useEffect)(()=>(s(null),l(null),f),[e,t,n,f]),(0,g.useEffect)(()=>{if(i!==`node`)return;let e=e=>{e.key===`Escape`&&f()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,f]),{busy:i,image:o,error:c,capture:(0,g.useCallback)(async i=>{f();let o=u.current;s(null),l(null),a(i);try{let a=window.openpond?.browser;if(!a)throw Error(`Snapshots are available in the desktop app.`);let c;if(n){let e=r.current;if(!e)throw Error(`Wait for the HTML page to finish loading.`);d.current=()=>e.cancel();let t=await e.capture(i);if(o!==u.current)return;c=await a.captureHtml(t)}else{if(!t)throw Error(`Open a browser page before taking a snapshot.`);let n={conversationId:e,tabId:t};d.current=()=>{a.cancelCapture(n)},c=await a.capturePage({...n,mode:i})}if(o!==u.current)return;c.ok?s(c.image):c.canceled||l(c.error)}catch(e){o===u.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&l(e instanceof Error?e.message:`Snapshot failed.`)}finally{o===u.current&&(a(null),d.current=null)}},[f,e,t,n,r]),cancel:f,close:()=>s(null)}}function S({conversationId:e,expanded:t,onResizeStart:n,connection:r=null,visualTabs:i}){let a=f(e),o=s(),[u,h]=(0,g.useState)({}),S=i?.tabs.find(e=>e.publicationId===i.activeId),C=(0,g.useRef)(null),w=x(e,a.activeTab?.id??null,S?.publicationId??null,C),T=(i?.tabs??[]).map(e=>({id:e.publicationId,url:`${e.output.title}.html`,title:e.output.title,faviconUrl:null,loading:!1,canGoBack:!1,canGoForward:!1,error:null})),E=T.find(e=>e.id===S?.publicationId),D=(0,g.useCallback)(t=>{window.openpond?.browser?.setBounds({conversationId:e,bounds:t})},[e]),O=(0,g.useCallback)(e=>{i?.showBrowser(),a.open(e,{explicitFile:!0}).catch(e=>o?.(e instanceof Error?e.message:`Could not open browser.`,`error`))},[a,i,o]),k=(0,g.useCallback)(()=>{window.confirm(`Clear shared browser data? Cookies, logins, cache, and site storage will be removed for all chats. This chat's browser tabs will also close.`)&&a.clearData()},[a]);return(0,_.jsxs)(`aside`,{className:`workspace-diff-panel browser-sidebar-panel ${t?`expanded`:``} ${w.busy===`node`||w.error?`has-capture-status`:``}`,"aria-label":`Browser`,children:[!t&&(0,_.jsx)(`div`,{className:`workspace-diff-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize browser panel`,onPointerDown:n}),(0,_.jsx)(p,{activeTabId:S?.publicationId??a.state.activeTabId,tabs:[...a.state.tabs,...T],onCloseTab:e=>{T.some(t=>t.id===e)?i?.close(e):a.closeTab(e)},onNewTab:()=>{i?.showBrowser(),a.newTab()},onSelectTab:e=>{T.some(t=>t.id===e)?i?.select(e):(i?.showBrowser(),a.selectTab(e))}}),(0,_.jsx)(m,{activeTab:E??a.activeTab,documentName:E?.url,available:a.available,snapshotActions:(0,_.jsx)(y,{available:!w.image&&!!(S?window.openpond?.browser?.captureHtml:a.activeTab&&!a.activeTab.loading&&window.openpond?.browser?.capturePage),busy:!!w.busy,onCapture:e=>void w.capture(e),onCancel:w.cancel}),onBack:()=>void a.back(),onClearData:k,onForward:()=>void a.forward(),onNavigate:O,onOpenExternal:()=>void a.openExternal(),onReload:()=>{S?h(e=>({...e,[S.publicationId]:(e[S.publicationId]??0)+1})):a.reload()},onStop:()=>void a.stop()}),w.busy===`node`?(0,_.jsx)(`p`,{className:`browser-snapshot-status`,role:`status`,children:`Hover to highlight an element, then click to capture it. Press Esc to cancel.`}):null,w.error?(0,_.jsx)(c,{error:w.error}):null,(0,_.jsxs)(`div`,{className:`browser-content`,children:[w.image?(0,_.jsx)(b,{image:w.image,onClose:w.close}):null,i?.tabs.map(e=>(0,_.jsx)(`div`,{className:`browser-visual-document`,role:`tabpanel`,"aria-label":e.output.title,hidden:!!w.image||e.publicationId!==S?.publicationId,children:(0,_.jsx)(d,{visual:e,connection:r,expanded:!0,snapshotRef:e.publicationId===S?.publicationId?C:void 0},u[e.publicationId]??0)},e.publicationId)),!S&&!a.available?(0,_.jsxs)(`div`,{className:`browser-empty-state`,children:[(0,_.jsx)(l,{size:18}),(0,_.jsx)(`span`,{children:`Desktop browser bridge unavailable.`})]}):!S&&a.state.tabs.length===0?(0,_.jsxs)(`div`,{className:`browser-empty-state`,children:[(0,_.jsx)(l,{size:18}),(0,_.jsx)(`span`,{children:`Enter a URL to open a browser tab for this conversation.`})]}):null,(0,_.jsx)(v,{active:!w.image&&!S&&a.available&&a.state.tabs.length>0,onBounds:D})]})]})}export{S as BrowserSidebar};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{g as t,m as n}from"./index-D7igQSAg.js";import"./icons-B8_Rkg-l.js";import{t as r}from"./createLucideIcon-CmkSm39S.js";import{N as i}from"./training-model-data-CWnu1bz9.js";import{t as a}from"./copy-DRnATDDY.js";import{t as o}from"./x-Bhl-4Zlt.js";import{n as s}from"./AppToastContext-Dklk6CaG.js";import{Bt as c,en as l,on as u}from"./App-CNQi3RlI.js";import{t as d}from"./HtmlVisual-C2WsMj90.js";import{S as f,t as p,x as m}from"./MainPane-CqtgV9rU.js";var h=r(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),g=e(t(),1),_=n();function v({active:e,onBounds:t}){let n=(0,g.useRef)(null),r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useCallback)(e=>{let n=e?`${e.x}:${e.y}:${e.width}:${e.height}`:`null`;r.current!==n&&(r.current=n,t(e))},[t]),o=(0,g.useCallback)(()=>{let t=n.current;if(!e||!t){a(null);return}let r=t.getBoundingClientRect(),i=Math.max(0,Math.round(r.width)),o=Math.max(0,Math.round(r.height));a(i===0||o===0?null:{x:Math.round(r.left),y:Math.round(r.top),width:i,height:o})},[e,a]),s=(0,g.useCallback)(()=>{i.current===null&&(i.current=window.requestAnimationFrame(()=>{i.current=null,o()}))},[o]);return(0,g.useLayoutEffect)(()=>{r.current=null,o();let t=n.current;if(!e||!t)return a(null),()=>a(null);let c=new ResizeObserver(s);return c.observe(t),window.addEventListener(`resize`,s),window.addEventListener(`scroll`,s,!0),()=>{i.current!==null&&(window.cancelAnimationFrame(i.current),i.current=null),c.disconnect(),window.removeEventListener(`resize`,s),window.removeEventListener(`scroll`,s,!0),a(null)}},[e,a,o,s]),(0,_.jsx)(`div`,{className:`browser-viewport`,ref:n,hidden:!e})}function y({available:e,busy:t,onCapture:n,onCancel:r}){let[i,a]=(0,g.useState)(!1),s=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!i)return;let e=e=>{s.current?.contains(e.target)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return window.addEventListener(`pointerdown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`pointerdown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,_.jsxs)(`div`,{className:`browser-menu-anchor`,ref:s,children:[(0,_.jsx)(`button`,{type:`button`,title:t?`Cancel snapshot`:`Take snapshot`,"aria-label":t?`Cancel snapshot`:`Take snapshot`,disabled:!e&&!t,"aria-haspopup":t?void 0:`menu`,"aria-expanded":i,onClick:()=>t?r():a(e=>!e),children:t?(0,_.jsx)(o,{size:15}):(0,_.jsx)(h,{size:15})}),i?(0,_.jsxs)(`div`,{className:`browser-options-menu browser-snapshot-menu`,role:`menu`,"aria-label":`Snapshot options`,children:[(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),n(`page`)},children:`Full page snapshot`}),(0,_.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{a(!1),n(`node`)},children:`Select an element…`})]}):null]})}function b({image:e,onClose:t}){let n=s(),r=e.source?.length===64e3?`HTML excerpt`:`HTML`;async function c(){let t=`${e.selector.replace(/[^a-z0-9._-]+/gi,`-`).slice(0,80)||`snapshot`}.png`;if(window.openpond?.files?.saveImage){let r=await window.openpond.files.saveImage({url:e.dataUrl,suggestedName:t});!r.ok&&!r.canceled&&n?.(r.error??`Snapshot could not be saved.`,`error`)}else{let n=document.createElement(`a`);n.href=e.dataUrl,n.download=t,n.click()}}return(0,_.jsxs)(`section`,{className:`browser-snapshot-preview`,"aria-label":`Snapshot preview`,children:[(0,_.jsxs)(`div`,{className:`html-visual-toolbar`,children:[(0,_.jsxs)(`span`,{children:[e.selector,` · `,e.width,` × `,e.height]}),e.source?(0,_.jsx)(`button`,{type:`button`,"aria-label":`Copy ${r}`,title:`Copy ${r}`,onClick:()=>void i(e.source),children:(0,_.jsx)(a,{size:15})}):null,(0,_.jsx)(`button`,{type:`button`,"aria-label":`Save snapshot PNG`,title:`Save snapshot PNG`,onClick:()=>void c(),children:(0,_.jsx)(u,{size:15})}),(0,_.jsx)(`button`,{type:`button`,"aria-label":`Close snapshot`,title:`Close snapshot`,onClick:t,children:(0,_.jsx)(o,{size:15})})]}),(0,_.jsx)(`div`,{className:`browser-snapshot-image`,children:(0,_.jsx)(`img`,{src:e.dataUrl,alt:`Snapshot of ${e.selector}`})}),e.source?(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:r}),(0,_.jsx)(`pre`,{children:e.source})]}):null]})}function x(e,t,n,r){let[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(null),u=(0,g.useRef)(0),d=(0,g.useRef)(null),f=(0,g.useCallback)(()=>{u.current++,d.current?.(),d.current=null,a(null)},[]);return(0,g.useEffect)(()=>(s(null),l(null),f),[e,t,n,f]),(0,g.useEffect)(()=>{if(i!==`node`)return;let e=e=>{e.key===`Escape`&&f()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,f]),{busy:i,image:o,error:c,capture:(0,g.useCallback)(async i=>{f();let o=u.current;s(null),l(null),a(i);try{let a=window.openpond?.browser;if(!a)throw Error(`Snapshots are available in the desktop app.`);let c;if(n){let e=r.current;if(!e)throw Error(`Wait for the HTML page to finish loading.`);d.current=()=>e.cancel();let t=await e.capture(i);if(o!==u.current)return;c=await a.captureHtml(t)}else{if(!t)throw Error(`Open a browser page before taking a snapshot.`);let n={conversationId:e,tabId:t};d.current=()=>{a.cancelCapture(n)},c=await a.capturePage({...n,mode:i})}if(o!==u.current)return;c.ok?s(c.image):c.canceled||l(c.error)}catch(e){o===u.current&&!(e instanceof DOMException&&e.name===`AbortError`)&&l(e instanceof Error?e.message:`Snapshot failed.`)}finally{o===u.current&&(a(null),d.current=null)}},[f,e,t,n,r]),cancel:f,close:()=>s(null)}}function S({conversationId:e,expanded:t,onResizeStart:n,connection:r=null,visualTabs:i}){let a=f(e),o=s(),[u,h]=(0,g.useState)({}),S=i?.tabs.find(e=>e.publicationId===i.activeId),C=(0,g.useRef)(null),w=x(e,a.activeTab?.id??null,S?.publicationId??null,C),T=(i?.tabs??[]).map(e=>({id:e.publicationId,url:`${e.output.title}.html`,title:e.output.title,faviconUrl:null,loading:!1,canGoBack:!1,canGoForward:!1,error:null})),E=T.find(e=>e.id===S?.publicationId),D=(0,g.useCallback)(t=>{window.openpond?.browser?.setBounds({conversationId:e,bounds:t})},[e]),O=(0,g.useCallback)(e=>{i?.showBrowser(),a.open(e,{explicitFile:!0}).catch(e=>o?.(e instanceof Error?e.message:`Could not open browser.`,`error`))},[a,i,o]),k=(0,g.useCallback)(()=>{window.confirm(`Clear shared browser data? Cookies, logins, cache, and site storage will be removed for all chats. This chat's browser tabs will also close.`)&&a.clearData()},[a]);return(0,_.jsxs)(`aside`,{className:`workspace-diff-panel browser-sidebar-panel ${t?`expanded`:``} ${w.busy===`node`||w.error?`has-capture-status`:``}`,"aria-label":`Browser`,children:[!t&&(0,_.jsx)(`div`,{className:`workspace-diff-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize browser panel`,onPointerDown:n}),(0,_.jsx)(p,{activeTabId:S?.publicationId??a.state.activeTabId,tabs:[...a.state.tabs,...T],onCloseTab:e=>{T.some(t=>t.id===e)?i?.close(e):a.closeTab(e)},onNewTab:()=>{i?.showBrowser(),a.newTab()},onSelectTab:e=>{T.some(t=>t.id===e)?i?.select(e):(i?.showBrowser(),a.selectTab(e))}}),(0,_.jsx)(m,{activeTab:E??a.activeTab,documentName:E?.url,available:a.available,snapshotActions:(0,_.jsx)(y,{available:!w.image&&!!(S?window.openpond?.browser?.captureHtml:a.activeTab&&!a.activeTab.loading&&window.openpond?.browser?.capturePage),busy:!!w.busy,onCapture:e=>void w.capture(e),onCancel:w.cancel}),onBack:()=>void a.back(),onClearData:k,onForward:()=>void a.forward(),onNavigate:O,onOpenExternal:()=>void a.openExternal(),onReload:()=>{S?h(e=>({...e,[S.publicationId]:(e[S.publicationId]??0)+1})):a.reload()},onStop:()=>void a.stop()}),w.busy===`node`?(0,_.jsx)(`p`,{className:`browser-snapshot-status`,role:`status`,children:`Hover to highlight an element, then click to capture it. Press Esc to cancel.`}):null,w.error?(0,_.jsx)(c,{error:w.error}):null,(0,_.jsxs)(`div`,{className:`browser-content`,children:[w.image?(0,_.jsx)(b,{image:w.image,onClose:w.close}):null,i?.tabs.map(e=>(0,_.jsx)(`div`,{className:`browser-visual-document`,role:`tabpanel`,"aria-label":e.output.title,hidden:!!w.image||e.publicationId!==S?.publicationId,children:(0,_.jsx)(d,{visual:e,connection:r,expanded:!0,snapshotRef:e.publicationId===S?.publicationId?C:void 0},u[e.publicationId]??0)},e.publicationId)),!S&&!a.available?(0,_.jsxs)(`div`,{className:`browser-empty-state`,children:[(0,_.jsx)(l,{size:18}),(0,_.jsx)(`span`,{children:`Desktop browser bridge unavailable.`})]}):!S&&a.state.tabs.length===0?(0,_.jsxs)(`div`,{className:`browser-empty-state`,children:[(0,_.jsx)(l,{size:18}),(0,_.jsx)(`span`,{children:`Enter a URL to open a browser tab for this conversation.`})]}):null,(0,_.jsx)(v,{active:!w.image&&!S&&a.available&&a.state.tabs.length>0,onBounds:D})]})]})}export{S as BrowserSidebar};