openpond 0.1.1 → 0.2.1

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 (225) hide show
  1. package/README.md +4 -4
  2. package/dist/cache.d.ts +7 -10
  3. package/dist/chunks/actions-command-QP3NMDK4.js +2 -0
  4. package/dist/chunks/app-layer-N7VFRVJ2.js +3 -0
  5. package/dist/chunks/app-server-runtime-OCLPUI7F.js +2 -0
  6. package/dist/chunks/apps-AMG75TI4.js +2 -0
  7. package/dist/chunks/chunk-22UARBPW.js +3 -0
  8. package/dist/chunks/chunk-3A7HZJNE.js +1 -0
  9. package/dist/chunks/chunk-3M53YXEI.js +2 -0
  10. package/dist/chunks/chunk-3NDRIQTI.js +2 -0
  11. package/dist/chunks/chunk-5BBVEWG3.js +2 -0
  12. package/dist/chunks/chunk-5O7ZVCMV.js +6 -0
  13. package/dist/chunks/chunk-6FA3GG5B.js +33 -0
  14. package/dist/chunks/chunk-6MI4KKWF.js +2 -0
  15. package/dist/chunks/chunk-BBG546O6.js +6 -0
  16. package/dist/chunks/chunk-BX4J2VDU.js +2 -0
  17. package/dist/chunks/chunk-BZMVB3GS.js +2 -0
  18. package/dist/chunks/chunk-C5LOZSVS.js +2 -0
  19. package/dist/chunks/chunk-CWQWV2T3.js +2 -0
  20. package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
  21. package/dist/chunks/chunk-EAPFMACH.js +10 -0
  22. package/dist/chunks/chunk-ES2ISFJC.js +66 -0
  23. package/dist/chunks/chunk-F65NIZLM.js +2199 -0
  24. package/dist/chunks/chunk-FGJ5LFPL.js +5 -0
  25. package/dist/chunks/chunk-FTQLQJQV.js +2 -0
  26. package/dist/chunks/chunk-FY7OQ5RK.js +24 -0
  27. package/dist/chunks/chunk-FYCJSUFV.js +53 -0
  28. package/dist/chunks/chunk-GLUWATL5.js +2 -0
  29. package/dist/chunks/chunk-H7IWJN7L.js +17 -0
  30. package/dist/chunks/chunk-HZP5U2AA.js +3 -0
  31. package/dist/chunks/chunk-I5K74TOH.js +3 -0
  32. package/dist/chunks/chunk-IR3YJWPW.js +7 -0
  33. package/dist/chunks/chunk-KU7QOHFT.js +2872 -0
  34. package/dist/chunks/chunk-KV553EWX.js +16 -0
  35. package/dist/chunks/chunk-MGN6GLNZ.js +2 -0
  36. package/dist/chunks/chunk-OG5Q6NXK.js +28 -0
  37. package/dist/chunks/chunk-OGPHXXCD.js +1 -0
  38. package/dist/chunks/chunk-PI36UHRA.js +18 -0
  39. package/dist/chunks/chunk-RWSAGQTP.js +2 -0
  40. package/dist/chunks/chunk-SAE4OIPC.js +2 -0
  41. package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
  42. package/dist/chunks/chunk-UKUVMXOW.js +12 -0
  43. package/dist/chunks/chunk-VCLCFK3O.js +36 -0
  44. package/dist/chunks/chunk-VYUMTRB3.js +5 -0
  45. package/dist/chunks/chunk-X37KMV27.js +1 -0
  46. package/dist/chunks/chunk-XDHAGACI.js +3 -0
  47. package/dist/chunks/chunk-XEOEKFG6.js +71 -0
  48. package/dist/chunks/chunk-ZF7TEGY5.js +5 -0
  49. package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
  50. package/dist/chunks/cli-M2FG7SSI.js +2 -0
  51. package/dist/chunks/configuration-command-XBKBIZBO.js +2 -0
  52. package/dist/chunks/continual-D75WA7E7.js +7 -0
  53. package/dist/chunks/core-commands-LUZVWXQR.js +2 -0
  54. package/dist/chunks/database-X2CUV732.js +2 -0
  55. package/dist/chunks/desktop-test-KGC4JVJ7.js +3 -0
  56. package/dist/chunks/dist-NKLXFA37.js +2 -0
  57. package/dist/chunks/extension-NQ7N5LEY.js +5 -0
  58. package/dist/chunks/help-MWK66XZK.js +8 -0
  59. package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
  60. package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
  61. package/dist/chunks/opchat-XJZA3QKZ.js +3 -0
  62. package/dist/chunks/organizations-UECDFEYE.js +2 -0
  63. package/dist/chunks/profile-KUMIZURM.js +3 -0
  64. package/dist/chunks/project-agent-NILMJHLV.js +2 -0
  65. package/dist/chunks/sandbox-command-QHH65OSE.js +2 -0
  66. package/dist/chunks/sandbox-template-N7I63PNU.js +10 -0
  67. package/dist/chunks/src-724HF43W.js +82 -0
  68. package/dist/chunks/src-VTKTTKQO.js +319 -0
  69. package/dist/chunks/taskset-PISBOILQ.js +2 -0
  70. package/dist/chunks/teams-bot-UV4RU53M.js +3 -0
  71. package/dist/chunks/training-2NDOWH5S.js +2 -0
  72. package/dist/chunks/workspaces-XXT4KUD3.js +2 -0
  73. package/dist/cli.js +3 -101
  74. package/dist/client.d.ts +1 -1
  75. package/dist/config.d.ts +1 -0
  76. package/dist/index.js +1 -26305
  77. package/dist/private-json-file.d.ts +1 -2
  78. package/dist/sandbox-template/manifest.js +1 -18380
  79. package/dist/web/assets/App-DxecRQUL.js +176 -0
  80. package/dist/web/assets/AppDialog-B65Eo3gp.js +1 -0
  81. package/dist/web/assets/AppTerminalPanel-B2EKQM7W.js +2 -0
  82. package/dist/web/assets/{AppsView-Ck_OzQWf.js → AppsView-BBoVe7s2.js} +1 -1
  83. package/dist/web/assets/{BrowserSidebar-CqciX8aL.js → BrowserSidebar-CSM1atSJ.js} +1 -1
  84. package/dist/web/assets/{CartesianChart-Y0lsL4vC.js → CartesianChart-CJKfXiEG.js} +1 -1
  85. package/dist/web/assets/{CollaborationTabs-BOb9PjvS.js → CollaborationTabs-BMZamWFC.js} +1 -1
  86. package/dist/web/assets/{CommandMenu-Co6JnmTu.js → CommandMenu-B3U1z2eo.js} +1 -1
  87. package/dist/web/assets/{CommunityView-BbTSeL7h.js → CommunityView-CTyRUcfy.js} +1 -1
  88. package/dist/web/assets/{ComposerCreateImproveStrip-BGzCWVFp.js → ComposerCreateImproveStrip-D7usvRtK.js} +1 -1
  89. package/dist/web/assets/GetStartedView-Ibu7oKWJ.js +1 -0
  90. package/dist/web/assets/HostedModelLearningReview-qnzIkT70.js +1 -0
  91. package/dist/web/assets/HostedModelLearningSettings--PKjpYsy.js +1 -0
  92. package/dist/web/assets/LabModelVersionDetailPage-s9uUN6fV.js +1 -0
  93. package/dist/web/assets/{LabSkillSidebar-C5oS6UmH.js → LabSkillSidebar-BKYseMiJ.js} +1 -1
  94. package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
  95. package/dist/web/assets/LabsRoute-DoRs0K6v.js +32 -0
  96. package/dist/web/assets/MainChatThread-DvuyMcMB.js +2 -0
  97. package/dist/web/assets/MainPane-BWwcxgHD.js +8 -0
  98. package/dist/web/assets/{MarkdownText-DqJarmTh.js → MarkdownText-D8XC5UT_.js} +1 -1
  99. package/dist/web/assets/{Messages-BaT7HOzB.js → Messages-e4A8JUjD.js} +6 -6
  100. package/dist/web/assets/{NativeSkillSidebar-DXp8snN5.js → NativeSkillSidebar-D2Joh8XB.js} +1 -1
  101. package/dist/web/assets/{NewExperienceSwitcher-CLHuGUN5.js → NewExperienceSwitcher-CzGebt2E.js} +1 -1
  102. package/dist/web/assets/{NewProjectDialog-CzpHCAaC.js → NewProjectDialog-CdMTSxUE.js} +1 -1
  103. package/dist/web/assets/{OutputsPage-DIzx-Ge6.js → OutputsPage-m7cSb8dW.js} +1 -1
  104. package/dist/web/assets/{ProjectsPage-DojwrhOy.js → ProjectsPage-C9mz8W1g.js} +1 -1
  105. package/dist/web/assets/RightChatPanelStack-B4LEqKEj.js +1 -0
  106. package/dist/web/assets/{RightSidebarHomePanel-DTzfuEX3.js → RightSidebarHomePanel-DOeUsH7h.js} +1 -1
  107. package/dist/web/assets/ScheduledWorkPage-UXZSSWgA.js +1 -0
  108. package/dist/web/assets/SettingsView-CAH0vreE.css +1 -0
  109. package/dist/web/assets/SettingsView-CQm1ai73.js +9 -0
  110. package/dist/web/assets/TeamChatView-C4haojB7.js +3 -0
  111. package/dist/web/assets/{TerminalOverlay-DnNVrCtu.js → TerminalOverlay-p2GZsuyQ.js} +3 -3
  112. package/dist/web/assets/{TrainingCreationPanel-CDwwyucO.js → TrainingCreationPanel-BYJSlO8X.js} +1 -1
  113. package/dist/web/assets/{TrainingDraftPanel-BijDnV_0.js → TrainingDraftPanel-DR5KlayH.js} +1 -1
  114. package/dist/web/assets/{UsageSettingsSection-Y5BFAu1p.js → UsageSettingsSection-BQToNXE4.js} +5 -5
  115. package/dist/web/assets/{WorkSidebarPanel-CkJlvZKm.js → WorkSidebarPanel--EeytWeg.js} +1 -1
  116. package/dist/web/assets/WorkspaceDiffPanel-BrovSYhn.js +14 -0
  117. package/dist/web/assets/{WorkspaceEnvironmentMenu-D8knAy1q.js → WorkspaceEnvironmentMenu-l-keRgvj.js} +3 -3
  118. package/dist/web/assets/{WorkspaceGitDialogs-_LHTrvh6.js → WorkspaceGitDialogs-aicWzaZu.js} +1 -1
  119. package/dist/web/assets/{WorkspaceMonacoEditor-B2B7OM_L.js → WorkspaceMonacoEditor-CO_E74jM.js} +36 -36
  120. package/dist/web/assets/{arrow-up-right-4nAzMtjW.js → arrow-up-right-rwPXNfVn.js} +1 -1
  121. package/dist/web/assets/chat-file-links-B3jDstSC.js +1 -0
  122. package/dist/web/assets/chevron-up-D089nvYQ.js +1 -0
  123. package/dist/web/assets/{clipboard-BzjUoZFo.js → clipboard-DwEExyU4.js} +1 -1
  124. package/dist/web/assets/{cloud-upload-CsrrwS-b.js → cloud-upload-D2he0-vQ.js} +1 -1
  125. package/dist/web/assets/{cssMode-CIbSSHKJ.js → cssMode-DS4k0NcI.js} +1 -1
  126. package/dist/web/assets/{folder-open-vRTuLzpS.js → folder-open-CAOLduKD.js} +1 -1
  127. package/dist/web/assets/{folder-plus-hyqwgUnx.js → folder-plus-D56MrxVT.js} +1 -1
  128. package/dist/web/assets/{git-commit-horizontal-CaxKfeYa.js → git-commit-horizontal-CeNM0oKJ.js} +1 -1
  129. package/dist/web/assets/{htmlMode-C3MGQGam.js → htmlMode-Xkni5erh.js} +1 -1
  130. package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
  131. package/dist/web/assets/{index-Dvq7bpBG.js → index-KwyAyscP.js} +1 -1
  132. package/dist/web/assets/{info-aYWeE1Iw.js → info-CcrBaEE_.js} +1 -1
  133. package/dist/web/assets/{jsonMode-CpD6UkT7.js → jsonMode-C4YPbQB7.js} +1 -1
  134. package/dist/web/assets/{lspLanguageFeatures-DpcK8ZI6.js → lspLanguageFeatures-CF5oMTz6.js} +1 -1
  135. package/dist/web/assets/{minimize-2-DeYg7XqB.js → minimize-2-DzHQnInk.js} +1 -1
  136. package/dist/web/assets/{monaco.contribution-CrrdDQgP.js → monaco.contribution-0EN4mGCC.js} +2 -2
  137. package/dist/web/assets/{monaco.contribution-JWFq0HzV.js → monaco.contribution-B4qcTP0w.js} +2 -2
  138. package/dist/web/assets/{monaco.contribution-BDTM0ZJq.js → monaco.contribution-CJK_NrBm.js} +2 -2
  139. package/dist/web/assets/{monaco.contribution-C-_ekTxy.js → monaco.contribution-CkPGKNd-.js} +2 -2
  140. package/dist/web/assets/{play-BqgRTddV.js → play-p3-AMTPL.js} +1 -1
  141. package/dist/web/assets/{python-B67wope9.js → python-B0kpTxAZ.js} +1 -1
  142. package/dist/web/assets/{refresh-cw-DwMA_2On.js → refresh-cw-_jbTIzzr.js} +1 -1
  143. package/dist/web/assets/{save-B0BKh5oQ.js → save-Cy6hEotx.js} +1 -1
  144. package/dist/web/assets/{square-LY3oz82L.js → square-DKQkcrOH.js} +1 -1
  145. package/dist/web/assets/{toggleHighContrast-B2jka5B1.js → toggleHighContrast-Bnk1VVVq.js} +1 -1
  146. package/dist/web/assets/{tsMode-1MUwluYD.js → tsMode-BDrSVy7V.js} +1 -1
  147. package/dist/web/assets/{upload-bSKSkFVa.js → upload-COn0my_O.js} +1 -1
  148. package/dist/web/assets/{useLocalAgentSchedules--jnnM4Fz.js → useLocalAgentSchedules-iZNB4Oee.js} +1 -1
  149. package/dist/web/assets/{wifi-off-DA34iPmr.js → wifi-off-Cqt-ZLXY.js} +1 -1
  150. package/dist/web/assets/{workers-CczIcRcl.js → workers-hu0Ym93h.js} +1 -1
  151. package/dist/web/assets/{yaml-DwEGoHA9.js → yaml-D-JLDGL6.js} +1 -1
  152. package/dist/web/index.html +2 -2
  153. package/docs/command-reference.md +28 -2
  154. package/package.json +10 -7
  155. package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
  156. package/dist/chunks/app-layer-XEYHFJHI.js +0 -214
  157. package/dist/chunks/app-server-runtime-FJM2EQPH.js +0 -21
  158. package/dist/chunks/apps-GSXUDK6V.js +0 -427
  159. package/dist/chunks/chunk-2JABRRNR.js +0 -183
  160. package/dist/chunks/chunk-47EIAYI7.js +0 -2162
  161. package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
  162. package/dist/chunks/chunk-5TKZBMQM.js +0 -731
  163. package/dist/chunks/chunk-6G6MDZLM.js +0 -14509
  164. package/dist/chunks/chunk-BVY5JYM6.js +0 -512
  165. package/dist/chunks/chunk-C5TKGE5Y.js +0 -1275
  166. package/dist/chunks/chunk-CNTM26OW.js +0 -602
  167. package/dist/chunks/chunk-D7BO5Y5J.js +0 -1531
  168. package/dist/chunks/chunk-DJL4TJYG.js +0 -70
  169. package/dist/chunks/chunk-DLQQIWN2.js +0 -648
  170. package/dist/chunks/chunk-DNXBJZAU.js +0 -630
  171. package/dist/chunks/chunk-EFET7LB7.js +0 -1331
  172. package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
  173. package/dist/chunks/chunk-HFPUR4CQ.js +0 -669
  174. package/dist/chunks/chunk-J3YDKJFD.js +0 -88
  175. package/dist/chunks/chunk-J7PYGDRY.js +0 -634
  176. package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
  177. package/dist/chunks/chunk-KSRWKXRB.js +0 -12
  178. package/dist/chunks/chunk-KWDOAJJI.js +0 -238
  179. package/dist/chunks/chunk-MUMPWI4O.js +0 -92
  180. package/dist/chunks/chunk-N3TGCM7J.js +0 -1135
  181. package/dist/chunks/chunk-NTK22KJD.js +0 -10707
  182. package/dist/chunks/chunk-O6B6YCMI.js +0 -57688
  183. package/dist/chunks/chunk-R3C3MNSI.js +0 -140
  184. package/dist/chunks/chunk-SMNFI2FU.js +0 -113
  185. package/dist/chunks/chunk-UACZUFIA.js +0 -47
  186. package/dist/chunks/chunk-W5GKHH77.js +0 -168
  187. package/dist/chunks/chunk-WBAZFKC7.js +0 -1643
  188. package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
  189. package/dist/chunks/chunk-YVCYVDNP.js +0 -746
  190. package/dist/chunks/cli-6PFRZ2WV.js +0 -21
  191. package/dist/chunks/continual-FYDKLCO7.js +0 -803
  192. package/dist/chunks/core-commands-MAN3CSJQ.js +0 -48
  193. package/dist/chunks/desktop-test-OE5SST2W.js +0 -146
  194. package/dist/chunks/extension-J3CIEDP4.js +0 -10041
  195. package/dist/chunks/help-JNGJJFU5.js +0 -67
  196. package/dist/chunks/opchat-6HEQJFLL.js +0 -167
  197. package/dist/chunks/organizations-MWAPNOCK.js +0 -804
  198. package/dist/chunks/profile-P7HMONTZ.js +0 -1134
  199. package/dist/chunks/project-agent-2RAK7GAZ.js +0 -514
  200. package/dist/chunks/sandbox-command-G22CPFNK.js +0 -1659
  201. package/dist/chunks/sandbox-template-S4WRUWJ6.js +0 -1653
  202. package/dist/chunks/src-BKBZ7WLO.js +0 -3624
  203. package/dist/chunks/src-RTGN2O4H.js +0 -65745
  204. package/dist/chunks/taskset-BMI7KOWP.js +0 -66
  205. package/dist/chunks/teams-bot-5VBYEN7M.js +0 -144
  206. package/dist/chunks/training-UPVSGDTB.js +0 -17
  207. package/dist/chunks/workspaces-IJQPWX3H.js +0 -99
  208. package/dist/web/assets/App-BOkhmdHu.js +0 -173
  209. package/dist/web/assets/AppDialog-BCjKFUBn.js +0 -1
  210. package/dist/web/assets/AppTerminalPanel-DRU8GIfy.js +0 -2
  211. package/dist/web/assets/GetStartedView-jEogFjxP.js +0 -1
  212. package/dist/web/assets/LabModelVersionDetailPage-CrudId_1.js +0 -1
  213. package/dist/web/assets/LabsRoute-9v8qwEBc.js +0 -2
  214. package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
  215. package/dist/web/assets/MainChatThread-VtMpAxlP.js +0 -2
  216. package/dist/web/assets/MainPane-BbknUzp3.js +0 -8
  217. package/dist/web/assets/RightChatPanelStack-CIE5bgmO.js +0 -1
  218. package/dist/web/assets/ScheduledWorkPage-DdbcQGSv.js +0 -1
  219. package/dist/web/assets/SettingsView-CC5GXaE1.css +0 -1
  220. package/dist/web/assets/SettingsView-QT_OLmDh.js +0 -6
  221. package/dist/web/assets/TeamChatView-C4-nG1tC.js +0 -3
  222. package/dist/web/assets/WorkspaceDiffPanel-CBgzmBk8.js +0 -14
  223. package/dist/web/assets/chat-file-links-Bned0MT7.js +0 -1
  224. package/dist/web/assets/chevron-up-DK7ejCfk.js +0 -1
  225. package/dist/web/assets/index-66-ohHD5.js +0 -1
@@ -1 +1 @@
1
- import{r as l,j as e}from"./index-Dvq7bpBG.js";import{S as Z,W as ee,B as se,a as ne}from"./wifi-off-DA34iPmr.js";import{R as O}from"./refresh-cw-DwMA_2On.js";import{X as H,ai as te,ap as M,cr as F}from"./App-BOkhmdHu.js";import{k as ie,m as ae,P as le,n as oe,r as re,o as ce,R as de}from"./MainPane-BbknUzp3.js";import{M as J}from"./MarkdownText-DqJarmTh.js";import{T as me}from"./chat-file-links-Bned0MT7.js";import"./cloud-upload-CsrrwS-b.js";import"./arrow-up-right-4nAzMtjW.js";import"./square-LY3oz82L.js";import"./desktop-files-BQj1J-ob.js";const ue=2e4,R=10,he=12*1024*1024,ye=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function ge(s){const[n,m]=l.useState(""),[a,y]=l.useState(0),[c,u]=l.useState([]),[f,i]=l.useState(null),[b,h]=l.useState(!1),[p,C]=l.useState([]),[N,v]=l.useState(0),[o,I]=l.useState(null),k=l.useRef(null),E=l.useRef(null),D=l.useRef(c);D.current=c;const g=l.useMemo(()=>xe(n,a),[n,a]),S=g?`${g.start}:${g.end}:${g.query}`:null,T=g?.query??null,w=l.useMemo(()=>{if(!g)return[];const t=new Map;for(const d of[...s.members,...p])t.set(d.userId,d);const r=g.query.toLowerCase();return[...t.values()].filter(d=>`${d.handle??""} ${d.name??""}`.toLowerCase().includes(r)).slice(0,8)},[g,s.members,p]),B=!!(g&&S!==o&&w.length>0),L=!!(s.disabled||s.busy||b),U=!L&&(!!n.trim()||c.length>0);l.useEffect(()=>{if(T==null){C([]);return}let t=!0;const r=window.setTimeout(()=>{s.onSearchMembers(T).then(d=>{t&&C(d)},()=>{t&&C([])})},150);return()=>{t=!1,window.clearTimeout(r)}},[T,s.onSearchMembers]),l.useEffect(()=>{v(0)},[S]),l.useEffect(()=>()=>K(D.current),[]);async function $(t){if(t?.preventDefault(),!!U){i(null),h(!0);try{const r=await Promise.all(c.map(re));if(!await s.onSend({body:n,mentionUserIds:fe(n,s.members),attachments:r,replyToMessageId:s.replyTo?.id??null}))return;K(c),m(""),y(0),u([]),s.onCancelReply()}catch(r){i(r instanceof Error?r.message:String(r))}finally{h(!1)}}}function V(t){if(B){if(t.key==="ArrowDown"){t.preventDefault(),v(r=>(r+1)%w.length);return}if(t.key==="ArrowUp"){t.preventDefault(),v(r=>(r-1+w.length)%w.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),z(w[N]??w[0]);return}if(t.key==="Escape"){t.preventDefault(),I(S);return}}t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),$())}function G(t){if(!t)return;i(null);const r=Math.max(0,R-c.length);if(r===0){i(`You can attach up to ${R} images.`),A();return}const d=[...t],j=d.slice(0,r),P=j.find(x=>!ye.has(x.type)),q=j.find(x=>x.size<=0||x.size>he);if(P){i(`${P.name} is not a supported image type.`),A();return}if(q){i(`${q.name} must be smaller than 12 MB.`),A();return}const Q=j.map(x=>({id:ce(),file:x,name:x.name,mediaType:x.type,sizeBytes:x.size,kind:"image",previewUrl:URL.createObjectURL(x)}));u(x=>[...x,...Q]),d.length>r&&i(`Only ${R} images can be attached to one message.`),A()}function W(t){u(r=>{const d=r.find(j=>j.id===t);return d?.previewUrl&&URL.revokeObjectURL(d.previewUrl),r.filter(j=>j.id!==t)})}function A(){k.current&&(k.current.value="")}function z(t){if(!g)return;const r=`@${X(t)} `,d=`${n.slice(0,g.start)}${r}${n.slice(g.end)}`,j=g.start+r.length;m(d),y(j),I(null),window.requestAnimationFrame(()=>E.current?.focusAtPromptIndex(j))}return e.jsxs("form",{className:`composer dock community-composer${c.length>0?" has-attachments":""}${f?" has-attachment-error":""}`,onSubmit:$,children:[s.replyTo?e.jsxs("div",{className:"community-composer-reply",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Replying to"}),s.replyTo.body.slice(0,100)||"message"]}),e.jsx("button",{type:"button","aria-label":"Cancel reply",onClick:s.onCancelReply,children:e.jsx(H,{size:13})})]}):null,B?e.jsx("div",{className:"community-mention-menu",role:"listbox","aria-label":"Community members",children:w.map((t,r)=>e.jsxs("button",{type:"button",role:"option","aria-selected":r===N,onMouseDown:d=>d.preventDefault(),onClick:()=>z(t),children:[e.jsx("strong",{children:t.name??t.handle??"Community member"}),t.handle?e.jsxs("small",{children:["@",t.handle]}):null]},t.userId))}):null,e.jsxs("div",{className:"composer-input-shell",children:[c.length>0?e.jsx("div",{className:"composer-attachments","aria-label":"Selected attachments",children:c.map(t=>e.jsx(ie,{attachment:t,onRemove:()=>W(t.id)},t.id))}):null,f?e.jsx("div",{className:"composer-attachment-error",role:"status",children:f}):null,e.jsx("div",{className:"composer-textarea-frame",onClick:t=>{t.target===t.currentTarget&&E.current?.focusAtPromptIndex(a)},children:e.jsx(ae,{ref:E,disabled:L,onCursorChange:y,onKeyDown:V,onPromptChange:(t,r)=>{const d=t.slice(0,ue);m(d),y(Math.min(r,d.length))},onTokenPositionChange:()=>{},placeholder:s.disabled?"Accept the community rules to post":"Message community",prompt:n,token:null})}),e.jsxs("div",{className:"composer-primary-controls team-chat-composer-controls",children:[e.jsx("input",{ref:k,className:"composer-file-input",hidden:!0,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,onChange:t=>G(t.currentTarget.files)}),e.jsx("button",{type:"button",className:"composer-icon","aria-label":"Attach images",disabled:L||c.length>=R,onClick:()=>k.current?.click(),children:e.jsx(le,{size:17})}),e.jsx("div",{className:"composer-spacer"}),e.jsx("button",{type:"submit",className:"send-button","aria-label":"Send message",disabled:!U,children:e.jsx(oe,{size:17})})]})]})]})}function xe(s,n=s.length){const m=Math.max(0,Math.min(n,s.length)),a=/(?:^|\s)@([\w-]*)$/.exec(s.slice(0,m));return!a||a.index==null?null:{start:a.index+a[0].indexOf("@"),end:m,query:a[1]??""}}function fe(s,n){const m=new Set([...s.matchAll(/(?:^|\s)@([\w-]+)/g)].map(a=>a[1]?.toLowerCase()));return n.filter(a=>m.has(X(a).toLowerCase())).map(a=>a.userId)}function X(s){return s.handle??s.name?.replace(/[^\w-]/g,"")??s.userId}function K(s){for(const n of s)n.previewUrl&&URL.revokeObjectURL(n.previewUrl)}function be(s){const[n,m]=l.useState(!1),[a,y]=l.useState(s.message.body),c=s.message.refs.find(i=>i.refType==="message_reply"),u=c?s.messagesById.get(c.refId)??null:null,f=u?.authorUserId?s.membersById.get(u.authorUserId)??null:null;return e.jsxs("article",{className:`community-message${s.own?" own":""}`,id:`community-message-${s.message.id}`,children:[e.jsx("div",{className:"community-avatar",children:je(s.author?.name??s.author?.handle??"?")}),e.jsxs("div",{className:"community-message-content",children:[e.jsxs("header",{children:[e.jsx("strong",{children:s.author?.name??s.author?.handle??"Community member"}),e.jsx("time",{dateTime:s.message.createdAt,children:pe(s.message.createdAt)}),s.message.editedAt?e.jsx("span",{children:"edited"}):null,s.message.deletedAt?null:e.jsxs("div",{className:"community-message-actions",children:[e.jsx("button",{type:"button","aria-label":"Reply",onClick:()=>s.onReply(s.message),children:e.jsx(de,{size:13})}),s.own?e.jsx("button",{type:"button","aria-label":"Edit",onClick:()=>m(!0),children:e.jsx(te,{size:13})}):null,s.own?e.jsx("button",{type:"button","aria-label":"Delete",onClick:()=>{s.onDelete(s.message.id)},children:e.jsx(me,{size:13})}):null]})]}),c?e.jsxs("button",{type:"button",className:"community-reply-quote",onClick:()=>document.getElementById(`community-message-${c.refId}`)?.scrollIntoView({behavior:"smooth",block:"center"}),children:[e.jsx("strong",{children:f?.name??"Community member"}),e.jsx("span",{children:u?.deletedAt?"Message deleted":u?.body??String(c.preview.body??"Earlier message")})]}):null,n?e.jsxs("form",{className:"community-message-edit",onSubmit:i=>{i.preventDefault(),s.onEdit(s.message.id,a).then(b=>{b&&m(!1)})},children:[e.jsx("textarea",{autoFocus:!0,value:a,onChange:i=>y(i.currentTarget.value)}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>m(!1),children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!a.trim(),children:"Save"})]})]}):s.message.deletedAt?e.jsx("div",{className:"community-message-deleted",children:"Message deleted"}):e.jsx(J,{content:s.message.body}),!s.message.deletedAt&&s.message.attachments.length>0?e.jsx("div",{className:"community-message-attachments",children:s.message.attachments.map(i=>s.attachmentsAccessible?e.jsxs("button",{type:"button",onClick:()=>{s.onDownloadAttachment(i.id)},children:[e.jsx("span",{children:i.name}),e.jsx("small",{children:_(i.sizeBytes)})]},i.id):e.jsxs("div",{className:"community-attachment-placeholder",children:[e.jsx("span",{children:i.name}),e.jsxs("small",{children:["Join to view · ",_(i.sizeBytes)]})]},i.id))}):null]})]})}function je(s){return s.split(/\s+/).slice(0,2).map(n=>n[0]?.toUpperCase()??"").join("")||"?"}function pe(s){const n=new Date(s);return Number.isNaN(n.getTime())?"":n.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function _(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function ve(s){const[n,m]=l.useState(!1),a=l.useRef(null),y=l.useRef(s.onClose);l.useEffect(()=>m(!1),[s.rules.id]),l.useEffect(()=>{y.current=s.onClose},[s.onClose]),l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null,f=a.current,i=()=>[...f?.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')??[]];i()[0]?.focus();const b=h=>{if(h.key==="Escape"){h.preventDefault(),y.current();return}if(h.key!=="Tab")return;const p=i();if(p.length===0){h.preventDefault(),f?.focus();return}const C=p[0],N=p.at(-1);h.shiftKey&&document.activeElement===C?(h.preventDefault(),N.focus()):!h.shiftKey&&document.activeElement===N&&(h.preventDefault(),C.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),u?.focus()}},[]);const c=s.mode!=="review";return e.jsx("div",{className:"community-dialog-backdrop",role:"presentation",onMouseDown:s.onClose,children:e.jsxs("section",{ref:a,className:"community-rules-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"community-rules-title",tabIndex:-1,onMouseDown:u=>u.stopPropagation(),children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("small",{children:["Community rules · version ",s.rules.version]}),e.jsx("h2",{id:"community-rules-title",children:s.rules.title})]}),e.jsx("button",{type:"button","aria-label":"Close rules",onClick:s.onClose,children:e.jsx(H,{size:16})})]}),e.jsx("div",{className:"community-rules-body",children:e.jsx(J,{content:s.rules.bodyMarkdown})}),e.jsxs("footer",{children:[c?e.jsxs("label",{className:"community-rules-acceptance",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:u=>m(u.currentTarget.checked)}),e.jsx("span",{children:"I have read and agree to follow these rules."})]}):e.jsx("span",{}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"secondary",onClick:s.onClose,children:"Cancel"}),c?e.jsx("button",{type:"button",disabled:!n||s.busy,onClick:()=>{s.onAccept().then(u=>{u&&s.onClose()})},children:s.busy?"Saving…":s.mode==="join"?"Agree and join":"Accept updated rules"}):null]})]})]})})}function De({communities:s,chat:n,currentUserId:m}){M(s.discoveryError),M(s.previewError),M(s.membershipError?.message),M(n.channelsError,{prefix:"Channels"}),M(n.messagesError,{prefix:"Messages"}),M(n.actionError);const[a,y]=l.useState(null),[c,u]=l.useState(null),f=l.useRef(null),i=s.preview,b=i?.membership?.status==="active",h=!!i?.capabilities.requiresRulesAcceptance,p=l.useMemo(()=>new Map(n.members.map(o=>[o.userId,o])),[n.members]),C=l.useMemo(()=>new Map(n.messages.map(o=>[o.id,o])),[n.messages]),N=n.messages.at(-1)?.sequence??0;if(l.useEffect(()=>{const o=f.current;o&&(o.scrollTop=o.scrollHeight)},[n.selectedChannelId,N]),l.useEffect(()=>{u(null),h&&i?.currentRules&&y("reaccept")},[i?.currentRules,h]),!s.selectedSummary)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-discovery-card",children:[e.jsx(F,{size:30}),e.jsx("h1",{children:"Discover communities"}),e.jsx("p",{children:s.discoveryLoading&&s.items.length===0?"Finding communities…":"Preview public conversations and join after accepting each community's rules."}),s.items.length>0?e.jsx("div",{className:"community-discovery-list",children:s.items.map(o=>e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(o.id),children:[e.jsx(Y,{name:o.displayName,imageUrl:o.imageUrl}),e.jsxs("span",{children:[e.jsx("strong",{children:o.displayName}),e.jsx("small",{children:o.description})]}),e.jsx("em",{children:o.membership?.status==="active"?"Joined":o.featuredAt?"Featured":`${o.memberCount.toLocaleString()} members`})]},o.id))}):s.discoveryLoading?null:e.jsx("div",{className:"community-state",children:"No public communities are available yet."}),e.jsxs("div",{className:"community-discovery-actions",children:[e.jsxs("button",{type:"button",onClick:()=>{s.refresh()},disabled:s.discoveryLoading,children:[e.jsx(O,{size:14})," Refresh"]}),s.nextCursor?e.jsx("button",{type:"button",className:"secondary",onClick:()=>{s.loadMore()},disabled:s.discoveryLoading,children:"Load more"}):null]})]})});if(!i&&s.previewLoading)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("span",{className:"community-spinner"})," Loading community…"]})});if(!i)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("h1",{children:s.selectedSummary.displayName}),e.jsx("div",{className:"community-state",children:"This community preview is unavailable."}),e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(s.selectedSummary.id),children:[e.jsx(O,{size:14})," Retry preview"]})]})});const v=i.currentRules;return e.jsxs("section",{className:"community-view",children:[e.jsxs("header",{className:"community-header",children:[e.jsxs("div",{className:"community-heading",children:[e.jsx(Y,{name:i.displayName,imageUrl:i.imageUrl}),e.jsxs("div",{children:[e.jsx("small",{children:i.displayName}),e.jsx("h1",{children:n.selectedChannel?`# ${n.selectedChannel.displayName}`:i.displayName}),e.jsx("p",{children:n.selectedChannel?.topic||i.description})]})]}),e.jsxs("div",{className:"community-header-actions",children:[e.jsxs("span",{className:"community-member-count",children:[e.jsx(F,{size:14})," ",i.memberCount.toLocaleString()]}),v?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y("review"),children:[e.jsx(Z,{size:14})," Rules"]}):null,b?e.jsx(Ce,{mode:i.membership?.notificationMode??"mentions",busy:s.membershipBusy,onMode:s.updateNotifications,onLeave:s.leave}):null]})]}),e.jsxs("div",{className:"community-chat-main conversation-surface-main",children:[e.jsxs("div",{className:"community-chat-notices",children:[b?h?e.jsxs("div",{className:"community-preview-banner warning",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"The rules have changed"}),e.jsx("span",{children:"Accept the current rules to continue reading live updates and posting."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("reaccept"),children:"Review updated rules"})]}):null:e.jsxs("div",{className:"community-preview-banner",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Previewing ",i.displayName]}),e.jsx("span",{children:"Read the public conversation, then accept the rules to join and post."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("join"),children:"Join community"})]}),n.realtimeError&&b&&!h?e.jsxs("div",{className:"community-realtime-state",children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Live updates are reconnecting. Loaded messages are still available."})]}):null,n.lostMembership?e.jsx("div",{className:"community-state error",children:"Your membership changed. Refresh the community before continuing."}):null,n.channelsError?e.jsx("button",{type:"button",className:"community-state",onClick:()=>{n.loadChannels()},children:"Retry loading channels"}):null]}),e.jsxs("div",{className:"community-message-pane conversation-message-scroll",ref:f,role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":n.messagesLoading,"aria-label":n.selectedChannel?`${i.displayName}, ${n.selectedChannel.displayName}`:i.displayName,tabIndex:0,children:[n.hasMoreBefore?e.jsx("button",{type:"button",className:"community-load-older",disabled:n.olderMessagesLoading,onClick:()=>{n.loadOlder()},children:n.olderMessagesLoading?"Loading…":"Load earlier messages"}):null,n.messagesLoading&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"Loading messages…"}):null,n.messagesError?e.jsxs("div",{className:"community-message-state",children:["Messages are unavailable. ",e.jsx("button",{type:"button",onClick:()=>{n.loadMessages()},children:"Retry"})]}):null,!n.messagesLoading&&!n.messagesError&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"No messages in this channel yet."}):null,n.messages.map(o=>e.jsx(be,{message:o,author:o.authorUserId?p.get(o.authorUserId)??null:null,own:o.authorUserId===m,attachmentsAccessible:!n.previewMode,membersById:p,messagesById:C,onReply:u,onEdit:n.editMessage,onDelete:n.deleteMessage,onDownloadAttachment:n.downloadAttachment},o.id))]}),b?e.jsxs("div",{className:"community-composer-wrap conversation-composer-shell",children:[n.failedSend?e.jsxs("div",{className:"community-failed-send",children:[e.jsx("span",{children:"Message not sent."}),e.jsx("button",{type:"button",disabled:n.sending,onClick:()=>{n.retrySend()},children:"Retry"}),e.jsx("button",{type:"button",onClick:n.dismissFailedSend,children:"Dismiss"})]}):null,e.jsx(ge,{members:n.members,replyTo:c,busy:n.sending,disabled:h||n.lostMembership||!n.selectedChannel||n.selectedChannel.postingPolicy==="admins"&&i.membership?.role==="member",onCancelReply:()=>u(null),onSearchMembers:n.searchMembers,onSend:n.sendMessage})]}):null]}),a&&v?e.jsx(ve,{rules:v,mode:a,busy:s.membershipBusy,onAccept:a==="join"?s.join:s.acceptRules,onClose:()=>y(null)}):null]})}function Ce(s){const[n,m]=l.useState(!1);return e.jsxs("div",{className:"community-membership-menu",children:[e.jsxs("button",{type:"button",className:"secondary","aria-expanded":n,onClick:()=>m(a=>!a),children:[s.mode==="none"?e.jsx(se,{size:14}):e.jsx(ne,{size:14})," Joined"]}),n?e.jsxs("div",{className:"community-membership-popover",children:[e.jsx("strong",{children:"Notifications"}),["mentions","all","none"].map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"community-notifications",checked:s.mode===a,disabled:s.busy,onChange:()=>{s.onMode(a)}})," ",a==="mentions"?"Mentions":a==="all"?"All messages":"Nothing"]},a)),e.jsx("button",{type:"button",className:"danger",disabled:s.busy,onClick:()=>{window.confirm("Leave this community? You can join again later by accepting the current rules.")&&s.onLeave().then(a=>{a&&m(!1)})},children:"Leave community"})]}):null]})}function Y({name:s,imageUrl:n}){return n?e.jsx("img",{className:"community-icon",src:n,alt:""}):e.jsx("span",{className:"community-icon fallback",children:s.slice(0,2).toUpperCase()})}export{De as CommunityView};
1
+ import{r as l,j as e}from"./index-KwyAyscP.js";import{S as Z,W as ee,B as se,a as ne}from"./wifi-off-Cqt-ZLXY.js";import{R as O}from"./refresh-cw-_jbTIzzr.js";import{X as H,am as te,aw as M,dQ as F}from"./App-DxecRQUL.js";import{k as ie,m as ae,P as le,n as oe,r as re,o as ce,R as de}from"./MainPane-BWwcxgHD.js";import{M as J}from"./MarkdownText-D8XC5UT_.js";import{T as me}from"./chat-file-links-B3jDstSC.js";import"./cloud-upload-D2he0-vQ.js";import"./arrow-up-right-rwPXNfVn.js";import"./square-DKQkcrOH.js";import"./desktop-files-BQj1J-ob.js";const ue=2e4,R=10,he=12*1024*1024,ye=new Set(["image/png","image/jpeg","image/webp","image/gif"]);function ge(s){const[n,m]=l.useState(""),[a,y]=l.useState(0),[c,u]=l.useState([]),[f,i]=l.useState(null),[b,h]=l.useState(!1),[p,C]=l.useState([]),[N,v]=l.useState(0),[o,I]=l.useState(null),k=l.useRef(null),E=l.useRef(null),D=l.useRef(c);D.current=c;const g=l.useMemo(()=>xe(n,a),[n,a]),S=g?`${g.start}:${g.end}:${g.query}`:null,T=g?.query??null,w=l.useMemo(()=>{if(!g)return[];const t=new Map;for(const d of[...s.members,...p])t.set(d.userId,d);const r=g.query.toLowerCase();return[...t.values()].filter(d=>`${d.handle??""} ${d.name??""}`.toLowerCase().includes(r)).slice(0,8)},[g,s.members,p]),B=!!(g&&S!==o&&w.length>0),L=!!(s.disabled||s.busy||b),U=!L&&(!!n.trim()||c.length>0);l.useEffect(()=>{if(T==null){C([]);return}let t=!0;const r=window.setTimeout(()=>{s.onSearchMembers(T).then(d=>{t&&C(d)},()=>{t&&C([])})},150);return()=>{t=!1,window.clearTimeout(r)}},[T,s.onSearchMembers]),l.useEffect(()=>{v(0)},[S]),l.useEffect(()=>()=>K(D.current),[]);async function $(t){if(t?.preventDefault(),!!U){i(null),h(!0);try{const r=await Promise.all(c.map(re));if(!await s.onSend({body:n,mentionUserIds:fe(n,s.members),attachments:r,replyToMessageId:s.replyTo?.id??null}))return;K(c),m(""),y(0),u([]),s.onCancelReply()}catch(r){i(r instanceof Error?r.message:String(r))}finally{h(!1)}}}function V(t){if(B){if(t.key==="ArrowDown"){t.preventDefault(),v(r=>(r+1)%w.length);return}if(t.key==="ArrowUp"){t.preventDefault(),v(r=>(r-1+w.length)%w.length);return}if(t.key==="Enter"||t.key==="Tab"){t.preventDefault(),z(w[N]??w[0]);return}if(t.key==="Escape"){t.preventDefault(),I(S);return}}t.key!=="Enter"||t.shiftKey||t.nativeEvent.isComposing||(t.preventDefault(),$())}function G(t){if(!t)return;i(null);const r=Math.max(0,R-c.length);if(r===0){i(`You can attach up to ${R} images.`),A();return}const d=[...t],j=d.slice(0,r),P=j.find(x=>!ye.has(x.type)),q=j.find(x=>x.size<=0||x.size>he);if(P){i(`${P.name} is not a supported image type.`),A();return}if(q){i(`${q.name} must be smaller than 12 MB.`),A();return}const W=j.map(x=>({id:ce(),file:x,name:x.name,mediaType:x.type,sizeBytes:x.size,kind:"image",previewUrl:URL.createObjectURL(x)}));u(x=>[...x,...W]),d.length>r&&i(`Only ${R} images can be attached to one message.`),A()}function Q(t){u(r=>{const d=r.find(j=>j.id===t);return d?.previewUrl&&URL.revokeObjectURL(d.previewUrl),r.filter(j=>j.id!==t)})}function A(){k.current&&(k.current.value="")}function z(t){if(!g)return;const r=`@${X(t)} `,d=`${n.slice(0,g.start)}${r}${n.slice(g.end)}`,j=g.start+r.length;m(d),y(j),I(null),window.requestAnimationFrame(()=>E.current?.focusAtPromptIndex(j))}return e.jsxs("form",{className:`composer dock community-composer${c.length>0?" has-attachments":""}${f?" has-attachment-error":""}`,onSubmit:$,children:[s.replyTo?e.jsxs("div",{className:"community-composer-reply",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Replying to"}),s.replyTo.body.slice(0,100)||"message"]}),e.jsx("button",{type:"button","aria-label":"Cancel reply",onClick:s.onCancelReply,children:e.jsx(H,{size:13})})]}):null,B?e.jsx("div",{className:"community-mention-menu",role:"listbox","aria-label":"Community members",children:w.map((t,r)=>e.jsxs("button",{type:"button",role:"option","aria-selected":r===N,onMouseDown:d=>d.preventDefault(),onClick:()=>z(t),children:[e.jsx("strong",{children:t.name??t.handle??"Community member"}),t.handle?e.jsxs("small",{children:["@",t.handle]}):null]},t.userId))}):null,e.jsxs("div",{className:"composer-input-shell",children:[c.length>0?e.jsx("div",{className:"composer-attachments","aria-label":"Selected attachments",children:c.map(t=>e.jsx(ie,{attachment:t,onRemove:()=>Q(t.id)},t.id))}):null,f?e.jsx("div",{className:"composer-attachment-error",role:"status",children:f}):null,e.jsx("div",{className:"composer-textarea-frame",onClick:t=>{t.target===t.currentTarget&&E.current?.focusAtPromptIndex(a)},children:e.jsx(ae,{ref:E,disabled:L,onCursorChange:y,onKeyDown:V,onPromptChange:(t,r)=>{const d=t.slice(0,ue);m(d),y(Math.min(r,d.length))},onTokenPositionChange:()=>{},placeholder:s.disabled?"Accept the community rules to post":"Message community",prompt:n,token:null})}),e.jsxs("div",{className:"composer-primary-controls team-chat-composer-controls",children:[e.jsx("input",{ref:k,className:"composer-file-input",hidden:!0,type:"file",accept:"image/png,image/jpeg,image/webp,image/gif",multiple:!0,onChange:t=>G(t.currentTarget.files)}),e.jsx("button",{type:"button",className:"composer-icon","aria-label":"Attach images",disabled:L||c.length>=R,onClick:()=>k.current?.click(),children:e.jsx(le,{size:17})}),e.jsx("div",{className:"composer-spacer"}),e.jsx("button",{type:"submit",className:"send-button","aria-label":"Send message",disabled:!U,children:e.jsx(oe,{size:17})})]})]})]})}function xe(s,n=s.length){const m=Math.max(0,Math.min(n,s.length)),a=/(?:^|\s)@([\w-]*)$/.exec(s.slice(0,m));return!a||a.index==null?null:{start:a.index+a[0].indexOf("@"),end:m,query:a[1]??""}}function fe(s,n){const m=new Set([...s.matchAll(/(?:^|\s)@([\w-]+)/g)].map(a=>a[1]?.toLowerCase()));return n.filter(a=>m.has(X(a).toLowerCase())).map(a=>a.userId)}function X(s){return s.handle??s.name?.replace(/[^\w-]/g,"")??s.userId}function K(s){for(const n of s)n.previewUrl&&URL.revokeObjectURL(n.previewUrl)}function be(s){const[n,m]=l.useState(!1),[a,y]=l.useState(s.message.body),c=s.message.refs.find(i=>i.refType==="message_reply"),u=c?s.messagesById.get(c.refId)??null:null,f=u?.authorUserId?s.membersById.get(u.authorUserId)??null:null;return e.jsxs("article",{className:`community-message${s.own?" own":""}`,id:`community-message-${s.message.id}`,children:[e.jsx("div",{className:"community-avatar",children:je(s.author?.name??s.author?.handle??"?")}),e.jsxs("div",{className:"community-message-content",children:[e.jsxs("header",{children:[e.jsx("strong",{children:s.author?.name??s.author?.handle??"Community member"}),e.jsx("time",{dateTime:s.message.createdAt,children:pe(s.message.createdAt)}),s.message.editedAt?e.jsx("span",{children:"edited"}):null,s.message.deletedAt?null:e.jsxs("div",{className:"community-message-actions",children:[e.jsx("button",{type:"button","aria-label":"Reply",onClick:()=>s.onReply(s.message),children:e.jsx(de,{size:13})}),s.own?e.jsx("button",{type:"button","aria-label":"Edit",onClick:()=>m(!0),children:e.jsx(te,{size:13})}):null,s.own?e.jsx("button",{type:"button","aria-label":"Delete",onClick:()=>{s.onDelete(s.message.id)},children:e.jsx(me,{size:13})}):null]})]}),c?e.jsxs("button",{type:"button",className:"community-reply-quote",onClick:()=>document.getElementById(`community-message-${c.refId}`)?.scrollIntoView({behavior:"smooth",block:"center"}),children:[e.jsx("strong",{children:f?.name??"Community member"}),e.jsx("span",{children:u?.deletedAt?"Message deleted":u?.body??String(c.preview.body??"Earlier message")})]}):null,n?e.jsxs("form",{className:"community-message-edit",onSubmit:i=>{i.preventDefault(),s.onEdit(s.message.id,a).then(b=>{b&&m(!1)})},children:[e.jsx("textarea",{autoFocus:!0,value:a,onChange:i=>y(i.currentTarget.value)}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>m(!1),children:"Cancel"}),e.jsx("button",{type:"submit",disabled:!a.trim(),children:"Save"})]})]}):s.message.deletedAt?e.jsx("div",{className:"community-message-deleted",children:"Message deleted"}):e.jsx(J,{content:s.message.body}),!s.message.deletedAt&&s.message.attachments.length>0?e.jsx("div",{className:"community-message-attachments",children:s.message.attachments.map(i=>s.attachmentsAccessible?e.jsxs("button",{type:"button",onClick:()=>{s.onDownloadAttachment(i.id)},children:[e.jsx("span",{children:i.name}),e.jsx("small",{children:_(i.sizeBytes)})]},i.id):e.jsxs("div",{className:"community-attachment-placeholder",children:[e.jsx("span",{children:i.name}),e.jsxs("small",{children:["Join to view · ",_(i.sizeBytes)]})]},i.id))}):null]})]})}function je(s){return s.split(/\s+/).slice(0,2).map(n=>n[0]?.toUpperCase()??"").join("")||"?"}function pe(s){const n=new Date(s);return Number.isNaN(n.getTime())?"":n.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"})}function _(s){return s<1024?`${s} B`:s<1024*1024?`${Math.round(s/1024)} KB`:`${(s/1024/1024).toFixed(1)} MB`}function ve(s){const[n,m]=l.useState(!1),a=l.useRef(null),y=l.useRef(s.onClose);l.useEffect(()=>m(!1),[s.rules.id]),l.useEffect(()=>{y.current=s.onClose},[s.onClose]),l.useEffect(()=>{const u=document.activeElement instanceof HTMLElement?document.activeElement:null,f=a.current,i=()=>[...f?.querySelectorAll('button:not([disabled]), input:not([disabled]), [href], [tabindex]:not([tabindex="-1"])')??[]];i()[0]?.focus();const b=h=>{if(h.key==="Escape"){h.preventDefault(),y.current();return}if(h.key!=="Tab")return;const p=i();if(p.length===0){h.preventDefault(),f?.focus();return}const C=p[0],N=p.at(-1);h.shiftKey&&document.activeElement===C?(h.preventDefault(),N.focus()):!h.shiftKey&&document.activeElement===N&&(h.preventDefault(),C.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),u?.focus()}},[]);const c=s.mode!=="review";return e.jsx("div",{className:"community-dialog-backdrop",role:"presentation",onMouseDown:s.onClose,children:e.jsxs("section",{ref:a,className:"community-rules-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"community-rules-title",tabIndex:-1,onMouseDown:u=>u.stopPropagation(),children:[e.jsxs("header",{children:[e.jsxs("div",{children:[e.jsxs("small",{children:["Community rules · version ",s.rules.version]}),e.jsx("h2",{id:"community-rules-title",children:s.rules.title})]}),e.jsx("button",{type:"button","aria-label":"Close rules",onClick:s.onClose,children:e.jsx(H,{size:16})})]}),e.jsx("div",{className:"community-rules-body",children:e.jsx(J,{content:s.rules.bodyMarkdown})}),e.jsxs("footer",{children:[c?e.jsxs("label",{className:"community-rules-acceptance",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:u=>m(u.currentTarget.checked)}),e.jsx("span",{children:"I have read and agree to follow these rules."})]}):e.jsx("span",{}),e.jsxs("div",{children:[e.jsx("button",{type:"button",className:"secondary",onClick:s.onClose,children:"Cancel"}),c?e.jsx("button",{type:"button",disabled:!n||s.busy,onClick:()=>{s.onAccept().then(u=>{u&&s.onClose()})},children:s.busy?"Saving…":s.mode==="join"?"Agree and join":"Accept updated rules"}):null]})]})]})})}function De({communities:s,chat:n,currentUserId:m}){M(s.discoveryError),M(s.previewError),M(s.membershipError?.message),M(n.channelsError,{prefix:"Channels"}),M(n.messagesError,{prefix:"Messages"}),M(n.actionError);const[a,y]=l.useState(null),[c,u]=l.useState(null),f=l.useRef(null),i=s.preview,b=i?.membership?.status==="active",h=!!i?.capabilities.requiresRulesAcceptance,p=l.useMemo(()=>new Map(n.members.map(o=>[o.userId,o])),[n.members]),C=l.useMemo(()=>new Map(n.messages.map(o=>[o.id,o])),[n.messages]),N=n.messages.at(-1)?.sequence??0;if(l.useEffect(()=>{const o=f.current;o&&(o.scrollTop=o.scrollHeight)},[n.selectedChannelId,N]),l.useEffect(()=>{u(null),h&&i?.currentRules&&y("reaccept")},[i?.currentRules,h]),!s.selectedSummary)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-discovery-card",children:[e.jsx(F,{size:30}),e.jsx("h1",{children:"Discover communities"}),e.jsx("p",{children:s.discoveryLoading&&s.items.length===0?"Finding communities…":"Preview public conversations and join after accepting each community's rules."}),s.items.length>0?e.jsx("div",{className:"community-discovery-list",children:s.items.map(o=>e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(o.id),children:[e.jsx(Y,{name:o.displayName,imageUrl:o.imageUrl}),e.jsxs("span",{children:[e.jsx("strong",{children:o.displayName}),e.jsx("small",{children:o.description})]}),e.jsx("em",{children:o.membership?.status==="active"?"Joined":o.featuredAt?"Featured":`${o.memberCount.toLocaleString()} members`})]},o.id))}):s.discoveryLoading?null:e.jsx("div",{className:"community-state",children:"No public communities are available yet."}),e.jsxs("div",{className:"community-discovery-actions",children:[e.jsxs("button",{type:"button",onClick:()=>{s.refresh()},disabled:s.discoveryLoading,children:[e.jsx(O,{size:14})," Refresh"]}),s.nextCursor?e.jsx("button",{type:"button",className:"secondary",onClick:()=>{s.loadMore()},disabled:s.discoveryLoading,children:"Load more"}):null]})]})});if(!i&&s.previewLoading)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("span",{className:"community-spinner"})," Loading community…"]})});if(!i)return e.jsx("section",{className:"community-empty-page",children:e.jsxs("div",{className:"community-empty-card",children:[e.jsx("h1",{children:s.selectedSummary.displayName}),e.jsx("div",{className:"community-state",children:"This community preview is unavailable."}),e.jsxs("button",{type:"button",onClick:()=>s.selectCommunity(s.selectedSummary.id),children:[e.jsx(O,{size:14})," Retry preview"]})]})});const v=i.currentRules;return e.jsxs("section",{className:"community-view",children:[e.jsxs("header",{className:"community-header",children:[e.jsxs("div",{className:"community-heading",children:[e.jsx(Y,{name:i.displayName,imageUrl:i.imageUrl}),e.jsxs("div",{children:[e.jsx("small",{children:i.displayName}),e.jsx("h1",{children:n.selectedChannel?`# ${n.selectedChannel.displayName}`:i.displayName}),e.jsx("p",{children:n.selectedChannel?.topic||i.description})]})]}),e.jsxs("div",{className:"community-header-actions",children:[e.jsxs("span",{className:"community-member-count",children:[e.jsx(F,{size:14})," ",i.memberCount.toLocaleString()]}),v?e.jsxs("button",{type:"button",className:"secondary",onClick:()=>y("review"),children:[e.jsx(Z,{size:14})," Rules"]}):null,b?e.jsx(Ce,{mode:i.membership?.notificationMode??"mentions",busy:s.membershipBusy,onMode:s.updateNotifications,onLeave:s.leave}):null]})]}),e.jsxs("div",{className:"community-chat-main conversation-surface-main",children:[e.jsxs("div",{className:"community-chat-notices",children:[b?h?e.jsxs("div",{className:"community-preview-banner warning",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"The rules have changed"}),e.jsx("span",{children:"Accept the current rules to continue reading live updates and posting."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("reaccept"),children:"Review updated rules"})]}):null:e.jsxs("div",{className:"community-preview-banner",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Previewing ",i.displayName]}),e.jsx("span",{children:"Read the public conversation, then accept the rules to join and post."})]}),e.jsx("button",{type:"button",disabled:!v||s.membershipBusy,onClick:()=>y("join"),children:"Join community"})]}),n.realtimeError&&b&&!h?e.jsxs("div",{className:"community-realtime-state",children:[e.jsx(ee,{size:14}),e.jsx("span",{children:"Live updates are reconnecting. Loaded messages are still available."})]}):null,n.lostMembership?e.jsx("div",{className:"community-state error",children:"Your membership changed. Refresh the community before continuing."}):null,n.channelsError?e.jsx("button",{type:"button",className:"community-state",onClick:()=>{n.loadChannels()},children:"Retry loading channels"}):null]}),e.jsxs("div",{className:"community-message-pane conversation-message-scroll",ref:f,role:"log","aria-live":"polite","aria-relevant":"additions text","aria-busy":n.messagesLoading,"aria-label":n.selectedChannel?`${i.displayName}, ${n.selectedChannel.displayName}`:i.displayName,tabIndex:0,children:[n.hasMoreBefore?e.jsx("button",{type:"button",className:"community-load-older",disabled:n.olderMessagesLoading,onClick:()=>{n.loadOlder()},children:n.olderMessagesLoading?"Loading…":"Load earlier messages"}):null,n.messagesLoading&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"Loading messages…"}):null,n.messagesError?e.jsxs("div",{className:"community-message-state",children:["Messages are unavailable. ",e.jsx("button",{type:"button",onClick:()=>{n.loadMessages()},children:"Retry"})]}):null,!n.messagesLoading&&!n.messagesError&&n.messages.length===0?e.jsx("div",{className:"community-message-state",children:"No messages in this channel yet."}):null,n.messages.map(o=>e.jsx(be,{message:o,author:o.authorUserId?p.get(o.authorUserId)??null:null,own:o.authorUserId===m,attachmentsAccessible:!n.previewMode,membersById:p,messagesById:C,onReply:u,onEdit:n.editMessage,onDelete:n.deleteMessage,onDownloadAttachment:n.downloadAttachment},o.id))]}),b?e.jsxs("div",{className:"community-composer-wrap conversation-composer-shell",children:[n.failedSend?e.jsxs("div",{className:"community-failed-send",children:[e.jsx("span",{children:"Message not sent."}),e.jsx("button",{type:"button",disabled:n.sending,onClick:()=>{n.retrySend()},children:"Retry"}),e.jsx("button",{type:"button",onClick:n.dismissFailedSend,children:"Dismiss"})]}):null,e.jsx(ge,{members:n.members,replyTo:c,busy:n.sending,disabled:h||n.lostMembership||!n.selectedChannel||n.selectedChannel.postingPolicy==="admins"&&i.membership?.role==="member",onCancelReply:()=>u(null),onSearchMembers:n.searchMembers,onSend:n.sendMessage})]}):null]}),a&&v?e.jsx(ve,{rules:v,mode:a,busy:s.membershipBusy,onAccept:a==="join"?s.join:s.acceptRules,onClose:()=>y(null)}):null]})}function Ce(s){const[n,m]=l.useState(!1);return e.jsxs("div",{className:"community-membership-menu",children:[e.jsxs("button",{type:"button",className:"secondary","aria-expanded":n,onClick:()=>m(a=>!a),children:[s.mode==="none"?e.jsx(se,{size:14}):e.jsx(ne,{size:14})," Joined"]}),n?e.jsxs("div",{className:"community-membership-popover",children:[e.jsx("strong",{children:"Notifications"}),["mentions","all","none"].map(a=>e.jsxs("label",{children:[e.jsx("input",{type:"radio",name:"community-notifications",checked:s.mode===a,disabled:s.busy,onChange:()=>{s.onMode(a)}})," ",a==="mentions"?"Mentions":a==="all"?"All messages":"Nothing"]},a)),e.jsx("button",{type:"button",className:"danger",disabled:s.busy,onClick:()=>{window.confirm("Leave this community? You can join again later by accepting the current rules.")&&s.onLeave().then(a=>{a&&m(!1)})},children:"Leave community"})]}):null]})}function Y({name:s,imageUrl:n}){return n?e.jsx("img",{className:"community-icon",src:n,alt:""}):e.jsx("span",{className:"community-icon fallback",children:s.slice(0,2).toUpperCase()})}export{De as CommunityView};
@@ -1 +1 @@
1
- import{r as v,j as e}from"./index-Dvq7bpBG.js";import{aC as _,ci as A,aL as P,i as x,X as j,d as y,b9 as w}from"./App-BOkhmdHu.js";import{a as q}from"./chat-file-links-Bned0MT7.js";import{P as C}from"./play-BqgRTddV.js";import{R as k}from"./refresh-cw-DwMA_2On.js";function L({runtime:s}){const[a,i]=v.useState(!1),[o,l]=v.useState(""),[n,u]=v.useState(null),t=s.run,h=t.plan,g=N(t),c={run:t},f=E(t.state),r=S(t),R=r?.git?.pullRequest??t.releaseOutcome.pullRequest;v.useEffect(()=>{i(!1),l(""),u(null)},[t.id,t.revision,t.state,h?.id,g?.id]);async function d(p,b){if(!(!b||n)){u(p);try{await b()}finally{u(null)}}}return e.jsxs("section",{className:`composer-create-strip ${f}`,"aria-label":"Create or improve status",children:[e.jsxs("div",{className:"composer-create-strip-heading",children:[f==="danger"?e.jsx(_,{size:15}):t.state==="awaiting_questions"?e.jsx(A,{size:15}):I(t.state)?e.jsx(P,{className:"composer-create-spin",size:15}):e.jsx(x,{size:15}),e.jsx("span",{children:z(t)}),e.jsx("small",{children:t.target.kind})]}),t.state==="awaiting_questions"&&g?e.jsxs("div",{className:"composer-create-question",children:[e.jsx("p",{children:g.prompt}),e.jsx("div",{className:"composer-create-options",children:g.options.map(p=>e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d(`answer:${p.id}`,()=>s.onAnswerQuestion?s.onAnswerQuestion(c,g.id,p.value):Promise.resolve())},children:[e.jsx("span",{children:n===`answer:${p.id}`?"Saving":p.label}),p.description?e.jsx("small",{children:p.description}):null]},p.id))})]}):t.state==="awaiting_plan_approval"&&h?e.jsxs("div",{className:"composer-create-plan-summary",children:[e.jsx("p",{children:h.summary}),e.jsx(m,{run:t}),a?e.jsxs("div",{className:"composer-create-revision",children:[e.jsx("textarea",{rows:2,value:o,placeholder:"Describe the plan revision",onChange:p=>l(p.currentTarget.value)}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:!o.trim()||!!n,onClick:()=>{d("revise",()=>s.onRevise?s.onRevise(c,o):Promise.resolve())},children:[e.jsx(x,{size:13}),e.jsx("span",{children:n==="revise"?"Saving":"Save revision"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>i(!1),children:[e.jsx(j,{size:13}),e.jsx("span",{children:"Close"})]})]})]}):e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("approve",()=>s.onApprove?s.onApprove(c):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:n==="approve"?"Confirming":"Confirm plan"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>i(!0),children:[e.jsx(x,{size:13}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("cancel",()=>s.onCancel?s.onCancel(c):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="cancel"?"Cancelling":"Cancel"})]})]})]}):t.state==="paused"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"This work is paused. Resume it when you are ready to continue."}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:n==="resume"?"Resuming":"Resume"})]})]}):t.state==="awaiting_promotion"&&r?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:T(t,r.id)}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n||!$(t,r.id),onClick:()=>{d("apply-candidate",()=>s.onApplyCandidate?s.onApplyCandidate(c,r.id):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:n==="apply-candidate"?"Applying":"Apply update"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="reject-candidate"?"Keeping current version":"Keep current version"})]})]})]}):t.state==="pull_request_open"&&r&&R?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:t.target.kind==="agent"?"An Agent update review is open. Finish or close it, then refresh its status.":"An external review is open. Merge or close it, then refresh its status."}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:n==="reconcile-pr"?"Checking":"Refresh review"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="reject-candidate"?"Closing":"Close review"})]})]})]}):t.state==="blocked"||t.state==="failed"||t.state==="cancelled"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:t.blockedReason??"This work stopped before it was ready."}),t.state==="blocked"&&r?.git?.worktreePath&&["draft","checking"].includes(r.status)?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:n==="resume"?"Continuing":"Continue update"})]}):t.state==="blocked"&&r?.git?.pullRequest?.state==="merged"?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:n==="reconcile-pr"?"Checking":"Re-run verification"})]}):null]}):t.state==="released"||t.state==="rejected"||t.state==="ready_local"||t.state==="ready"||t.state==="published_hosted"?e.jsxs("div",{className:"composer-create-status-body composer-create-status-body-reveals",children:[e.jsx("p",{children:t.state==="released"?"The Agent update is saved and its Evals passed.":t.state==="rejected"?"The Agent update was not applied.":t.state==="published_hosted"?"Published to the hosted Profile.":"The Agent and its actions are ready to use."}),e.jsx("div",{className:"composer-create-hover-details",children:e.jsx(m,{run:t})})]}):e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:B(t)}),e.jsx(m,{run:t}),t.executionPolicy.pauseAllowed&&s.onPause?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("pause",()=>s.onPause?.(c)??Promise.resolve())},children:[e.jsx(q,{size:13}),e.jsx("span",{children:n==="pause"?"Pausing":"Pause"})]}):null]})]})}function N(s){return s.questions.find(a=>a.status==="pending"&&a.required)??s.questions.find(a=>a.status==="pending")??null}function m({run:s}){const a=s.plan,i=s.target.kind==="agent",o=i?null:s.sourceRefs[0]??a?.sourcePlan[0]?.path??null,l=s.checkRefs.length||a?.checks.length||0,n=i?0:a?.requirements.length??0,u=i?[]:[...s.sourceRefs,...s.checkRefs].slice(0,4),t=w(a?.metadata);return!o&&l===0&&n===0&&u.length===0&&!t?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"composer-create-facts",children:[t?e.jsx("span",{title:t.detail,children:t.label}):null,o?e.jsx("span",{title:o,children:o}):null,l?e.jsx("span",{children:i?`${l} Evals`:s.checkRefs.length?`${s.checkRefs.length} check refs`:`${l} checks`}):null,n?e.jsxs("span",{children:[n," setup rows"]}):null]}),u.length?e.jsx("ul",{className:"composer-create-refs","aria-label":"Source and check refs",children:u.map(h=>e.jsx("li",{children:e.jsx("code",{title:h,children:h})},h))}):null]})}function z(s){const a=s.target.kind==="agent";return s.state==="awaiting_questions"?"Question":s.state==="awaiting_plan_approval"?"Plan":s.state==="applying_source"?a?"Saving Agent":"Applying source":s.state==="running_checks"?"Running Evals":s.state==="evaluating"?a?"Checking Agent":"Evaluating":s.state==="awaiting_promotion"?a?"Update ready":"Candidate ready":s.state==="opening_pull_request"?"Opening review":s.state==="pull_request_open"?"Review open":s.state==="reconciling_release"?a?"Applying update":"Merging change":s.state==="released"?a?"Agent updated":"Released":s.state==="rejected"?a?"Current Agent kept":"Rejected":s.state==="paused"?"Paused":s.state==="ready"||s.state==="ready_local"?"Ready":s.state==="published_hosted"?"Published":s.state==="cancelled"?"Cancelled":s.state==="blocked"?"Blocked":s.state==="failed"?"Failed":s.operation==="improve"?"Improve":"Create"}function B(s){const a=s.state,i=s.target.kind==="agent";return a==="applying_source"?i?"Saving the approved Agent plan.":"Applying the approved source changes.":a==="running_checks"?i?"Running Evals against the Agent.":"Running checks against the candidate.":a==="evaluating"?i?"Checking the Agent's behavior.":"Evaluating the candidate against its Evals.":a==="opening_pull_request"?i?"Preparing the Agent update review.":"Opening the candidate review.":a==="reconciling_release"?"Applying the change and verifying the active Profile.":a==="pushing_hosted"?"Pushing the Profile source.":a==="running_hosted_checks"?i?"Running hosted Evals.":"Running hosted checks.":"Preparing the work."}function E(s){return["released","ready","ready_local","published_hosted"].includes(s)?"success":["rejected","blocked","failed","cancelled"].includes(s)?"danger":["awaiting_questions","awaiting_plan_approval","awaiting_promotion","pull_request_open","paused"].includes(s)?"warning":"info"}function I(s){return["planning","applying_source","running_checks","evaluating","opening_pull_request","reconciling_release","pushing_hosted","running_hosted_checks"].includes(s)}function S(s){return[...s.candidates].reverse().find(a=>a.target.kind==="agent")??null}function $(s,a){const i=s.evaluationReceipts.filter(o=>o.candidateId===a&&o.subject==="candidate");return i.length>0&&i.every(o=>o.status==="passed"&&o.publishGate!=="failed")}function T(s,a){const i=s.evaluationReceipts.find(n=>n.candidateId===a&&n.subject==="active"),o=s.evaluationReceipts.find(n=>n.candidateId===a&&n.subject==="candidate"),l=n=>n?.summaryCounts?`${n.summaryCounts.passed}/${n.summaryCounts.total}`:n?.status??"not run";return s.target.kind==="agent"?`Current Agent: ${l(i)} Evals passed. Updated Agent: ${l(o)} Evals passed.`:`Base Evals: ${l(i)} passed. Candidate Evals: ${l(o)} passed.`}export{L as ComposerCreateImproveStrip};
1
+ import{r as v,j as e}from"./index-KwyAyscP.js";import{aJ as _,dH as A,aS as P,i as x,X as j,d as y,bh as w}from"./App-DxecRQUL.js";import{P as q}from"./chat-file-links-B3jDstSC.js";import{P as C}from"./play-p3-AMTPL.js";import{R as k}from"./refresh-cw-_jbTIzzr.js";function U({runtime:s}){const[a,i]=v.useState(!1),[o,l]=v.useState(""),[n,u]=v.useState(null),t=s.run,h=t.plan,g=N(t),c={run:t},f=E(t.state),r=I(t),R=r?.git?.pullRequest??t.releaseOutcome.pullRequest;v.useEffect(()=>{i(!1),l(""),u(null)},[t.id,t.revision,t.state,h?.id,g?.id]);async function d(p,b){if(!(!b||n)){u(p);try{await b()}finally{u(null)}}}return e.jsxs("section",{className:`composer-create-strip ${f}`,"aria-label":"Create or improve status",children:[e.jsxs("div",{className:"composer-create-strip-heading",children:[f==="danger"?e.jsx(_,{size:15}):t.state==="awaiting_questions"?e.jsx(A,{size:15}):S(t.state)?e.jsx(P,{className:"composer-create-spin",size:15}):e.jsx(x,{size:15}),e.jsx("span",{children:z(t)}),e.jsx("small",{children:t.target.kind})]}),t.state==="awaiting_questions"&&g?e.jsxs("div",{className:"composer-create-question",children:[e.jsx("p",{children:g.prompt}),e.jsx("div",{className:"composer-create-options",children:g.options.map(p=>e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d(`answer:${p.id}`,()=>s.onAnswerQuestion?s.onAnswerQuestion(c,g.id,p.value):Promise.resolve())},children:[e.jsx("span",{children:n===`answer:${p.id}`?"Saving":p.label}),p.description?e.jsx("small",{children:p.description}):null]},p.id))})]}):t.state==="awaiting_plan_approval"&&h?e.jsxs("div",{className:"composer-create-plan-summary",children:[e.jsx("p",{children:h.summary}),e.jsx(m,{run:t}),a?e.jsxs("div",{className:"composer-create-revision",children:[e.jsx("textarea",{rows:2,value:o,placeholder:"Describe the plan revision",onChange:p=>l(p.currentTarget.value)}),e.jsxs("div",{children:[e.jsxs("button",{type:"button",disabled:!o.trim()||!!n,onClick:()=>{d("revise",()=>s.onRevise?s.onRevise(c,o):Promise.resolve())},children:[e.jsx(x,{size:13}),e.jsx("span",{children:n==="revise"?"Saving":"Save revision"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>i(!1),children:[e.jsx(j,{size:13}),e.jsx("span",{children:"Close"})]})]})]}):e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("approve",()=>s.onApprove?s.onApprove(c):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:n==="approve"?"Confirming":"Confirm plan"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>i(!0),children:[e.jsx(x,{size:13}),e.jsx("span",{children:"Edit plan"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("cancel",()=>s.onCancel?s.onCancel(c):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="cancel"?"Cancelling":"Cancel"})]})]})]}):t.state==="paused"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:"This work is paused. Resume it when you are ready to continue."}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:n==="resume"?"Resuming":"Resume"})]})]}):t.state==="awaiting_promotion"&&r?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:T(t,r.id)}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n||!$(t,r.id),onClick:()=>{d("apply-candidate",()=>s.onApplyCandidate?s.onApplyCandidate(c,r.id):Promise.resolve())},children:[e.jsx(y,{size:13}),e.jsx("span",{children:n==="apply-candidate"?"Applying":"Apply update"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="reject-candidate"?"Keeping current version":"Keep current version"})]})]})]}):t.state==="pull_request_open"&&r&&R?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:t.target.kind==="agent"?"An Agent update review is open. Finish or close it, then refresh its status.":"An external review is open. Merge or close it, then refresh its status."}),e.jsxs("div",{className:"composer-create-actions",children:[e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:n==="reconcile-pr"?"Checking":"Refresh review"})]}),e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reject-candidate",()=>s.onRejectCandidate?s.onRejectCandidate(c,r.id):Promise.resolve())},children:[e.jsx(j,{size:13}),e.jsx("span",{children:n==="reject-candidate"?"Closing":"Close review"})]})]})]}):t.state==="blocked"||t.state==="failed"||t.state==="cancelled"?e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:t.blockedReason??"This work stopped before it was ready."}),t.state==="blocked"&&r?.git?.worktreePath&&["draft","checking"].includes(r.status)?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("resume",()=>s.onResume?s.onResume(c):Promise.resolve())},children:[e.jsx(C,{size:13}),e.jsx("span",{children:n==="resume"?"Continuing":"Continue update"})]}):t.state==="blocked"&&r?.git?.pullRequest?.state==="merged"?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("reconcile-pr",()=>s.onReconcilePullRequest?s.onReconcilePullRequest(c,r.id):Promise.resolve())},children:[e.jsx(k,{size:13}),e.jsx("span",{children:n==="reconcile-pr"?"Checking":"Re-run verification"})]}):null]}):t.state==="released"||t.state==="rejected"||t.state==="ready_local"||t.state==="ready"||t.state==="published_hosted"?e.jsxs("div",{className:"composer-create-status-body composer-create-status-body-reveals",children:[e.jsx("p",{children:t.state==="released"?"The Agent update is saved and its Evals passed.":t.state==="rejected"?"The Agent update was not applied.":t.state==="published_hosted"?"Published to the hosted Profile.":"The Agent and its actions are ready to use."}),e.jsx("div",{className:"composer-create-hover-details",children:e.jsx(m,{run:t})})]}):e.jsxs("div",{className:"composer-create-status-body",children:[e.jsx("p",{children:B(t)}),e.jsx(m,{run:t}),t.executionPolicy.pauseAllowed&&s.onPause?e.jsxs("button",{type:"button",disabled:!!n,onClick:()=>{d("pause",()=>s.onPause?.(c)??Promise.resolve())},children:[e.jsx(q,{size:13}),e.jsx("span",{children:n==="pause"?"Pausing":"Pause"})]}):null]})]})}function N(s){return s.questions.find(a=>a.status==="pending"&&a.required)??s.questions.find(a=>a.status==="pending")??null}function m({run:s}){const a=s.plan,i=s.target.kind==="agent",o=i?null:s.sourceRefs[0]??a?.sourcePlan[0]?.path??null,l=s.checkRefs.length||a?.checks.length||0,n=i?0:a?.requirements.length??0,u=i?[]:[...s.sourceRefs,...s.checkRefs].slice(0,4),t=w(a?.metadata);return!o&&l===0&&n===0&&u.length===0&&!t?null:e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"composer-create-facts",children:[t?e.jsx("span",{title:t.detail,children:t.label}):null,o?e.jsx("span",{title:o,children:o}):null,l?e.jsx("span",{children:i?`${l} Evals`:s.checkRefs.length?`${s.checkRefs.length} check refs`:`${l} checks`}):null,n?e.jsxs("span",{children:[n," setup rows"]}):null]}),u.length?e.jsx("ul",{className:"composer-create-refs","aria-label":"Source and check refs",children:u.map(h=>e.jsx("li",{children:e.jsx("code",{title:h,children:h})},h))}):null]})}function z(s){const a=s.target.kind==="agent";return s.state==="awaiting_questions"?"Question":s.state==="awaiting_plan_approval"?"Plan":s.state==="applying_source"?a?"Saving Agent":"Applying source":s.state==="running_checks"?"Running Evals":s.state==="evaluating"?a?"Checking Agent":"Evaluating":s.state==="awaiting_promotion"?a?"Update ready":"Candidate ready":s.state==="opening_pull_request"?"Opening review":s.state==="pull_request_open"?"Review open":s.state==="reconciling_release"?a?"Applying update":"Merging change":s.state==="released"?a?"Agent updated":"Released":s.state==="rejected"?a?"Current Agent kept":"Rejected":s.state==="paused"?"Paused":s.state==="ready"||s.state==="ready_local"?"Ready":s.state==="published_hosted"?"Published":s.state==="cancelled"?"Cancelled":s.state==="blocked"?"Blocked":s.state==="failed"?"Failed":s.operation==="improve"?"Improve":"Create"}function B(s){const a=s.state,i=s.target.kind==="agent";return a==="applying_source"?i?"Saving the approved Agent plan.":"Applying the approved source changes.":a==="running_checks"?i?"Running Evals against the Agent.":"Running checks against the candidate.":a==="evaluating"?i?"Checking the Agent's behavior.":"Evaluating the candidate against its Evals.":a==="opening_pull_request"?i?"Preparing the Agent update review.":"Opening the candidate review.":a==="reconciling_release"?"Applying the change and verifying the active Profile.":a==="pushing_hosted"?"Pushing the Profile source.":a==="running_hosted_checks"?i?"Running hosted Evals.":"Running hosted checks.":"Preparing the work."}function E(s){return["released","ready","ready_local","published_hosted"].includes(s)?"success":["rejected","blocked","failed","cancelled"].includes(s)?"danger":["awaiting_questions","awaiting_plan_approval","awaiting_promotion","pull_request_open","paused"].includes(s)?"warning":"info"}function S(s){return["planning","applying_source","running_checks","evaluating","opening_pull_request","reconciling_release","pushing_hosted","running_hosted_checks"].includes(s)}function I(s){return[...s.candidates].reverse().find(a=>a.target.kind==="agent")??null}function $(s,a){const i=s.evaluationReceipts.filter(o=>o.candidateId===a&&o.subject==="candidate");return i.length>0&&i.every(o=>o.status==="passed"&&o.publishGate!=="failed")}function T(s,a){const i=s.evaluationReceipts.find(n=>n.candidateId===a&&n.subject==="active"),o=s.evaluationReceipts.find(n=>n.candidateId===a&&n.subject==="candidate"),l=n=>n?.summaryCounts?`${n.summaryCounts.passed}/${n.summaryCounts.total}`:n?.status??"not run";return s.target.kind==="agent"?`Current Agent: ${l(i)} Evals passed. Updated Agent: ${l(o)} Evals passed.`:`Base Evals: ${l(i)} passed. Candidate Evals: ${l(o)} passed.`}export{U as ComposerCreateImproveStrip};
@@ -0,0 +1 @@
1
+ import{r as x,j as t}from"./index-KwyAyscP.js";import{P as k}from"./play-p3-AMTPL.js";import{a$ as ae,A as se,X as ne,bG as I,bH as ie,bI as re,bJ as oe,bK as de,p as D,bL as le,bM as ce,bN as ue}from"./App-DxecRQUL.js";import{A as pe}from"./AppDialog-B65Eo3gp.js";import{a as fe}from"./chat-file-links-B3jDstSC.js";function ge({badge:e,onPlay:a,titleElement:i="h3",video:s}){const[d,n]=x.useState(!1),r=x.useRef(null),u=i,l=`${s.id}-title`;function p(){if(a){a();return}ae.flushSync(()=>n(!0));const c=r.current;c&&(c.load(),c.play().catch(()=>{}))}return t.jsxs(t.Fragment,{children:[t.jsxs("article",{className:"get-started-course-card","aria-labelledby":l,children:[t.jsx("button",{"aria-haspopup":"dialog","aria-label":`Play ${s.title}`,className:"get-started-course-open",onClick:p,type:"button"}),t.jsxs("div",{className:"get-started-course-media",children:[t.jsx("img",{alt:"",className:"get-started-course-poster",decoding:"async",src:s.posterUrl}),t.jsx("span",{className:"get-started-course-play-icon","aria-hidden":"true",children:t.jsx(k,{fill:"currentColor",size:19})}),e?t.jsx("span",{className:"get-started-course-badge","aria-hidden":"true",children:e}):null]}),t.jsxs("div",{className:"get-started-course-copy",children:[t.jsx(u,{id:l,children:s.title}),t.jsxs("div",{className:"get-started-course-meta","aria-label":`${s.title} details`,children:[t.jsx("span",{children:s.eyebrow}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:s.duration})]}),s.description?t.jsx("p",{children:s.description}):null]})]}),d&&!a?t.jsx(L,{onClose:()=>n(!1),video:s,videoRef:r}):null]})}function L({autoAdvance:e=!1,contained:a=!1,inertExclusionSelector:i,navigation:s,onEnded:d,onClose:n,onPause:r,onTimeUpdate:u,video:l,videoRef:p}){return t.jsxs(pe,{ariaLabel:`${l.title} player`,backdropClassName:"get-started-course-player-backdrop",className:"get-started-course-player",contained:a,inertExclusionSelector:i,onClose:n,children:[t.jsxs("header",{className:"get-started-course-player-header",children:[t.jsxs("div",{className:"get-started-course-player-copy",children:[t.jsx("strong",{children:l.title}),t.jsxs("span",{children:[s?`Lesson ${s.currentIndex+1} of ${s.total}`:l.eyebrow," · ",l.duration]})]}),t.jsxs("div",{className:"get-started-course-player-actions",children:[s?t.jsxs(t.Fragment,{children:[t.jsx("button",{"aria-label":"Previous lesson",disabled:!s.onPrevious,onClick:s.onPrevious,title:"Previous lesson",type:"button",children:t.jsx(se,{size:17})}),t.jsx("button",{"aria-label":"Next lesson",disabled:!s.onNext,onClick:s.onNext,title:"Next lesson",type:"button",children:t.jsx(fe,{size:17})})]}):null,t.jsx("button",{"aria-label":"Close video player","data-autofocus":!0,onClick:n,title:"Close",type:"button",children:t.jsx(ne,{size:18})})]})]}),t.jsx("div",{className:"get-started-course-player-body",children:t.jsx("div",{className:"get-started-course-player-media",children:t.jsx("div",{className:"get-started-course-player-stage",children:t.jsx("video",{"aria-label":`${l.title} video`,className:"get-started-course-player-video",controls:!0,"data-auto-advance":e?"true":void 0,onEnded:c=>d?.(c.currentTarget),onPause:c=>r?.(c.currentTarget),onTimeUpdate:c=>u?.(c.currentTarget),playsInline:!0,poster:l.posterUrl,preload:"metadata",ref:p,src:l.videoUrl,children:l.captionsUrl?t.jsx("track",{kind:"captions",label:"English",src:l.captionsUrl,srcLang:"en"}):null},l.id)})})})]})}const me=[{id:"post-training-from-first-principles",fullVideoId:"post-training-full-course",status:"draft",title:"Post-training from first principles",videoIds:["post-training-01-how-post-training-works","post-training-02-definitions","post-training-03-on-policy-off-policy","post-training-04-rewards-credit-assignment","post-training-05-verifiable-rewards-rlvr","post-training-06-ppo-grpo","post-training-07-distillation","post-training-08-opsd-sdft-sdpo","post-training-09-credible-experiments","post-training-10-technical-appendix"]},{id:"how-to-make-an-agent",status:"published",title:"Agents",playAllVideoId:"make-agent-tutorial",videoIds:["make-agent-tutorial-create","make-agent-tutorial-use","make-agent-tutorial-improve"]}],be=[{id:"post-training-01-how-post-training-works",localPath:"courses/post-training/01-how-post-training-works.mp4",objectKey:"media/videos/aeb54dfb42eb940672df6e41bae075ffa5e45e1609e173a91e485c808b61fd4a.mp4",sha256:"aeb54dfb42eb940672df6e41bae075ffa5e45e1609e173a91e485c808b61fd4a",sizeBytes:2114638,durationSeconds:64.967},{id:"post-training-02-definitions",localPath:"courses/post-training/02-definitions.mp4",objectKey:"media/videos/c57d021989cdf058c683b9d017eb91bd23075e6bd00d0cc055e1285b3ea119fc.mp4",sha256:"c57d021989cdf058c683b9d017eb91bd23075e6bd00d0cc055e1285b3ea119fc",sizeBytes:11956956,durationSeconds:374.367},{id:"post-training-03-on-policy-off-policy",localPath:"courses/post-training/03-on-policy-off-policy.mp4",objectKey:"media/videos/a807bd7d704f8603addc875623a3cfcc938e60e0170d555d47569394a1c31762.mp4",sha256:"a807bd7d704f8603addc875623a3cfcc938e60e0170d555d47569394a1c31762",sizeBytes:2291518,durationSeconds:66.367},{id:"post-training-04-rewards-credit-assignment",localPath:"courses/post-training/04-rewards-credit-assignment.mp4",objectKey:"media/videos/685f7ecff7fcea262dd2cf60568079633816e9116efd80c069d0e20a4959a87f.mp4",sha256:"685f7ecff7fcea262dd2cf60568079633816e9116efd80c069d0e20a4959a87f",sizeBytes:5677418,durationSeconds:179.834},{id:"post-training-05-verifiable-rewards-rlvr",localPath:"courses/post-training/05-verifiable-rewards-rlvr.mp4",objectKey:"media/videos/0633584b2036843edd1ff9c63f0858db4272ddf55b10b160ec2ef6f7650c7d3a.mp4",sha256:"0633584b2036843edd1ff9c63f0858db4272ddf55b10b160ec2ef6f7650c7d3a",sizeBytes:5666892,durationSeconds:172.534},{id:"post-training-06-ppo-grpo",localPath:"courses/post-training/06-ppo-grpo.mp4",objectKey:"media/videos/66760fec7508c413844adb06c3f3920c5f7e3a874b18dc244ba090c55f452ff3.mp4",sha256:"66760fec7508c413844adb06c3f3920c5f7e3a874b18dc244ba090c55f452ff3",sizeBytes:5519257,durationSeconds:173.6},{id:"post-training-07-distillation",localPath:"courses/post-training/07-distillation.mp4",objectKey:"media/videos/3590f94325c1986f2025b42d182f04957e9eff6d5c06b1effc28dc369651c466.mp4",sha256:"3590f94325c1986f2025b42d182f04957e9eff6d5c06b1effc28dc369651c466",sizeBytes:4687640,durationSeconds:161.667},{id:"post-training-08-opsd-sdft-sdpo",localPath:"courses/post-training/08-opsd-sdft-sdpo.mp4",objectKey:"media/videos/3c45d8c1df0a24132ec425762dc6a4274b1e5cac6dfd220a2994f8754f431031.mp4",sha256:"3c45d8c1df0a24132ec425762dc6a4274b1e5cac6dfd220a2994f8754f431031",sizeBytes:5439835,durationSeconds:163.134},{id:"post-training-09-credible-experiments",localPath:"courses/post-training/09-credible-experiments.mp4",objectKey:"media/videos/fc701a8ba4b42de53bcaec3dcf191e6ec66f1dc0c48480f0aff01c3849aff023.mp4",sha256:"fc701a8ba4b42de53bcaec3dcf191e6ec66f1dc0c48480f0aff01c3849aff023",sizeBytes:6909405,durationSeconds:211.934},{id:"post-training-10-technical-appendix",localPath:"courses/post-training/10-technical-appendix.mp4",objectKey:"media/videos/17e6b5ef161fcdc97678e5b63650bffdb4b4b0d510ba75725a2af8a5db0d7e21.mp4",sha256:"17e6b5ef161fcdc97678e5b63650bffdb4b4b0d510ba75725a2af8a5db0d7e21",sizeBytes:5481950,durationSeconds:191.767},{id:"post-training-full-course",localPath:"courses/post-training/full-course.mp4",objectKey:"media/videos/d3df6a3b2ffe6c696b9dc0774ceaec19a2b8a92b170476cacb9df8dbdb2a526f.mp4",sha256:"d3df6a3b2ffe6c696b9dc0774ceaec19a2b8a92b170476cacb9df8dbdb2a526f",sizeBytes:55740426,durationSeconds:1760.192},{id:"openpond-agent-overview",localPath:"tutorials/what-is-an-openpond-agent.mp4",objectKey:"media/videos/421160f56d82abd6515df0d5ccf144591749e0ab1d58d630805c4807913812c7.mp4",sha256:"421160f56d82abd6515df0d5ccf144591749e0ab1d58d630805c4807913812c7",sizeBytes:5259848,durationSeconds:77.467},{id:"make-agent-tutorial",localPath:"tutorials/how-to-make-an-agent.mp4",objectKey:"media/videos/252d2f27076c904d85c9854c2f4c494fe9e92b3cea7d2c58ffbaa0323c17f255.mp4",sha256:"252d2f27076c904d85c9854c2f4c494fe9e92b3cea7d2c58ffbaa0323c17f255",sizeBytes:17339101,durationSeconds:273.067},{id:"make-agent-tutorial-create",localPath:"tutorials/how-to-make-an-agent-create.mp4",objectKey:"media/videos/322c999225d4759c34334eee22edee25a737fb06c5c6d66ee1f84485bb586c44.mp4",sha256:"322c999225d4759c34334eee22edee25a737fb06c5c6d66ee1f84485bb586c44",sizeBytes:6050301,durationSeconds:100.4},{id:"make-agent-tutorial-use",localPath:"tutorials/how-to-make-an-agent-use.mp4",objectKey:"media/videos/6e28bb710f90de8968fa18f996973b869e6748797739dd93cce49d8fbba564c1.mp4",sha256:"6e28bb710f90de8968fa18f996973b869e6748797739dd93cce49d8fbba564c1",sizeBytes:5084394,durationSeconds:75.1},{id:"make-agent-tutorial-improve",localPath:"tutorials/how-to-make-an-agent-improve.mp4",objectKey:"media/videos/fe8b62bf6ed5f5b933b0023dfdd9a06e69b5b352d4c702b671ec7677b395d58d.mp4",sha256:"fe8b62bf6ed5f5b933b0023dfdd9a06e69b5b352d4c702b671ec7677b395d58d",sizeBytes:6255324,durationSeconds:108.634}],he={playlists:me,videos:be},ye="https://media.openpond.ai",K=he,Te=new Map(K.playlists.map(e=>[e.id,e])),xe=new Map(K.videos.map(e=>[e.id,e]));function $(e){const a=Te.get(e);if(!a)throw new Error(`Public video manifest is missing playlist ${e}`);return a}function Ae(e,a){return a?`${ye}/${e.objectKey}`:I(e.localPath)}function E(e){const a=xe.get(e);if(!a)throw new Error(`Public video manifest is missing ${e}`);return Ae(a,!0)}const ve=E("make-agent-tutorial"),Pe=E("openpond-agent-overview");function je(e){return E(`make-agent-tutorial-${e}`)}const Ne={title:"How to make an agent"},Ie=[{id:"create",label:"Create",title:"Create an Agent",subtitle:"Turn a plain-language purpose into a working Account Health Agent.",outroTitle:"Account Health Agent created",outroSubtitle:"The agent is ready to use. · AI-generated narration",cardDuration:1.5},{id:"use",label:"Use",title:"Use the Agent",subtitle:"Chat with the Account Health Agent and run its actions with approval.",outroTitle:"First agent run complete",outroSubtitle:"The result and supporting evidence are ready to review. · AI-generated narration",cardDuration:1.5},{id:"improve",label:"Improve",title:"Improve the Agent",subtitle:"Use real run evidence and Evals to make the Account Health Agent better.",outroTitle:"Account Health Agent improved",outroSubtitle:"The updated agent passed its Evals. · AI-generated narration",cardDuration:1.5}],z={tutorial:Ne,chapters:Ie},Ee=$("how-to-make-an-agent"),B=z.chapters,Se={create:"1:24",use:"1:05",improve:"1:10"},w=Ee.title,we=z.tutorial.title,F="4:33",H={captionsUrl:re,chapterIds:B.map(e=>e.id),description:"Create, use, and improve an Account Health Agent in one continuous walkthrough.",duration:F,eyebrow:"Play all",id:"make-agent-tutorial",lessonNumber:null,posterUrl:ie,title:we,videoId:"play-all",videoUrl:ve},T=B.map((e,a)=>({captionsUrl:de(e.id),chapterIds:[e.id],description:e.subtitle,duration:Se[e.id],eyebrow:`Lesson ${a+1}`,id:`make-agent-tutorial-${e.id}`,lessonNumber:a+1,posterUrl:oe(e.id),title:e.title,videoId:e.id,videoUrl:je(e.id)})),Re=[H,...T];function W(e){return Re.find(a=>a.videoId===e)??H}function _e(e){const a=T.findIndex(i=>i.videoId===e);return a<0?null:T[a+1]?.videoId??null}const Oe=[2,1,0];function ke({activeVideoId:e="play-all",autoplay:a=!0,onClose:i,onOpen:s,onSelectVideo:d,open:n=!1,playRequestId:r=0}={}){const u=x.useRef(null),l=W(e);x.useEffect(()=>{if(!n)return;const c=u.current;c&&(c.load(),r>0&&c.play().catch(()=>{}))},[l.id,n,r]);function p(){if(!a||!d)return;const c=_e(e);c&&d(c)}return t.jsxs("section",{className:"get-started-series","aria-label":w,children:[t.jsxs("article",{className:"get-started-playlist-card","aria-labelledby":"make-agent-series-title",children:[t.jsx("button",{"aria-haspopup":"dialog","aria-label":`Open ${w} playlist`,className:"get-started-playlist-open",onClick:s,type:"button"}),t.jsxs("div",{className:"get-started-playlist-stack","aria-hidden":"true",children:[Oe.map((c,f)=>{const m=T[c];return t.jsx("div",{className:`get-started-playlist-poster layer-${f+1}`,children:t.jsx("img",{alt:"",decoding:"async",src:m.posterUrl})},m.id)}),t.jsx("span",{className:"get-started-course-play-icon",children:t.jsx(k,{fill:"currentColor",size:19})}),t.jsxs("span",{className:"get-started-playlist-count",children:[T.length," lessons"]})]}),t.jsxs("div",{className:"get-started-playlist-copy",children:[t.jsx("h1",{id:"make-agent-series-title",children:w}),t.jsxs("div",{className:"get-started-course-meta",children:[t.jsx("span",{children:"Walkthrough playlist"}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:F})]}),t.jsx("p",{children:"Create, use, and improve an Account Health Agent, or play the full walkthrough."})]})]}),n&&i&&d?t.jsx(Le,{activeVideoId:e,autoplay:a,contained:!0,inertExclusionSelector:".get-started-learning-panel",onClose:i,onEnded:p,onSelectVideo:d,videoRef:u}):null]})}function Le({activeVideoId:e="play-all",autoplay:a=!0,contained:i=!1,inertExclusionSelector:s,onClose:d,onEnded:n,onSelectVideo:r=()=>{},videoRef:u}){const l=W(e),p=T.findIndex(m=>m.videoId===e),c=p>=0?T[p+1]?.videoId:void 0,f=p>0?T[p-1]?.videoId:void 0;return t.jsx(L,{autoAdvance:a&&p>=0,contained:i,inertExclusionSelector:s,navigation:p>=0?{currentIndex:p,onNext:c?()=>r(c):void 0,onPrevious:f?()=>r(f):void 0,total:T.length}:void 0,onClose:d,onEnded:n?()=>n():void 0,video:l,videoRef:u})}const U=$("post-training-from-first-principles"),q=U.title,Ue=U.status;function h(e,a,i,s,d,n){const r=`courses/post-training/${a}`,u=`post-training-${a}`;return{captionsUrl:I(`${r}.vtt`),description:n,duration:d,eyebrow:s,id:u,lessonNumber:e,posterUrl:I(`${r}-poster.webp`),slug:a,title:i,videoUrl:E(u)}}const A=[h(1,"01-how-post-training-works","How post-training works","Start here","1:05","The choose, judge, and update loop behind every method in this series."),h(2,"02-definitions","Definitions","Reference","6:14","Policy notation, softmax, rollouts, advantages, gradients, GRPO, and the acronyms used throughout the series."),h(3,"03-on-policy-off-policy","On-policy and off-policy data","Data source","1:06","Why learner rollouts and teacher or stored data support different updates."),h(4,"04-rewards-credit-assignment","Rewards and credit assignment","RL foundation","3:00","Follow a code-repair trajectory from actions and observations to advantage."),h(5,"05-verifiable-rewards-rlvr","Verifiable rewards","RLVR","2:53","See how tests create scalable rewards—and how a model can exploit the checker."),h(6,"06-ppo-grpo","PPO and GRPO","Policy updates","2:54","Compare PPO's learned critic with GRPO's sibling-response baseline."),h(7,"07-distillation","Distillation","Teacher targets","2:42","Transfer a teacher's token distribution instead of copying one final answer."),h(8,"08-opsd-sdft-sdpo","OPSD, SDFT, and SDPO","Teacher evidence","2:43","Compare trusted solutions, demonstrations, and failure feedback at one prefix."),h(9,"09-credible-experiments","Credible experiments","Research design","3:32","Build versioned datasets, fair baselines, and claims that survive scrutiny."),h(10,"10-technical-appendix","Technical appendix","Advanced details","3:12","Inspect GRPO normalization, compressed teacher logits, reported method results, and sample routing.")],Ce="29 min",O=U.fullVideoId;if(!O)throw new Error("Post-training playlist is missing its full video");const Y={captionsUrl:I("courses/post-training/full-course.vtt"),description:"All ten lessons in one continuous video for watching, sharing, or uploading.",duration:"29:20",eyebrow:"Full course",id:O,posterUrl:I("courses/post-training/full-course-poster.webp"),title:q,videoUrl:E(O)};function J(e){const a=e+1;return a<A.length?a:null}const M="Subject to change, lesson work in progress";function Me(){const e=Ue==="draft"?"Draft":"Published";return t.jsx("span",{"aria-label":`${e}: ${M}`,className:"get-started-playlist-status app-tooltip","data-tooltip":M,tabIndex:0,children:e})}const X="openpond.post-training-progress.v1",j=Object.freeze({}),Ge=1e3,Q=new Set;let P=null,N=null,G=!1;function R(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Ve(e){if(!e||typeof e!="object"||Array.isArray(e))return j;const a={};for(const[i,s]of Object.entries(e)){if(!i||!s||typeof s!="object"||Array.isArray(s))continue;const d=s,n=R(d.duration),r=R(d.currentTime),u=R(d.updatedAt);if(n===null||n<=0||r===null)continue;const l=d.completed===!0;a[i]={completed:l,currentTime:l?n:Math.min(n,Math.max(0,r)),duration:n,updatedAt:u===null?0:Math.max(0,u)}}return Object.keys(a).length>0?a:j}function De(e){if(!e)return j;try{return Ve(JSON.parse(e))}catch{return j}}function Z(){if(typeof window>"u")return j;try{return De(D.getItem(X))}catch{return j}}function ee(){if(typeof window<"u"&&N!==null&&window.clearTimeout(N),N=null,!(typeof window>"u"||P===null))try{D.setItem(X,JSON.stringify(P))}catch{}}function Ke(){typeof window>"u"||N!==null||(N=window.setTimeout(ee,Ge))}function $e(){typeof window>"u"||G||(G=!0,window.addEventListener("pagehide",ee),le(()=>{P=Z(),Q.forEach(e=>e())}))}function te(){return P===null&&(P=Z()),$e(),P}function V({completed:e=!1,currentTime:a,duration:i,lessonId:s}){if(!s||!Number.isFinite(i)||i<=0||!Number.isFinite(a))return;const d=te(),n=d[s],r=!!(n?.completed||e),u=r?i:Math.min(i,Math.max(0,a));n&&n.completed===r&&Math.abs(n.currentTime-u)<.25&&Math.abs(n.duration-i)<.25||(P={...d,[s]:{completed:r,currentTime:u,duration:i,updatedAt:Date.now()}},Ke(),Q.forEach(l=>l()))}function ze(e){return!e||e.completed||e.currentTime<1?0:e.currentTime<e.duration-2?e.currentTime:0}const _=q,Be=[2,1,0];function Fe({activeLessonIndex:e,fullCourseSelected:a=!1,autoplay:i=!0,open:s,onClose:d,onOpen:n,onSelectLesson:r,playRequestId:u=0}){const l=x.useRef(null),p=x.useRef(null),c=A[e]??A[0],f=a?Y:c;x.useEffect(()=>{if(!s)return;const o=l.current;if(!o)return;let b=!1;p.current=null,o.load();const y=()=>{if(b)return;const C=ze(te()[f.id]);C>0&&(o.currentTime=C),u>0&&o.play().catch(()=>{})};return o.readyState>=HTMLMediaElement.HAVE_METADATA?y():o.addEventListener("loadedmetadata",y,{once:!0}),()=>{b=!0,o.removeEventListener("loadedmetadata",y),Number.isFinite(o.duration)&&o.duration>0&&o.currentTime>0&&V({completed:o.ended,currentTime:o.currentTime,duration:o.duration,lessonId:f.id})}},[f.id,s,u]);function m(o,b=!1){!Number.isFinite(o.duration)||o.duration<=0||V({completed:b,currentTime:b?o.duration:o.currentTime,duration:o.duration,lessonId:f.id})}function S(o){if(!Number.isFinite(o.duration)||o.duration<=0)return;const b=Math.min(99,Math.floor(o.currentTime/o.duration*100)),y=p.current;y?.lessonId===f.id&&y.percent===b||(p.current={lessonId:f.id,percent:b},m(o))}function v(o){m(o,!0),i&&!a&&g()}function g(){const o=J(e);o!==null&&r(o)}return t.jsxs("section",{className:"get-started-series","aria-label":_,children:[t.jsxs("article",{className:"get-started-playlist-card","aria-labelledby":"post-training-series-title",children:[t.jsx("button",{"aria-haspopup":"dialog","aria-label":`Open ${_} playlist`,className:"get-started-playlist-open",onClick:n,type:"button"}),t.jsxs("div",{className:"get-started-playlist-stack","aria-hidden":"true",children:[Be.map((o,b)=>{const y=A[o];return t.jsx("div",{className:`get-started-playlist-poster layer-${b+1}`,children:t.jsx("img",{alt:"",decoding:"async",src:y.posterUrl})},y.id)}),t.jsx("span",{className:"get-started-course-play-icon",children:t.jsx(k,{fill:"currentColor",size:19})}),t.jsxs("span",{className:"get-started-playlist-count",children:[A.length," lessons"]})]}),t.jsxs("div",{className:"get-started-playlist-copy",children:[t.jsxs("div",{className:"get-started-playlist-title",children:[t.jsx("h1",{id:"post-training-series-title",children:_}),t.jsx(Me,{})]}),t.jsxs("div",{className:"get-started-course-meta",children:[t.jsx("span",{children:"Learning series"}),t.jsx("span",{"aria-hidden":"true",children:"·"}),t.jsx("span",{children:Ce})]}),t.jsx("p",{children:"Rewards, GRPO, RLVR, distillation, experiments, and a technical appendix."})]})]}),s?t.jsx(He,{activeLessonIndex:e,autoplay:i,fullCourseSelected:a,onClose:d,onEnded:v,onPause:m,onSelectLesson:r,onTimeUpdate:S,videoRef:l}):null]})}function He({activeLessonIndex:e,autoplay:a,fullCourseSelected:i,onClose:s,onEnded:d,onPause:n,onSelectLesson:r,onTimeUpdate:u,videoRef:l}){const p=A[e]??A[0],c=J(e),f=i?Y:p;return t.jsx(L,{autoAdvance:a&&!i,contained:!0,inertExclusionSelector:".get-started-learning-panel",navigation:i?void 0:{currentIndex:e,onNext:c!==null?()=>r(c):void 0,onPrevious:e>0?()=>r(e-1):void 0,total:A.length},onClose:s,onEnded:d,onPause:n,onTimeUpdate:u,video:f,videoRef:l})}const We={captionsUrl:ue,description:"See how Profile Agents combine chat, direct actions, shared runtime surfaces, and Evals.",duration:"1:16",eyebrow:"Agent overview",id:"openpond-agent-overview",posterUrl:ce,title:"What is an OpenPond Agent?",videoUrl:Pe};function Ze(e={}){const[a,i]=x.useState(null),[s,d]=x.useState(null),n=e.makeAgentTutorial===void 0?a:e.makeAgentTutorial,r=e.postTrainingCourse===void 0?s:e.postTrainingCourse,u=!!(r||n);function l(){if(e.onOpenMakeAgentTutorial){e.onOpenMakeAgentTutorial();return}d(null),i({autoplay:!0,playRequestId:0,videoId:"create"})}function p(){if(e.onCloseMakeAgentTutorial){e.onCloseMakeAgentTutorial();return}i(null)}function c(v){if(e.onSelectMakeAgentTutorialVideo){e.onSelectMakeAgentTutorialVideo(v);return}i(g=>g&&{...g,playRequestId:g.playRequestId+1,videoId:v})}function f(){if(e.onOpenPostTrainingCourse){e.onOpenPostTrainingCourse();return}i(null),d({autoplay:!0,fullCourseSelected:!1,lessonIndex:0,playRequestId:0})}function m(){if(e.onClosePostTrainingCourse){e.onClosePostTrainingCourse();return}d(null)}function S(v){if(e.onSelectPostTrainingLesson){e.onSelectPostTrainingLesson(v);return}d(g=>g&&{...g,fullCourseSelected:!1,lessonIndex:v,playRequestId:g.playRequestId+1})}return t.jsx("section",{className:`get-started-view ${u?"course-player-open":""}`,"aria-label":"Walkthroughs",children:t.jsxs("div",{className:"get-started-shell",children:[t.jsxs("section",{className:"get-started-start-here","aria-labelledby":"get-started-start-here-title",children:[t.jsx("header",{className:"get-started-section-heading",children:t.jsx("h2",{id:"get-started-start-here-title",children:"Start here"})}),t.jsx("div",{className:"get-started-learning-grid",children:t.jsx(ge,{titleElement:"h1",video:We})})]}),t.jsxs("section",{className:"get-started-walkthroughs","aria-labelledby":"get-started-walkthroughs-title",children:[t.jsx("header",{className:"get-started-section-heading",children:t.jsx("h2",{id:"get-started-walkthroughs-title",children:"Walkthroughs"})}),t.jsx("div",{className:"get-started-learning-grid",children:t.jsx(ke,{activeVideoId:n?.videoId??"create",autoplay:n?.autoplay??!0,onClose:p,onOpen:l,onSelectVideo:c,open:!!n,playRequestId:n?.playRequestId??0})})]}),t.jsxs("section",{className:"get-started-learn","aria-labelledby":"get-started-learn-title",children:[t.jsx("header",{className:"get-started-section-heading",children:t.jsx("h2",{id:"get-started-learn-title",children:"Learn deeper"})}),t.jsx("div",{className:"get-started-learning-grid",children:t.jsx(Fe,{activeLessonIndex:r?.lessonIndex??0,autoplay:r?.autoplay??!0,fullCourseSelected:r?.fullCourseSelected??!1,open:!!r,onClose:m,onOpen:f,onSelectLesson:S,playRequestId:r?.playRequestId??0})})]})]})})}export{Ze as GetStartedView};
@@ -0,0 +1 @@
1
+ import{r as i,j as e}from"./index-KwyAyscP.js";import{p as u}from"./LabsRoute-DoRs0K6v.js";import{dY as n}from"./App-DxecRQUL.js";import"./AppDialog-B65Eo3gp.js";import"./cloud-upload-D2he0-vQ.js";import"./MainPane-BWwcxgHD.js";import"./arrow-up-right-rwPXNfVn.js";import"./chat-file-links-B3jDstSC.js";import"./square-DKQkcrOH.js";import"./training-model-data-CKOkpBBL.js";import"./refresh-cw-_jbTIzzr.js";import"./info-CcrBaEE_.js";/* empty css */import"./ComposerCreateImproveStrip-D7usvRtK.js";import"./play-p3-AMTPL.js";function H({api:o,policyId:r,sourceId:t,onBack:s}){const a=i.useMemo(()=>o.reviewClient(r,t),[o,r,t]),[p,m]=i.useState(null),[l,c]=i.useState(null);return e.jsxs("section",{"aria-label":"Hosted example review",children:[e.jsx("button",{type:"button",className:"training-button secondary",onClick:()=>{n(s)},children:"Back to continual learning"}),e.jsx("p",{children:"Reviewing hosted examples. Approved tasks become eligible for this policy's next training check."}),e.jsx(u,{client:a,selectedId:p,after:l,sourceId:t,onSelect:d=>{n(()=>m(d))},onPage:c})]})}export{H as HostedModelLearningReview};
@@ -0,0 +1 @@
1
+ import{r as s,j as t}from"./index-KwyAyscP.js";import{u as K,n as W,o as Y}from"./LabsRoute-DoRs0K6v.js";import{bS as U,cj as Z,dX as _,bT as C,cB as H,da as ee}from"./App-DxecRQUL.js";import{A as ne}from"./AppDialog-B65Eo3gp.js";import"./cloud-upload-D2he0-vQ.js";import"./MainPane-BWwcxgHD.js";import"./arrow-up-right-rwPXNfVn.js";import"./chat-file-links-B3jDstSC.js";import"./square-DKQkcrOH.js";import"./training-model-data-CKOkpBBL.js";import"./refresh-cw-_jbTIzzr.js";import"./info-CcrBaEE_.js";/* empty css */import"./ComposerCreateImproveStrip-D7usvRtK.js";import"./play-p3-AMTPL.js";function te(r,a){const n=a?.limits.maxIterationSpendUsd??r.trainingSetup.preferredMaximumSpendUsd??1;return{enabled:a?.enabled??!1,scheduled:a?.trigger.kind==="schedule",intervalSeconds:a?.trigger.kind==="schedule"?a.trigger.intervalSeconds:86400,humanReviewRequired:a?.admission.mode!=="qualified_automatic",minimumApprovedExamples:a?.admission.minimumApprovedExamples??8,maxBatchExamples:a?.limits.maxBatchExamples??8,maxIterationSpendUsd:n,maxDailySpendUsd:a?.limits.maxDailySpendUsd??n,cooldownSeconds:a?.limits.cooldownSeconds??3600,maxRetries:a?.limits.maxRetries??0,maxBacklogExamples:a?.limits.maxBacklogExamples??1e3}}function ae(r){const{project:a,previous:n,settings:i}=r;if(n&&(n.id!==r.policyId||n.modelProjectId!==a.portableProjectId||n.executionOwner!=="hosted"))throw new U("learning_policy_model_mismatch",422,"Learning settings must belong to this hosted Model.");const g=r.applyModelConfiguration||!n,o=g?ie(a):null,h=g?a.trainingSetup.recipe?.method:n?.training.method;if(i.enabled&&h!=="grpo")throw new U("learning_training_method_unsupported",422,"Hosted continual learning currently supports GRPO.");return Z.parse({schemaVersion:"openpond.learningPolicy.v1",id:r.policyId,revision:(n?.revision??0)+1,modelProjectId:a.portableProjectId,executionOwner:"hosted",enabled:i.enabled,sources:r.sources,taskDefinition:r.taskDefinition,rewardBinding:g?a.trainingSetup.rewardBindingRef:n?.rewardBinding,admission:{mode:i.humanReviewRequired?"human":"qualified_automatic",qualification:i.humanReviewRequired?null:n?.admission.qualification??null,minimumApprovedExamples:i.minimumApprovedExamples},trigger:i.scheduled?{kind:"schedule",intervalSeconds:i.intervalSeconds}:{kind:"manual"},trainingParent:o?.trainingParent??n?.trainingParent,teacher:n?.teacher??null,training:{method:h,recipe:o?.recipe??n?.training.recipe,retentionEvaluation:o?.retentionEvaluation??n?.training.retentionEvaluation,replayBatches:n?.training.replayBatches??[]},limits:{maxIterationSpendUsd:i.maxIterationSpendUsd,maxDailySpendUsd:i.maxDailySpendUsd,cooldownSeconds:i.cooldownSeconds,maxRetries:i.maxRetries,maxBatchExamples:i.maxBatchExamples,maxBacklogExamples:i.maxBacklogExamples},automation:{collect:!1,train:i.scheduled,accept:!1,serve:!1},acceptance:n?.acceptance??{minimumScore:0,maximumRetentionRegression:0,requireImprovement:!0,rollbackVersion:null}})}function ie(r){const a=r.trainingSetup,n=a.baseModel??r.defaultBaseModel;if(!a.recipe||!n||!a.evaluationTasksetRef)throw new U("learning_model_configuration_incomplete",422,"Select a training recipe, starting model and retained evaluation before enabling hosted learning.");return{recipe:{id:`model-recipe-${r.etag}`,contentHash:_(a.recipe)},trainingParent:{id:n.modelId,contentHash:_(n)},retentionEvaluation:{id:a.evaluationTasksetRef.id,contentHash:a.evaluationTasksetRef.contentHash}}}function Se({client:r,project:a,policy:n,onClose:i}){const[g]=s.useState(()=>n?.id??`policy-${crypto.randomUUID()}`),[o]=s.useState(()=>te(a,n)),[h,T]=s.useState(o.enabled),[w,O]=s.useState(o.scheduled),[E,$]=s.useState(!n),[j,F]=s.useState(o.humanReviewRequired),[c,I]=s.useState(n?.sources??[]),[x,M]=s.useState(n?.taskDefinition??null),[d,V]=s.useState({interval:String(o.intervalSeconds/60),minimum:String(o.minimumApprovedExamples),batch:String(o.maxBatchExamples),spend:String(o.maxIterationSpendUsd),daily:String(o.maxDailySpendUsd),cooldown:String(o.cooldownSeconds/60),retries:String(o.maxRetries),backlog:String(o.maxBacklogExamples)}),[G,v]=s.useState(!1),[p,N]=s.useState(!1),[Q,P]=s.useState(null),[f,X]=s.useState(),[R,z]=s.useState(null),[q,L]=s.useState(null),u=s.useRef(null),y=s.useRef(!1);s.useEffect(()=>{let e=!1;return r.sources(f).then(l=>{e||(z({after:f,data:l}),L(null))},l=>{e||L(l instanceof Error?l.message:String(l))}),()=>{e=!0}},[r,f]);const S=R&&R.after===f?R.data:null,B=E?a.trainingSetup.rewardBindingRef:n?.rewardBinding;function J(e){const l=c.some(m=>m.id===e.id);I(l?c.filter(m=>m.id!==e.id):[...c,H(e)]),M(l&&c.length===1?null:x??e.taskDefinition),v(!0)}async function A(){if(y.current)return!1;y.current=!0,N(!0),P(null);try{if(!u.current){if(!x||!c.length||!B)throw new Error("Select task sources and a Model Reward before saving.");const e=ae({project:a,previous:n,policyId:g,applyModelConfiguration:E,sources:c,taskDefinition:x,settings:{enabled:h,scheduled:w,humanReviewRequired:j,intervalSeconds:Number(d.interval)*60,minimumApprovedExamples:Number(d.minimum),maxBatchExamples:Number(d.batch),maxIterationSpendUsd:Number(d.spend),maxDailySpendUsd:Number(d.daily),cooldownSeconds:Number(d.cooldown)*60,maxRetries:Number(d.retries),maxBacklogExamples:Number(d.backlog)}});u.current={action:"publish",kind:"policy",operationId:crypto.randomUUID(),expectedRevision:n?.revision??0,content:e}}return await r.command(u.current),u.current=null,v(!1),!0}catch(e){return e instanceof ee&&e.status>=400&&e.status<500&&![408,429].includes(e.status)&&(u.current=null),P(e instanceof Error?e.message:"Unable to save learning settings."),!1}finally{y.current=!1,N(!1)}}const k=K({name:"learning settings",dirty:G,busy:p,save:A});return t.jsxs(t.Fragment,{children:[t.jsxs(ne,{ariaLabel:"Continual learning settings",className:"labs-rename-dialog learning-workspace hosted-learning-settings",backdropClassName:"labs-rename-backdrop",dismissDisabled:p,onClose:()=>{k.requestLeave(i)},children:[t.jsx("h2",{children:"Continual learning settings"}),t.jsxs("p",{children:["Train ",a.name," from approved tasks. Acceptance and serving remain separate decisions."]}),t.jsx(W,{error:Q??q}),t.jsxs("form",{onSubmit:async e=>{e.preventDefault(),await A()&&(k.allowNextNavigation(),i())},children:[t.jsxs("fieldset",{disabled:p||!!u.current,onChange:()=>v(!0),children:[t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:h,onChange:e=>T(e.target.checked)})," Enable learning"]}),t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:j,disabled:j,onChange:()=>F(!0)})," Human review required"]}),t.jsx("p",{children:"New policies require human review. Qualified automatic admission cannot be configured here yet."}),n?t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:E,onChange:e=>$(e.target.checked)})," Use the Model’s current training configuration"]}):null,t.jsxs("fieldset",{children:[t.jsx("legend",{children:"Task sources"}),!S&&!q?t.jsx("p",{children:"Loading sources…"}):null,S?.sources.items.map(e=>{const l=S.definitions.find(D=>C(H(D),e.taskDefinition)),m=!!(B&&l&&C(B,l.rewardBinding)&&(!x||C(x,e.taskDefinition))),b=c.find(D=>D.id===e.id);return t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:!!b,disabled:!b&&(!e.enabled||!m),onChange:()=>J(e)})," ",e.name,b&&b.revision!==e.revision?t.jsxs("small",{children:["Using saved revision ",b.revision,"; clear and reselect to update."]}):m?null:t.jsx("small",{children:"Different task format or Reward."})]},e.id)}),t.jsxs("p",{children:[c.length," sources selected. ",t.jsx("button",{type:"button",onClick:()=>{I([]),M(null),v(!0)},children:"Clear selection"})]}),t.jsx(Y,{after:f,next:S?.sources.nextCursor,onPage:e=>X(e??void 0)})]}),t.jsxs("label",{children:[t.jsx("input",{type:"checkbox",checked:w,onChange:e=>O(e.target.checked)})," Schedule training"]}),Object.keys(d).filter(e=>e!=="interval"||w).map(e=>t.jsxs("label",{children:[{interval:"Check interval (minutes)",minimum:"Minimum approved examples",batch:"Maximum examples per batch",spend:"Maximum spend per iteration ($)",daily:"Maximum daily spend ($)",cooldown:"Cooldown (minutes)",retries:"Automatic retries",backlog:"Maximum backlog"}[e],t.jsx("input",{type:"number",value:d[e],min:"0",step:e==="spend"||e==="daily"?"0.01":"1",onChange:l=>V(m=>({...m,[e]:l.target.value}))})]},e))]}),t.jsxs("div",{className:"model-build-actions",children:[t.jsx("button",{type:"submit",className:"training-button",disabled:p,children:p?"Saving…":u.current?"Retry save":"Save settings"}),t.jsx("button",{type:"button",className:"training-button secondary",disabled:p,onClick:()=>{k.requestLeave(i)},children:"Cancel"})]})]})]}),k.dialog]})}export{Se as HostedModelLearningSettings};
@@ -0,0 +1 @@
1
+ import{r as u,j as n}from"./index-KwyAyscP.js";import{o as X,aw as Bt,a as Vt,dp as Ut,C as Kt,d as Ve,aS as Wt}from"./App-DxecRQUL.js";import{a as Ee,i as be,aw as dt,al as ut,ax as pt,ay as qt,a1 as Ie,X as Re,W as $e,d as mt,af as Gt,az as Ht,y as Ce,ag as ht,aA as Jt,aB as Xt,E as Le,H as ft,aC as Yt,J as gt,K as vt,M as Zt,aD as Qt,L as Ue,p as en,r as xt,aE as tn,Z as bt,_ as nn,$ as an,a0 as rn,a2 as ie,a3 as yt,a4 as sn,a5 as ln,a6 as on,aF as cn,a7 as dn,ab as un,a9 as pn,aa as jt,aG as Ke,ah as mn,ai as hn,aj as fn,ak as gn,s as vn,D as xn,ap as bn,aq as yn,ar as jn,as as kn,at as Nn,au as wn,av as Cn}from"./CartesianChart-CJKfXiEG.js";import{s as Y,f as Se,c as se,b as le,g as We,d as ye}from"./training-model-data-CKOkpBBL.js";import{L as Oe,b as Me,a as Sn,l as Pn,c as Tn,d as An,e as En,m as In,f as Rn,g as $n,h as Ln,r as On,i as Mn,M as kt,j as Dn,k as zn,E as qe}from"./LabsRoute-DoRs0K6v.js";import"./AppDialog-B65Eo3gp.js";import"./cloud-upload-D2he0-vQ.js";import"./MainPane-BWwcxgHD.js";import"./arrow-up-right-rwPXNfVn.js";import"./chat-file-links-B3jDstSC.js";import"./square-DKQkcrOH.js";import"./refresh-cw-_jbTIzzr.js";import"./info-CcrBaEE_.js";/* empty css */import"./ComposerCreateImproveStrip-D7usvRtK.js";import"./play-p3-AMTPL.js";function Pe(){return Pe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},Pe.apply(null,arguments)}var Nt=e=>{var t=e.cx,a=e.cy,r=e.r,s=e.className,i=Ee("recharts-dot",s);return be(t)&&be(a)&&be(r)?u.createElement("circle",Pe({},ut(e),dt(e),{className:i,cx:t,cy:a,r})):null},Fn=["points"];function Ge(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),a.push.apply(a,r)}return a}function je(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Ge(Object(a),!0).forEach(function(r){_n(e,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Ge(Object(a)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))})}return e}function _n(e,t,a){return(t=Bn(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function Bn(e){var t=Vn(e,"string");return typeof t=="symbol"?t:t+""}function Vn(e,t){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var r=a.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function pe(){return pe=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},pe.apply(null,arguments)}function Un(e,t){if(e==null)return{};var a,r,s=Kn(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(s[a]=e[a])}return s}function Kn(e,t){if(e==null)return{};var a={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;a[r]=e[r]}return a}function Wn(e){var t=e.option,a=e.dotProps,r=e.className;if(u.isValidElement(t))return u.cloneElement(t,a);if(typeof t=="function")return t(a);var s=Ee(r,typeof t!="boolean"?t.className:""),i=a??{};i.points;var o=Un(i,Fn);return u.createElement(Nt,pe({},o,{className:s}))}function qn(e,t){return e==null?!1:t?!0:e.length===1}function Gn(e){var t=e.points,a=e.dot,r=e.className,s=e.dotClassName,i=e.dataKey,o=e.baseProps,l=e.needClip,d=e.clipPathId,c=e.zIndex,h=c===void 0?Re.scatter:c;if(!qn(t,a))return null;var p=pt(a),m=qt(a),f=t.map((k,N)=>{var j,x,w=je(je(je({r:3},o),m),{},{index:N,cx:(j=k.x)!==null&&j!==void 0?j:void 0,cy:(x=k.y)!==null&&x!==void 0?x:void 0,dataKey:i,value:k.value,payload:k.payload,points:t});return u.createElement(Wn,{key:"dot-".concat(N),option:a,dotProps:w,className:s})}),y={};return l&&d!=null&&(y.clipPath="url(#clipPath-".concat(p?"":"dots-").concat(d,")")),u.createElement(Ie,{zIndex:h},u.createElement($e,pe({className:r},y),f))}function He(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),a.push.apply(a,r)}return a}function ke(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?He(Object(a),!0).forEach(function(r){Hn(e,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):He(Object(a)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))})}return e}function Hn(e,t,a){return(t=Jn(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function Jn(e){var t=Xn(e,"string");return typeof t=="symbol"?t:t+""}function Xn(e,t){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var r=a.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Yn=e=>{var t=e.point,a=e.childIndex,r=e.mainColor,s=e.activeDot,i=e.dataKey,o=e.clipPath;if(s===!1||t.x==null||t.y==null)return null;var l={index:a,dataKey:i,cx:t.x,cy:t.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},d=ke(ke(ke({},l),ht(s)),dt(s)),c;return u.isValidElement(s)?c=u.cloneElement(s,d):typeof s=="function"?c=s(d):c=u.createElement(Nt,d),u.createElement($e,{className:"recharts-active-dot",clipPath:o},c)};function Zn(e){var t=e.points,a=e.mainColor,r=e.activeDot,s=e.itemDataKey,i=e.clipPath,o=e.zIndex,l=o===void 0?Re.activeDot:o,d=mt(Gt),c=Ht();if(t==null||c==null)return null;var h=t.find(p=>c.includes(p.payload));return Ce(h)?null:u.createElement(Ie,{zIndex:l},u.createElement(Yn,{point:h,childIndex:Number(d),mainColor:a,dataKey:s,activeDot:r,clipPath:i}))}var Qn=["animationElapsedTime","isAnimating","isEntrance","visibleLength","strokeDasharray","connectNulls"];function Te(){return Te=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},Te.apply(null,arguments)}function ea(e,t){if(e==null)return{};var a,r,s=ta(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(s[a]=e[a])}return s}function ta(e,t){if(e==null)return{};var a={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;a[r]=e[r]}return a}function na(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function wt(e,t){return"".concat(t,"px ").concat(e,"px")}function aa(e){return e.length%2!==0?[...e,...e]:e}function ra(e,t){for(var a=[],r=0;r<t;++r)a.push(...e);return a}function ia(e,t,a){var r=aa(a),s=r.reduce((f,y)=>f+y,0);if(!s)return wt(t,e);for(var i=Math.floor(e/s),o=e%s,l=[],d=0,c=0;d<r.length;c+=(h=r[d])!==null&&h!==void 0?h:0,++d){var h,p=r[d];if(p!=null&&c+p>o){l=[...r.slice(0,d),o-c];break}}var m=l.length%2===0?[0,t]:[t];return[...ra(r,i),...l,...m].map(f=>"".concat(f,"px")).join(", ")}function sa(e,t,a){if(e){var r="".concat(e).split(/[,\s]+/gim).map(s=>parseFloat(s));return ia(a,t,r)}return wt(t,a)}function la(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,a=e.strokeDasharray,r=e.connectNulls,s=ea(e,Qn),i=r??!1,o;if(t!=null){var l,d=s.pathRef,c=na((l=d?.current)!==null&&l!==void 0?l:null);o=sa(a,c,t)}else a!=null&&(o=String(a));return u.createElement(Jt,Te({},s,{connectNulls:i,strokeDasharray:o}))}function oa(e){var t=u.useRef(0),a=u.useRef(0),r=u.useRef(!1),s=u.useRef(e);return s.current!==e&&(t.current=a.current,s.current=e),u.useCallback((i,o)=>{if(r.current)return null;var l=Math.min(Xt(t.current+i*o),o);return i>0&&o>0&&(a.current=Math.max(a.current,l),l>=o)?(r.current=!0,null):l},[])}var Ct=(e,t,a,r)=>gt(e,"xAxis",t,r),St=(e,t,a,r)=>vt(e,"xAxis",t,r),Pt=(e,t,a,r)=>gt(e,"yAxis",a,r),Tt=(e,t,a,r)=>vt(e,"yAxis",a,r),ca=Le([ft,Ct,Pt,St,Tt],(e,t,a,r,s)=>Qt(e,"xAxis")?Ue(t,r,!1):Ue(a,s,!1)),da=(e,t,a,r,s)=>s;function ua(e){return e.type==="line"}var pa=Le([Zt,da],(e,t)=>e.filter(ua).find(a=>a.id===t)),ma=Le([ft,Ct,Pt,St,Tt,pa,ca,Yt],(e,t,a,r,s,i,o,l)=>{var d=l.chartData,c=l.dataStartIndex,h=l.dataEndIndex;if(!(i==null||t==null||a==null||r==null||s==null||r.length===0||s.length===0||o==null||e!=="horizontal"&&e!=="vertical")){var p=i.dataKey,m=i.data,f;if(m!=null&&m.length>0?f=m:f=d?.slice(c,h+1),f!=null)return Oa({layout:e,xAxis:t,yAxis:a,xAxisTicks:r,yAxisTicks:s,dataKey:p,bandSize:o,displayedData:f})}});function ha(e){var t=ht(e),a=3,r=2;if(t!=null){var s=t.r,i=t.strokeWidth,o=Number(s),l=Number(i);return(Number.isNaN(o)||o<0)&&(o=a),(Number.isNaN(l)||l<0)&&(l=r),{r:o,strokeWidth:l}}return{r:a,strokeWidth:r}}var fa=["id"],ga=["type","layout","connectNulls","needClip","shape","strokeDasharray"],va=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function me(){return me=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},me.apply(null,arguments)}function De(e,t){if(e==null)return{};var a,r,s=xa(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)a=i[r],t.indexOf(a)===-1&&{}.propertyIsEnumerable.call(e,a)&&(s[a]=e[a])}return s}function xa(e,t){if(e==null)return{};var a={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;a[r]=e[r]}return a}function Je(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),a.push.apply(a,r)}return a}function U(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Je(Object(a),!0).forEach(function(r){ba(e,r,a[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Je(Object(a)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))})}return e}function ba(e,t,a){return(t=ya(t))in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function ya(e){var t=ja(e,"string");return typeof t=="symbol"?t:t+""}function ja(e,t){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var r=a.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ka(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function Na(e){var t=0,a=0;for(var r of e)r.status==="matched"&&r.prev.x!=null&&r.next.x!=null&&(t+=r.next.x-r.prev.x,a++);return a>0?t/a:0}var wa=(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(l=>l.status==="removed"?[]:[l.next]);var a=Na(e),r=[];for(var s of e)if(s.status==="matched")r.push(U(U({},s.next),{},{x:ie(s.prev.x,s.next.x,t),y:ie(s.prev.y,s.next.y,t)}));else if(s.status==="added")if(s.next.x!=null){var i=s.next.x-a;r.push(U(U({},s.next),{},{x:ie(i,s.next.x,t),y:s.next.y}))}else r.push(s.next);else if(s.status==="removed"&&s.prev.x!=null){var o=s.prev.x+a;r.push(U(U({},s.prev),{},{x:ie(s.prev.x,o,t),y:s.prev.y}))}return r},ze={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",animationInterpolateFn:wa,animationMatchBy:tn,connectNulls:!1,dot:!0,fill:"#fff",hide:!1,isAnimationActive:"auto",label:!1,legendType:"line",shape:la,stroke:"#3182bd",strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Re.line,type:"linear"},Ca=e=>{var t=e.dataKey,a=e.name,r=e.stroke,s=e.legendType,i=e.hide;return[{inactive:i,dataKey:t,type:s,color:r,value:yt(a,t),payload:e}]},Sa=u.memo(e=>{var t=e.dataKey,a=e.data,r=e.stroke,s=e.strokeWidth,i=e.fill,o=e.name,l=e.hide,d=e.unit,c=e.formatter,h=e.tooltipType,p=e.id,m={dataDefinedOnItem:a,getPosition:ln,settings:{stroke:r,strokeWidth:s,fill:i,dataKey:t,nameKey:void 0,name:yt(o,t),hide:l,type:h,color:r,unit:d,formatter:c,graphicalItemId:p}};return u.createElement(sn,{tooltipEntrySettings:m})});function Pa(e){var t=e.clipPathId,a=e.points,r=e.props,s=r.dot,i=r.dataKey,o=r.needClip;r.id;var l=De(r,fa),d=ut(l);return u.createElement(Gn,{points:a,dot:s,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:d,needClip:o,clipPathId:t})}function Ta(e){var t=e.showLabels,a=e.children,r=e.points,s=u.useMemo(()=>r?.map(i=>{var o,l,d={x:(o=i.x)!==null&&o!==void 0?o:0,y:(l=i.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return U(U({},d),{},{value:i.value,payload:i.payload,viewBox:d,parentViewBox:void 0,fill:void 0})}),[r]);return u.createElement(gn,{value:t?s:void 0},a)}function Aa(e){var t=e.clipPathId,a=e.pathRef,r=e.points,s=e.props,i=e.animationElapsedTime,o=e.isAnimating,l=e.isEntrance,d=e.visibleLength,c=s.type,h=s.layout,p=s.connectNulls,m=s.needClip,f=s.shape,y=s.strokeDasharray,k=De(s,ga),N=U(U({},vn(k)),{},{fill:"none",className:"recharts-line-curve",clipPath:m?"url(#clipPath-".concat(t,")"):void 0,points:r,type:c,layout:h,connectNulls:p,strokeDasharray:y??s.strokeDasharray,pathRef:a,animationElapsedTime:i,isAnimating:o,isEntrance:s.animateNewValues?l:!1,visibleLength:d});return u.createElement(u.Fragment,null,r?.length>1&&u.createElement(xn,{option:f,DefaultShape:ze.shape,shapeProps:N}),u.createElement(Pa,{points:r,clipPathId:t,props:s}))}function Ea(e){var t=e.clipPathId,a=e.props,r=e.pathRef,s=e.previousPointsRef,i=a.points,o=a.isAnimationActive,l=a.animationBegin,d=a.animationDuration,c=a.animationEasing,h=a.animationMatchBy,p=a.animationInterpolateFn,m=a.layout,f=ka(r.current),y=mn(a.onAnimationStart,a.onAnimationEnd),k=y.isAnimating,N=y.handleAnimationStart,j=y.handleAnimationEnd,x=!k,w=oa(i),S=u.useCallback(b=>b>0&&f>0,[f]);return u.createElement(Ta,{points:i,showLabels:x},a.children,u.createElement(hn,{animationInput:i,animationIdPrefix:"recharts-line-",items:i,previousItemsRef:s,isAnimationActive:o,animationBegin:l,animationDuration:d,animationEasing:c,onAnimationStart:N,onAnimationEnd:j,animationInterpolateFn:p,animationMatchBy:h,shouldUpdatePreviousRef:S,layout:m},(b,g,z)=>{var K=k||g<1,F=K?w(g,f):null;return u.createElement(Aa,{props:a,points:b,clipPathId:t,pathRef:r,animationElapsedTime:g,isAnimating:K,isEntrance:z,visibleLength:F})}),u.createElement(fn,{label:a.label}))}function Ia(e){var t=e.clipPathId,a=e.props,r=u.useRef(null),s=u.useRef(null);return u.createElement(Ea,{props:a,clipPathId:t,previousPointsRef:r,pathRef:s})}var Ra=(e,t)=>{var a,r;return{x:(a=e.x)!==null&&a!==void 0?a:void 0,y:(r=e.y)!==null&&r!==void 0?r:void 0,value:e.value,errorVal:jt(e.payload,t)}};class $a extends u.Component{render(){var t=this.props,a=t.hide,r=t.dot,s=t.points,i=t.className,o=t.xAxisId,l=t.yAxisId,d=t.top,c=t.left,h=t.width,p=t.height,m=t.id,f=t.needClip,y=t.zIndex;if(a)return null;var k=Ee("recharts-line",i),N=m,j=ha(r),x=j.r,w=j.strokeWidth,S=pt(r),b=x*2+w,g=f?"url(#clipPath-".concat(S?"":"dots-").concat(N,")"):void 0;return u.createElement(Ie,{zIndex:y},u.createElement($e,{className:k},f&&u.createElement("defs",null,u.createElement(un,{clipPathId:N,xAxisId:o,yAxisId:l}),!S&&u.createElement("clipPath",{id:"clipPath-dots-".concat(N)},u.createElement("rect",{x:c-b/2,y:d-b/2,width:h+b,height:p+b}))),u.createElement(pn,{xAxisId:o,yAxisId:l,data:s,dataPointFormatter:Ra,errorBarOffset:0},u.createElement(Ia,{props:this.props,clipPathId:N}))),u.createElement(Zn,{activeDot:this.props.activeDot,points:s,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:g}))}}function La(e){var t=xt(e,ze),a=t.activeDot,r=t.animateNewValues,s=t.animationBegin,i=t.animationDuration,o=t.animationEasing,l=t.connectNulls,d=t.dot,c=t.hide,h=t.isAnimationActive,p=t.label,m=t.legendType,f=t.xAxisId,y=t.yAxisId,k=t.id,N=De(t,va),j=on(f,y),x=j.needClip,w=cn(),S=dn(),b=bt(),g=mt(_=>ma(_,f,y,b,k));if(S!=="horizontal"&&S!=="vertical"||g==null||w==null)return null;var z=w.height,K=w.width,F=w.x,q=w.y;return u.createElement($a,me({},N,{id:k,connectNulls:l,dot:d,activeDot:a,animateNewValues:r,animationBegin:s,animationDuration:i,animationEasing:o,isAnimationActive:h,hide:c,label:p,legendType:m,xAxisId:f,yAxisId:y,points:g,layout:S,height:z,width:K,left:F,top:q,needClip:x}))}function Oa(e){var t=e.layout,a=e.xAxis,r=e.yAxis,s=e.xAxisTicks,i=e.yAxisTicks,o=e.dataKey,l=e.bandSize,d=e.displayedData;return d.map((c,h)=>{var p=jt(c,o);if(t==="horizontal"){var m=Ke({axis:a,ticks:s,bandSize:l,entry:c,index:h}),f=Ce(p)?null:r.scale.map(p);return{x:m,y:f??null,value:p,payload:c}}var y=Ce(p)?null:a.scale.map(p),k=Ke({axis:r,ticks:i,bandSize:l,entry:c,index:h});return y==null||k==null?null:{x:y,y:k,value:p,payload:c}}).filter(Boolean)}function Ma(e){var t=xt(e,ze),a=bt();return u.createElement(nn,{id:t.id,type:"line"},r=>u.createElement(u.Fragment,null,u.createElement(an,{legendPayload:Ca(t)}),u.createElement(Sa,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:r}),u.createElement(rn,{type:"line",id:r,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:a}),u.createElement(La,me({},t,{id:r}))))}var At=u.memo(Ma,en);At.displayName="Line";var Da=["axis"],za=u.forwardRef((e,t)=>u.createElement(bn,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:Da,tooltipPayloadSearcher:yn,categoricalChartProps:e,ref:t}));function Fa({events:e}){const t=e.filter(a=>a.type==="metric"&&a.payload.metricKind==="rollout_trajectory");return t.length?n.jsx("div",{className:"training-rollout-receipts",children:t.map((a,r)=>{const s=a.payload.rewardEligible===!0,i=Q(a.payload.reward),o=typeof a.payload.failureClass=="string"?a.payload.failureClass:null,l=typeof a.payload.failureCode=="string"?a.payload.failureCode:null;return n.jsxs("details",{children:[n.jsxs("summary",{children:[n.jsxs("span",{children:["Attempt ",r+1]}),n.jsx("strong",{children:s?"eligible":"ineligible"}),n.jsx("em",{children:s&&i!=null?i.toFixed(3):l??o??"not reward eligible"})]}),n.jsxs("dl",{className:"training-configuration-list",children:[n.jsx(E,{label:"Rollout",value:Xe(a.payload.rolloutId)}),n.jsx(E,{label:"Group",value:Xe(a.payload.rolloutGroupId)}),n.jsx(E,{label:"Policy",value:`v${Q(a.payload.policyVersion)??0}`}),n.jsx(E,{label:"Worker",value:String((Q(a.payload.workerSlot)??0)+1)}),n.jsx(E,{label:"Reward",value:i==null?"Not eligible":String(i)}),n.jsx(E,{label:"Failure class",value:o??"None"}),n.jsx(E,{label:"Failure code",value:l??"None"}),n.jsx(E,{label:"Components",value:JSON.stringify(a.payload.rewardComponents??{})}),n.jsx(E,{label:"Tokens",value:`${Q(a.payload.inputTokens)??0} input · ${Q(a.payload.outputTokens)??0} output`})]})]},a.id)})}):n.jsx("div",{className:"training-run-placeholder",children:"No managed attempts were recorded for this run."})}function _a({receipts:e}){const[t,a]=u.useState(!1);if(!e.length)return n.jsx("div",{className:"training-run-placeholder",children:"No on-policy rollout receipts were recorded for this run."});const r=[...e].sort((i,o)=>o.updatedAt.localeCompare(i.updatedAt)),s=t?r:r.slice(0,24);return n.jsxs("div",{className:"training-rollout-receipts",children:[e.length>24?n.jsxs("div",{className:"training-rollout-receipt-controls",children:[n.jsx("span",{children:t?`Showing all ${e.length} receipts`:`Showing latest ${s.length} of ${e.length} receipts`}),n.jsx("button",{className:"training-text-button",type:"button",onClick:()=>a(i=>!i),children:t?"Show latest 24":`Show all ${e.length}`})]}):null,s.map(i=>n.jsxs("details",{children:[n.jsxs("summary",{children:[n.jsx("span",{children:Ba(i.providerTrace.rolloutId)}),n.jsx("strong",{children:i.status}),n.jsx("em",{children:i.reward.eligible&&i.reward.raw!=null?i.reward.raw.toFixed(3):i.failureClass??"not reward eligible"})]}),n.jsxs("dl",{className:"training-configuration-list",children:[n.jsx(E,{label:"Correlation",value:i.correlationId}),n.jsx(E,{label:"Task",value:i.taskId}),n.jsx(E,{label:"Policy",value:i.policy.modelId}),n.jsx(E,{label:"Checkpoint",value:i.policy.checkpointId??"Provider initial policy"}),n.jsx(E,{label:"Environment",value:`${i.environment.id}@${i.environment.version}`}),n.jsx(E,{label:"World",value:`${i.environment.worldId} · ${i.environment.worldHash}`}),n.jsx(E,{label:"Raw reward",value:i.reward.raw==null?"Not eligible":String(i.reward.raw)}),n.jsx(E,{label:"Components",value:JSON.stringify(i.reward.components)}),n.jsx(E,{label:"Outcome",value:i.verifier?.outcome??i.failureClass??"Pending"}),n.jsx(E,{label:"Trace",value:`${i.providerTrace.experimentId}/${i.providerTrace.rolloutId}`})]})]},i.id))]})}function E({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{children:e}),n.jsx("dd",{children:t})]})}function Q(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Xe(e){return typeof e=="string"&&e?e:"Not recorded"}function Ba(e){return e.replace(/^lineage_/,"").slice(0,18)}function Va({detail:e,loading:t,pending:a=!1}){if(t&&!e)return n.jsx("div",{className:"training-run-placeholder",children:"Loading evaluation results…"});const r=e?.evaluation;return r?n.jsxs("div",{className:"training-run-evaluation",children:[n.jsxs("div",{className:"training-metric-summary",children:[n.jsx(oe,{label:"Base score",value:Ye(r.base.meanScore)}),n.jsx(oe,{label:"Trained score",value:Ye(r.trained.meanScore)}),n.jsx(oe,{label:"Score change",value:Wa(r.meanScoreDelta)}),n.jsx(oe,{label:"Trained pass rate",value:Ka(r.trained.passRate)})]}),r.base.count===0?n.jsx("p",{className:"training-muted",children:"Base-model scoring was not imported for this earlier run. New runs retain both base and trained evaluations."}):null,r.trained.count>0&&r.trained.scoredCount===0?n.jsx("p",{className:"training-muted",children:"Outputs were captured, but the grader was unavailable, so this run has no evaluation score."}):null,n.jsx("div",{className:"training-table-wrap",children:n.jsxs("table",{className:"training-data-table training-evaluation-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Test example"}),n.jsx("th",{children:"Base"}),n.jsx("th",{children:"Trained"}),n.jsx("th",{children:"Result"})]})}),n.jsx("tbody",{children:r.examples.map(s=>n.jsxs("tr",{children:[n.jsx("td",{children:n.jsxs("details",{children:[n.jsx("summary",{children:s.taskId}),n.jsx(Ua,{input:s.input,baseOutput:s.baseOutput,trainedOutput:s.trainedOutput,baseGrade:s.baseGrade,trainedGrade:s.trainedGrade})]})}),n.jsx("td",{children:Ze(s.baseGrade)}),n.jsx("td",{children:Ze(s.trainedGrade)}),n.jsx("td",{children:qa(s.baseGrade,s.trainedGrade)})]},s.taskId))})]})})]}):n.jsx("div",{className:"training-run-placeholder",children:a?"Evaluation will appear here after the first eligible checkpoint is scored.":"No scored evaluation results are available for this run."})}function Ua({input:e,baseOutput:t,trainedOutput:a,baseGrade:r,trainedGrade:s}){const i=[...new Set([...r?.feedback??[],...s?.feedback??[]])];return n.jsxs("div",{className:"training-evaluation-output",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Input"}),n.jsx("pre",{children:JSON.stringify(e,null,2)})]}),t?n.jsxs("div",{children:[n.jsx("span",{children:"Base output"}),n.jsx("pre",{children:JSON.stringify(t,null,2)})]}):null,a?n.jsxs("div",{children:[n.jsx("span",{children:"Trained output"}),n.jsx("pre",{children:JSON.stringify(a,null,2)})]}):null,i.length?n.jsxs("div",{children:[n.jsx("span",{children:"Grader feedback"}),n.jsx("p",{children:i.join(" ")})]}):null]})}function oe({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("span",{children:e}),n.jsx("strong",{children:t})]})}function Ye(e){return e==null?"Not recorded":e.toFixed(3)}function Ka(e){return e==null?"Not recorded":`${Math.round(e*100)}%`}function Wa(e){return e==null?"Not comparable":`${e>=0?"+":""}${e.toFixed(3)}`}function Ze(e){return e?.status==="unavailable"?"Unavailable":e?.score==null?"Not scored":e.score.toFixed(3)}function qa(e,t){if(!t)return"Not evaluated";if(t.status==="unavailable")return"Unavailable";if(!e||e.score==null||t.score==null)return t.passed?"Passed":"Failed";const a=t.score-e.score;return Math.abs(a)<5e-4?"No change":a>0?`Improved ${a.toFixed(3)}`:`Regressed ${Math.abs(a).toFixed(3)}`}function Qe({connection:e,lineageId:t,jobId:a,onSaved:r}){const s=a??t,i=a?"jobs":"models",[o,l]=u.useState(null),[d,c]=u.useState(0),[h,p]=u.useState(!0),[m,f]=u.useState(!1),[y,k]=u.useState(!1),[N,j]=u.useState(null),[x,w]=u.useState(null),[S,b]=u.useState(""),[g,z]=u.useState(null),[K,F]=u.useState([]),[q,_]=u.useState(!1);u.useEffect(()=>{if(!e){p(!1),f(!1),j("Connect to OpenPond to review this candidate.");return}let C=!0;return p(!0),f(!1),j(null),F([]),(async()=>{try{if(i==="models"){const A=await X.candidateReview(e,s);C&&A&&l(A)}const M=await X.candidateReview(e,s,!0,i);C&&(l(M),f(!!M))}catch(M){C&&j(Ne(M))}finally{C&&p(!1)}})(),()=>{C=!1}},[e,s,i,d]);function P(C){w(C),b(""),z(null)}async function ae(){if(!e||!o||!x||!S.trim())return;const C=g&&g.reason===S.trim()&&g.decision===x?g:{schemaVersion:"openpond.trainingCandidateDecisionRequest.v1",...o.target,decision:x,reason:S.trim(),idempotencyKey:crypto.randomUUID(),expectedDecision:o.decision?{id:o.decision.id,contentHash:o.decision.contentHash}:null};z(C),k(!0),j(null);try{l(await X.recordCandidateReview(e,s,C,i)),w(null),z(null),F([]),await r()}catch(M){j(Ne(M))}finally{k(!1)}}const H=(K.at(-1)??o?.decision)?.request.expectedDecision;async function L(){if(!(!e||!H)){_(!0),j(null);try{const C=await X.candidateReviewHistory(e,s,H,i);F(M=>[...M,C])}catch(C){j(Ne(C))}finally{_(!1)}}}const T=o?.decision;return n.jsxs("section",{className:"training-run-evaluation","aria-label":"Candidate review",children:[n.jsx("h3",{children:"Candidate review"}),T?n.jsxs(n.Fragment,{children:[n.jsx("strong",{children:T.request.decision==="accepted"?"Accepted":"Rejected"}),n.jsx("p",{children:T.request.reason}),n.jsxs("p",{className:"training-muted",children:["Review ",T.revision," · ",new Date(T.decidedAt).toLocaleString()]})]}):n.jsx("p",{className:"training-muted",children:h?"Loading candidate review…":o?"No candidate decision recorded.":"Candidate review unavailable."}),o?n.jsxs("p",{className:"training-muted",children:["Last synced ",new Date(o.syncedAt).toLocaleString(),". Acceptance keeps this candidate for later use; serving is activated separately."]}):null,N?n.jsx("p",{role:"alert",className:"training-error",children:N}):null,n.jsxs("div",{className:"training-dialog-actions",children:[n.jsx("button",{className:"training-button secondary",type:"button",disabled:h||y,onClick:()=>c(C=>C+1),children:"Refresh review"}),n.jsx("button",{className:"training-button",type:"button",disabled:!m||h||y||T?.request.decision==="accepted",onClick:()=>P("accepted"),children:"Accept candidate"}),n.jsx("button",{className:"training-button danger",type:"button",disabled:!m||h||y||T?.request.decision==="rejected",onClick:()=>P("rejected"),children:"Reject candidate"})]}),K.map(C=>n.jsxs("details",{className:"training-evidence",children:[n.jsxs("summary",{children:["Review ",C.revision," · ",C.request.decision]}),n.jsx("p",{children:C.request.reason}),n.jsx("p",{children:new Date(C.decidedAt).toLocaleString()})]},C.id)),H?n.jsx("button",{className:"training-button secondary",type:"button",disabled:q||y,onClick:()=>{L()},children:q?"Loading…":"Earlier review"}):null,x?n.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:()=>!y&&w(null),children:n.jsxs("section",{className:"training-dialog training-promotion-dialog",role:"dialog","aria-modal":"true","aria-label":"Review candidate",onMouseDown:C=>C.stopPropagation(),children:[n.jsx("div",{className:"training-dialog-header",children:n.jsx("h2",{children:x==="accepted"?"Accept this candidate?":"Reject this candidate?"})}),n.jsx("p",{children:"The adapter and its recorded evaluation remain in the candidate’s history."}),n.jsxs("label",{className:"training-promotion-reason",children:[n.jsx("span",{children:"Reason"}),n.jsx("textarea",{autoFocus:!0,maxLength:5e3,value:S,onChange:C=>b(C.target.value)})]}),N?n.jsx("p",{role:"alert",className:"training-error",children:N}):null,n.jsxs("div",{className:"training-dialog-actions",children:[n.jsx("button",{className:"training-button secondary",type:"button",disabled:y,onClick:()=>w(null),children:"Cancel"}),n.jsx("button",{className:`training-button ${x==="rejected"?"danger":""}`,type:"button",disabled:y||!S.trim(),onClick:()=>{ae()},children:y?"Saving…":g?"Retry save":"Save decision"})]})]})}):null]})}function Ne(e){return e instanceof Error?e.message:"Candidate review could not be loaded."}function Ga({connection:e,jobId:t,evaluations:a}){const[r,s]=u.useState(null),i=a.filter(l=>l.reference),o=i.find(l=>l.reference?.id===r)??i.filter(l=>l.kind==="candidate").at(-1)??i[0];return!e||!o?.reference?null:n.jsxs("section",{className:"training-run-evaluation","aria-label":"Retained evaluation answers",children:[n.jsxs("label",{className:"training-taskset-selector",children:[n.jsx("span",{children:"Evaluation answers"}),n.jsx("select",{value:o.reference.id,onChange:l=>s(l.target.value),children:i.map(l=>n.jsxs("option",{value:l.reference.id,children:[l.kind==="baseline"?"Baseline":"Candidate"," · policy ",l.policyVersion]},l.reference.id))})]}),n.jsx(Ha,{connection:e,jobId:t,evaluation:o.reference},`${t}:${o.reference.id}:${o.reference.contentHash}`)]})}function Ha({connection:e,jobId:t,evaluation:a}){const[r,s]=u.useState(),[i,o]=u.useState([]),[l,d]=u.useState(null),[c,h]=u.useState(null),[p,m]=u.useState(!0),[f,y]=u.useState(0),{id:k,contentHash:N}=a;return u.useEffect(()=>{let j=!0;return m(!0),h(null),d(null),X.trainingEvaluationTasks(e,t,{id:k,contentHash:N},r).then(x=>{j&&d(x)}).catch(x=>{j&&h(x instanceof Error?x.message:String(x))}).finally(()=>{j&&m(!1)}),()=>{j=!1}},[e,t,k,N,r,f]),n.jsxs("div",{className:"training-run-evaluation","aria-busy":p,children:[p?n.jsx("p",{className:"training-muted",children:"Loading recorded answers…"}):null,c?n.jsxs("div",{role:"alert",children:[n.jsx("p",{children:c}),n.jsx("button",{className:"training-button secondary",type:"button",onClick:()=>y(j=>j+1),children:"Retry answers"})]}):null,l?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"training-muted",children:["Tasks ",l.offset+1,"–",l.offset+l.tasks.length," of"," ",l.total,". Recorded outputs and scores are retained for this run."]}),l.tasks.map((j,x)=>n.jsxs("details",{className:"training-evidence",children:[n.jsxs("summary",{children:["Example ",l.offset+x+1," · score ",j.score.toFixed(3)]}),n.jsxs("div",{className:"training-evaluation-output",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Instruction"}),n.jsx("pre",{children:j.input.instruction})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Context"}),n.jsx("pre",{children:JSON.stringify(j.input.context,null,2)})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Recorded output"}),n.jsx("pre",{children:j.output})]})]})]},j.taskId))]}):null,n.jsxs("div",{className:"training-dialog-actions",children:[n.jsx("button",{className:"training-button secondary",type:"button",disabled:p||!i.length,onClick:()=>{s(i.at(-1)),o(j=>j.slice(0,-1))},children:"Previous tasks"}),n.jsx("button",{className:"training-button secondary",type:"button",disabled:p||!l?.nextCursor,onClick:()=>{l?.nextCursor&&(o(j=>[...j,r]),s(l.nextCursor))},children:"Next tasks"})]})]})}const Ja=[{id:"optimizer.reward",label:"Mean reward",points:[]},{id:"reward.variance",label:"Reward variance",points:[]},{id:"optimizer.kl",label:"Policy update KL",points:[]},{id:"optimizer.policy_loss",label:"Policy loss",points:[]},{id:"optimizer.learning_rate",label:"Learning rate",points:[],format:"scientific"}];function Xa({series:e,loading:t=!1,live:a=!1}){const[r,s]=u.useState("raw"),i=u.useMemo(()=>{const l=e.filter(c=>c.points.length);if(!t&&!a)return l;const d=new Map(l.map(c=>[c.id,c]));for(const c of Ja)d.has(c.id)||d.set(c.id,c);return[...d.values()]},[a,t,e]),o=i.some(l=>l.points.length>1);return i.length?n.jsxs("section",{className:"training-metric-workbench","aria-label":"Training metrics",children:[o?n.jsx("div",{className:"training-metric-workbench-controls",children:n.jsxs("label",{children:[n.jsx("span",{children:"Display"}),n.jsxs("select",{"aria-label":"Metric display",onChange:l=>s(l.currentTarget.value),value:r,children:[n.jsx("option",{value:"raw",children:"Raw values"}),n.jsx("option",{value:"smoothed",children:"Smoothed trend"})]})]})}):null,n.jsx("div",{className:"training-metric-chart-grid",children:i.map(l=>n.jsx(Ya,{display:r,loading:t&&!l.points.length,metric:l,pending:a&&!l.points.length},l.id))})]}):n.jsx("div",{className:"training-run-placeholder",children:"This run did not report chartable metrics."})}const Ya=u.memo(function({metric:t,display:a,loading:r,pending:s}){const i=u.useMemo(()=>a==="smoothed"?er(t.points,3):t.points,[a,t.points]),o=u.useMemo(()=>t.points.length?tr(t.points.map(c=>c.value)):null,[t.points]),l=c=>nr(c,t.format),d=t.xLabel??"training step";return n.jsxs("article",{className:"training-metric-chart-card",children:[n.jsxs("header",{children:[n.jsxs("div",{className:"training-metric-chart-title",children:[n.jsx("h4",{children:t.label}),n.jsx("span",{children:t.points.length?`${t.points.length} ${t.points.length===1?"point":"points"}`:s?"Live":"No data"})]}),n.jsx("div",{className:"training-metric-chart-header-actions",children:o?n.jsx("strong",{children:l(o.latest)}):null})]}),t.points.length?n.jsx("div",{className:"training-metric-card-chart","aria-label":`${t.label} by ${d}`,children:n.jsx(jn,{height:"100%",width:"100%",children:n.jsxs(za,{data:i,margin:{top:18,right:18,bottom:4,left:0},children:[n.jsx(kn,{stroke:"var(--border)",strokeDasharray:"3 4",vertical:!1}),n.jsx(Nn,{axisLine:!1,dataKey:"step",fontSize:10,stroke:"var(--muted)",tickLine:!1}),n.jsx(wn,{axisLine:!1,dataKey:"value",domain:t.format==="percent"?[0,1]:["auto","auto"],fontSize:10,stroke:"var(--muted)",tickFormatter:l,tickLine:!1,width:66}),n.jsx(Cn,{content:c=>n.jsx(Za,{active:c.active,format:l,label:t.label,payload:c.payload,xLabel:d}),isAnimationActive:!1}),n.jsx(At,{activeDot:{fill:"var(--cyan, #06b6d4)",r:5},dataKey:"value",dot:{fill:"var(--cyan, #06b6d4)",r:2.5},isAnimationActive:!1,stroke:"var(--cyan, #06b6d4)",strokeWidth:2,type:"monotone"})]})})}):n.jsxs("div",{className:r?"training-metric-chart-empty is-loading":"training-metric-chart-empty",children:[r?n.jsxs("span",{className:"sr-only",children:["Loading ",t.label]}):null,r?null:n.jsx("span",{children:s?"Waiting for rollout…":"No data reported"})]}),o?n.jsxs("dl",{className:"training-metric-card-stats",children:[n.jsx(ce,{label:"Mean",value:l(o.mean)}),n.jsx(ce,{label:"Min",value:l(o.min)}),n.jsx(ce,{label:"Max",value:l(o.max)}),n.jsx(ce,{label:"Std. dev.",value:l(o.standardDeviation)})]}):null]})});function Za({active:e,payload:t,label:a,format:r,xLabel:s}){if(!e||!t.length)return null;const i=t[0]?.payload;return typeof i?.value!="number"?null:n.jsxs("div",{className:"training-chart-tooltip",children:[n.jsxs("strong",{children:[Qa(s)," ",String(i.step??"—")]}),n.jsx("dl",{children:n.jsxs("div",{children:[n.jsx("dt",{children:a}),n.jsx("dd",{children:r(i.value)})]})})]})}function Qa(e){return e.replace(/^./,t=>t.toUpperCase())}function ce({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{children:e}),n.jsx("dd",{children:t})]})}function er(e,t){return e.map((a,r)=>{const s=e.slice(Math.max(0,r-t+1),r+1);return{step:a.step,value:s.reduce((i,o)=>i+o.value,0)/s.length}})}function tr(e){const t=[...e].sort((s,i)=>s-i),a=e.reduce((s,i)=>s+i,0)/e.length,r=e.reduce((s,i)=>s+(i-a)**2,0)/e.length;return{latest:e.at(-1),mean:a,min:t[0],max:t.at(-1),standardDeviation:Math.sqrt(r)}}function nr(e,t="number"){return t==="percent"?`${(e*100).toFixed(2)}%`:t==="scientific"?e.toExponential(2):Math.abs(e)>=1e3?e.toLocaleString(void 0,{maximumFractionDigits:2}):e.toFixed(4)}function ar(e,t=[]){const a=t.filter(d=>d.split==="train"),r=new Map(a.map(d=>[d.id,d])),s=new Map,i=new Set,o=new Map,l=new Set;for(const d of e){if(d.type!=="metric")continue;const c=d.payload;if(c.metricKind==="rollout_trajectory"){const h=$(c.rolloutGroupId)??"group-0",p=s.get(h),m=V(c.rolloutGroupIndex)??p?.groupIndex??s.size,f=$(c.taskId),y=(f?r.get(f):null)??(a.length?a[m%a.length]??null:null),k=Et(y?.metadata),N={id:d.id,rolloutIndex:V(c.rolloutIndex),workerSlot:V(c.workerSlot),attempt:V(c.attempt)??1,policyVersion:V(c.policyVersion),reward:Fe(c.reward),rewardEligible:c.rewardEligible===!0,terminalClass:$(c.terminalClass),failure:$(c.failureCode)??$(c.failureClass),inputTokens:V(c.inputTokens)??0,outputTokens:V(c.outputTokens)??0,components:rr(c)};s.set(h,{id:h,groupIndex:m,taskId:f??y?.id??p?.taskId??null,taskLabel:sr(y)??p?.taskLabel??null,taskFamily:$(c.taskFamily)??$(c.scenarioFamily)??y?.clusterKey??$(k.scenarioFamily)??p?.taskFamily??null,policyVersion:V(c.policyVersion)??p?.policyVersion??null,trajectories:[...p?.trajectories??[],N]});continue}if(c.metricKind==="optimizer_disposition"){const h=$(c.rolloutGroupId);if(!h)continue;const p=$(c.optimizerDisposition)??$(c.disposition)??$(c.remotePhase);p?.includes("skipped")&&i.add(h),p==="applied"&&o.set(h,V(c.step));continue}if(c.metricKind==="policy_optimization"){const h=V(c.step),p=$(c.rolloutGroupId);h!==null&&l.add(h),p&&o.set(p,h)}}return[...s.values()].sort((d,c)=>d.groupIndex-c.groupIndex).map(d=>{const c=d.trajectories.flatMap(m=>m.rewardEligible&&m.reward!==null?[m.reward]:[]),h=o.get(d.id);let p=h===void 0?null:h;if(p===null&&!i.has(d.id)){const m=d.groupIndex+1;l.has(m)&&(p=m)}return{...d,optimizerDisposition:i.has(d.id)?"skipped":p!==null?"applied":"pending",optimizerStep:p,mean:ir(c),minimum:c.length?Math.min(...c):null,maximum:c.length?Math.max(...c):null}})}function rr(e){const t=[e.rewardComponents,e.rubricComponents,e.components].find(Ae);return t?Object.entries(t).flatMap(([a,r])=>{if(typeof r=="number"&&Number.isFinite(r))return[{id:a,label:et(a),score:r,passed:null,feedback:null}];if(!Ae(r))return[];const s=[r.score,r.reward,r.value,r.rewardContribution].map(Fe).find(i=>i!==null);return s===void 0?[]:[{id:a,label:$(r.label)??$(r.name)??et(a),score:s,passed:typeof r.passed=="boolean"?r.passed:null,feedback:$(r.feedback)}]}):[]}function ir(e){return e.length?e.reduce((t,a)=>t+a,0)/e.length:null}function Fe(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function V(e){const t=Fe(e);return t!==null&&Number.isInteger(t)?t:null}function $(e){return typeof e=="string"&&e.trim()?e.trim():null}function Ae(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Et(e){return Ae(e)?e:{}}function et(e){return e.replaceAll(/[._-]+/g," ").replace(/^./,t=>t.toUpperCase())}function sr(e){if(!e)return null;const t=Et(e.input),a=[t.title,t.name,t.prompt,t.instruction,t.question,t.query].find(s=>typeof s=="string"&&!!s.trim());if(!a)return null;const r=a.trim().split(/\n\s*\n/,1)[0].replaceAll(/\s+/g," ");return r.length>110?`${r.slice(0,107).trimEnd()}…`:r}const lr=new Set(["optimizer.reward","rollout.reward"]),or=[{key:"meanReward",id:"optimizer.reward",label:"Mean reward"},{key:"meanReturn",id:"optimizer.return",label:"Mean return"},{key:"learningRate",id:"optimizer.learning_rate",label:"Learning rate",format:"scientific"},{key:"policyLoss",id:"optimizer.policy_loss",label:"Policy loss"},{key:"valueLoss",id:"optimizer.value_loss",label:"Value loss"},{key:"gradientNorm",id:"optimizer.gradient_norm",label:"Gradient norm"},{key:"kl",id:"optimizer.kl",label:"Policy update KL"},{key:"behaviorPolicyKlPreUpdate",id:"optimizer.behavior_policy_kl",label:"Behavior-policy KL (pre-update)"},{key:"entropy",id:"optimizer.entropy",label:"Entropy"},{key:"policyClipFraction",id:"optimizer.policy_clip_fraction",label:"Post-update clip fraction",format:"percent"},{key:"behaviorPolicyClipFractionPreUpdate",id:"optimizer.behavior_policy_clip_fraction",label:"Behavior-policy clip fraction (pre-update)",format:"percent"},{key:"valueClipFraction",id:"optimizer.value_clip_fraction",label:"Value clip fraction",format:"percent"},{key:"explainedVariance",id:"optimizer.explained_variance",label:"Explained variance"}],cr=[{key:"loss",id:"optimizer.loss",label:"Loss"},{key:"reward",id:"optimizer.reward",label:"Reward"},{key:"policyLoss",id:"optimizer.policy_loss",label:"Policy loss"},{key:"advantageLoss",id:"optimizer.advantage_loss",label:"Advantage loss"},{key:"learningRate",id:"optimizer.learning_rate",label:"Learning rate",format:"scientific"},{key:"gradientNorm",id:"optimizer.gradient_norm",label:"Gradient norm"},{key:"meanTokenAccuracy",id:"train.token_accuracy",label:"Token accuracy",format:"percent"},{key:"preferenceAccuracy",id:"train.preference_accuracy",label:"Preference accuracy",format:"percent"},{key:"preferenceMargin",id:"train.preference_margin",label:"Preference margin"},{key:"chosenReward",id:"train.chosen_reward",label:"Chosen reward"},{key:"rejectedReward",id:"train.rejected_reward",label:"Rejected reward"},{key:"entropy",id:"optimizer.entropy",label:"Entropy"}];function dr({detail:e,loading:t,error:a,taskset:r=null}){Bt(a,{prefix:"Training metrics"});const s=u.useMemo(()=>e?ar(e.events,r?.tasks):[],[e,r]),i=u.useMemo(()=>e?pr(mr(e),s):[],[e,s]);if(a&&!e)return n.jsx("div",{className:"training-run-placeholder",children:"Training metrics are unavailable."});if(!e&&!t)return n.jsx("div",{className:"training-run-placeholder",children:"Select a training run to inspect its metrics."});const o=e?["queued","starting","running","reconciling"].includes(e.job.status):!1;return n.jsx(Xa,{live:o,loading:t&&!e,series:i})}function ur(e){const t=e.flatMap((a,r)=>a.mean===null?[]:[{step:r+1,value:a.mean}]);return t.length?{id:"optimizer.reward",label:"Mean reward",points:t,xLabel:"rollout group"}:null}function pr(e,t){const a=ur(t);return a?[a,...e.filter(r=>!lr.has(r.id))]:e}function mr(e){const t=It(e.job.metadata.rolloutProgress),a=W(e.job.metadata.optimizerUpdatesObserved)??W(t.optimizerUpdatesApplied),r=fr(e)==="grpo"&&a!==null?Math.max(0,a):null,s=at(e.stepMetrics).filter(d=>r===null||d.step<=r),i=[...nt(at(e.policyMetrics),or),...nt(s,cr),...hr(e.events)],o=new Map;for(const d of i){const c=o.get(d.id);(!c||d.points.length>c.points.length)&&o.set(d.id,d)}const l=["optimizer.reward","rollout.reward","optimizer.kl","optimizer.loss","optimizer.learning_rate"];return[...o.values()].sort((d,c)=>tt(d.id,l)-tt(c.id,l)||d.label.localeCompare(c.label))}function tt(e,t){const a=t.indexOf(e);return a<0?999:a}function nt(e,t){return t.flatMap(a=>{const r=e.flatMap(s=>{const i=s[a.key];return typeof i=="number"&&Number.isFinite(i)?[{step:s.step,value:i}]:[]});return r.length?[{id:a.id,label:a.label,points:r,format:a.format}]:[]})}function at(e){const t=new Map;for(const a of e)t.set(a.step,a);return[...t.values()].sort((a,r)=>a.step-r.step)}function hr(e){const t=new Map,a=new Map,r=(i,o,l,d)=>{t.set(i,[...t.get(i)??[],{step:l,value:d}]),a.set(i,o)},s=new Map;for(const i of e)if(i.type==="metric"){if(i.payload.metricKind==="managed_telemetry"){const o=typeof i.payload.metricId=="string"?i.payload.metricId:null,l=W(i.payload.value),d=W(i.payload.step)??i.sequence;o&&l!==null&&r(o,rt(o),d,l)}if(i.payload.metricKind==="rollout_trajectory"){const o=W(i.payload.rolloutIndex)??i.sequence,l=W(i.payload.reward);l!==null&&r("rollout.reward","Rollout reward",o,l);const d=typeof i.payload.rolloutGroupId=="string"?i.payload.rolloutGroupId:"group-0",c=i.payload.rewardEligible===!1||typeof i.payload.failureClass=="string"||typeof i.payload.failureCode=="string";s.set(d,[...s.get(d)??[],{reward:l,eligible:i.payload.rewardEligible===!0,resolved:l!==null||c,attempt:W(i.payload.attempt)??1,input:W(i.payload.inputTokens)??0,output:W(i.payload.outputTokens)??0}])}}return[...s.values()].forEach((i,o)=>{const l=i.filter(m=>m.resolved);if(!l.length)return;const d=l.flatMap(m=>m.eligible&&m.reward!==null?[m.reward]:[]),c=d.length?d.reduce((m,f)=>m+f,0)/d.length:0,h=d.length?d.reduce((m,f)=>m+(f-c)**2,0)/d.length:0,p=d.length?Math.max(...d):0;r("attempt.valid_rate","Valid attempt rate",o,d.length/l.length),r("attempt.failure_count","Attempt failures",o,l.length-d.length),r("attempt.retry_count","Attempt retries",o,l.reduce((m,f)=>m+Math.max(0,f.attempt-1),0)),r("reward.variance","Reward variance",o,h),r("reward.best","Best reward",o,p),r("tokens.input","Input tokens",o,i.reduce((m,f)=>m+f.input,0)),r("tokens.output","Output tokens",o,i.reduce((m,f)=>m+f.output,0))}),[...t].map(([i,o])=>({id:i,label:a.get(i)??rt(i),points:o,format:i.endsWith("rate")||i.includes("fraction")?"percent":"number"}))}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function rt(e){return e.replaceAll(/[._]/g," ").replace(/^./,t=>t.toUpperCase())}function fr(e){const t=e.job.metadata.trainingMethod;if(typeof t=="string")return t;const a=It(e.job.metadata.sourceSnapshot);return typeof a.method=="string"?a.method:null}function It(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}const gr=new Set(["queued","starting","running","cancelling","reconciling"]),it=new WeakMap;function vr(e,t,a,r=!1){const[s,i]=u.useState(null),[o,l]=u.useState(!1),[d,c]=u.useState(null),h=u.useRef(t),p=u.useRef(null);h.current=t;const m=u.useCallback((f=r)=>{if(!e||!t)return Promise.resolve(null);const y=`${t}:${f?"full":"live"}`;if(p.current?.key===y)return p.current.request;l(!0);const k=X.trainingRunDetail(e,t,{includeEvaluation:f}).then(N=>{const j=st(e),x=j.get(t),w=!f&&x?.includesEvaluation?{...N,evaluation:x.detail.evaluation}:N;return j.set(t,{detail:w,includesEvaluation:f||x?.includesEvaluation===!0}),h.current===t&&(i(w),c(null)),w}).catch(N=>(h.current===t&&c(N instanceof Error?N.message:String(N)),null)).finally(()=>{p.current?.request===k&&(p.current=null,l(!1))});return p.current={key:y,request:k},k},[e,r,t]);return u.useEffect(()=>{if(c(null),!e||!t){i(null);return}const f=st(e).get(t);i(f?.detail??null),m(r)},[e,r,t,a,m]),u.useEffect(()=>{if(!e||!t||!a||!gr.has(a))return;const f=window.setInterval(()=>{m(!1)},2e3);return()=>window.clearInterval(f)},[e,t,a,m]),{detail:s,error:d,loading:o,refresh:m}}function st(e){const t=it.get(e);if(t)return t;const a=new Map;return it.set(e,a),a}function xr({title:e,status:t,statusValue:a,versionStatus:r,method:s,baseModel:i,taskset:o,compute:l,duration:d,output:c,reward:h,telemetry:p,evidence:m,configuration:f,children:y,failure:k,onOpenTaskset:N,showHeader:j=!0}){const x=p?.cost.providerReportedUsd??p?.cost.estimatedUsd??m?.cost.totalUsd??null;return n.jsxs("div",{className:"labs-model-run-summary",children:[j?n.jsx("section",{className:"labs-run-outcome-card",children:n.jsx("header",{children:n.jsxs("div",{children:[n.jsxs("div",{className:"labs-run-title-row",children:[n.jsx("h2",{children:e}),n.jsx(Oe,{label:t,value:a})]}),n.jsxs("p",{children:[yr(s)," on ",i]})]})})}):null,y,n.jsxs("section",{className:"labs-run-summary-card",children:[n.jsx("header",{children:n.jsx("h3",{children:"Run setup"})}),n.jsxs("dl",{className:"labs-run-detail-list",children:[n.jsx(D,{label:"Training method",value:s}),n.jsx(D,{label:"Base model",value:i}),n.jsx(D,{label:"Compute",value:l}),n.jsx(D,{label:"Output",value:c}),r?n.jsx(D,{label:"Version status",value:r}):null,n.jsx(D,{label:"Duration",value:d}),n.jsx(D,{label:"Run cost",value:x===null?"Not reported":`$${x.toFixed(4)}`}),n.jsx(D,{label:"Final reward",value:h===null?"Not reported":h.toFixed(4)}),f.map(w=>n.jsx(D,{label:w.label,value:w.value},w.label)),p||m?n.jsxs(n.Fragment,{children:[n.jsx(ee,{label:"GPU",value:br(p,m)}),n.jsx(ee,{label:"Tokens",value:`${te(p?.usage.promptTokens??m?.usage.inputTokens??null)} prompt · ${te(p?.usage.generatedTokens??m?.usage.outputTokens??null)} generated`}),n.jsx(ee,{label:"Trajectories",value:`${te(p?.usage.successfulTrajectories??m?.reward.eligibleTrajectoryCount??null)} succeeded · ${te(p?.usage.failedTrajectories??(m?m.reward.trajectoryCount-m.reward.eligibleTrajectoryCount:null))} failed`}),n.jsx(ee,{label:"Optimizer updates",value:te(p?.usage.optimizerSteps??m?.progress.committedOptimizerSteps??null)}),n.jsx(ee,{label:"GPU time",value:p?.usage.gpuSeconds==null?"Not reported":`${p.usage.gpuSeconds.toFixed(1)} seconds`})]}):n.jsx(D,{label:"Resource usage",value:"Not retained for this run"}),n.jsxs("div",{children:[n.jsx("dt",{children:"Taskset"}),n.jsx("dd",{children:N?n.jsxs("button",{className:"labs-run-taskset-link",type:"button",onClick:N,children:[n.jsx("span",{children:o}),n.jsx(Vt,{"aria-hidden":"true",size:14})]}):o})]})]})]}),k?n.jsx("p",{className:"labs-training-error",children:k}):null]})}function D({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{children:e}),n.jsx("dd",{children:t})]})}function ee({label:e,value:t}){return n.jsx(D,{label:e,value:t})}function br(e,t){const a=e?.resource.gpuCount??t?.resource.gpuCount??null,r=e?.resource.gpuType??t?.resource.gpuType??null;return a===null&&r===null?"Not reported":`${a??"Unknown"} × ${r?jr(r):"Unreported"}`}function te(e){return e===null?"Not reported":e.toLocaleString()}function yr(e){return e==="RFT"?"Reinforcement fine-tuning":`${e} training`}function jr(e){return e.split(" · ").map(t=>t.replaceAll("_"," ").replace(/\b[a-z]/g,a=>a.toUpperCase())).join(" · ")}function kr({receipt:e,onOpenConversation:t}){return n.jsxs(n.Fragment,{children:[n.jsxs("section",{className:"labs-run-summary-card",children:[n.jsx("header",{children:n.jsx("h3",{children:"Inconclusive benchmark"})}),n.jsx("p",{className:"training-run-placeholder",children:e.reason}),n.jsxs("dl",{className:"labs-run-detail-list",children:[n.jsx(I,{label:"Held-out baseline tokens",value:e.usage.baseline.totalTokens.toLocaleString()}),n.jsx(I,{label:"Adaptation baseline tokens",value:e.usage.adaptation.totalTokens.toLocaleString()}),n.jsx(I,{label:"Refiner tokens",value:e.usage.refiner.totalTokens.toLocaleString()}),n.jsx(I,{label:"Grader tokens",value:e.usage.grader.totalTokens.toLocaleString()}),n.jsx(I,{label:"Observed / maximum spend",value:`$${e.budget.observedSpendUsd.toFixed(4)} / $${e.budget.maximumSpendUsd.toFixed(2)}`}),n.jsx(I,{label:"Harness candidate",value:e.stopReason==="candidate_harness_unchanged"?"Unchanged":"Lineage invalid"}),n.jsx(I,{label:"Completed attempts",value:e.attempts.length.toLocaleString()}),n.jsx(I,{label:"Candidate attempts",value:"Skipped"})]})]}),e.attempts.length?n.jsx(Rt,{receipt:e,onOpenConversation:t}):null]})}function Nr({run:e}){const t=["baseline","adaptation","refiner","candidate_adaptation","candidate","comparison"],a={baseline:"Baseline",adaptation:"Adaptation",refiner:"Refiner",candidate_adaptation:"Sequential adaptation",candidate:"Candidate",comparison:"Comparison"},r=Math.max(0,t.indexOf(e.evaluationProgress?.stage??"baseline")),s=e.evaluationProgress?.completedAttempts??0,i=e.evaluationProgress?.totalAttempts??1;return n.jsxs("div",{className:"labs-benchmark-progress",children:[n.jsxs("header",{children:[n.jsx("h3",{children:"Benchmark progress"}),n.jsxs("strong",{children:[s," of ",i," attempts"]})]}),n.jsx("div",{className:"labs-benchmark-progress-track","aria-hidden":"true",children:n.jsx("span",{style:{width:`${Math.min(100,s/i*100)}%`}})}),n.jsx("ol",{children:t.map((o,l)=>n.jsxs("li",{className:l<r?"complete":l===r?"active":void 0,children:[n.jsx("span",{}),a[o]]},o))})]})}function wr({receipt:e}){const t=Me(e),a=t.pairs.filter(i=>i.cohort==="held_out"),r=t.pairs.filter(i=>i.cohort==="adaptation"),s=i=>i.length?i.reduce((o,l)=>o+l,0)/i.length:0;return n.jsxs("div",{className:"labs-benchmark-attempt-charts",children:[n.jsx(de,{title:"Held-out tokens by task",baseline:a.map(i=>i.baseline.totalTokens),candidate:a.map(i=>i.refined.totalTokens),format:i=>Math.round(i).toLocaleString()}),n.jsx(de,{title:"Adaptation tokens by task",baseline:r.map(i=>i.baseline.totalTokens),candidate:r.map(i=>i.refined.totalTokens),format:i=>Math.round(i).toLocaleString()}),n.jsx(de,{title:"Held-out quality by task",baseline:a.map(i=>i.baseline.score),candidate:a.map(i=>i.refined.score),format:i=>i.toFixed(2),summarize:s}),n.jsx(de,{title:"Adaptation quality by task",baseline:r.map(i=>i.baseline.score),candidate:r.map(i=>i.refined.score),format:i=>i.toFixed(2),summarize:s})]})}function Cr({receipt:e,run:t,tasksetName:a,onOpenTaskset:r}){const s=Me(e),i=s.comparedTaskCount>0,o=s.passed,l=s.tokenDeltaPercent===null?"—":`${s.tokenDeltaPercent>0?"+":""}${s.tokenDeltaPercent.toFixed(2)}%`,d=c=>{const h=s.cohorts[c];return`${h.passedTaskCount}/${h.comparedTaskCount} passed`};return n.jsxs("section",{className:"labs-run-summary-card",children:[n.jsx("header",{children:n.jsx("h3",{children:"Token efficiency"})}),i?n.jsxs("div",{className:"labs-benchmark-efficiency-summary",children:[n.jsxs("strong",{children:[s.passedTaskCount," of ",s.comparedTaskCount," tasks passed"]}),n.jsxs("p",{children:["A task passes only when its refined token count is strictly lower than its own baseline. ",s.failedTaskCount," failed this token-efficiency test; aggregate usage changed by ",l,"."]})]}):n.jsx("p",{className:"training-run-placeholder",children:"Paired task-level token evidence is unavailable for this run."}),n.jsxs("dl",{className:"labs-run-detail-list",children:[n.jsx(I,{label:"Execution",value:Y(t.status)}),n.jsx(I,{label:"Token-efficiency result",value:o?"Passed":"Failed"}),n.jsx(I,{label:"Efficiency passes",value:`${s.passedTaskCount}/${s.comparedTaskCount}`}),n.jsx(I,{label:"Efficiency failures",value:`${s.failedTaskCount}/${s.comparedTaskCount}`}),n.jsx(I,{label:"All-task foreground tokens",value:`${s.baselineTokens.toLocaleString()} → ${s.refinedTokens.toLocaleString()}`}),n.jsx(I,{label:"Aggregate token change",value:l}),n.jsx(I,{label:"Adaptation replay",value:d("adaptation")}),n.jsx(I,{label:"Held-out replay",value:d("held_out")}),n.jsx(I,{label:"Task quality",value:`${s.baselinePassedCount}/${s.comparedTaskCount} → ${s.refinedPassedCount}/${s.comparedTaskCount}`}),n.jsx(I,{label:"Result lineage",value:e.lineage.valid?"Valid":"Invalid"}),n.jsxs("div",{children:[n.jsx("dt",{children:"Taskset"}),n.jsx("dd",{children:r?n.jsx("button",{className:"labs-run-taskset-link",type:"button",onClick:r,children:a}):a})]})]})]})}function de({title:e,baseline:t,candidate:a,format:r,summarize:s=i=>i.reduce((o,l)=>o+l,0)}){const i=t.filter(p=>p!==null),o=a.filter(p=>p!==null),l=Math.max(1,...i,...o),d=Math.max(2,t.length,a.length),c=p=>{const m=[];let f=[];return p.forEach((y,k)=>{if(y===null){f.length&&m.push(f.join(" ")),f=[];return}const N=6+k/(d-1)*88,j=44-y/l*36;f.push(`${N},${j}`)}),f.length&&m.push(f.join(" ")),m},h=p=>p.flatMap((m,f)=>m===null?[]:[{x:6+f/(d-1)*88,y:44-m/l*36}]);return n.jsxs("section",{className:"labs-benchmark-line-chart",children:[n.jsxs("header",{children:[n.jsx("h4",{children:e}),n.jsxs("div",{children:[n.jsxs("span",{children:["Baseline ",r(s(i))]}),n.jsxs("span",{children:["Refined ",r(s(o))]})]})]}),n.jsxs("svg",{"aria-label":e,role:"img",viewBox:"0 0 100 50",preserveAspectRatio:"none",children:[n.jsx("line",{x1:"6",x2:"94",y1:"44",y2:"44"}),c(t).map((p,m)=>n.jsx("polyline",{className:"baseline",points:p},`baseline-${m}`)),c(a).map((p,m)=>n.jsx("polyline",{className:"candidate",points:p},`candidate-${m}`)),h(t).map((p,m)=>n.jsx("circle",{className:"baseline",cx:p.x,cy:p.y,r:"1"},`baseline-point-${m}`)),h(a).map((p,m)=>n.jsx("circle",{className:"candidate",cx:p.x,cy:p.y,r:"1"},`candidate-point-${m}`))]})]})}function Rt({receipt:e,onOpenConversation:t}){const a=e.schemaVersion==="openpond.modelEvaluationReceipt.v1"?Sn(e.attempts??[]):e.attempts??[];return n.jsxs("section",{className:"labs-run-summary-card",children:[n.jsx("header",{children:n.jsx("h3",{children:e.schemaVersion==="openpond.modelEvaluationReceipt.v1"?"Selected task results":"Completed attempts"})}),n.jsx("div",{className:"training-table-wrap",children:n.jsxs("table",{className:"training-data-table labs-benchmark-attempt-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Task"}),n.jsx("th",{children:"Phase"}),n.jsx("th",{children:"Result"}),n.jsx("th",{children:"Score"}),n.jsx("th",{children:"Tokens"}),n.jsx("th",{children:"Work chat"})]})}),n.jsx("tbody",{children:a.map(r=>n.jsxs("tr",{children:[n.jsx("td",{children:Sr(r.taskId)}),n.jsx("td",{children:r.phase}),n.jsx("td",{children:n.jsx(Oe,{label:r.passed?"Passed":"Failed",value:r.passed?"succeeded":"failed"})}),n.jsx("td",{children:r.score===null?"—":r.score.toFixed(2)}),n.jsx("td",{children:r.totalTokens.toLocaleString()}),n.jsx("td",{children:r.sessionId?n.jsx("button",{className:"labs-run-taskset-link",type:"button",onClick:()=>t(r.sessionId),children:"Open chat"}):"Not retained"})]},`${r.phase}:${r.attemptId}`))})]})})]})}function Sr(e){return e.replace(/^(?:adaptation|frozen)-/,"").replaceAll("-"," ").replace(/^./,t=>t.toUpperCase())}function I({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{children:e}),n.jsx("dd",{children:t})]})}function $t(e){const t=["B","KB","MB","GB","TB"];let a=e,r=0;for(;a>=1024&&r<t.length-1;)a/=1024,r+=1;return`${a.toFixed(r===0?0:2)} ${t[r]}`}function Pr({error:e,events:t,loading:a,pending:r}){const[s,i]=u.useState(!1),[o,l]=u.useState({}),[d,c]=u.useState(!0),h=u.useRef(null),p=u.useRef(null),m=u.useRef(null),f=u.useMemo(()=>Tr(t),[t]),y=u.useMemo(()=>t.filter(x=>o[ue(x)]??we(ue(x))),[t,o]),k=f.filter(x=>o[x.id]??we(x.id)).length,N=f.length>0&&k===f.length,j=k>0&&!N;return u.useEffect(()=>{m.current&&(m.current.indeterminate=j)},[j]),u.useEffect(()=>{if(!s)return;const x=S=>{p.current?.contains(S.target)||i(!1)},w=S=>{S.key==="Escape"&&i(!1)};return document.addEventListener("pointerdown",x),document.addEventListener("keydown",w),()=>{document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",w)}},[s]),u.useLayoutEffect(()=>{const x=h.current;!x||!d||(x.scrollTop=x.scrollHeight)},[e,d,r,y]),a&&!t.length?n.jsx("div",{className:"training-run-placeholder",children:"Loading run events…"}):t.length?n.jsxs("div",{className:"training-event-log-shell",children:[n.jsxs("div",{className:"training-event-log-toolbar",children:[n.jsx("div",{children:n.jsx("strong",{children:"Activity log"})}),n.jsxs("div",{className:"training-event-filter",ref:p,children:[n.jsxs("button",{"aria-expanded":s,"aria-haspopup":"menu",className:"training-event-filter-trigger",type:"button",onClick:()=>i(x=>!x),children:[n.jsx(Ut,{"aria-hidden":"true",size:14}),"Event types",n.jsxs("span",{children:[k,"/",f.length]}),n.jsx(Kt,{"aria-hidden":"true",size:13})]}),s?n.jsxs("div",{"aria-label":"Filter training activity by event type",className:"training-event-filter-menu",role:"menu",children:[n.jsxs("label",{className:"training-event-filter-option select-all",children:[n.jsx("input",{checked:N,ref:m,type:"checkbox",onChange:x=>{const w=x.currentTarget.checked;l(Object.fromEntries(f.map(S=>[S.id,w])))}}),n.jsx("span",{className:"training-event-filter-check",children:n.jsx(Ve,{"aria-hidden":"true",size:12})}),"Select all"]}),n.jsx("div",{className:"training-event-filter-options",children:f.map(x=>{const w=o[x.id]??we(x.id);return n.jsxs("label",{className:"training-event-filter-option",children:[n.jsx("input",{checked:w,type:"checkbox",onChange:S=>l(b=>({...b,[x.id]:S.currentTarget.checked}))}),n.jsx("span",{className:"training-event-filter-check",children:n.jsx(Ve,{"aria-hidden":"true",size:12})}),n.jsx("span",{children:x.label}),n.jsx("small",{children:x.count.toLocaleString()})]},x.id)})})]}):null]})]}),n.jsxs("div",{"aria-label":"Training activity log","aria-live":"polite",className:"training-event-log",ref:h,role:"log",onScroll:x=>{const w=x.currentTarget,S=w.scrollHeight-w.scrollTop-w.clientHeight;c(S<=6)},children:[n.jsxs("div",{"aria-hidden":"true",className:"training-event-log-header",children:[n.jsx("span",{children:"Time"}),n.jsx("span",{children:"Event type"}),n.jsx("span",{children:"Details"})]}),y.map(x=>n.jsxs("div",{className:`training-event-log-line ${x.type}`,children:[n.jsx("time",{dateTime:x.timestamp,children:Se(x.timestamp)}),n.jsx("span",{children:Lt(ue(x))}),n.jsx("code",{children:Ar(x)})]},x.id)),r&&!e?n.jsxs("div",{className:"training-event-log-loading",role:"status",children:[n.jsx(Wt,{"aria-hidden":"true",className:"spin",size:14}),n.jsx("span",{className:"sr-only",children:"Waiting for new activity"})]}):null,y.length?null:n.jsx("div",{className:"training-event-log-empty",children:"No events match the selected event types."}),e?n.jsxs("div",{className:"training-event-log-line failure",children:[n.jsx("time",{children:"—"}),n.jsx("span",{children:"Failure"}),n.jsx("code",{children:e})]}):null]})]}):n.jsx("div",{className:"training-run-placeholder",children:e??"No normalized run events were recorded."})}function ue(e){return typeof e.payload.remoteEventType=="string"&&e.payload.remoteEventType.trim()?e.payload.remoteEventType:typeof e.payload.telemetryType=="string"&&e.payload.telemetryType.trim()?e.payload.telemetryType:e.type}function Tr(e){const t=new Map;for(const a of e){const r=ue(a);t.set(r,(t.get(r)??0)+1)}return[...t.entries()].map(([a,r])=>({id:a,count:r,label:Lt(a)})).sort((a,r)=>a.label.localeCompare(r.label))}function we(e){return e!=="metric"&&!e.endsWith("_metric")}function Lt(e){return e.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function Ar(e){const t=e.payload,a=J(t.step),r=J(t.maxSteps);if(typeof t.telemetryType=="string"){const s=typeof t.message=="string"?t.message:null,i=typeof t.errorCode=="string"?t.errorCode:null,o=typeof t.telemetrySource=="string"?` · ${t.telemetrySource}`:"";return`${s??t.telemetryType.replaceAll("_"," ")}${a==null?"":` · step ${a}`}${o}${i?` · ${i}`:""}`}if(typeof t.remoteEventType=="string"){const s=Er(t.remoteEventType),i=typeof t.remotePhase=="string"?Ir(t.remotePhase):null,o=typeof t.errorCode=="string"&&t.errorCode.trim()?t.errorCode.trim():null;return[s,i,a==null?null:`step ${a}`,o?`error ${o}`:null].filter(l=>!!l).join(" · ")}if(e.type==="start")return typeof t.device=="string"?`Worker started on ${t.device}.`:"Worker started.";if(e.type==="progress"&&a!=null)return r==null?`Step ${a}.`:`Step ${a} of ${r}.`;if(e.type==="metric"){const s=typeof t.metricKind=="string"?t.metricKind.replaceAll("_"," "):"metric",i=[ne("loss",t.loss),ne("reward",t.meanReward??t.reward),ne("policy loss",t.policyLoss),ne("value loss",t.valueLoss),ne("preference accuracy",t.preferenceAccuracy,Rr)].filter(c=>!!c),o=typeof t.failureClass=="string"?t.failureClass:null,l=typeof t.failureCode=="string"?t.failureCode:null,d=typeof t.metricId=="string"&&typeof t.value=="number"?` · ${t.metricId}: ${t.value.toPrecision(4)}`:"";return`${s}${a==null?"":` · step ${a}`}${d}${o?` · ${o}`:""}${l?` · ${l}`:""}${i.length?` · ${i.join(" · ")}`:""}`}if(e.type==="checkpoint"){const s=J(t.policyVersion),i=J(t.sizeBytes),o=[s==null?null:`policy ${s}`,i==null?null:$t(i),t.final===!0?"final":null].filter(l=>!!l);return o.length?`Checkpoint committed · ${o.join(" · ")}.`:"Checkpoint committed."}if(e.type==="complete"){const s=J(t.artifactCount);return s==null?"Worker completed.":`Worker completed with ${s} artifacts.`}return e.type==="failure"&&typeof t.message=="string"?t.message:Object.keys(t).length?JSON.stringify(t):"Recorded."}function Er(e){return{drain:"Rollout drain",infer:"Model inference",materialize_checkpoint:"Checkpoint materialization",optimizer_metric:"Optimizer metric",provision_gpu:"GPU provisioning",rollout_metric:"Rollout trajectory",score_reward_model:"Reward scoring",start_inference:"Policy server",train_step:"Optimizer update",upload_checkpoint:"Checkpoint upload"}[e]??Ot(e)}function Ir(e){return{committed:"committed",completed:"completed",eligible:"recorded",failed:"failed",running:"running",succeeded:"succeeded"}[e]??Ot(e).toLocaleLowerCase()}function Ot(e){return e.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase())}function ne(e,t,a=r=>new Intl.NumberFormat(void 0,{maximumFractionDigits:4}).format(r)){const r=J(t);return r==null?null:`${e} ${a(r)}`}function J(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Rr(e){return`${(e*100).toFixed(1)}%`}function ri({connection:e,detailTab:t,onDetailTabChange:a,selectedEntryKey:r,workproduct:s,runs:i,training:o,onOpenDataset:l,onOpenConversation:d,detailKind:c}){const h=o.payload,[p,m]=u.useState(null),f=u.useMemo(()=>Pn(s,i,h),[i,h,s]),y=u.useMemo(()=>Tn(s,i,h),[i,h,s]),k=u.useMemo(()=>An(s,h),[h,s]),N=u.useMemo(()=>En(s,i,h),[i,h,s]),j=u.useMemo(()=>new Map(N.map(v=>[v.id,v])),[N]),w=u.useMemo(()=>In(f,y),[f,y]).find(v=>v.key===r)??null,S=r.startsWith("model-run:")?r.slice(10):null,b=S?k.find(v=>v.id===S)??null:w?.job?k.find(v=>v.id===w.job?.metadata.modelRunId)??null:null,g=w?.job??(b?h?.jobs.find(v=>v.id===b.id||v.metadata.modelRunId===b.id)??null:null),z=h?.comparisonSeriesEntries.find(v=>v.modelRunId===b?.id||v.modelRunId===g?.metadata.modelRunId)??null,K=typeof g?.metadata.parentHostedArtifactId=="string"?"Prior hosted run":_r(h,z),F=u.useMemo(()=>{const v=Rn(f,y,k);return $n(v,b?.kind==="evaluation"?"evals":"training")},[f,k,b?.kind,y]),q=F.findIndex(v=>v.key===r||g!==null&&v.job?.id===g.id||b!==null&&v.lifecycleRun?.id===b.id),_=q<0?null:F.length-q,P=w?.version??(b?.adapterArtifactLineageId?y.find(v=>v.lineage.id===b.adapterArtifactLineageId)??null:null),ae=(b?h?.modelVersions.find(v=>v.id===b.modelVersionId)?.baseModel.modelId:null)??h?.modelVersions.filter(v=>v.modelId===s.id&&v.kind==="base_reference").sort((v,G)=>G.version-v.version)[0]?.baseModel.modelId??(typeof g?.metadata.baseModelId=="string"?g.metadata.baseModelId:null),H=P?.lineage.frozenEvaluationArtifactId??null,L=P?.plan??(g?j.get(g.planId)??null:null),T=P?.taskset??Ln(h).find(v=>v.id===(b?.taskset.id??L?.tasksetId))??null,C=T?.name??(typeof g?.metadata.tasksetId=="string"?g.metadata.tasksetId:"Unavailable"),M=b?.method??L?.recipe.method??Mr(g?.metadata),A=vr(e,g?.id??null,g?.status??null,t==="evaluation"),he=g?h?.rolloutReceipts.filter(v=>v.jobId===g.id)??[]:[],R=A.detail?.managedEvidence??null,Mt=A.detail?.events.some(v=>v.type==="metric"&&v.payload.metricKind==="rollout_trajectory")??!1,re=On({lifecycleRun:b,job:A.detail?.job??g}),fe=Mn(re),Dt=b?.status==="failed"&&g?.metadata.phase==="artifact_collection_failed",ge=M==="grpo",Z=Lr(g?.metadata),ve=(L&&(L.recipe.method==="sft"||L.recipe.method==="dpo"||L.recipe.method==="grpo")?L.recipe.optimizer.maxSteps:null)??R?.progress.targetOptimizerSteps??null,zt=ve!==null&&typeof g?.metadata.progress=="number"&&Number.isFinite(g.metadata.progress)?Math.floor(Math.max(0,g.metadata.progress)*ve):0,Ft=Math.max(0,Z?.optimizerUpdatesApplied??0,zt,A.detail?.policyMetrics.reduce((v,G)=>Math.max(v,G.step),0)??0,A.detail?.stepMetrics.reduce((v,G)=>Math.max(v,G.step),0)??0,R?.progress.committedOptimizerSteps??0),_t=$r(ge&&Z?Z.groupsCompleted:Ft,ge&&Z?Z.groupsTarget:ve),_e=c==="run"?{id:"details",label:"Details"}:{id:"overview",label:"Overview"},xe=[...c==="run"&&g?[{id:"metrics",label:"Metrics"}]:[],_e,...c==="version"&&g?[{id:"metrics",label:"Metrics"}]:[],{id:"evaluation",label:"Evaluation"},...he.length||Mt?[{id:"rollouts",label:"Rollouts"}]:[],{id:"artifacts",label:"Artifacts"},...g?[{id:"activity",label:"Activity"}]:[]],Be=t,B=xe.some(v=>v.id===Be)?Be:xe[0].id;return!w&&!b?n.jsx("div",{className:"labs-model-version-detail",children:n.jsx("div",{className:"training-run-placeholder",children:"This training attempt is no longer available."})}):b?.kind==="evaluation"?n.jsx(Or,{run:b,runNumber:_,tasksetName:T?.name??"Unavailable",onOpenTaskset:T?()=>l(T.id):void 0,onOpenConversation:d}):n.jsxs("div",{className:"labs-model-version-detail",children:[n.jsx(kt,{title:b||g?_?`Run ${_}`:"Run details":P?`Version ${P.number}`:"Run details",description:`${We(M)} on ${lt(L,ae)}`,status:n.jsx(Dn,{status:re}),actions:fe&&(b||g)?n.jsx("button",{type:"button",className:"training-button secondary",disabled:o.busyAction!==null||re==="cancelling",onClick:async()=>{const v=b?.id??g.id,G=b?await o.actions.cancelModelRun(b.id):await o.actions.cancelJob(g.id);m({runId:v,message:G?"Cancellation requested. Waiting for the training service to confirm.":"Cancellation could not be requested. Try again."})},children:re==="cancelling"?"Cancelling…":o.busyAction==="cancel-model-run"||o.busyAction==="cancel-job"?"Requesting cancellation…":"Cancel run"}):Dt&&b?n.jsx("button",{type:"button",className:"training-button secondary",disabled:o.busyAction!==null,onClick:async()=>{const v=await o.actions.retryModelRunCollection(b.id);m({runId:b.id,message:v?.state==="succeeded"?"Outputs collected from the completed training job.":"Collection failed. The training job and its outputs are retained."})},children:o.busyAction==="retry-model-run-collection"?"Collecting…":"Retry collection"}):void 0,metrics:[{label:ge?"Training tasks":"Training steps",value:_t.value},{label:"Final reward",value:Dr(b?.reward?.raw??R?.reward.finalMean??null)},{label:"Duration",value:b?se(b.startedAt,le(b.status,b.completedAt,b.updatedAt)):g?se(g.startedAt,le(g.status,g.completedAt,g.updatedAt)):"Not recorded"},{label:"Output",value:P?`Version ${P.number}`:"No version"},{label:"Based on",value:K},{label:"Taskset",value:C,onSelect:T?()=>l(T.id):void 0,ariaLabel:T?`Open Taskset ${T.name}`:void 0}]}),p&&p.runId===(b?.id??g?.id)?n.jsx("p",{role:"status",children:p.message}):null,n.jsxs("section",{className:"labs-run-detail-tabs",children:[n.jsx("div",{className:"training-detail-tabs",role:"tablist","aria-label":"Run details",children:xe.map(v=>n.jsx("button",{"aria-controls":`run-detail-panel-${v.id}`,"aria-selected":B===v.id,className:B===v.id?"active":void 0,id:`run-detail-tab-${v.id}`,role:"tab",type:"button",onClick:()=>a(v.id),children:v.label},v.id))}),n.jsxs("div",{"aria-labelledby":`run-detail-tab-${B}`,className:"labs-run-detail-tab-panel",id:`run-detail-panel-${B}`,role:"tabpanel",children:[B===_e.id?n.jsx(xr,{baseModel:lt(L,ae),compute:b?ye(b.destinationId??""):L?ye(L.destinationId):g?ye(g.destinationId):"Not recorded",duration:b?se(b.startedAt,le(b.status,b.completedAt,b.updatedAt)):g?se(g.startedAt,le(g.status,g.completedAt,g.updatedAt)):"Not recorded",failure:g?.error??b?.failure??null,configuration:[...Fr(h,z),...zr(L)],evidence:R,method:We(M),output:P?`Version ${P.number}`:"No version created",reward:b?.reward?.raw??R?.reward.finalMean??null,status:b?Y(b.status):g?Y(g.status):"Imported",statusValue:b?.status??g?.status??"imported",taskset:C,telemetry:b?.receipt?.schemaVersion==="openpond.modelRunReceipt.v1"?b.receipt.telemetry:null,title:b||g?_?`Run ${_}`:"Run details":P?`Version ${P.number}`:"Run details",versionStatus:P?P.current?"Active":"Available":null,onOpenTaskset:T?()=>l(T.id):void 0,showHeader:!1}):null,B==="metrics"&&g?n.jsx(dr,{detail:A.detail,error:A.error,loading:A.loading,taskset:T}):null,B==="artifacts"?n.jsxs("dl",{className:"training-configuration-list",children:[n.jsx(O,{label:"Training attempt",value:g?.id??"Provider import"}),n.jsx(O,{label:"Taskset",value:C}),n.jsx(O,{label:"Prepared data",value:g?.bundleHash??"Provider managed"}),n.jsx(O,{label:"Version ID",value:P?.lineage.id??"No version created"}),R?.checkpoint?n.jsxs(n.Fragment,{children:[n.jsx(O,{label:"Checkpoint",value:R.checkpoint.id}),n.jsx(O,{label:"Checkpoint size",value:R.checkpoint.sizeBytes==null?"Not reported":$t(R.checkpoint.sizeBytes)}),n.jsx(O,{label:"Checkpoint hash",value:R.checkpoint.sha256??"Not reported"})]}):null,R?.canonicalPublication.state?n.jsx(O,{label:"Registry publication",value:Br(R.canonicalPublication.state)}):null]}):null,B==="evaluation"?n.jsxs("div",{className:"training-run-evaluation",children:[!R?.evaluations.length||A.detail?.evaluation?n.jsx(Va,{detail:A.detail,loading:A.loading,pending:fe}):null,!A.detail?.evaluation&&R?.evaluations.length?n.jsx("dl",{className:"labs-inline-facts",children:R.evaluations.map(v=>n.jsxs(u.Fragment,{children:[n.jsx(O,{label:v.kind==="baseline"?"Baseline score":"Candidate score",value:v.score==null?"Not reported":v.score.toFixed(6)}),n.jsx(O,{label:v.kind==="baseline"?"Baseline coverage":"Candidate coverage",value:v.taskCount==null?"Not reported":v.targetTaskCount==null?`${v.taskCount} ${v.taskCount===1?"task":"tasks"} scored`:`${v.taskCount} of ${v.targetTaskCount} ${v.targetTaskCount===1?"task":"tasks"} scored`})]},`${v.kind}:${v.policyVersion}`))}):null,P&&g?.destinationId==="openpond_managed"?n.jsx(Qe,{connection:e,lineageId:P.lineage.id,onSaved:o.refresh},P.lineage.id):null,!P&&g?.metadata.source==="hosted_model_project_import"&&g.status==="succeeded"?n.jsx(Qe,{connection:e,jobId:g.id,onSaved:o.refresh},`candidate:${g.id}`):null,g&&R?.evaluations.length?n.jsx(Ga,{connection:e,jobId:g.id,evaluations:R.evaluations},g.id):null,H?n.jsx("button",{className:"training-button secondary",type:"button",onClick:()=>{o.actions.downloadArtifact(H)},children:"Download evaluation receipt"}):null]}):null,B==="rollouts"?he.length?n.jsx(_a,{receipts:he}):n.jsx(Fa,{events:A.detail?.events??[]}):null,B==="activity"&&g?n.jsx(Pr,{error:g.error??A.error,events:A.detail?.events??[],loading:A.loading,pending:fe}):null]})]})]})}function $r(e,t){const a=Math.max(0,Math.floor(e));if(t===null||!Number.isFinite(t)||t<=0)return{value:a.toLocaleString(),hint:a===1?"completed update":"completed updates"};const r=Math.max(1,Math.floor(t));return{value:`${a.toLocaleString()} / ${r.toLocaleString()}`,hint:"completed / planned"}}function Lr(e){const t=e?.rolloutProgress;if(!t||typeof t!="object"||Array.isArray(t))return null;const a=t;return["groupsCompleted","groupsTarget","optimizerUpdatesApplied","optimizerUpdatesSkipped"].some(s=>typeof a[s]!="number"||!Number.isInteger(a[s])||a[s]<0)?null:{groupsCompleted:a.groupsCompleted,groupsTarget:a.groupsTarget,optimizerUpdatesApplied:a.optimizerUpdatesApplied,optimizerUpdatesSkipped:a.optimizerUpdatesSkipped}}function Or({run:e,runNumber:t,tasksetName:a,onOpenTaskset:r,onOpenConversation:s}){const[i,o]=u.useState("results"),l=e.receipt?.schemaVersion==="openpond.modelEvaluationReceipt.v1"?e.receipt:null,d=e.receipt?.schemaVersion==="openpond.modelEvaluationStopReceipt.v1"?e.receipt:null,c=l?zn(l):null,h=l?Me(l):null;return n.jsxs("div",{className:"labs-model-version-detail labs-model-evaluation-detail",children:[n.jsx(kt,{title:t?`Eval ${t}`:"Evaluation run",description:`Harness Refiner benchmark · ${a}`,status:n.jsx(Oe,{label:l?h?.comparedTaskCount?`${h.passedTaskCount}/${h.comparedTaskCount} passed`:"No paired result":d?"Inconclusive":Y(e.status),value:l?h?.comparedTaskCount&&h.passed?"succeeded":"neutral":d?.terminalClassification??e.status}),metrics:[{label:"Baseline pass rate",value:l?`${(l.quality.baselinePassRate*100).toFixed(1)}%`:"—"},{label:"Candidate pass rate",value:l?`${(l.quality.candidatePassRate*100).toFixed(1)}%`:"—"},{label:"Scenarios",value:l?.attempts?.length??0},{label:"Execution",value:Y(e.status)}]}),n.jsx("div",{className:"training-detail-tabs",role:"tablist","aria-label":"Evaluation details",children:["results","scenarios","activity"].map(p=>n.jsx("button",{className:i===p?"active":void 0,"aria-selected":i===p,role:"tab",type:"button",onClick:()=>o(p),children:p==="results"?"Results":p==="scenarios"?"Scenarios":"Activity"},p))}),i==="results"&&l?n.jsxs(n.Fragment,{children:[n.jsx(qe,{series:[{id:"baseline",label:"Held-out baseline",inputTokens:c.baseline.inputTokens,outputTokens:c.baseline.outputTokens,tokens:c.baseline.totalTokens,passRate:l.quality.baselinePassRate,costUsd:c.baseline.costUsd},{id:"candidate",label:"Held-out refined",inputTokens:c.candidate.inputTokens,outputTokens:c.candidate.outputTokens,tokens:c.candidate.totalTokens,passRate:l.quality.candidatePassRate,costUsd:c.candidate.costUsd}]}),n.jsx(qe,{series:[{id:"adaptation-baseline",label:"Adaptation baseline",inputTokens:c.adaptation.inputTokens,outputTokens:c.adaptation.outputTokens,tokens:c.adaptation.totalTokens,passRate:l.quality.adaptationBaselinePassRate,costUsd:c.adaptation.costUsd},{id:"adaptation-candidate",label:"Adaptation replay",inputTokens:c.candidate_adaptation.inputTokens,outputTokens:c.candidate_adaptation.outputTokens,tokens:c.candidate_adaptation.totalTokens,passRate:l.quality.adaptationCandidatePassRate,costUsd:c.candidate_adaptation.costUsd}]}),n.jsx(Cr,{receipt:l,run:e,tasksetName:a,onOpenTaskset:r})]}):i==="results"&&d?n.jsx(kr,{receipt:d,onOpenConversation:s}):i==="results"?n.jsx("section",{className:"labs-run-summary-card",children:e.failure?n.jsx("p",{className:"training-run-placeholder",children:e.failure}):n.jsx(Nr,{run:e})}):null,i==="scenarios"&&l?n.jsxs(n.Fragment,{children:[(l.attempts??[]).length?n.jsx(wr,{receipt:l}):null,(l.attempts??[]).length?n.jsx(Rt,{receipt:l,onOpenConversation:s}):n.jsx("div",{className:"training-run-placeholder",children:"No per-scenario attempts were retained."})]}):null,i==="activity"?n.jsxs("dl",{className:"labs-inline-facts",children:[n.jsx(O,{label:"Run ID",value:e.id}),n.jsx(O,{label:"Status",value:Y(e.status)}),n.jsx(O,{label:"Started",value:e.startedAt?Se(e.startedAt):"Not started"}),n.jsx(O,{label:"Completed",value:e.completedAt?Se(e.completedAt):"In progress"})]}):null]})}function lt(e,t=null){if(!e)return t?ot(t):"Not recorded";const a=e.recipe.method==="sft"||e.recipe.method==="grpo"?e.recipe.baseModel:e.recipe.method==="dpo"?e.recipe.policyModel:e.recipe.method==="ppo"?e.recipe.policyOptimization.policyModel:null;return a?ot(a.id):"Not recorded"}function Mr(e){const t=e?.trainingMethod;return t==="sft"||t==="dpo"||t==="grpo"||t==="ppo"||t==="sdft"||t==="opd"||t==="opsd"||t==="sdpo"?t:null}function ot(e){return e.split("/").at(-1)??e}function Dr(e){return e===null?"Not reported":e.toFixed(4)}function zr(e){if(!e)return[];const t=e.recipe;return t.method==="grpo"?[{label:"LoRA rank",value:String(t.lora.rank)},{label:"Learning rate",value:ct(t.optimizer.learningRate)},{label:"Optimizer steps",value:String(t.optimizer.maxSteps)},{label:"Rollouts per update",value:String(t.rollout.groupSize)},{label:"Rollout concurrency",value:String(t.rollout.concurrency)},{label:"Max output tokens",value:t.rollout.maxOutputTokens.toLocaleString()},{label:"Temperature",value:String(t.rollout.temperature)},{label:"Top P",value:String(t.rollout.topP)}]:t.method==="sft"||t.method==="dpo"?[{label:"LoRA rank",value:String(t.lora.rank)},{label:"Learning rate",value:ct(t.optimizer.learningRate)},{label:"Optimizer steps",value:String(t.optimizer.maxSteps)}]:[]}function Fr(e,t){if(!e||!t)return[];if(t.parent.kind==="base_model")return[{label:"Starting checkpoint",value:`Frozen base · ${t.parent.revision}`},{label:"Optimizer",value:"Fresh"}];const a=e.modelVersions.find(i=>i.id===t.parent.id);return[{label:"Starting checkpoint",value:[e.comparisonSeriesEntries.find(i=>i.seriesId===t.seriesId&&i.modelVersionId===t.parent.id)?.label??null,a?`Version ${a.version}`:t.parent.id].filter(i=>!!i).join(" · ")},{label:"Optimizer",value:"Fresh"}]}function _r(e,t){if(!e||!t||t.parent.kind==="base_model")return"Frozen base";const a=e.comparisonSeriesEntries.find(s=>s.seriesId===t.seriesId&&s.modelVersionId===t.parent.id),r=e.modelVersions.find(s=>s.id===t.parent.id);return[a?.label??"Prior checkpoint",r?`Version ${r.version}`:null].filter(s=>!!s).join(" · ")}function ct(e){return e===0?"0":e.toExponential(2)}function O({label:e,value:t}){return n.jsxs("div",{children:[n.jsx("dt",{children:e}),n.jsx("dd",{children:t})]})}function Br(e){return e?e.replaceAll("_"," ").replace(/^./,t=>t.toUpperCase()):"Pending"}export{ri as LabModelVersionDetailPage,Ar as eventSummary,$r as formatTrainingProgress,Lr as managedRolloutProgress};
@@ -1 +1 @@
1
- import{r as n,j as e}from"./index-Dvq7bpBG.js";import{o as g,b8 as z,X as y,aL as w,i as L}from"./App-BOkhmdHu.js";import{F as C}from"./chat-file-links-Bned0MT7.js";import{I as k}from"./MainPane-BbknUzp3.js";import{M as F}from"./minimize-2-DeYg7XqB.js";import"./cloud-upload-CsrrwS-b.js";import"./arrow-up-right-4nAzMtjW.js";import"./square-LY3oz82L.js";function H({connection:a,expanded:l,selection:s,onClose:j,onResizeStart:h,onToggleExpanded:v}){const c=`${s.scope}:${s.name}`,[o,N]=n.useState({selectionKey:c,path:s.files[0]??"SKILL.md"}),r=o.selectionKey===c&&s.files.includes(o.path)?o.path:s.files[0]??"SKILL.md",[d,u]=n.useState(null),[m,p]=n.useState(null),[S,f]=n.useState(!1);n.useEffect(()=>{if(!a){u(null),p("Connect to the local OpenPond server to load this skill source.");return}let i=!1;return f(!0),p(null),u(null),g.skillSourceFile(a,s.scope,s.name,r).then(t=>{i||u(t)}).catch(t=>{i||p(t instanceof Error?t.message:String(t))}).finally(()=>{i||f(!1)}),()=>{i=!0}},[a,r,s.name,s.scope]);const x=r.split("/").at(-1)??r;return e.jsxs("aside",{className:`workspace-diff-panel native-skill-sidebar lab-skill-sidebar ${l?"expanded":""}`,"aria-label":`Skill package source: ${s.name}`,children:[l?null:e.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize skill source",onPointerDown:h}),e.jsxs("div",{className:"workspace-diff-topbar native-skill-sidebar-topbar",children:[e.jsx("div",{className:"workspace-diff-tabs",role:"tablist","aria-label":"Selected skill file",children:e.jsxs("button",{className:"workspace-diff-tab active",type:"button",role:"tab","aria-selected":!0,children:[e.jsx(b,{path:r}),e.jsx("span",{children:x})]})}),e.jsxs("div",{className:"workspace-diff-toolbar-actions",children:[e.jsx("button",{className:"diff-icon-button",type:"button",title:l?"Dock sidebar":"Expand sidebar","aria-label":l?"Dock sidebar":"Expand sidebar",onClick:v,children:l?e.jsx(F,{size:14}):e.jsx(z,{size:14})}),e.jsx("button",{className:"diff-icon-button",type:"button",title:"Close skill source","aria-label":"Close skill source",onClick:j,children:e.jsx(y,{size:14})})]})]}),e.jsxs("div",{className:"lab-skill-source-layout",children:[e.jsxs("nav",{className:"lab-skill-file-list","aria-label":`${s.name} package files`,children:[e.jsx("div",{className:"lab-skill-file-list-heading",children:"Package files"}),s.files.map(i=>e.jsxs("button",{"aria-current":i===r?"page":void 0,className:i===r?"active":void 0,type:"button",title:i,onClick:()=>N({selectionKey:c,path:i}),children:[e.jsx(b,{path:i}),e.jsx("span",{children:i})]},i))]}),e.jsxs("div",{className:"native-skill-sidebar-body lab-skill-source-body",children:[e.jsxs("header",{className:"native-skill-source-header",children:[e.jsxs("div",{className:"lab-skill-source-title-row",children:[e.jsx("h2",{children:s.name}),e.jsx("span",{children:$(s.scope)})]}),e.jsx("p",{children:s.description}),e.jsx("code",{children:s.packagePath})]}),S?e.jsxs("div",{className:"lab-skill-source-state",children:[e.jsx(w,{className:"spin",size:16})," Loading source…"]}):m?e.jsx("div",{className:"lab-skill-source-state error",children:m}):d?.isBinary?e.jsxs("div",{className:"lab-skill-source-state",children:[e.jsx(k,{size:18}),"Binary asset · ",B(d.byteSize)]}):e.jsx("pre",{className:"native-skill-markdown-source","aria-label":`${x} source`,children:e.jsx("code",{children:d?.content??""})})]})]})]})}function $(a){return a==="codex"?"Codex skill":a==="extension"?"GitHub extension":"OpenPond skill"}function b({path:a}){const l=a.split(".").at(-1)?.toLowerCase();return["avif","gif","jpeg","jpg","png","webp"].includes(l??"")?e.jsx(k,{size:14}):["md","txt","yaml","yml"].includes(l??"")?e.jsx(L,{size:14}):e.jsx(C,{size:14})}function B(a){return a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`}export{H as LabSkillSidebar};
1
+ import{r as n,j as e}from"./index-KwyAyscP.js";import{o as g,bg as z,X as y,aS as w,i as L}from"./App-DxecRQUL.js";import{F as C}from"./chat-file-links-B3jDstSC.js";import{I as k}from"./MainPane-BWwcxgHD.js";import{M as F}from"./minimize-2-DzHQnInk.js";import"./cloud-upload-D2he0-vQ.js";import"./arrow-up-right-rwPXNfVn.js";import"./square-DKQkcrOH.js";function H({connection:a,expanded:l,selection:s,onClose:j,onResizeStart:h,onToggleExpanded:v}){const c=`${s.scope}:${s.name}`,[o,N]=n.useState({selectionKey:c,path:s.files[0]??"SKILL.md"}),r=o.selectionKey===c&&s.files.includes(o.path)?o.path:s.files[0]??"SKILL.md",[d,u]=n.useState(null),[m,p]=n.useState(null),[S,f]=n.useState(!1);n.useEffect(()=>{if(!a){u(null),p("Connect to the local OpenPond server to load this skill source.");return}let i=!1;return f(!0),p(null),u(null),g.skillSourceFile(a,s.scope,s.name,r).then(t=>{i||u(t)}).catch(t=>{i||p(t instanceof Error?t.message:String(t))}).finally(()=>{i||f(!1)}),()=>{i=!0}},[a,r,s.name,s.scope]);const x=r.split("/").at(-1)??r;return e.jsxs("aside",{className:`workspace-diff-panel native-skill-sidebar lab-skill-sidebar ${l?"expanded":""}`,"aria-label":`Skill package source: ${s.name}`,children:[l?null:e.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize skill source",onPointerDown:h}),e.jsxs("div",{className:"workspace-diff-topbar native-skill-sidebar-topbar",children:[e.jsx("div",{className:"workspace-diff-tabs",role:"tablist","aria-label":"Selected skill file",children:e.jsxs("button",{className:"workspace-diff-tab active",type:"button",role:"tab","aria-selected":!0,children:[e.jsx(b,{path:r}),e.jsx("span",{children:x})]})}),e.jsxs("div",{className:"workspace-diff-toolbar-actions",children:[e.jsx("button",{className:"diff-icon-button",type:"button",title:l?"Dock sidebar":"Expand sidebar","aria-label":l?"Dock sidebar":"Expand sidebar",onClick:v,children:l?e.jsx(F,{size:14}):e.jsx(z,{size:14})}),e.jsx("button",{className:"diff-icon-button",type:"button",title:"Close skill source","aria-label":"Close skill source",onClick:j,children:e.jsx(y,{size:14})})]})]}),e.jsxs("div",{className:"lab-skill-source-layout",children:[e.jsxs("nav",{className:"lab-skill-file-list","aria-label":`${s.name} package files`,children:[e.jsx("div",{className:"lab-skill-file-list-heading",children:"Package files"}),s.files.map(i=>e.jsxs("button",{"aria-current":i===r?"page":void 0,className:i===r?"active":void 0,type:"button",title:i,onClick:()=>N({selectionKey:c,path:i}),children:[e.jsx(b,{path:i}),e.jsx("span",{children:i})]},i))]}),e.jsxs("div",{className:"native-skill-sidebar-body lab-skill-source-body",children:[e.jsxs("header",{className:"native-skill-source-header",children:[e.jsxs("div",{className:"lab-skill-source-title-row",children:[e.jsx("h2",{children:s.name}),e.jsx("span",{children:$(s.scope)})]}),e.jsx("p",{children:s.description}),e.jsx("code",{children:s.packagePath})]}),S?e.jsxs("div",{className:"lab-skill-source-state",children:[e.jsx(w,{className:"spin",size:16})," Loading source…"]}):m?e.jsx("div",{className:"lab-skill-source-state error",children:m}):d?.isBinary?e.jsxs("div",{className:"lab-skill-source-state",children:[e.jsx(k,{size:18}),"Binary asset · ",B(d.byteSize)]}):e.jsx("pre",{className:"native-skill-markdown-source","aria-label":`${x} source`,children:e.jsx("code",{children:d?.content??""})})]})]})]})}function $(a){return a==="codex"?"Codex skill":a==="extension"?"GitHub extension":"OpenPond skill"}function b({path:a}){const l=a.split(".").at(-1)?.toLowerCase();return["avif","gif","jpeg","jpg","png","webp"].includes(l??"")?e.jsx(k,{size:14}):["md","txt","yaml","yml"].includes(l??"")?e.jsx(L,{size:14}):e.jsx(C,{size:14})}function B(a){return a<1024?`${a} B`:a<1048576?`${(a/1024).toFixed(1)} KB`:`${(a/1048576).toFixed(1)} MB`}export{H as LabSkillSidebar};