openpond 0.0.30-bootstrap.0

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 (193) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/LICENSE +21 -0
  3. package/README.md +162 -0
  4. package/RELEASE.md +20 -0
  5. package/dist/api/core.d.ts +22 -0
  6. package/dist/api/deployments.d.ts +30 -0
  7. package/dist/api/types.d.ts +624 -0
  8. package/dist/api.d.ts +90 -0
  9. package/dist/cache.d.ts +22 -0
  10. package/dist/chunks/app-layer-YKXEQGOW.js +163 -0
  11. package/dist/chunks/apps-GGSIN2ZF.js +539 -0
  12. package/dist/chunks/chunk-3CC6MH35.js +1663 -0
  13. package/dist/chunks/chunk-3Y4EL3P6.js +1090 -0
  14. package/dist/chunks/chunk-4HYJG2JE.js +3875 -0
  15. package/dist/chunks/chunk-5G4E547X.js +294 -0
  16. package/dist/chunks/chunk-74O6FGVN.js +598 -0
  17. package/dist/chunks/chunk-AUJLPKGI.js +632 -0
  18. package/dist/chunks/chunk-BYAPLT37.js +744 -0
  19. package/dist/chunks/chunk-FUP7EGT7.js +1845 -0
  20. package/dist/chunks/chunk-I6HN3ZGW.js +88 -0
  21. package/dist/chunks/chunk-KRKGHVMQ.js +294 -0
  22. package/dist/chunks/chunk-LHYK6QO2.js +1300 -0
  23. package/dist/chunks/chunk-NLBKZZEK.js +224 -0
  24. package/dist/chunks/chunk-OG75GMVO.js +1 -0
  25. package/dist/chunks/chunk-Q57SVPEH.js +11663 -0
  26. package/dist/chunks/chunk-UACZUFIA.js +47 -0
  27. package/dist/chunks/chunk-VQX33YAG.js +5135 -0
  28. package/dist/chunks/chunk-W5GKHH77.js +168 -0
  29. package/dist/chunks/chunk-WYDVQOBL.js +17581 -0
  30. package/dist/chunks/chunk-XSAXENQD.js +4167 -0
  31. package/dist/chunks/chunk-Y6G6WRTG.js +210 -0
  32. package/dist/chunks/cli-NVKNE4AZ.js +11 -0
  33. package/dist/chunks/cli-X3HPLSOV.js +19 -0
  34. package/dist/chunks/core-commands-IM2UKLU4.js +41 -0
  35. package/dist/chunks/extend-YXCBULPO.js +84 -0
  36. package/dist/chunks/harness-GMK6IY2U.js +140 -0
  37. package/dist/chunks/help-LMH5FGT2.js +65 -0
  38. package/dist/chunks/opchat-BWXZ32GX.js +169 -0
  39. package/dist/chunks/organizations-4ISQRGMQ.js +738 -0
  40. package/dist/chunks/profile-NLDZDT3L.js +1110 -0
  41. package/dist/chunks/project-agent-ZPVO25HA.js +892 -0
  42. package/dist/chunks/sandbox-command-5GFJ2U3V.js +1652 -0
  43. package/dist/chunks/sandbox-template-LZN4F55Z.js +1646 -0
  44. package/dist/chunks/src-3RBI4DNN.js +3595 -0
  45. package/dist/chunks/src-EYXQS6XD.js +73427 -0
  46. package/dist/chunks/teams-bot-WP3FHKGA.js +137 -0
  47. package/dist/cli.js +77 -0
  48. package/dist/client-types.d.ts +222 -0
  49. package/dist/client.d.ts +19 -0
  50. package/dist/config.d.ts +184 -0
  51. package/dist/hosted-chat.d.ts +162 -0
  52. package/dist/index.d.ts +5 -0
  53. package/dist/index.js +25481 -0
  54. package/dist/indicators.d.ts +38 -0
  55. package/dist/opchat-smoke.d.ts +47 -0
  56. package/dist/private-json-file.d.ts +3 -0
  57. package/dist/profile/local-profile-types.d.ts +160 -0
  58. package/dist/profile/local-profile.d.ts +69 -0
  59. package/dist/profile/profile-catalog.d.ts +14 -0
  60. package/dist/profile/profile-git.d.ts +17 -0
  61. package/dist/profile/profile-promotion.d.ts +21 -0
  62. package/dist/profile/profile-setup-gate.d.ts +22 -0
  63. package/dist/profile/profile-skills.d.ts +30 -0
  64. package/dist/profile/profile-source-upload.d.ts +29 -0
  65. package/dist/profile/source-upload-cache.d.ts +29 -0
  66. package/dist/sandbox/async-request-options.d.ts +2 -0
  67. package/dist/sandbox/client-handles.d.ts +113 -0
  68. package/dist/sandbox/client.d.ts +348 -0
  69. package/dist/sandbox/runtime-handle.d.ts +36 -0
  70. package/dist/sandbox/sandbox-instance-client.d.ts +72 -0
  71. package/dist/sandbox/smoke.d.ts +3 -0
  72. package/dist/sandbox/stream.d.ts +7 -0
  73. package/dist/sandbox/types/billing.d.ts +176 -0
  74. package/dist/sandbox/types/client.d.ts +103 -0
  75. package/dist/sandbox/types/core.d.ts +140 -0
  76. package/dist/sandbox/types/index.d.ts +14 -0
  77. package/dist/sandbox/types/io.d.ts +240 -0
  78. package/dist/sandbox/types/microsoft-teams-bot.d.ts +51 -0
  79. package/dist/sandbox/types/org-project-agent.d.ts +610 -0
  80. package/dist/sandbox/types/record.d.ts +53 -0
  81. package/dist/sandbox/types/responses.d.ts +295 -0
  82. package/dist/sandbox/types/runtime-profiles.d.ts +15 -0
  83. package/dist/sandbox/types/runtime.d.ts +152 -0
  84. package/dist/sandbox/types/schedules.d.ts +141 -0
  85. package/dist/sandbox/types/snapshots.d.ts +205 -0
  86. package/dist/sandbox/types/workflow-modes.d.ts +1 -0
  87. package/dist/sandbox/types/workload-sources.d.ts +20 -0
  88. package/dist/sandbox/url.d.ts +2 -0
  89. package/dist/sandbox-template/manifest.d.ts +304 -0
  90. package/dist/sandbox-template/manifest.js +18381 -0
  91. package/dist/skills/openpond-cli/SKILL.md +49 -0
  92. package/dist/skills/openpond-desktop-harness/SKILL.md +113 -0
  93. package/dist/skills/openpond-desktop-harness/agents/openai.yaml +4 -0
  94. package/dist/skills/openpond-taskset-authoring/SKILL.md +38 -0
  95. package/dist/skills/openpond-taskset-authoring/references/graders-and-rewards.md +11 -0
  96. package/dist/skills/openpond-taskset-authoring/references/method-selection.md +12 -0
  97. package/dist/skills/openpond-taskset-authoring/references/privacy-and-provenance.md +8 -0
  98. package/dist/skills/openpond-taskset-authoring/references/task-design.md +13 -0
  99. package/dist/stream.d.ts +20 -0
  100. package/dist/types.d.ts +57 -0
  101. package/dist/urls.d.ts +4 -0
  102. package/dist/web/assets/AppsView-Bu-Nc3Ew.js +1 -0
  103. package/dist/web/assets/AppsView-DIhprTIC.css +1 -0
  104. package/dist/web/assets/BrowserSidebar-CCguQ-DR.js +1 -0
  105. package/dist/web/assets/BrowserSidebar-D9i7gQzw.css +1 -0
  106. package/dist/web/assets/CloudWorkView-DNoPIlMj.css +1 -0
  107. package/dist/web/assets/CloudWorkView-Dr3xqLE5.js +1 -0
  108. package/dist/web/assets/CommandMenu-CnodJFHD.js +1 -0
  109. package/dist/web/assets/CommandMenu-hNQCm8mw.css +1 -0
  110. package/dist/web/assets/CommunityView-CIbjNUZr.js +1 -0
  111. package/dist/web/assets/CommunityView-DSik4sd2.css +1 -0
  112. package/dist/web/assets/GetStartedView-C3ZrnEz5.css +1 -0
  113. package/dist/web/assets/GetStartedView-C8nyH_PT.js +1 -0
  114. package/dist/web/assets/LabsExtensions-GtJzxDnK.js +1 -0
  115. package/dist/web/assets/LabsProfile-DG7rWYur.js +1 -0
  116. package/dist/web/assets/LabsRoute-D6MDHBzq.js +2 -0
  117. package/dist/web/assets/LabsRoute-TEt9j1vB.css +1 -0
  118. package/dist/web/assets/LabsSignals-BfsDN86w.js +1 -0
  119. package/dist/web/assets/LabsSignals-D6iA6Ryl.css +1 -0
  120. package/dist/web/assets/NewProjectDialog-CaKiCoVS.js +1 -0
  121. package/dist/web/assets/ProfileSettingsSection-DTQS2DVL.css +1 -0
  122. package/dist/web/assets/ProfileSettingsSection-DxEzoF3K.js +1 -0
  123. package/dist/web/assets/ProfileView-CEscW7Ru.js +1 -0
  124. package/dist/web/assets/SettingsView-DwbGu8Kj.css +1 -0
  125. package/dist/web/assets/SettingsView-JIRR_FO4.js +63 -0
  126. package/dist/web/assets/TeamChatView-B5M1ThhJ.js +3 -0
  127. package/dist/web/assets/TeamChatView-Bx44q3WV.css +1 -0
  128. package/dist/web/assets/TerminalOverlay-C1iP4OS1.js +19 -0
  129. package/dist/web/assets/TerminalOverlay-DwBiZLwk.css +1 -0
  130. package/dist/web/assets/TrainingSettingsSection-BDYvI2te.js +1 -0
  131. package/dist/web/assets/TrainingView-CoCFK6W3.js +5 -0
  132. package/dist/web/assets/WorkspaceDiffPanel-CMxKQeo7.js +14 -0
  133. package/dist/web/assets/WorkspaceEnvironmentMenu-B8JJbwIz.js +32 -0
  134. package/dist/web/assets/WorkspaceEnvironmentMenu-DGIFdG3o.css +1 -0
  135. package/dist/web/assets/WorkspaceGitDialogs-B4sp9BGn.js +1 -0
  136. package/dist/web/assets/WorkspaceMonacoEditor-BBqimG5X.js +845 -0
  137. package/dist/web/assets/WorkspaceMonacoEditor-BwKcXIZw.css +1 -0
  138. package/dist/web/assets/boxes-DAaDUabq.js +1 -0
  139. package/dist/web/assets/codicon-ngg6Pgfi.ttf +0 -0
  140. package/dist/web/assets/css.worker-DBVD8oXr.js +93 -0
  141. package/dist/web/assets/cssMode-CBF1mieJ.js +1 -0
  142. package/dist/web/assets/dockerfile-BG73LgW2.js +1 -0
  143. package/dist/web/assets/editor.worker-CdQrwHl8.js +26 -0
  144. package/dist/web/assets/git-commit-horizontal-CAickXpN.js +1 -0
  145. package/dist/web/assets/git-dialogs-BZDqS1eT.css +1 -0
  146. package/dist/web/assets/html.worker-CwpTb9lJ.js +470 -0
  147. package/dist/web/assets/htmlMode-2u8OHtWO.js +1 -0
  148. package/dist/web/assets/index-BdY6A-YN.css +1 -0
  149. package/dist/web/assets/index-CU2qhUYV.js +195 -0
  150. package/dist/web/assets/index-Dz2B3-4C.js +1 -0
  151. package/dist/web/assets/info-CQNTh78o.js +1 -0
  152. package/dist/web/assets/json.worker-BoL8UZqY.js +58 -0
  153. package/dist/web/assets/jsonMode-C4CWXViX.js +7 -0
  154. package/dist/web/assets/lspLanguageFeatures-CBs_BOlB.js +4 -0
  155. package/dist/web/assets/markdown-BFxVWTOG.js +1 -0
  156. package/dist/web/assets/monaco.contribution-C1LUxAKf.js +2 -0
  157. package/dist/web/assets/monaco.contribution-Cpf6dWsh.js +2 -0
  158. package/dist/web/assets/monaco.contribution-lOXpG2xQ.js +2 -0
  159. package/dist/web/assets/monaco.contribution-sd3cFkcN.js +2 -0
  160. package/dist/web/assets/monitor-DsIswrMV.js +1 -0
  161. package/dist/web/assets/play-CeRw21NV.js +1 -0
  162. package/dist/web/assets/python-CXYq3BUl.js +1 -0
  163. package/dist/web/assets/refresh-cw-N5b_6AP5.js +1 -0
  164. package/dist/web/assets/reply-BSKjZrJg.js +1 -0
  165. package/dist/web/assets/save-D0oHH1a3.js +1 -0
  166. package/dist/web/assets/settings-lists-BEg6LMcy.css +1 -0
  167. package/dist/web/assets/shell-DiJ1NA_G.js +1 -0
  168. package/dist/web/assets/toggleHighContrast-B7NOMXDY.css +1 -0
  169. package/dist/web/assets/toggleHighContrast-DRjlcwes.js +62 -0
  170. package/dist/web/assets/training-model-data-BPrc68VG.js +1 -0
  171. package/dist/web/assets/ts.worker-BH9nVgjN.js +67718 -0
  172. package/dist/web/assets/tsMode-x-1A7ZcB.js +11 -0
  173. package/dist/web/assets/wifi-off-Dt52ofzh.js +1 -0
  174. package/dist/web/assets/workers-Ciff6Dzi.js +1 -0
  175. package/dist/web/assets/yaml-CB67Kxnz.js +1 -0
  176. package/dist/web/connected-apps/github.svg +3 -0
  177. package/dist/web/connected-apps/google.svg +6 -0
  178. package/dist/web/connected-apps/linear.svg +3 -0
  179. package/dist/web/connected-apps/microsoft.svg +6 -0
  180. package/dist/web/connected-apps/notion.svg +3 -0
  181. package/dist/web/connected-apps/openpond-mcp.svg +4 -0
  182. package/dist/web/connected-apps/slack.svg +6 -0
  183. package/dist/web/connected-apps/x.svg +3 -0
  184. package/dist/web/favicon-16x16.png +0 -0
  185. package/dist/web/favicon-32x32.png +0 -0
  186. package/dist/web/index.html +16 -0
  187. package/dist/web/openpond-icon.png +0 -0
  188. package/dist/web/openpond-wordlogo-white.png +0 -0
  189. package/dist/web/tokens/eth.svg +1 -0
  190. package/dist/web/tokens/usdc.svg +1 -0
  191. package/docs/agent-edit-check-status-json.md +132 -0
  192. package/docs/command-reference.md +695 -0
  193. package/package.json +84 -0
@@ -0,0 +1 @@
1
+ .guake-terminal-overlay{position:relative;z-index:30;min-width:0;min-height:0;height:0;pointer-events:none;overflow:hidden}.main-pane.terminal-open>.guake-terminal-overlay{height:100%}.guake-terminal-panel{display:grid;grid-template-rows:38px minmax(0,1fr);width:100%;height:100%;min-height:0;border-top:1px solid var(--border);background:var(--bg);box-shadow:none;color:var(--text);opacity:0;pointer-events:none;transform:translateY(100%);transition:transform .19s ease,opacity .12s ease,visibility 0s linear .19s;visibility:hidden}.guake-terminal-overlay.open .guake-terminal-panel{box-shadow:0 -18px 48px #0000006b;opacity:1;pointer-events:auto;transform:translateY(0);transition:transform .19s ease,opacity .12s ease;visibility:visible;-webkit-app-region:no-drag;app-region:no-drag}.guake-terminal-tabs{display:flex;align-items:center;min-width:0;gap:7px;border-bottom:1px solid var(--border);background:var(--bg);padding:5px 8px}.guake-terminal-tab-list{display:flex;align-items:center;min-width:0;max-width:min(64vw,760px);gap:4px;overflow-x:auto;scrollbar-width:none}.guake-terminal-tab-list::-webkit-scrollbar{display:none}.guake-terminal-tab{display:inline-flex;align-items:center;min-width:118px;max-width:188px;height:28px;flex:0 0 auto;border:0;border-radius:7px;background:transparent;color:#9d9d9d;overflow:hidden}.guake-terminal-tab.active,.guake-terminal-tab:hover{background:#ffffff14;color:#f1f1f1}.guake-terminal-tab-main{display:inline-flex;align-items:center;min-width:0;height:100%;flex:1 1 auto;gap:7px;border:0;background:transparent;color:inherit;padding:0 6px 0 8px}.terminal-status-dot{width:7px;height:7px;flex:0 0 7px;border-radius:999px;background:#7b8492}.terminal-status-dot.running{background:#62d26f}.terminal-status-dot.connecting{background:#f5c451}.terminal-status-dot.exited,.terminal-status-dot.error{background:#ff706a}.guake-terminal-tab-title{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;font-weight:500}.guake-terminal-tab-close,.guake-terminal-icon-button{display:inline-grid;place-items:center;flex:0 0 auto;border:0;background:transparent;color:#8d8d8d;padding:0}.guake-terminal-tab-close{width:24px;height:100%}.guake-terminal-tab-close:hover,.guake-terminal-icon-button:hover{color:#f3f3f3;background:#ffffff14}.guake-terminal-icon-button{width:28px;height:28px;border-radius:7px}.guake-terminal-spacer{flex:1 1 auto;min-width:10px}.guake-terminal-cwd,.guake-terminal-error{min-width:0;max-width:min(38vw,560px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}.guake-terminal-cwd{color:var(--muted)}.guake-terminal-error{color:#ff8a86}.guake-terminal-body{position:relative;min-width:0;min-height:0;background:#0f0f0f}.guake-terminal-pane{position:absolute;inset:0;min-width:0;min-height:0;opacity:0;pointer-events:none;visibility:hidden}.guake-terminal-pane.active{opacity:1;pointer-events:auto;visibility:visible}.guake-terminal-pane .xterm{height:100%;padding:10px 12px}.guake-terminal-pane .xterm-viewport{scrollbar-color:rgba(255,255,255,.28) transparent}.guake-terminal-pane .xterm-viewport::-webkit-scrollbar{width:10px}.guake-terminal-pane .xterm-viewport::-webkit-scrollbar-track{background:transparent}.guake-terminal-pane .xterm-viewport::-webkit-scrollbar-thumb{border:3px solid #0f0f0f;border-radius:999px;background:#ffffff42}.guake-terminal-empty{position:absolute;top:50%;left:50%;display:inline-flex;align-items:center;gap:8px;border:1px solid rgba(255,255,255,.1);border-radius:8px;background:var(--panel-soft);color:var(--text);padding:8px 11px;transform:translate(-50%,-50%)}.guake-terminal-empty:hover{border-color:#ffffff24;background:var(--panel-hover)}@media(max-width:760px){.main-pane{--terminal-panel-height: clamp(200px, 42vh, 360px)}.guake-terminal-tab-list{max-width:calc(100vw - 116px)}.guake-terminal-tab{min-width:104px;max-width:148px}.guake-terminal-cwd,.guake-terminal-error{display:none}}.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;inset:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{position:absolute;inset:0;z-index:10;color:transparent;pointer-events:none}.xterm .xterm-accessibility-tree:not(.debug) *::selection{color:transparent}.xterm .xterm-accessibility-tree{font-family:monospace;-webkit-user-select:text;user-select:text;white-space:pre}.xterm .xterm-accessibility-tree>div{transform-origin:left;width:fit-content}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;background:#0000;transition:opacity .1s linear;z-index:11}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{position:absolute;display:none}.xterm .xterm-scrollable-element>.shadow.top{display:block;top:0;left:3px;height:3px;width:100%;box-shadow:var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.left{display:block;top:3px;left:0;height:100%;width:3px;box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}.xterm .xterm-scrollable-element>.shadow.top-left-corner{display:block;top:0;left:0;height:3px;width:3px}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset}
@@ -0,0 +1 @@
1
+ import{r as o,z as R,A as T,bv as k,j as e,B as y,G as C,m as O}from"./index-CU2qhUYV.js";const v="default";function z({connection:s,embedded:t=!1,onError:f,onPreferences:S,preferences:i,providers:l}){const n=i.training,[m,p]=o.useState(g(n.defaultModelRef)),[u,x]=o.useState(n.creationMode),[h,j]=o.useState(n.autoApproveEvidence),[c,M]=o.useState(!1),b=o.useMemo(()=>R(l,{includeUnavailable:!0}),[l]),N=o.useMemo(()=>b.map(a=>({provider:a,models:T(a.value,l)})).filter(a=>a.models.length>0),[b,l]),d=P(m),A=k(i.defaultChatProvider,i.defaultChatModel,l)?` · ${w(i.codexReasoningEffort)} reasoning`:"",I=U(d,n.defaultModelRef??null)&&u===n.creationMode&&h===n.autoApproveEvidence;o.useEffect(()=>{p(g(n.defaultModelRef)),x(n.creationMode),j(n.autoApproveEvidence)},[i.defaultChatModel,i.defaultChatProvider,n.autoApproveEvidence,n.creationMode,n.defaultModelRef]);async function E(a){if(a.preventDefault(),!!s){M(!0),f(null);try{S(await O.savePreferences(s,{training:{defaultModelRef:d,creationMode:u,autoApproveEvidence:h}}))}catch(r){f(r instanceof Error?r.message:String(r))}finally{M(!1)}}}return e.jsxs("section",{className:`account-settings training-settings${t?" embedded":""}`,children:[t?null:e.jsx("h1",{children:"Training"}),e.jsxs("form",{className:"provider-settings-form",onSubmit:a=>{E(a)},children:[e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Taskset authoring"}),e.jsx("small",{children:"The coding model that proposes tasks, graders, fixtures, and policy boundaries"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Authoring model"}),e.jsxs("select",{value:m,disabled:c,onChange:a=>p(a.target.value),children:[e.jsxs("option",{value:v,children:["Use chat default — ",y(i.defaultChatProvider,l)," · ",C(i.defaultChatModel,l,i.defaultChatProvider),A]}),N.map(a=>e.jsx("optgroup",{label:a.provider.label,children:a.models.map(r=>e.jsx("option",{value:g({providerId:a.provider.value,modelId:r.value}),children:r.label},r.value))},a.provider.value))]}),e.jsx("small",{children:"By default, /train follows the same provider, model, and reasoning level selected for chat."})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Default flow"}),e.jsx("small",{children:"Used by /train and Task Creator unless you choose another mode"})]}),e.jsx("div",{className:"provider-settings-grid single",children:e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Task Creator mode"}),e.jsxs("select",{value:u,disabled:c,onChange:a=>x(a.target.value),children:[e.jsx("option",{value:"customize",children:"Guided plan — review and revise before materializing"}),e.jsx("option",{value:"defaults",children:"Fast draft — use reversible defaults"})]})]})}),e.jsxs("div",{className:"account-list-heading",children:[e.jsx("span",{children:"Evidence confirmation"}),e.jsx("small",{children:"Controls the first authoring gate; materialization and training remain separate"})]}),e.jsxs("label",{className:"settings-check-row",children:[e.jsx("input",{type:"checkbox",checked:h,disabled:c,onChange:a=>j(a.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:"Skip evidence confirmation"}),e.jsx("small",{children:"Immediately send excerpts from explicitly selected chats to the authoring model. This never approves Taskset materialization or training spend."})]})]}),e.jsx("button",{className:"settings-primary",disabled:c||I,children:e.jsx("span",{children:c?"Saving":"Save training settings"})})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Authoring model"}),e.jsx("strong",{children:d?`${y(d.providerId,l)} / ${C(d.modelId,l,d.providerId)}`:"Chat default"})]}),e.jsxs("div",{className:"settings-footnote",children:[e.jsx("span",{children:"Safety boundary"}),e.jsx("strong",{children:"Taskset and training approvals always required"})]})]})}function g(s){return s?JSON.stringify([s.providerId,s.modelId]):v}function P(s){if(s===v)return null;try{const t=JSON.parse(s);return!Array.isArray(t)||t.length!==2||typeof t[0]!="string"||typeof t[1]!="string"?null:{providerId:t[0],modelId:t[1]}}catch{return null}}function w(s){return`${s.slice(0,1).toUpperCase()}${s.slice(1)}`}function U(s,t){return s?.providerId===t?.providerId&&s?.modelId===t?.modelId}export{z as T};
@@ -0,0 +1,5 @@
1
+ import{r as c,j as e,N as ne,br as _e,bs as on,m as cn,X as Fe,v as Un,M as Gn,bt as Kn,aS as Vn,bu as dn,z as Wn,A as Jn,bv as Qn,S as un,D as We,bw as Xn,a as Yn,bx as Zn,U as et,a8 as nt,ba as tt,t as st,by as at}from"./index-CU2qhUYV.js";import{P as it}from"./play-CeRw21NV.js";import{R as rt}from"./refresh-cw-N5b_6AP5.js";import{j as lt,p as Je,c as ot,t as ct,a as Qe,m as dt,s as Me,d as Re,f as hn,b as ut,e as ht}from"./training-model-data-BPrc68VG.js";import{T as mt}from"./TrainingSettingsSection-BDYvI2te.js";/* empty css */const Te=8,Xe=24,pt=2;function gt(n){const t=jt(n);if(t.length){const u=Xe+t.reduce((r,f)=>r+Te+ce(f.content),0),o=t.filter(r=>r.role==="assistant").map(r=>Te+ce(r.content));return{renderedTokens:u,maximumAssistantTargetTokens:Math.max(0,...o),assistantTargetCount:o.length}}const s=vt(n.input),a=bt(n.expectedOutput);return{renderedTokens:Xe+ce(s)+ce(a),maximumAssistantTargetTokens:Te+ce(a),assistantTargetCount:a?1:0}}function xt(n,t={}){const s=t.minimum??64,a=t.maximum??4096,u=n.tasks.filter(o=>o.split==="train").reduce((o,r)=>Math.max(o,gt(r).renderedTokens),0);return u<=s?s:Math.min(a,2**Math.ceil(Math.log2(u)))}function jt(n){const t=[...Ye(n.input.messages),...Ye(n.expectedOutput?.messages)],s=[],a=new Map,u=o=>{const r=typeof o=="string"&&o?o:`missing_${a.size+1}`;return a.has(r)||a.set(r,`call_${a.size+1}`),a.get(r)};for(const o of t){if(!xe(o))continue;const r=o.role,f=o.content;if(r==="tool"){s.push({role:"user",content:fe({content:typeof f=="string"?f:"",tool_call_id:u(o.tool_call_id),type:"tool_result"})});continue}if(r==="assistant"&&Array.isArray(o.tool_calls)&&o.tool_calls.length){for(const d of o.tool_calls)!xe(d)||!xe(d.function)||(s.push({role:"assistant",content:fe({arguments:ft(d.function.arguments),name:d.function.name??null,type:"tool_call"})}),u(d.id));typeof f=="string"&&f&&s.push({role:"assistant",content:f});continue}(r==="system"||r==="user"||r==="assistant")&&typeof f=="string"&&f&&s.push({role:r,content:f})}return s}function Ye(n){return Array.isArray(n)?n:[]}function ft(n){if(typeof n!="string")return{};try{return JSON.parse(n)}catch{return{malformed_arguments:n}}}function fe(n){return JSON.stringify(Ee(n))}function Ee(n){return Array.isArray(n)?n.map(Ee):xe(n)?Object.fromEntries(Object.keys(n).sort().map(t=>[t,Ee(n[t])])):n}function vt(n){return typeof n.prompt=="string"?n.prompt:fe(n)}function bt(n){return n?typeof n.text=="string"?n.text:fe(n):""}function ce(n){return Math.ceil(n.length/pt)}function xe(n){return!!(n&&typeof n=="object"&&!Array.isArray(n))}function yt({taskset:n,training:t,onOpenChat:s}){const a=c.useRef(null),u=n.readiness?.tasksetHash===n.contentHash,o=n.learningSignals.demonstrations.filter(d=>d.approved).length,r=n.tasks.filter(d=>d.split==="frozen_eval").length,f=n.readiness?.recommendedMethod&&n.readiness.recommendedMethod!=="none"?n.readiness.recommendedMethod:n.capabilities.compatibleMethods.find(d=>!["none","retrieval"].includes(d))??"none";return c.useEffect(()=>{if(u)return;const d=`${n.id}:${n.contentHash}`;a.current!==d&&(a.current=d,t.actions.readiness(n.id))},[u,n.contentHash,n.id,t.actions]),e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"training-taskset-facts","aria-label":"Taskset summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Method"}),e.jsx("dd",{children:f.toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Training examples"}),e.jsx("dd",{children:o})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Test examples"}),e.jsx("dd",{children:r})]})]}),e.jsxs("div",{className:"training-taskset-content",children:[e.jsx("section",{className:"training-primary-section",children:u?e.jsx(Nt,{taskset:n}):e.jsxs("div",{className:"training-validation-pending",children:[e.jsx(ne,{className:"spin",size:15}),e.jsx("span",{children:"Checking Taskset…"})]})}),e.jsxs("section",{className:"training-grader-summary",children:[e.jsx("h3",{children:"Evaluation"}),e.jsx("p",{children:Ct(n)}),e.jsx("pre",{children:e.jsx("code",{children:kt(n)})})]}),e.jsxs("details",{className:"training-simple-section training-source-details",children:[e.jsxs("summary",{children:[n.sourceRefs.length," chat",n.sourceRefs.length===1?"":"s"]}),e.jsx("div",{className:"training-source-list",children:n.sourceRefs.map(d=>e.jsxs("div",{children:[e.jsx("button",{className:"training-chat-link",type:"button",onClick:()=>s(d.sessionId),children:d.title}),e.jsxs("span",{className:"training-source-metadata",children:[e.jsxs("span",{children:[d.turnIds.length," turns"]}),e.jsx("span",{children:d.consent.scope.replaceAll("_"," ")}),e.jsxs("span",{children:["Privacy ",d.secretScanStatus==="passed"&&d.piiScanStatus==="passed"?"passed":"needs review"]})]})]},d.id))})]})]})]})}function Nt({taskset:n}){const t=n.readiness;return e.jsxs("div",{className:`training-readiness ${t.ready?"ready":"blocked"}`,children:[t.ready?e.jsx("strong",{children:"Ready to train"}):null,t.blockers.length?e.jsx("ul",{children:t.blockers.map(s=>e.jsx("li",{children:St(s.code,s.message)},s.code))}):null]})}function St(n,t){return{sft_demonstrations_missing:"Add another successful chat as a training example.",grader_audit_missing:"Review the evaluation setup.",grader_audit_stale:"The evaluation setup changed and needs to be checked again.",grader_hacking:"The evaluation accepted an adversarial example.",environment_leakage:"The evaluation exposed information the model should not see.",infrastructure_reward:"The evaluation rewarded an infrastructure failure."}[n]??t}function Ct(n){if(n.graders.length>1)return`${n.graders.length} checks combined into one score`;const t=n.graders[0];return t.kind==="model_judge"?`Model judge using ${t.judge.modelId}`:t.kind==="human"?`Human review by ${t.reviewerRole}`:t.kind==="custom_verifier"?"Custom deterministic check":{content:"Content match",schema:"Schema validation",file:"File validation",diff:"Diff validation",test:"Test suite",runtime_event:"Runtime event check",state:"Expected output match"}[t.kind]??t.label}function kt(n){const t=n.graders[0];if(n.graders.length>1)return n.graders.map(a=>a.label).join(`
2
+ `);if(t.kind==="model_judge"||t.kind==="human")return t.rubric;if(t.kind==="custom_verifier")return`${t.module} exports ${t.exportName}`;const s=Array.isArray(t.config.fields)?t.config.fields.filter(a=>typeof a=="string"):[];return s.length?s.map(a=>`output.${a} === expected.${a}`).join(`
3
+ `):t.kind==="content"&&t.config.operator==="exact_equals"?`output.${typeof t.config.outputField=="string"?t.config.outputField:"text"} exactly matches the saved expected value`:t.kind==="test"?"Run the saved test suite and require a passing result":t.kind==="schema"?"Validate the output against the saved schema":t.label}const wt={efficient:_e,full_harness:on.parse({profile:"full_harness",systemPromptMode:"full_harness",contextWindowTokens:4096,maxOutputTokens:256,temperature:.2,repetitionPenalty:1.05,noRepeatNgramSize:0,compaction:"when_needed",keepWarmSeconds:300})};function Mt({lineage:n,training:t,onToast:s}){const[a,u]=c.useState(n?.chatConfiguration??_e),[o,r]=c.useState(!1),f=n?`${n.id}:${n.chatConfiguration.updatedAt??"initial"}`:"none";if(c.useEffect(()=>{u(n?.chatConfiguration??_e)},[f]),!n)return e.jsx("div",{className:"training-run-placeholder",children:"Chat configuration is available after an adapter is imported."});const d=n.chatConfiguration,x=JSON.stringify({...a,updatedAt:null})!==JSON.stringify({...d,updatedAt:null});function y(m){u(p=>on.parse({...p,...m,profile:m.profile??"custom",updatedAt:p.updatedAt}))}function h(m){if(m==="custom"){u(p=>({...p,profile:"custom"}));return}u({...wt[m],updatedAt:d.updatedAt})}return e.jsxs("form",{className:"training-model-configuration",onSubmit:async m=>{m.preventDefault(),r(!0);const p=await t.actions.updateModelConfiguration(n.id,a);r(!1),s(p?"Configuration saved.":"Couldn’t save configuration.",p?"success":"error")},children:[e.jsxs("div",{className:"training-configuration-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Chat profile"}),e.jsxs("select",{value:a.profile,onChange:m=>h(m.target.value),children:[e.jsx("option",{value:"efficient",children:"Efficient"}),e.jsx("option",{value:"full_harness",children:"Full harness"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"System prompt"}),e.jsxs("select",{value:a.systemPromptMode,onChange:m=>y({systemPromptMode:m.target.value}),children:[e.jsx("option",{value:"lean",children:"Lean"}),e.jsx("option",{value:"full_harness",children:"Full harness"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),a.systemPromptMode==="custom"?e.jsxs("label",{className:"wide",children:[e.jsx("span",{children:"Custom system prompt"}),e.jsx("textarea",{value:a.customSystemPrompt??"",onChange:m=>y({customSystemPrompt:m.target.value||null})})]}):null,e.jsx(ie,{label:"Context window",value:a.contextWindowTokens,min:128,max:32768,onChange:m=>y({contextWindowTokens:m})}),e.jsx(ie,{label:"Maximum output",value:a.maxOutputTokens,min:1,max:512,onChange:m=>y({maxOutputTokens:m})}),e.jsx(ie,{label:"Temperature",value:a.temperature,min:0,max:2,step:.1,onChange:m=>y({temperature:m})}),e.jsx(ie,{label:"Repetition penalty",value:a.repetitionPenalty,min:.5,max:2,step:.05,onChange:m=>y({repetitionPenalty:m})}),e.jsx(ie,{label:"No-repeat n-gram",value:a.noRepeatNgramSize,min:0,max:10,onChange:m=>y({noRepeatNgramSize:m})}),e.jsxs("label",{children:[e.jsx("span",{children:"Compaction"}),e.jsxs("select",{value:a.compaction,onChange:m=>y({compaction:m.target.value}),children:[e.jsx("option",{value:"when_needed",children:"When needed"}),e.jsx("option",{value:"off",children:"Off"})]})]}),e.jsx(ie,{label:"Keep warm",suffix:"seconds",value:a.keepWarmSeconds,min:0,max:3600,onChange:m=>y({keepWarmSeconds:m})})]}),e.jsxs("div",{className:"training-configuration-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:!x||o||!!t.busyAction,onClick:()=>u(d),children:"Reset"}),e.jsx("button",{className:"training-button",type:"submit",disabled:!x||o||!!t.busyAction,children:o?"Saving…":"Save configuration"})]})]})}function ie({label:n,value:t,min:s,max:a,step:u=1,suffix:o,onChange:r}){return e.jsxs("label",{children:[e.jsxs("span",{children:[n,o?` (${o})`:""]}),e.jsx("input",{type:"number",min:s,max:a,step:u,value:t,onChange:f=>{const d=f.currentTarget.valueAsNumber;Number.isFinite(d)&&r(d)}})]})}function Tt({detail:n,loading:t}){if(t&&!n)return e.jsx("div",{className:"training-run-placeholder",children:"Loading evaluation results…"});const s=n?.evaluation;return s?e.jsxs("div",{className:"training-run-evaluation",children:[e.jsxs("div",{className:"training-metric-summary",children:[e.jsx(me,{label:"Base score",value:Ze(s.base.meanScore)}),e.jsx(me,{label:"Trained score",value:Ze(s.trained.meanScore)}),e.jsx(me,{label:"Score change",value:Rt(s.meanScoreDelta)}),e.jsx(me,{label:"Trained pass rate",value:_t(s.trained.passRate)})]}),s.base.count===0?e.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,s.trained.count>0&&s.trained.scoredCount===0?e.jsx("p",{className:"training-muted",children:"Outputs were captured, but the grader was unavailable, so this run has no evaluation score."}):null,e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table training-evaluation-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Test example"}),e.jsx("th",{children:"Base"}),e.jsx("th",{children:"Trained"}),e.jsx("th",{children:"Result"})]})}),e.jsx("tbody",{children:s.examples.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("details",{children:[e.jsx("summary",{children:a.taskId}),e.jsx(At,{input:a.input,baseOutput:a.baseOutput,trainedOutput:a.trainedOutput,baseGrade:a.baseGrade,trainedGrade:a.trainedGrade})]})}),e.jsx("td",{children:en(a.baseGrade)}),e.jsx("td",{children:en(a.trainedGrade)}),e.jsx("td",{children:Et(a.baseGrade,a.trainedGrade)})]},a.taskId))})]})})]}):e.jsx("div",{className:"training-run-placeholder",children:"No scored evaluation results are available for this run."})}function At({input:n,baseOutput:t,trainedOutput:s,baseGrade:a,trainedGrade:u}){const o=[...new Set([...a?.feedback??[],...u?.feedback??[]])];return e.jsxs("div",{className:"training-evaluation-output",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Input"}),e.jsx("pre",{children:JSON.stringify(n,null,2)})]}),t?e.jsxs("div",{children:[e.jsx("span",{children:"Base output"}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]}):null,s?e.jsxs("div",{children:[e.jsx("span",{children:"Trained output"}),e.jsx("pre",{children:JSON.stringify(s,null,2)})]}):null,o.length?e.jsxs("div",{children:[e.jsx("span",{children:"Grader feedback"}),e.jsx("p",{children:o.join(" ")})]}):null]})}function me({label:n,value:t}){return e.jsxs("div",{children:[e.jsx("span",{children:n}),e.jsx("strong",{children:t})]})}function Ze(n){return n==null?"Not recorded":n.toFixed(3)}function _t(n){return n==null?"Not recorded":`${Math.round(n*100)}%`}function Rt(n){return n==null?"Not comparable":`${n>=0?"+":""}${n.toFixed(3)}`}function en(n){return n?.status==="unavailable"?"Unavailable":n?.score==null?"Not scored":n.score.toFixed(3)}function Et(n,t){if(!t)return"Not evaluated";if(t.status==="unavailable")return"Unavailable";if(!n||n.score==null||t.score==null)return t.passed?"Passed":"Failed";const s=t.score-n.score;return Math.abs(s)<5e-4?"No change":s>0?`Improved ${s.toFixed(3)}`:`Regressed ${Math.abs(s).toFixed(3)}`}const nn=[{key:"loss",label:"Loss",format:je},{key:"learningRate",label:"Learning rate",format:Dt},{key:"gradientNorm",label:"Gradient norm",format:je},{key:"meanTokenAccuracy",label:"Token accuracy",format:Lt},{key:"entropy",label:"Entropy",format:je},{key:"memoryBytes",label:"Memory",format:mn}];function It({detail:n,loading:t,error:s}){const a=c.useMemo(()=>nn.filter(x=>n?.stepMetrics.some(y=>y[x.key]!=null)),[n?.stepMetrics]),[u,o]=c.useState("loss"),r=a.find(x=>x.key===u)??a[0]??nn[0],f=n?.stepMetrics.flatMap(x=>x[r.key]==null?[]:[{step:x.step,value:x[r.key]}])??[],d=n?zt(n):{};return t&&!n?e.jsx("div",{className:"training-run-placeholder",children:"Loading training metrics…"}):s&&!n?e.jsx("div",{className:"training-run-placeholder error",children:s}):n?e.jsxs("div",{className:"training-run-metrics",children:[e.jsxs("div",{className:"training-metric-summary",children:[e.jsx(pe,{label:"Steps",value:d.steps??Pt(n.stepMetrics)}),e.jsx(pe,{label:"Final loss",value:d.trainLoss==null?null:je(d.trainLoss)}),e.jsx(pe,{label:"Peak memory",value:$t(n.stepMetrics)}),e.jsx(pe,{label:"Adapter parameters",value:d.adapterParameterCount==null?null:d.adapterParameterCount.toLocaleString()})]}),a.length?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"training-metric-tabs",role:"tablist","aria-label":"Training metrics",children:a.map(x=>e.jsx("button",{type:"button",role:"tab","aria-selected":x.key===r.key,className:x.key===r.key?"active":"",onClick:()=>o(x.key),children:x.label},x.key))}),e.jsx(Ft,{label:r.label,points:f,format:r.format})]}):e.jsx("div",{className:"training-run-placeholder",children:"This earlier run recorded its final result but not per-step Trainer logs."})]}):e.jsx("div",{className:"training-run-placeholder",children:"Select a training run to inspect its metrics."})}function Ft({label:n,points:t,format:s}){const o={top:20,right:20,bottom:58,left:64},r=t.map(C=>C.value),f=Math.min(...r),d=Math.max(...r),x=d-f||Math.max(Math.abs(d)*.1,1e-9),y=f-x*.08,h=d+x*.08,m=t[0]?.step??0,p=t.at(-1)?.step??m+1,N=Math.max(1,p-m),k=C=>o.left+(C-m)/N*(760-o.left-o.right),l=C=>o.top+(h-C)/(h-y)*(270-o.top-o.bottom),S=t.map((C,M)=>`${M?"L":"M"}${k(C.step).toFixed(2)},${l(C.value).toFixed(2)}`).join(" ");return e.jsx("figure",{className:"training-line-chart","aria-label":`${n} by optimizer step`,children:e.jsxs("svg",{viewBox:"0 0 760 270",role:"img","aria-labelledby":`metric-${n.replaceAll(" ","-")}`,children:[e.jsx("title",{id:`metric-${n.replaceAll(" ","-")}`,children:`${n} by optimizer step`}),[0,.25,.5,.75,1].map(C=>{const M=o.top+C*(270-o.top-o.bottom),D=h-C*(h-y);return e.jsxs("g",{children:[e.jsx("line",{className:"training-chart-grid",x1:o.left,x2:760-o.right,y1:M,y2:M}),e.jsx("text",{className:"training-chart-label",x:o.left-10,y:M+4,textAnchor:"end",children:s(D)})]},C)}),e.jsx("line",{className:"training-chart-axis",x1:o.left,x2:760-o.right,y1:270-o.bottom,y2:270-o.bottom}),e.jsx("path",{className:"training-chart-line",d:S}),t.map(C=>e.jsx("circle",{className:"training-chart-point",cx:k(C.step),cy:l(C.value),r:"3",children:e.jsx("title",{children:`Step ${C.step}: ${s(C.value)}`})},`${C.step}-${C.value}`)),e.jsx("text",{className:"training-chart-label",x:o.left,y:236,textAnchor:"middle",children:m}),e.jsx("text",{className:"training-chart-label",x:760-o.right,y:236,textAnchor:"middle",children:p}),e.jsx("text",{className:"training-chart-label axis-title",x:(o.left+760-o.right)/2,y:261,textAnchor:"middle",children:"Optimizer step"})]})})}function pe({label:n,value:t}){return e.jsxs("div",{children:[e.jsx("span",{children:n}),e.jsx("strong",{children:t??"Not recorded"})]})}function zt(n){const t=[...n.events].reverse().find(s=>s.type==="metric"&&s.payload.metricKind!=="sft_step"&&(typeof s.payload.trainLoss=="number"||typeof s.payload.steps=="number"));return Object.fromEntries(Object.entries(t?.payload??{}).filter(s=>typeof s[1]=="number"))}function Pt(n){const t=n.at(-1);return t?`${t.step} of ${t.maxSteps}`:null}function $t(n){const t=n.flatMap(s=>s.memoryBytes==null?[]:[s.memoryBytes]);return t.length?mn(Math.max(...t)):null}function je(n){return new Intl.NumberFormat(void 0,{maximumFractionDigits:4}).format(n)}function Dt(n){return n===0?"0":n.toExponential(2)}function Lt(n){return`${(n*100).toFixed(1)}%`}function mn(n){return`${(n/1024**3).toFixed(2)} GB`}const Ot=64,Bt=4096;function qt(n){return xt(n,{minimum:Ot,maximum:Bt})}const Ht=["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"];function Ut({connection:n,taskset:t,destinations:s,busy:a,onClose:u,onStart:o}){const r=s.find(g=>g.destinationId==="local_cpu_fixture"&&g.available)?.destinationId??s.find(g=>g.available&&g.destinationId!=="export")?.destinationId??"local_cpu_fixture",[f,d]=c.useState(r),[x,y]=c.useState(null),[h,m]=c.useState("openpond/tiny-cpu-gpt2-fixture"),[p,N]=c.useState("automatic"),[k,l]=c.useState(2),[S,C]=c.useState(()=>qt(t)),[M,D]=c.useState(2),[L,I]=c.useState(()=>Ae(h)),$=t.readiness?.trainingPath??null,[H,B]=c.useState("primary"),q=s.find(g=>g.destinationId===f)??null,T=$?.primaryMethod??Kt(t),F=$?.bootstrap??null,j=H==="bootstrap"&&F?F.method:T,A=t.learningSignals.demonstrations.filter(g=>g.approved).length,K=t.tasks.filter(g=>g.split==="frozen_eval").length,_=c.useMemo(()=>x?.inventory?.devices.filter(g=>g.available)??[],[x?.inventory?.devices]),Z=c.useMemo(()=>x?.inventory?.models.filter(g=>g.trainingCompatible&&g.modelId&&g.revision&&g.tokenizerRevision&&g.chatTemplateHash)??[],[x?.inventory?.models]),V=Z.find(g=>g.modelId===h)??null,J=!!(t.readiness?.ready&&j==="sft"&&q?.available&&q.methods.includes("sft")&&t.capabilities.compatibleMethods.includes("sft")),z=t.readiness?.ready?j!=="sft"?`${j.toUpperCase()} is the primary recommendation but no compatible execution backend is available here.${F?" Choose the optional SFT trajectory bootstrap to run the local precursor.":""}`:q?.unavailableReason??null:"The Taskset must pass environment, grader, and data readiness before training.";c.useEffect(()=>{if(!n)return;let g=!0;return cn.computeState(n).then(O=>{if(!g)return;y(O),N(O.settings.defaultDeviceIds[0]??"automatic");const R=O.inventory?.models.find(ee=>ee.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct"&&ee.trainingCompatible);R?.modelId&&(m(R.modelId),I(Ae(R.modelId)))}).catch(()=>{}),()=>{g=!1}},[n]);async function re(){if(!J)return;await o(f,Gt({maxSteps:k,sequenceLength:S,rank:M,learningRate:L,model:V}))&&u()}return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:a?void 0:u,children:e.jsxs("section",{className:"training-dialog training-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Start training",onMouseDown:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Start training"}),e.jsx("p",{children:t.name})]}),e.jsx("button",{type:"button","aria-label":"Close start training",disabled:a,onClick:u,children:e.jsx(Fe,{size:16})})]}),e.jsxs("div",{className:"training-start-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Training stage"}),e.jsxs("select",{value:H,disabled:a||!F,onChange:g=>B(g.target.value),children:[e.jsxs("option",{value:"primary",children:["Primary · ",T.toUpperCase()]}),F?e.jsx("option",{value:"bootstrap",children:"Precursor · SFT trajectory bootstrap"}):null]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Base model"}),e.jsxs("select",{value:h,disabled:a,onChange:g=>{const O=g.target.value;m(O),I(Ae(O))},children:[e.jsx("option",{value:"openpond/tiny-cpu-gpt2-fixture",children:"Tiny CPU correctness fixture"}),Z.map(g=>e.jsxs("option",{value:g.modelId??g.id,children:[g.name," · ",Wt(g.sizeBytes)]},g.id))]})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Compute"}),e.jsx("select",{value:f,disabled:a,onChange:g=>d(g.target.value),children:s.filter(g=>!["custom","runpod_byoc","export"].includes(g.destinationId)).map(g=>e.jsxs("option",{value:g.destinationId,disabled:!g.available,children:[Vt(g.destinationId),g.available?"":` — ${g.unavailableReason??"Unavailable"}`]},g.destinationId))})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Device"}),e.jsxs("select",{value:p,disabled:a||f!=="local_cpu_fixture",onChange:g=>N(g.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),_.map(g=>e.jsx("option",{value:g.id,children:g.name},g.id))]})]})]}),e.jsxs("dl",{className:"training-start-summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Training data"}),e.jsxs("dd",{children:[A," approved example",A===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Evaluation"}),e.jsxs("dd",{children:[K," test example",K===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Estimate"}),e.jsx("dd",{children:f==="local_cpu_fixture"?V?`$0 · ${k} steps × ${S} tokens · 15-minute hard stop`:"$0 · 2-minute hard stop":"Provided before approval"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{children:x?.settings.modelStorePath??"App-managed local storage"})]})]}),H==="bootstrap"&&F?e.jsxs("div",{className:"training-bootstrap-limitations",children:[e.jsx("strong",{children:"Bootstrap limitations"}),e.jsx("ul",{children:F.limitations.map(g=>e.jsx("li",{children:g},g))})]}):null,e.jsxs("details",{className:"training-start-advanced",children:[e.jsx("summary",{children:"Advanced settings"}),e.jsxs("div",{className:"training-start-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Steps"}),e.jsx("input",{type:"number",min:1,max:1e3,value:k,onChange:g=>l(g.target.valueAsNumber||1)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Sequence length"}),e.jsx("input",{type:"number",min:16,max:4096,value:S,onChange:g=>C(g.target.valueAsNumber||64)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"LoRA rank"}),e.jsx("input",{type:"number",min:1,max:256,value:M,onChange:g=>D(g.target.valueAsNumber||2)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Learning rate"}),e.jsx("input",{type:"number",min:1e-6,max:.1,step:1e-4,value:L,onChange:g=>{const O=g.target.valueAsNumber;Number.isFinite(O)&&I(O)}})]})]})]}),J?q?.nonProduction?e.jsx("p",{className:"training-start-note",children:"This local worker is an experimental correctness run. It does not claim useful model quality."}):null:e.jsx("div",{className:"training-banner error training-dialog-error",children:z??"This setup is unavailable."}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:a,onClick:u,children:"Cancel"}),e.jsx("button",{className:"training-button",type:"button",disabled:a||!J,onClick:()=>{re()},children:a?"Starting…":"Start training"})]})]})})}function Gt(n){return!n.model?.modelId||!n.model.revision||!n.model.tokenizerRevision||!n.model.chatTemplateHash?{schemaVersion:"openpond.sftRecipe.v1",method:"sft",parameterization:"lora",baseModel:{id:"openpond/tiny-cpu-gpt2-fixture",revision:"architecture-v2-seed-17-context-512",tokenizerRevision:"wordlevel-v1",chatTemplateHash:"fixture00000000"},dataset:{trainSplit:"train",validationSplit:"frozen_eval",completionOnly:!0,maxSequenceLength:n.sequenceLength},lora:{rank:n.rank,alpha:n.rank*2,dropout:0,targetModules:["c_attn"]},optimizer:{learningRate:n.learningRate,epochs:1,maxSteps:n.maxSteps,batchSize:1,gradientAccumulationSteps:1,seed:17},resourceLimits:{cpuThreads:4,memoryBytes:2e9,wallTimeMs:12e4}}:{schemaVersion:"openpond.sftRecipe.v1",method:"sft",parameterization:"lora",baseModel:{id:n.model.modelId,revision:n.model.revision,tokenizerRevision:n.model.tokenizerRevision,chatTemplateHash:n.model.chatTemplateHash},dataset:{trainSplit:"train",validationSplit:"frozen_eval",completionOnly:!0,maxSequenceLength:n.sequenceLength},lora:{rank:n.rank,alpha:n.rank*2,dropout:.05,targetModules:Ht},optimizer:{learningRate:n.learningRate,epochs:1,maxSteps:n.maxSteps,batchSize:1,gradientAccumulationSteps:1,seed:17},resourceLimits:{cpuThreads:4,memoryBytes:8e9,wallTimeMs:9e5}}}function Ae(n){return n==="openpond/tiny-cpu-gpt2-fixture"?.01:2e-4}function Kt(n){const t=n.metadata.trainingMethod;return typeof t=="string"&&t!=="none"?t:n.readiness?.recommendedMethod&&n.readiness.recommendedMethod!=="none"?n.readiness.recommendedMethod:"sft"}function Vt(n){return{export:"Export only",local_cpu_fixture:"Local CPU",local_cuda:"Local NVIDIA GPU",local_mlx:"Apple Silicon",ssh_gpu:"SSH GPU",prime_hosted:"Prime hosted",fireworks:"Fireworks",openpond_managed:"OpenPond managed"}[n]??n.replaceAll("_"," ")}function Wt(n){return n==null?"size unknown":`${(n/1024/1024).toFixed(0)} MB`}const Jt=new Set(["queued","starting","running","cancelling","reconciling"]);function Qt(n,t,s){const[a,u]=c.useState(null),[o,r]=c.useState(!1),[f,d]=c.useState(null),x=c.useCallback(async()=>{if(!n||!t)return null;r(!0);try{const y=await cn.trainingRunDetail(n,t);return u(y),d(null),y}catch(y){return d(y instanceof Error?y.message:String(y)),null}finally{r(!1)}},[n,t]);return c.useEffect(()=>{u(null),d(null),!(!n||!t)&&x()},[n,t,x]),c.useEffect(()=>{if(!n||!t||!s||!Jt.has(s))return;const y=window.setInterval(()=>{x()},2e3);return()=>window.clearInterval(y)},[n,t,s,x]),{detail:a,error:f,loading:o,refresh:x}}function Xt({taskset:n,training:t,connection:s,onDelete:a,onOpenTaskset:u,onOpenTasksetFiles:o,onSelectedJobIdChange:r,onToast:f}){const d=t.payload,x=c.useMemo(()=>lt(d,n.id),[d,n.id]),[y,h]=c.useState(x[0]?.id??null),[m,p]=c.useState("summary"),[N,k]=c.useState(!1),l=x.find(j=>j.id===y)??x[0]??null,S=Je(d,l),C=ot(d,l?.id??null),M=l?d?.models.find(j=>j.jobId===l.id)??null:null,D=d?.models.filter(j=>j.tasksetId===n.id&&j.status==="imported").sort((j,A)=>A.importedAt.localeCompare(j.importedAt))[0]??null,L=M?d?.artifacts.find(j=>j.id===M.artifactId)??null:null,I=Qt(s,l?.id??null,l?.status??null),$=ct(n),H=n.learningSignals.demonstrations.filter(j=>j.approved).length,B=n.tasks.filter(j=>j.split==="frozen_eval").length,q=!l||["succeeded","failed","cancelled"].includes(l.status),T=n.readiness?.trainingPath??null,F=Qe(n,S);return c.useEffect(()=>{r(l?.id??null)},[r,l?.id]),c.useEffect(()=>()=>r(null),[r]),e.jsxs("div",{className:"training-model-detail",children:[e.jsx("header",{className:"training-model-detail-header",children:e.jsxs("div",{children:[e.jsx("h1",{children:dt(n.name)}),e.jsx("span",{className:"training-status-text",children:l?Me(l.status):n.readiness?.ready?"Ready to train":"Taskset needs review"})]})}),e.jsxs("div",{className:"training-detail-tabs",role:"tablist","aria-label":"Model detail",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":m==="summary",className:m==="summary"?"active":"",onClick:()=>p("summary"),children:"Summary"}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="details",className:m==="details"?"active":"",onClick:()=>p("details"),children:"Details"}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="configuration",className:m==="configuration"?"active":"",onClick:()=>p("configuration"),children:"Configuration"}),e.jsx("button",{type:"button",role:"tab","aria-selected":m==="settings",className:m==="settings"?"active":"",onClick:()=>p("settings"),children:"Settings"})]}),m==="summary"?e.jsxs("div",{className:"training-detail-sections",children:[e.jsx(U,{title:"Taskset",actions:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"training-button secondary",type:"button",onClick:o,children:"Open files"}),n.readiness?.ready?null:e.jsx("button",{className:"training-text-button",type:"button",onClick:u,children:"Review Taskset"})]}),children:e.jsxs("div",{className:"training-taskset-facts",children:[e.jsxs("span",{children:[e.jsx("strong",{children:H})," training examples"]}),e.jsxs("span",{children:[e.jsx("strong",{children:B})," test examples"]}),e.jsxs("span",{children:[e.jsx("strong",{children:n.sourceRefs.length})," chats"]}),e.jsxs("span",{children:[e.jsx("strong",{children:$.toUpperCase()})," primary recommendation"]}),l?e.jsxs("span",{children:[e.jsx("strong",{children:F})," selected run"]}):null]})}),T?e.jsx(U,{title:"Training path",children:e.jsxs("div",{className:"training-path-stages",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Primary · ",T.primaryMethod.toUpperCase()]}),e.jsx("span",{children:tn(T.primaryMethod,d?.destinations??[])})]}),T.bootstrap?e.jsxs("div",{children:[e.jsx("strong",{children:"Optional precursor · SFT trajectory bootstrap"}),e.jsx("span",{children:tn("sft",d?.destinations??[])}),e.jsxs("small",{children:[T.bootstrap.demonstrationRefs.length," approved trajectories · ",T.bootstrap.limitations.join(" ")]})]}):null]})}):null,e.jsx(U,{title:"Training runs",actions:q?e.jsx("button",{className:"training-button",type:"button",disabled:!n.readiness?.ready||!!t.busyAction,onClick:()=>k(!0),children:"Start training"}):null,children:x.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table training-runs-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Run"}),e.jsx("th",{children:"Method"}),e.jsx("th",{children:"Compute"}),e.jsx("th",{children:"Started"}),e.jsx("th",{children:"Duration"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:x.map(j=>{const A=Je(d,j);return e.jsxs("tr",{className:j.id===l?.id?"selected":"",onClick:()=>h(j.id),children:[e.jsx("td",{children:e.jsx("button",{type:"button",onClick:()=>h(j.id),children:Yt(j.id)})}),e.jsx("td",{children:Qe(n,A)}),e.jsx("td",{children:A?Re(A.destinationId):j.destinationId}),e.jsx("td",{children:hn(j.startedAt??j.createdAt)}),e.jsx("td",{children:ut(j.startedAt,j.completedAt)}),e.jsx("td",{children:e.jsx("span",{className:`training-run-status ${j.status}`,children:Me(j.status)})})]},j.id)})})]})}):e.jsx("div",{className:"training-run-placeholder",children:"No training runs yet."})}),l?e.jsxs(e.Fragment,{children:[e.jsx(U,{title:"Training metrics",children:e.jsx(It,{detail:I.detail,loading:I.loading,error:I.error})}),e.jsx(U,{title:"Evaluation",children:e.jsx(Tt,{detail:I.detail,loading:I.loading})}),e.jsx(U,{title:"Result",actions:M&&L?e.jsxs("button",{className:"training-button secondary",type:"button",onClick:()=>{t.actions.downloadArtifact(L.id)},children:[e.jsx(Un,{size:14}),"Download adapter"]}):null,children:e.jsxs("div",{className:"training-result-summary",children:[e.jsx("strong",{children:M?`${F} adapter ready`:l.status==="succeeded"?"Collecting adapter":"No adapter created"}),L?e.jsxs("span",{children:[L.baseModelId," with LoRA"]}):null,S?.recipe.method==="sft"&&$!=="sft"?e.jsx("span",{children:"Supervised bootstrap only; verifier reward was not optimized."}):null,M?e.jsxs("span",{children:["Frozen evaluation ",M.frozenEvaluationArtifactId?"completed":"not recorded"]}):null]})})]}):null]}):m==="details"?e.jsxs("div",{className:"training-detail-sections",children:[e.jsx(U,{title:"Training recipe",children:S?.recipe.method==="sft"?e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(P,{label:"Method",value:S.recipe.method.toUpperCase()}),e.jsx(P,{label:"Base model",value:S.recipe.baseModel.id}),e.jsx(P,{label:"Revision",value:S.recipe.baseModel.revision}),e.jsx(P,{label:"Compute",value:Re(S.destinationId)}),e.jsx(P,{label:"LoRA rank",value:String(S.recipe.lora.rank)}),e.jsx(P,{label:"Learning rate",value:String(S.recipe.optimizer.learningRate)}),e.jsx(P,{label:"Maximum steps",value:String(S.recipe.optimizer.maxSteps)}),e.jsx(P,{label:"Batch size",value:String(S.recipe.optimizer.batchSize)}),e.jsx(P,{label:"Gradient accumulation",value:String(S.recipe.optimizer.gradientAccumulationSteps)}),e.jsx(P,{label:"Sequence length",value:String(S.recipe.dataset.maxSequenceLength)}),e.jsx(P,{label:"Seed",value:String(S.recipe.optimizer.seed)})]}):e.jsx("div",{className:"training-run-placeholder",children:"No run configuration yet."})}),e.jsx(U,{title:"Lineage",children:M?e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(P,{label:"Taskset hash",value:M.tasksetHash}),e.jsx(P,{label:"Grader hash",value:M.graderHash}),e.jsx(P,{label:"Plan hash",value:M.planHash}),e.jsx(P,{label:"Bundle hash",value:M.bundleHash}),e.jsx(P,{label:"Recipe hash",value:M.recipeHash}),e.jsx(P,{label:"Worker",value:M.workerVersion}),e.jsx(P,{label:"Trainer",value:M.trainerVersion})]}):e.jsx("div",{className:"training-run-placeholder",children:"Lineage is created with a verified adapter."})}),e.jsx(U,{title:"Artifacts",children:C.length?e.jsx("div",{className:"training-artifact-list",children:C.map(j=>e.jsxs("div",{children:[e.jsx("span",{children:j.kind}),e.jsx("code",{children:String(j.metadata.relativePath??j.path)}),e.jsx("strong",{children:Zt(j.sizeBytes)})]},j.id))}):e.jsx("div",{className:"training-run-placeholder",children:"No artifacts yet."})}),e.jsx(U,{title:"Event log",children:I.detail?.events.length?e.jsx("div",{className:"training-event-log",children:I.detail.events.map(j=>e.jsxs("div",{children:[e.jsx("time",{children:new Date(j.timestamp).toLocaleTimeString()}),e.jsx("strong",{children:Me(j.type)}),e.jsx("code",{children:es(j.payload)})]},j.id))}):e.jsx("div",{className:"training-run-placeholder",children:"No worker events yet."})})]}):m==="configuration"?e.jsx("div",{className:"training-detail-sections",children:e.jsx(U,{title:"Chat",children:e.jsx(Mt,{lineage:D,training:t,onToast:f})})}):e.jsx("div",{className:"training-detail-sections",children:e.jsx(U,{title:"Settings",children:e.jsx("div",{className:"training-model-settings-actions",children:e.jsx("button",{className:"training-button danger",type:"button",onClick:a,children:"Delete model"})})})}),N?e.jsx(Ut,{connection:s,taskset:n,destinations:d?.destinations??[],busy:t.busyAction==="start-training",onClose:()=>k(!1),onStart:async(j,A)=>!!await t.actions.startTraining({tasksetId:n.id,destinationId:j,recipe:A,exportApproved:!0,maximumCostUsd:j==="local_cpu_fixture"?0:null})}):null]})}function U({title:n,actions:t,children:s}){return e.jsxs("section",{className:"training-detail-section",children:[e.jsxs("div",{className:"training-detail-section-heading",children:[e.jsx("h2",{children:n}),t?e.jsx("div",{children:t}):null]}),e.jsx("div",{className:"training-detail-section-panel",children:s})]})}function P({label:n,value:t}){return e.jsxs("div",{children:[e.jsx("dt",{children:n}),e.jsx("dd",{children:t})]})}function Yt(n){return n.replace(/^training_job_/,"").slice(0,12)}function Zt(n){return n<1024?`${n} B`:n<1024**2?`${(n/1024).toFixed(1)} KB`:`${(n/1024**2).toFixed(1)} MB`}function es(n){const t=Object.fromEntries(Object.entries(n).filter(([,s])=>typeof s=="string"||typeof s=="number"||typeof s=="boolean").slice(0,8));return JSON.stringify(t)}function tn(n,t){const s=t.filter(a=>a.available&&a.methods.includes(n));return s.length?`Available on ${s.map(a=>Re(a.destinationId)).join(", ")}`:n==="sft"?"No SFT destination is currently available":"Execution backend unavailable; readiness contract only"}function ns({training:n,connection:t,onOpenTasksetFiles:s,onOpenTaskset:a,onSelectedTasksetIdChange:u,onSelectedJobIdChange:o,onChatWithModel:r,onToast:f,detailTasksetId:d,onDetailTasksetIdChange:x}){const y=c.useMemo(()=>ht(n.payload),[n.payload]),[h,m]=c.useState(null),p=y.find(l=>l.taskset.id===d)??null;c.useEffect(()=>{d&&!y.some(l=>l.taskset.id===d)&&x(null)},[d,x,y]);const N=h?e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:()=>m(null),children:e.jsxs("section",{className:"training-dialog training-delete-dialog",role:"dialog","aria-modal":"true","aria-label":"Delete model",onMouseDown:l=>l.stopPropagation(),children:[e.jsx("div",{className:"training-dialog-header",children:e.jsx("h2",{children:"Delete model?"})}),e.jsxs("p",{children:["This removes the Taskset, training setup, runs, and locally managed artifacts for ",h.name,"."]}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",onClick:()=>m(null),children:"Cancel"}),e.jsx("button",{className:"training-button danger",type:"button",disabled:!!n.busyAction,onClick:async()=>{await n.actions.deleteTaskset(h.id)&&(m(null),x(null))},children:"Delete"})]})]})}):null;if(p)return e.jsxs(e.Fragment,{children:[e.jsx(Xt,{taskset:p.taskset,training:n,connection:t,onDelete:()=>m(p.taskset),onOpenTaskset:()=>a(p.taskset.id),onOpenTasksetFiles:()=>s(p.taskset.id),onSelectedJobIdChange:o,onToast:f},p.taskset.id),N]});return e.jsxs("div",{className:"training-page-body training-model-list",children:[y.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table training-models-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Model"}),e.jsx("th",{children:"Primary"}),e.jsx("th",{children:"Latest run"}),e.jsx("th",{children:"Base model"}),e.jsx("th",{children:"Runs"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:y.map(l=>e.jsxs("tr",{onClick:()=>k(l.taskset.id),children:[e.jsx("td",{children:e.jsxs("button",{className:"training-model-link",type:"button",onClick:S=>{S.stopPropagation(),k(l.taskset.id)},children:[e.jsx("strong",{children:l.name}),e.jsx("span",{children:l.taskset.name})]})}),e.jsx("td",{children:l.primaryMethod.toUpperCase()}),e.jsx("td",{children:l.latestRunLabel}),e.jsx("td",{children:l.latestPlan?.recipe.method==="sft"?l.latestPlan.recipe.baseModel.id:"Not selected"}),e.jsx("td",{children:l.runCount}),e.jsx("td",{children:hn(l.updatedAt)}),e.jsx("td",{children:e.jsx("span",{className:`training-run-status ${l.latestJob?.status??"ready"}`,children:l.status})}),e.jsx("td",{children:e.jsxs("div",{className:"training-table-actions",children:[l.localModel?e.jsxs("button",{className:"training-table-chat",type:"button","aria-label":`Chat with ${l.name}`,onClick:S=>{S.stopPropagation(),r(Kn({modelId:l.localModel.id,taskset:l.taskset}))},children:[e.jsx(Gn,{size:13})," Chat"]}):null,e.jsx(Vn,{size:15})]})})]},l.taskset.id))})]})}):e.jsxs("div",{className:"training-empty-detail",children:[e.jsx("h2",{children:"No models yet"}),e.jsx("p",{children:"Create a Taskset from selected chats to start training."})]}),N]});function k(l){x(l),u(l)}}function ts({training:n,defaultModel:t,preferences:s,reasoningEffort:a,onPlanStarted:u}){const o=n.payload?.candidates??[];return e.jsxs("section",{className:"training-page-body training-suggestions",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"AI suggestions"}),e.jsx("p",{children:"Review repeated work found by the local Task Miner before creating a training plan."})]}),o.length?e.jsx("div",{className:"training-card-grid",children:o.map(r=>e.jsx(ss,{candidate:r,candidates:o,training:n,defaultModel:t,preferences:s,reasoningEffort:a,onPlanStarted:u},r.id))}):e.jsx("div",{className:"training-empty training-suggestions-empty",children:"No AI suggestions yet. Start New model with Automated to scan selected chats for repeated, verifiable work."})]})}function ss({candidate:n,candidates:t,training:s,defaultModel:a,preferences:u,reasoningEffort:o,onPlanStarted:r}){const[f,d]=c.useState(""),x=t.filter(h=>h.id!==n.id&&h.status!=="retired");async function y(){const h=await s.actions.createCandidate(n.id,u.creationMode,dn(u,a),o);h&&(h.state==="awaiting_disclosure_approval"&&u.autoApproveEvidence&&await s.actions.approveDisclosure(h.id,!0),r())}return e.jsxs("article",{className:"training-card",children:[e.jsxs("div",{className:"training-card-heading",children:[e.jsx("strong",{children:n.title}),e.jsx("span",{className:"training-pill",children:n.recommendation.tactic.replaceAll("_"," ")})]}),e.jsx("p",{children:n.summary}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Frequency"}),e.jsx("dd",{children:ge(n.scorecard.frequency)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Verifiable"}),e.jsx("dd",{children:ge(n.scorecard.verifiability)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Signal"}),e.jsx("dd",{children:ge(n.scorecard.signalQuality)})]})]}),e.jsxs("details",{className:"training-evidence",children:[e.jsx("summary",{children:"Evidence and recommendation"}),e.jsx("p",{children:n.recommendation.reasons.join(" ")}),n.recommendation.blockers.map(h=>e.jsx("p",{className:"training-draft-warning",children:h},h)),e.jsx("ul",{children:n.evidence.map(h=>e.jsxs("li",{children:[e.jsx("strong",{children:h.kind.replaceAll("_"," ")})," — ",h.summary," (",ge(h.confidence),")"]},h.id))})]}),e.jsxs("div",{className:"training-inline-actions",children:[e.jsx("button",{className:"training-button",type:"button",disabled:!!s.busyAction,onClick:()=>{y()},children:"Create plan"}),e.jsx("button",{className:"training-text-button",type:"button",onClick:()=>{s.actions.patchCandidate(n.id,{status:"rejected"})},children:"Reject"}),e.jsx("button",{className:"training-text-button",type:"button",onClick:()=>{s.actions.patchCandidate(n.id,{status:"dismissed"})},children:"Dismiss"})]}),x.length?e.jsxs("div",{className:"training-merge-row",children:[e.jsxs("select",{"aria-label":`Merge ${n.title} into`,value:f,onChange:h=>d(h.target.value),children:[e.jsx("option",{value:"",children:"Merge into…"}),x.map(h=>e.jsx("option",{value:h.id,children:h.title},h.id))]}),e.jsx("button",{className:"training-text-button",type:"button",disabled:!f,onClick:()=>{s.actions.patchCandidate(n.id,{mergeIntoId:f})},children:"Merge"})]}):null]})}function ge(n){return`${Math.round(n*100)}%`}function as({candidates:n,onRescan:t,onSelect:s}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-dialog-scroll-body",children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:n.length?"Review repeated workflows":"No repeated workflows found"}),e.jsx("p",{children:n.length?"Choose a candidate to review its supporting chats before anything is disclosed.":"Nothing met the current recurrence and evidence thresholds. No empty model was created."})]}),n.length?e.jsx("div",{className:"training-candidate-options",children:n.map(a=>e.jsxs("button",{type:"button",onClick:()=>s(a),children:[e.jsxs("span",{children:[e.jsx("strong",{children:a.title}),e.jsx("small",{children:a.summary})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Supporting chats"}),e.jsx("dd",{children:a.evidence.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Confidence"}),e.jsxs("dd",{children:[Math.round(a.scorecard.overall*100),"%"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Preliminary"}),e.jsx("dd",{children:a.recommendation.tactic.replaceAll("_"," ")})]})]})]},a.id))}):null]}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button secondary",type:"button",onClick:t,children:n.length?"Scan again":"Change scan"})})]})}function is({chatCount:n,frontierBaselineRun:t,frontierBaselineModel:s,frontierBaselineProject:a,frontierBaselineRunning:u,config:o,estimate:r,onConfigChange:f,onCancel:d,onCancelFrontierBaseline:x,onRunFrontierBaseline:y,onScan:h,run:m,scanning:p}){const N=t?.result??null;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-dialog-scroll-body",children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"Find repeated work"}),e.jsx("p",{children:"The scan indexes and clusters eligible completed chats locally. No chat content is sent to the authoring model."})]}),e.jsxs("dl",{className:"training-automatic-scope-summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Chats in scope"}),e.jsx("dd",{children:n})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Messages"}),e.jsx("dd",{children:r.measuredChats===n?r.messageCount:"Estimating…"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Approximate tokens"}),e.jsx("dd",{children:r.measuredChats===n?os(r.estimatedTokens):"Estimating…"})]})]}),e.jsxs("section",{className:"training-frontier-baseline",children:[e.jsxs("div",{children:[e.jsx("h4",{children:"Cross-System Operations proof evidence"}),e.jsxs("p",{children:["Run ",s," against 15 bounded tasks across train, validation, and frozen-evaluation worlds. Evidence chats are attached to ",a??"the imported Cross-System Operations project","; prompts and synthetic tool results are disclosed to the selected model provider."]})]}),e.jsx("div",{className:"training-frontier-baseline-actions",children:u?e.jsx("button",{className:"training-button secondary",type:"button",disabled:t?.status==="cancelling",onClick:x,children:t?.status==="cancelling"?"Cancelling…":"Cancel baseline"}):e.jsx("button",{className:"training-button secondary",type:"button",disabled:p||!a,onClick:y,children:N?"Run frontier baseline again":"Run frontier baseline"})}),a?null:e.jsx("p",{className:"training-frontier-baseline-note error",children:"Import the Cross-System Operations Agent SDK project through Make Agent before running this proof."}),t&&u?e.jsxs("div",{className:"training-frontier-baseline-progress",role:"status",children:[e.jsxs("div",{children:[e.jsx("strong",{children:rs(t)}),e.jsxs("span",{children:[t.progress.completedTasks," of ",t.progress.totalTasks," tasks"]})]}),e.jsx("progress",{max:Math.max(1,t.progress.totalTasks),value:t.progress.completedTasks}),t.progress.currentTask?e.jsxs("small",{children:[us(t.progress.currentTask.family)," · ",t.progress.currentTask.worldId]}):null]}):null,t?.status==="failed"?e.jsxs("p",{className:"training-frontier-baseline-note error",children:["Baseline failed: ",t.error]}):null,t?.status==="cancelled"?e.jsxs("p",{className:"training-frontier-baseline-note",children:["Baseline cancelled after ",t.progress.completedTasks," recorded tasks. Completed evidence chats were preserved."]}):null,t?.reboundSessionCount?e.jsxs("p",{className:"training-frontier-baseline-note",children:["Moved ",t.reboundSessionCount," earlier baseline chats into ",t.localProjectName,"."]}):null,N?e.jsxs("dl",{className:"training-frontier-baseline-results","aria-label":"Frontier baseline results",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Exact match"}),e.jsxs("dd",{children:[Math.round(N.report.exactMatchAccuracy*100),"%"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Tool calls"}),e.jsx("dd",{children:N.report.metrics.toolCalls})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Rows / bytes"}),e.jsxs("dd",{children:[N.report.metrics.rowsRead," / ",cs(N.report.metrics.bytesRead)]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Parse failures"}),e.jsx("dd",{children:N.report.metrics.parseFailures})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Wall time"}),e.jsx("dd",{children:ds(N.report.metrics.wallTimeMs)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reward variance"}),e.jsx("dd",{children:N.report.reward.variance.toFixed(4)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Approved traces"}),e.jsx("dd",{children:N.bootstrap.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Infrastructure failures"}),e.jsx("dd",{children:t?.progress.outcomes.infrastructureFailure??0})]})]}):null]}),e.jsxs("details",{className:"training-automatic-options",children:[e.jsx("summary",{children:"Scan options"}),e.jsxs("div",{children:[e.jsxs("label",{children:["Look back ",e.jsx("input",{type:"number",min:1,max:365,value:o.observationWindowDays,onChange:k=>f({...o,observationWindowDays:Number(k.target.value)})})," days"]}),e.jsxs("label",{children:["Minimum recurrence ",e.jsx("input",{type:"number",min:2,max:100,value:o.minimumRecurrence,onChange:k=>f({...o,minimumRecurrence:Number(k.target.value)})})]})]})]}),m&&["queued","running","cancelling"].includes(m.status)?e.jsxs("div",{className:"training-miner-progress",role:"status",children:[e.jsxs("div",{children:[e.jsx("strong",{children:ls(m)}),e.jsxs("span",{children:[m.progress.processedSources," of ",m.progress.totalSources||n," chats · ",m.progress.candidatesFound," candidates",m.progress.skippedSources?` · ${m.progress.skippedSources} skipped`:""]})]}),e.jsx("progress",{max:Math.max(1,m.progress.totalSources||n),value:m.progress.processedSources})]}):null,m?.status==="failed"?e.jsxs("p",{className:"training-empty",children:["Scan failed: ",m.error]}):null,m?.status==="cancelled"?e.jsx("p",{className:"training-empty",children:"The scan was cancelled. No candidate was selected."}):null]}),e.jsxs("div",{className:"training-dialog-actions",children:[p?e.jsx("button",{className:"training-button secondary",type:"button",disabled:m?.status==="cancelling",onClick:d,children:m?.status==="cancelling"?"Cancelling…":"Cancel scan"}):null,e.jsxs("button",{className:"training-button",type:"button",disabled:p||u||n===0&&!N,onClick:h,children:[p?e.jsx(ne,{className:"spin",size:14}):null,p?"Scanning…":"Scan chats"]})]})]})}function rs(n){return n.status==="queued"?"Preparing baseline":n.status==="cancelling"?"Cancelling baseline":n.progress.stage==="preparing"?"Binding project evidence":n.progress.stage==="persisting"?"Saving baseline report":"Running provider tool loop"}function ls(n){return n.status==="queued"?"Preparing scan":n.status==="cancelling"?"Cancelling scan":n.progress.stage==="ingesting"?"Preparing local evidence":n.progress.stage==="clustering"?"Clustering repeated work":n.progress.stage==="persisting"?"Saving candidates":"Scanning local evidence"}function os(n){return n<1e3?String(n):n<1e6?`${(n/1e3).toFixed(n>=1e4?0:1)}K`:`${(n/1e6).toFixed(n>=1e7?0:1)}M`}function cs(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(1)} KB`:`${(n/1048576).toFixed(1)} MB`}function ds(n){if(n<1e3)return`${n} ms`;const t=n/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`}function us(n){return n.replaceAll("_"," ").replace(/\b\w/g,t=>t.toUpperCase())}function hs({objective:n,onChange:t,onContinue:s}){const a=!!n.trim();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-dialog-scroll-body",children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"What should the model learn?"}),e.jsx("p",{children:"Describe a repeatable capability or outcome. You can add successful chats and corrections next."})]}),e.jsxs("label",{className:"training-objective-field",children:[e.jsxs("span",{children:["Capability ",e.jsx("small",{children:"Required"})]}),e.jsx("textarea",{"data-autofocus":!0,required:!0,value:n,onChange:u=>t(u.target.value),onKeyDown:u=>{(u.metaKey||u.ctrlKey)&&u.key==="Enter"&&a&&s()},placeholder:"For example: reconcile renewal, billing, and support risk across customer systems"})]})]}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",disabled:!a,onClick:s,children:"Add evidence"})})]})}function ms({creation:n,sources:t,training:s,onCreationChange:a}){const[u,o]=c.useState(""),r=n.proposal,[f,d]=c.useState(r?.name??"");if(c.useEffect(()=>d(r?.name??""),[r?.name]),!r)return null;const x=r.diagnosis,y=new Map(t.map(l=>[l.id,l])),h=r.proposedExamples.filter(l=>l.split==="train"),m=r.proposedExamples.filter(l=>l.split==="frozen_eval"),p=n.materializedTasksetId?s.payload?.graderAuditReports.find(l=>l.tasksetId===n.materializedTasksetId)??null:null;async function N(){const l=u.trim();if(!l)return;const S=await s.actions.chatCreation(n.id,l);S&&(o(""),a(S))}async function k(){const l=f.trim();if(!r||!l||l===r.name)return;const S=await s.actions.renameCreation(n.id,l);S&&a(S)}return e.jsxs("div",{className:"training-recommendation-review",children:[e.jsxs("div",{className:"training-recommendation-heading",children:[e.jsxs("label",{className:"training-recommendation-name",children:[e.jsx("span",{children:"Model name"}),e.jsx("input",{value:f,maxLength:500,onChange:l=>d(l.target.value),onBlur:()=>{k()},onKeyDown:l=>{l.key==="Enter"&&(l.preventDefault(),k())}})]}),e.jsx("span",{children:ps(x.intervention)})]}),e.jsx("p",{className:"training-recommendation-objective",children:r.objective}),e.jsxs("dl",{className:"training-recommendation-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Training examples"}),e.jsx("dd",{children:h.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Evaluation examples"}),e.jsx("dd",{children:m.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Grader"}),e.jsx("dd",{children:p?p.passed?"Passed":"Failed":r.proposedGraders.length?"Not run yet":"Not proposed"})]})]}),r.trainingPath?e.jsxs("section",{className:"training-path-review",children:[e.jsx("h4",{children:"Training path"}),e.jsxs("div",{children:[e.jsxs("strong",{children:["Primary · ",r.trainingPath.primaryMethod.toUpperCase()]}),e.jsx("p",{children:x.rationale.join(" ")})]}),r.trainingPath.bootstrap?e.jsxs("div",{children:[e.jsx("strong",{children:"Optional precursor · SFT trajectory bootstrap"}),e.jsxs("p",{children:[r.trainingPath.bootstrap.demonstrationRefs.length," reviewed demonstration",r.trainingPath.bootstrap.demonstrationRefs.length===1?"":"s",". ",r.trainingPath.bootstrap.limitations.join(" ")]})]}):null]}):null,e.jsxs("section",{children:[e.jsx("h4",{children:"What it should learn"}),x.stableBehavior.length?e.jsx("ul",{children:x.stableBehavior.map(l=>e.jsx("li",{children:l},l))}):e.jsx("p",{children:x.summary})]}),x.changingKnowledge.length||x.requiredContext.length?e.jsxs("section",{children:[e.jsx("h4",{children:"Keep in context"}),e.jsx("ul",{children:[...x.changingKnowledge,...x.requiredContext].map(l=>e.jsx("li",{children:l},l))})]}):null,n.state==="recommendation_ready"||!x.trainingEligible?e.jsxs("section",{className:"training-recommendation-guidance",children:[e.jsx("h4",{children:"Why this is not ready for a Taskset"}),e.jsx("ul",{children:r.warnings.map(l=>e.jsx("li",{children:l},l))})]}):null,e.jsxs("details",{className:"training-recommendation-details",children:[e.jsx("summary",{children:"Review examples and evaluation"}),e.jsxs("div",{className:"training-recommendation-detail-body",children:[r.proposedExamples.length?e.jsx("div",{className:"training-proposed-examples",children:r.proposedExamples.map(l=>e.jsxs("article",{children:[e.jsxs("div",{children:[e.jsx("strong",{children:l.split==="frozen_eval"?"Evaluation":l.split==="train"?"Training":sn(l.split)}),e.jsx("span",{children:sn(l.origin.replaceAll("_"," "))})]}),e.jsx("p",{children:l.inputPrompt}),e.jsx("small",{children:y.get(l.sourceId)?.title??"Selected chat"})]},l.id))}):e.jsx("p",{children:"No training examples are proposed for this recommendation."}),r.proposedGraders.length?e.jsxs("div",{className:"training-proposed-evaluation",children:[e.jsx("strong",{children:"Grader summary"}),e.jsxs("p",{children:[r.proposedGraders.map(l=>l.label).join(", ")," · ",p?p.passed?"executed successfully":"execution failed":"execution pending Taskset creation"]})]}):null,r.warnings.length&&n.state!=="recommendation_ready"?e.jsx("ul",{className:"training-recommendation-warnings",children:r.warnings.map(l=>e.jsx("li",{children:l},l))}):null]})]}),e.jsxs("details",{className:"training-recommendation-details",children:[e.jsx("summary",{children:"Revise recommendation"}),e.jsxs("div",{className:"training-recommendation-revision",children:[e.jsx("textarea",{value:u,onChange:l=>o(l.target.value),placeholder:"Explain what should change"}),e.jsx("button",{className:"training-button secondary",type:"button",disabled:!u.trim()||!!s.busyAction,onClick:()=>{N()},children:"Revise"})]})]})]})}function ps(n){return{no_training:"No training",prompting:"Prompt or agent instructions",retrieval:"Retrieval",sft:"SFT",preference:"Preference tuning",grpo_rft:"GRPO / RFT",sdft_opsd:"Distillation",sdpo:"SDPO",agentic_rl:"Agentic RL"}[n]}function sn(n){return n&&`${n[0].toUpperCase()}${n.slice(1)}`}function gs({busy:n,creation:t,onAddChats:s,onClose:a,onCreateTaskset:u,onCreationChange:o,sources:r,training:f}){const d=t.state==="awaiting_materialization_approval",x=t.state==="recommendation_ready"&&t.proposal?.diagnosis.trainingEligible===!0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"training-dialog-scroll-body",children:e.jsx(ms,{creation:t,sources:r,training:f,onCreationChange:o})}),e.jsxs("div",{className:"training-dialog-actions",children:[x?e.jsx("button",{className:"training-button secondary",type:"button",disabled:n,onClick:s,children:"Add chats"}):null,e.jsx("button",{className:"training-button secondary",type:"button",onClick:a,children:d?"Cancel":"Done"}),d?e.jsxs("button",{className:"training-button",type:"button",disabled:n,onClick:u,children:[n?e.jsx(ne,{className:"spin",size:14}):null,"Create Taskset"]}):null]})]})}function xs({authoringModel:n,authoringProvider:t,authoringReasoningEffort:s,busy:a,disclosurePending:u,estimatesBySessionId:o,matchingSessionCount:r,mode:f,objective:d,onAnalyze:x,onApproveDisclosure:y,onAuthoringModelChange:h,onAuthoringProviderChange:m,onAuthoringReasoningEffortChange:p,onDeclineDisclosure:N,onSearchChange:k,onLoadMore:l,onReturnToRecommendation:S,onToggleSession:C,onToggleVisible:M,providerSettings:D,recommendationAvailable:L,search:I,searchError:$,searchHasMore:H,searchIndexedChats:B,searchIndexing:q,searchLoading:T,searchTotalChats:F,selectedEntries:j,selectedEstimate:A,selectedSessionIds:K,visibleSessions:_}){const Z=c.useMemo(()=>Wn(D,{enabledOnly:!0}),[D]),V=c.useMemo(()=>Jn(t,D),[t,D]),J=Qn(t,n,D),z=K.size,re=_.length>0&&_.every(R=>K.has(R.sessionId)),g=_.filter(R=>!K.has(R.sessionId)),O=z>0||f==="manual"&&!!d.trim();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-dialog-scroll-body",children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"Review supporting chats"}),e.jsx("p",{children:f==="automated"?"Approve the chats that support this repeated workflow.":"Add successful examples, corrections, reviewer choices, or outcome-bearing runs."})]}),d?e.jsxs("div",{className:"training-evidence-objective",children:[e.jsx("span",{children:"Capability"}),e.jsx("strong",{children:d})]}):null,e.jsxs("fieldset",{className:"training-evidence-fields",disabled:a||u,children:[e.jsxs("div",{className:"training-source-toolbar",children:[e.jsxs("label",{className:"training-search",children:[e.jsx(un,{size:14}),e.jsx("input",{value:I,onChange:R=>k(R.target.value),placeholder:"Search chats"})]}),e.jsx("button",{className:"training-text-button",type:"button",disabled:!_.length,onClick:M,children:re?"Clear visible":"Select visible"})]}),e.jsxs("div",{className:"training-source-result-count",children:[e.jsxs("span",{children:["Showing ",_.length," of ",r," matching chats"]}),q?e.jsxs("span",{children:["Indexing messages ",B," of ",F]}):null]}),e.jsxs("div",{className:"training-source-options",onScroll:R=>{const ee=R.currentTarget;H&&!T&&ee.scrollHeight-ee.scrollTop-ee.clientHeight<72&&l()},children:[j.length?e.jsx("div",{className:"training-selected-chat-group",children:j.map(R=>e.jsx(an,{entry:R,checked:!0,estimatesBySessionId:o,onToggleSession:C,showSnippet:!!I.trim()},R.sessionId))}):null,g.map(R=>e.jsx(an,{entry:R,checked:!1,estimatesBySessionId:o,onToggleSession:C,showSnippet:!!I.trim()},R.sessionId)),T?e.jsxs("div",{className:"training-chat-search-state",children:[e.jsx(ne,{className:"spin",size:15}),e.jsx("span",{children:_.length?"Loading more chats…":"Searching chats…"})]}):null,$?e.jsx("p",{className:"training-empty",children:$}):null,!T&&!$&&!_.length?e.jsx("p",{className:"training-empty",children:q?"No matches yet. Message indexing is still running.":"No completed chats match this search."}):null]}),e.jsxs("div",{className:"training-authoring-row",children:[e.jsx("span",{children:"Analyzed with"}),e.jsxs("div",{className:"training-authoring-controls","aria-label":"Analysis model",children:[e.jsx(We,{compact:!0,placement:"bottom",label:"Provider",value:t,options:Z,disabled:a,onChange:R=>m(R)}),J?e.jsx(Xn,{disabled:a,model:n,modelOptions:V,placement:"bottom",reasoningEffort:s,onModelChange:h,onReasoningEffortChange:p}):e.jsx(We,{compact:!0,placement:"bottom",label:"Model",value:n,options:V,disabled:a,onChange:h})]})]})]}),u?e.jsxs("div",{className:"training-disclosure-review",role:"status",children:[e.jsx("strong",{children:"Approve evidence disclosure"}),e.jsxs("p",{children:[e.jsxs("b",{children:[t," / ",n]})," will receive raw excerpts from ",z," selected chat",z===1?"":"s",", ",A.messageCount," messages, and approximately ",Ie(A.estimatedTokens)," tokens. Unselected local chats and the local search index are not sent."]})]}):null]}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("span",{className:"training-selection-count",children:z===0?"No supporting chats selected":A.measuredChats===z?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[z," chat",z===1?"":"s"]}),e.jsxs("span",{children:[A.messageCount," messages"]}),e.jsxs("span",{children:["About ",Ie(A.estimatedTokens)," tokens"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[z," chat",z===1?"":"s"]}),e.jsx("span",{children:"Estimating…"})]})}),u?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:a,onClick:N,children:"Change evidence"}),e.jsxs("button",{className:"training-button",type:"button",disabled:a||A.measuredChats!==z,onClick:y,children:[a?e.jsx(ne,{className:"spin",size:14}):null,"Approve and analyze"]})]}):L?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:a,onClick:x,children:"Reanalyze changes"}),e.jsx("button",{className:"training-button",type:"button",onClick:S,children:"Return to recommendation"})]}):e.jsxs("button",{className:"training-button",type:"button",disabled:!O||a||z>0&&A.measuredChats!==z,onClick:x,children:[a?e.jsx(ne,{className:"spin",size:14}):null,"Review disclosure"]})]})]})}function an({checked:n,entry:t,estimatesBySessionId:s,onToggleSession:a,showSnippet:u}){return e.jsxs("label",{children:[e.jsx("input",{className:"training-chat-checkbox",type:"checkbox",checked:n,onChange:o=>a(t.sessionId,o.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:t.title}),u&&t.snippet?e.jsx("span",{className:"training-chat-search-snippet",children:t.snippet}):null,e.jsxs("small",{children:[new Date(t.updatedAt).toLocaleString(),e.jsx(js,{estimate:s[t.sessionId]})]})]})]})}function js({estimate:n}){return n?e.jsxs("span",{className:"training-chat-estimate",children:[e.jsxs("span",{children:[n.messageCount," messages"]}),e.jsxs("span",{children:["About ",Ie(n.estimatedTokens)," tokens"]})]}):e.jsx("span",{className:"training-chat-estimate",children:e.jsx("span",{children:"Estimating…"})})}function Ie(n){return n<1e3?String(n):n<1e6?`${(n/1e3).toFixed(n>=1e4?0:1)}K`:`${(n/1e6).toFixed(n>=1e7?0:1)}M`}const fs=[{id:"automated",title:"Automated",description:"Review repeated work in chats and recommend what, if anything, should be trained.",icon:un},{id:"manual",title:"Manual",description:"Start from a capability you already want the model to learn.",icon:Yn}];function vs({mode:n,onChange:t,onContinue:s}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"How do you want to start?"}),e.jsx("p",{children:"OpenPond will recommend the right intervention after it understands the work and evidence."})]}),e.jsx("div",{className:"training-method-options training-start-mode-options",role:"radiogroup","aria-label":"How to start a new model",children:fs.map(a=>{const u=a.icon,o=a.id===n;return e.jsxs("button",{type:"button",role:"radio","aria-checked":o,className:o?"selected":"",onClick:()=>t(a.id),onDoubleClick:s,children:[e.jsx(u,{size:17}),e.jsxs("span",{children:[e.jsx("strong",{children:a.title}),e.jsx("small",{children:a.description})]})]},a.id)})}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",disabled:!n,onClick:s,children:"Continue"})})]})}const rn=20;function bs({defaultModel:n,initialObjective:t,initialSessionIds:s=[],onClose:a,onTasksetCreated:u,preferences:o,providerSettings:r,reasoningEffort:f,localProjects:d=[],sessions:x,sources:y,training:h}){const m=dn(o,n),[p,N]=c.useState("start"),[k,l]=c.useState(null),[S,C]=c.useState(t??""),[M,D]=c.useState(null),[L,I]=c.useState(m.providerId),[$,H]=c.useState(m.modelId),[B,q]=c.useState(f),[T,F]=c.useState(""),[j,A]=c.useState([]),[K,_]=c.useState(0),[Z,V]=c.useState(!1),[J,z]=c.useState(!1),[re,g]=c.useState(null),[O,R]=c.useState(!1),[ee,ze]=c.useState(0),[pn,Pe]=c.useState(0),[gn,xn]=c.useState(0),Q=c.useRef(0),[te,ve]=c.useState(()=>new Set(s)),[X,be]=c.useState({}),[E,le]=c.useState(null),[$e,W]=c.useState(!1),[jn,de]=c.useState(!1),[De,Le]=c.useState(!1),[Oe,fn]=c.useState(null),[se,ye]=c.useState(null),[vn,bn]=c.useState([]),[Be,yn]=c.useState(()=>h.payload?.minerConfig??Ns()),qe=c.useRef(null),He=c.useRef(null),Y=c.useMemo(()=>x.filter(i=>!i.systemKind&&!i.hiddenFromDefaultSidebar&&i.status!=="active"),[x]),Ue=c.useMemo(()=>new Map(x.map(i=>[i.id,i])),[x]),Ne=c.useMemo(()=>new Map(y.map(i=>[i.sessionId,i])),[y]),ue=c.useMemo(()=>Y.slice(0,500).map(i=>({sessionId:i.id,title:i.title,updatedAt:i.updatedAt})),[Y]),Se=c.useMemo(()=>[...te].flatMap(i=>{const v=j.find(G=>G.sessionId===i);if(v)return[v];const b=Ue.get(i);if(b)return[{sessionId:i,title:b.title,updatedAt:b.updatedAt,snippet:null}];const w=Ne.get(i);return w?[{sessionId:i,title:w.title,updatedAt:w.occurredAt,snippet:null}]:[]}),[j,te,Ue,Ne]),Ce=c.useMemo(()=>[...new Set([...Se,...j].map(i=>i.sessionId))].filter(i=>!X[i]).join(`
4
+ `),[X,j,Se]),ae=c.useMemo(()=>h.payload?.minerRuns.find(i=>i.id===se)??null,[se,h.payload?.minerRuns]),ke=c.useMemo(()=>d.find(i=>Ss(i)&&i.agentSdk?.detected)??null,[d]),oe=c.useMemo(()=>{const i=h.payload?.frontierBaselineRuns??[];return i.find(v=>v.id===Oe)??i.find(v=>["queued","running","cancelling"].includes(v.status))??i[0]??null},[Oe,h.payload?.frontierBaselineRuns]),Ge=!!(oe&&["queued","running","cancelling"].includes(oe.status)),Nn=De||!!(ae&&["queued","running","cancelling"].includes(ae.status)),Ke=jn||De||!!h.busyAction;c.useEffect(()=>C(t??""),[t]),c.useEffect(()=>{if(p!=="automatic_scope"||se)return;const i=h.payload?.minerRuns.find(v=>["queued","running","cancelling"].includes(v.status));i&&ye(i.id)},[se,p,h.payload?.minerRuns]),c.useEffect(()=>{if(!Zn(p,ae))return;const i=new Set(ae.candidateIds);bn(h.payload?.candidates.filter(v=>i.has(v.id))??[]),N("automatic_candidates")},[ae,p,h.payload?.candidates]),c.useEffect(()=>(He.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>He.current?.focus()),[]),c.useEffect(()=>{const i=window.requestAnimationFrame(()=>{qe.current?.querySelector("[data-autofocus], [aria-label^='Back']")?.focus()});return()=>window.cancelAnimationFrame(i)},[p]),c.useEffect(()=>{p==="evidence"&&(A([]),_(0),V(!1),g(null))},[T,p]),c.useEffect(()=>{if(p!=="evidence")return;const i=Q.current+1;Q.current=i,z(!0),g(null);const v=window.setTimeout(()=>{h.actions.searchChats(T,ue,0,rn).then(b=>{Q.current===i&&(A(b.entries),_(b.total),V(b.hasMore),R(b.indexing),ze(b.indexedChats),Pe(b.totalChats))}).catch(b=>{Q.current===i&&(A([]),_(0),V(!1),R(!1),g(b instanceof Error?b.message:String(b)))}).finally(()=>{Q.current===i&&z(!1)})},220);return()=>window.clearTimeout(v)},[ue,T,gn,p,h.actions]),c.useEffect(()=>{if(p!=="evidence"||!T.trim()||!O)return;const i=window.setTimeout(()=>xn(v=>v+1),1500);return()=>window.clearTimeout(i)},[T,O,p]);const Sn=c.useCallback(async()=>{if(J||!Z)return;const i=Q.current,v=j.length;z(!0);try{const b=await h.actions.searchChats(T,ue,v,rn);if(Q.current!==i)return;A(w=>{const G=new Set(w.map(we=>we.sessionId));return[...w,...b.entries.filter(we=>!G.has(we.sessionId))]}),_(b.total),V(b.hasMore),R(b.indexing),ze(b.indexedChats),Pe(b.totalChats)}catch(b){Q.current===i&&g(b instanceof Error?b.message:String(b))}finally{Q.current===i&&z(!1)}},[ue,T,j.length,Z,J,h.actions]);c.useEffect(()=>{const i=Object.fromEntries(y.flatMap(v=>{const b=typeof v.metadata.messageCount=="number"?v.metadata.messageCount:null,w=typeof v.metadata.estimatedTokens=="number"?v.metadata.estimatedTokens:null;return b===null||w===null?[]:[[v.sessionId,{messageCount:b,estimatedTokens:w}]]}));Object.keys(i).length&&be(v=>({...i,...v}))},[y]),c.useEffect(()=>{if(p!=="evidence"||!Ce)return;let i=!1;const v=window.setTimeout(()=>{h.actions.estimateSources(Ce.split(`
5
+ `)).then(b=>{i||be(w=>({...w,...Object.fromEntries(b.map(G=>[G.sessionId,{messageCount:G.messageCount,estimatedTokens:G.estimatedTokens}]))}))}).catch(()=>{})},200);return()=>{i=!0,window.clearTimeout(v)}},[p,h.actions,Ce]),c.useEffect(()=>{if(p!=="automatic_scope"||!Y.length)return;const i=Y.map(b=>b.id).filter(b=>!X[b]);if(!i.length)return;let v=!1;return h.actions.estimateSources(i).then(b=>{v||be(w=>({...w,...Object.fromEntries(b.map(G=>[G.sessionId,{messageCount:G.messageCount,estimatedTokens:G.estimatedTokens}]))}))}).catch(()=>{}),()=>{v=!0}},[Y,X,p,h.actions]);const Cn=c.useMemo(()=>ln([...te],X),[X,te]),kn=c.useMemo(()=>ln(Y.map(i=>i.id),X),[Y,X]);function wn(i){i!==k&&k!==null&&W(!0),l(i)}function Mn(){k==="automated"&&N("automatic_scope"),k==="manual"&&N("manual_goal")}function Tn(i){i!==S&&W(!0),C(i)}function An(i){W(!0),I(i),H(v=>nt(i,v,r))}function _n(i){W(!0),H(i)}function Rn(i){W(!0),q(i)}function En(){W(!0),ve(i=>{const v=new Set(i),b=j.length>0&&j.every(w=>v.has(w.sessionId));for(const w of j)b?v.delete(w.sessionId):v.add(w.sessionId);return v})}function In(i,v){W(!0),ve(b=>{const w=new Set(b);return v?w.add(i):w.delete(i),w})}async function Fn(){const i=[],v=[];for(const b of te){const w=Ne.get(b);w?i.push(w):v.push(b)}return v.length&&i.push(...await h.actions.addSources(v)??[]),i}async function zn(){Le(!0);try{const i={...Be,enabled:!0},v=await h.actions.runMiner([],Y.map(b=>b.id),i);v&&ye(v.id)}finally{Le(!1)}}async function Pn(){if(!ke)return;const i=await h.actions.runCrossSystemFrontierBaseline(ke.id,{providerId:L,modelId:$},B);i&&fn(i.id)}async function $n(){!oe||!Ge||await h.actions.cancelCrossSystemFrontierBaseline(oe.id)}async function Dn(){se&&await h.actions.cancelMinerRun(se)}function Ln(i){const v=new Set(i.evidence.flatMap(w=>w.sourceRefIds)),b=y.filter(w=>v.has(w.id)).map(w=>w.sessionId);ve(new Set(b)),D(i.id),C(i.title),W(!0),N("evidence")}async function On(){de(!0);try{const i=await Fn();if(E&&$e&&!["cancelled","failed","ready"].includes(E.state)){const b=E;await h.actions.cancelCreation(b.id)}const v=await h.actions.startCreation(i.map(b=>b.id),{surface:k==="automated"?"task_candidate":"training_page",mode:"defaults",entryMode:k??"manual",objective:S.trim()||void 0,methodHint:null,candidateId:M,analysisModel:{providerId:L,modelId:$},analysisReasoningEffort:B});if(!v)return;le(v),W(!1),v.state!=="awaiting_disclosure_approval"&&N("recommendation")}finally{de(!1)}}async function Bn(){if(!(!E||E.state!=="awaiting_disclosure_approval")){de(!0);try{const i=await h.actions.approveDisclosure(E.id,!0);if(!i)return;le(i),N("recommendation")}finally{de(!1)}}}async function Ve(){E?.state==="awaiting_disclosure_approval"&&await h.actions.approveDisclosure(E.id,!1),le(null),W(!0)}function qn(){p==="automatic_scope"?N("start"):p==="automatic_candidates"?N("automatic_scope"):p==="manual_goal"?N("start"):p==="evidence"?(E?.state==="awaiting_disclosure_approval"&&Ve(),N(k==="automated"?"automatic_candidates":"manual_goal")):p==="recommendation"&&N("evidence")}async function he(){const i=E;(p!=="start"||S.trim()||te.size>0||i)&&!window.confirm("Close New model? The current selections will be discarded and any active authoring operation will be cancelled.")||(i&&!["cancelled","failed","ready"].includes(i.state)&&await h.actions.cancelCreation(i.id),a())}async function Hn(){if(!E||E.state!=="awaiting_materialization_approval")return;const i=await h.actions.materialize(E.id,!0);i&&(le(i),i.state==="ready"&&u(i))}return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:()=>{he()},children:e.jsxs("section",{ref:qe,className:`training-dialog training-run-dialog ${p==="start"?"training-run-start-step":"training-run-workflow-step"}`,role:"dialog","aria-modal":"true","aria-label":"New model",onKeyDown:i=>{i.key==="Escape"&&(i.preventDefault(),he())},onMouseDown:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{className:"training-run-dialog-title",children:[p!=="start"?e.jsx("button",{"data-autofocus":!0,type:"button","aria-label":ys(p),onClick:qn,children:e.jsx(et,{size:16})}):null,e.jsx("h2",{children:p==="recommendation"?"Recommendation":"New model"})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:()=>{he()},children:e.jsx(Fe,{size:16})})]}),p==="start"?e.jsx(vs,{mode:k,onChange:wn,onContinue:Mn}):p==="automatic_scope"?e.jsx(is,{chatCount:Y.length,config:Be,estimate:kn,frontierBaselineRun:oe,frontierBaselineModel:`${L} · ${$}`,frontierBaselineRunning:Ge,frontierBaselineProject:ke?.name??null,onCancel:()=>{Dn()},onConfigChange:yn,onRunFrontierBaseline:()=>{Pn()},onCancelFrontierBaseline:()=>{$n()},onScan:()=>{zn()},run:ae,scanning:Nn}):p==="automatic_candidates"?e.jsx(as,{candidates:vn,onRescan:()=>{ye(null),N("automatic_scope")},onSelect:Ln}):p==="manual_goal"?e.jsx(hs,{objective:S,onChange:Tn,onContinue:()=>N("evidence")}):p==="evidence"&&k?e.jsx(xs,{authoringModel:$,authoringProvider:L,authoringReasoningEffort:B,busy:Ke,disclosurePending:E?.state==="awaiting_disclosure_approval",estimatesBySessionId:X,matchingSessionCount:K,mode:k,objective:S,onAnalyze:()=>{On()},onApproveDisclosure:()=>{Bn()},onAuthoringModelChange:_n,onAuthoringProviderChange:An,onAuthoringReasoningEffortChange:Rn,onDeclineDisclosure:()=>{Ve()},onSearchChange:F,onLoadMore:()=>{Sn()},onReturnToRecommendation:()=>N("recommendation"),onToggleSession:In,onToggleVisible:En,providerSettings:r,recommendationAvailable:!!E?.proposal&&!$e,search:T,searchError:re,searchHasMore:Z,searchIndexedChats:ee,searchIndexing:O,searchLoading:J,searchTotalChats:pn,selectedEntries:Se,selectedEstimate:Cn,selectedSessionIds:te,visibleSessions:j}):p==="recommendation"&&E?.proposal?e.jsx(gs,{busy:Ke,creation:E,onAddChats:()=>N("evidence"),onClose:()=>{he()},onCreateTaskset:()=>{Hn()},onCreationChange:le,sources:y,training:h}):p==="recommendation"&&E?.state==="awaiting_questions"?e.jsxs("div",{className:"training-evidence-required",children:[e.jsx("div",{className:"training-dialog-scroll-body",children:e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"More evidence is needed"}),e.jsx("p",{children:E.blockingQuestions[0]?.prompt??E.blockedReason??"Add supporting evidence before authoring continues."})]})}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",onClick:()=>N("evidence"),children:"Add chats"})})]}):e.jsx("div",{className:"training-recommendation-loading",children:E?.state==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Analysis failed"}),e.jsx("p",{children:E.blockedReason})]}):e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"spin",size:18}),e.jsx("p",{children:"Preparing the recommendation…"})]})})]})})}function ln(n,t){let s=0,a=0,u=0;for(const o of n){const r=t[o];r&&(u+=1,s+=r.messageCount,a+=r.estimatedTokens)}return{messageCount:s,estimatedTokens:a,measuredChats:u}}function ys(n){return n==="automatic_scope"?"Back to start mode":n==="automatic_candidates"?"Back to scan scope":n==="manual_goal"?"Back to start mode":n==="evidence"?"Back to capability":"Back to evidence"}function Ns(){return{schemaVersion:"openpond.taskMinerConfig.v1",enabled:!1,localOnly:!0,observationWindowDays:30,minimumRecurrence:3,clustering:"hybrid_deterministic_first",consentRequired:!0}}function Ss(n){return[n.name,n.workspacePath.split(/[\\/]/).at(-1)??""].some(t=>t.toLowerCase().replace(/[^a-z0-9]/g,"")==="crosssystemoperations")}function Cs({connection:n,onClose:t,onError:s,onPreferences:a,preferences:u,providers:o}){return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:t,children:e.jsxs("section",{"aria-label":"Training settings","aria-modal":"true",className:"training-dialog training-settings-dialog",role:"dialog",onMouseDown:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsx("div",{children:e.jsx("h2",{children:"Training settings"})}),e.jsx("button",{type:"button","aria-label":"Close",onClick:t,children:e.jsx(Fe,{size:16})})]}),e.jsx("div",{className:"training-settings-dialog-body",children:e.jsx(mt,{connection:n,embedded:!0,onError:s,onPreferences:a,preferences:u,providers:o})})]})})}function Fs({section:n="models",onSectionChange:t,training:s,sessions:a,localProjects:u=[],connection:o,defaultModel:r,onError:f,onToast:d,onSettingsPreferences:x,onOpenChat:y,onChatWithModel:h,onOpenTasksetFiles:m,selectedTasksetId:p,onSelectedTasksetIdChange:N,onSelectedTrainingJobIdChange:k,detailTasksetId:l,onDetailTasksetIdChange:S,launchRequest:C,onLaunchHandled:M,preferences:D,settingsPreferences:L,providerSettings:I,reasoningEffort:$}){const[H,B]=c.useState(!1),[q,T]=c.useState(!1),F=s.payload,j=F?.tasksets.find(_=>_.id===p)??F?.tasksets[0]??null;c.useEffect(()=>{C&&B(!0)},[C]);function A(){B(!1),C&&M(C.id)}function K(_){B(!1),_.materializedTasksetId&&(N(_.materializedTasksetId),S(_.materializedTasksetId),t?.("models")),C&&M(C.id)}return e.jsxs("section",{className:"training-view","aria-label":Ms(n),children:[e.jsx("div",{className:"training-header actions-only",children:e.jsxs("div",{className:"training-header-actions",children:[e.jsx("button",{className:"training-icon-button",type:"button","aria-label":"Refresh training",title:"Refresh",disabled:s.loading,onClick:()=>{s.refresh()},children:e.jsx(rt,{className:s.loading?"spin":void 0,size:15})}),e.jsxs("button",{className:"training-button secondary",type:"button",onClick:()=>T(!0),children:[e.jsx(tt,{size:14})," Settings"]})]})}),s.error?e.jsxs("div",{className:"training-banner error",children:[e.jsx(st,{size:15}),s.error]}):null,s.busyAction?e.jsxs("div",{className:"training-banner",children:[e.jsx(ne,{className:"spin",size:15}),"Working on ",s.busyAction.replaceAll("-"," "),"…"]}):null,n==="suggestions"?e.jsx(ts,{training:s,defaultModel:r,preferences:D,reasoningEffort:$,onPlanStarted:()=>{S(null),t?.("evals")}}):n==="models"?e.jsx(ns,{training:s,connection:o,onOpenTasksetFiles:_=>{N(_),m()},onOpenTaskset:_=>{N(_),S(null),t?.("evals")},onSelectedTasksetIdChange:N,onSelectedJobIdChange:k,onChatWithModel:h,onToast:d,detailTasksetId:l,onDetailTasksetIdChange:S}):n==="evals"?e.jsx(ks,{onOpenChat:y,selectedTaskset:j,selectedTasksetId:j?.id??null,setSelectedTasksetId:N,training:s}):null,H&&F?e.jsx(bs,{defaultModel:r,initialObjective:C?.objective??null,initialSessionIds:C?.initialSessionIds??[],onClose:A,onTasksetCreated:K,preferences:D,providerSettings:I,reasoningEffort:$,localProjects:u,sessions:a,sources:F.sources,training:s}):null,q?e.jsx(Cs,{connection:o,onClose:()=>T(!1),onError:f,onPreferences:x,preferences:L,providers:I}):null]})}function ks({onOpenChat:n,selectedTaskset:t,selectedTasksetId:s,setSelectedTasksetId:a,training:u}){const o=u.payload,r=o?.creations.find(f=>!["cancelled","failed","ready"].includes(f.state))??null;return e.jsxs("div",{className:"training-workbench",children:[r?e.jsxs("section",{className:"training-active-plan",children:[e.jsx("div",{className:"training-section-heading",children:e.jsxs("div",{children:[e.jsx("h2",{children:"Current plan"}),e.jsx("p",{children:"Review the authoring model’s proposal before creating a Taskset."})]})}),e.jsx(at,{creation:r,training:u})]}):null,e.jsxs("section",{className:"training-workbench-section",children:[e.jsx("label",{className:"training-taskset-selector",children:e.jsxs("select",{"aria-label":"Taskset",disabled:!o?.tasksets.length,value:s??"",onChange:f=>a(f.target.value||null),children:[o?.tasksets.length?null:e.jsx("option",{value:"",children:"No Tasksets yet"}),o?.tasksets.map(f=>e.jsx("option",{value:f.id,children:f.name},f.id))]})}),t?e.jsx("main",{className:"training-detail",children:e.jsx(yt,{taskset:t,training:u,onOpenChat:n})}):e.jsx(ws,{})]})]})}function ws(){return e.jsxs("div",{className:"training-empty-detail",children:[e.jsx(it,{size:22}),e.jsx("h2",{children:"No Tasksets yet"}),e.jsx("p",{children:"Start a model to create one from selected chats."})]})}function Ms(n){return n==="evals"?"Evals":n==="suggestions"?"AI Suggestions":"Models"}export{Fs as TrainingView};
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./WorkspaceMonacoEditor-BBqimG5X.js","./index-CU2qhUYV.js","./index-BdY6A-YN.css","./WorkspaceMonacoEditor-BwKcXIZw.css"])))=>i.map(i=>d[i]);
2
+ import{d as be,j as e,aB as Ge,aC as ms,t as Ut,r as o,m as z,aD as ft,aE as pt,N as Fe,T as Wn,aF as On,s as ot,F as Bn,aG as Un,Z as As,aH as qn,aI as Vn,K as Hn,X as xs,h as Gn,M as Kn,S as Qn,aJ as Zn,aK as Xn,aL as Yn,aM as Jn,R as gs,aN as Wt,aO as ea,aP as ta,aQ as Ps,aR as sa,aS as na,x as aa,aT as ia,aU as Tt,aV as la,aW as Ot,aX as me,aY as ra,aZ as bs,a_ as oa,a$ as ca,b0 as js,b1 as da,b2 as ua}from"./index-CU2qhUYV.js";import{R as Bt}from"./refresh-cw-N5b_6AP5.js";import{t as fa,a as pa,m as ha,s as ma,d as xa,f as ga,b as ba}from"./training-model-data-BPrc68VG.js";import{I as vs}from"./info-CQNTh78o.js";import{S as ja}from"./save-D0oHH1a3.js";const va=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],wa=be("text-align-start",va);const ka=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],ya=be("chevrons-up",ka);const Sa=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Na=be("columns-2",Sa);const Ca=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],Ra=be("file",Ca);const $a=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}]],Fa=be("panel-top",$a);const Ea=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],Aa=be("redo-2",Ea);const Pa=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],La=be("undo-2",Pa);function Da({createRuntime:t,goalRuntime:s,subagentRuntime:n=null,onRunSubagentLifecycleAction:a}){const i=t?"Create Plan Details":"Goal Details",r=t?U(t.snapshot?.state??"planning"):n?.activeCount?n.label:s?.actionLabel??"No active goal";return e.jsxs("div",{className:"goal-details-view","aria-label":i,children:[e.jsxs("div",{className:"goal-details-header",children:[e.jsxs("div",{className:"goal-details-title",children:[e.jsx(Ge,{size:15,"aria-hidden":"true"}),e.jsx("span",{children:i})]}),e.jsx("span",{className:`goal-details-state ${ti(t?.snapshot?.state??null)}`,children:r})]}),e.jsx("div",{className:"goal-details-body",children:t?e.jsx(_a,{runtime:t}):s||n?e.jsx(Ma,{goalRuntime:s,subagentRuntime:n,onRunSubagentLifecycleAction:a}):e.jsx(ei,{})})]})}function _a({runtime:t}){const{request:s,snapshot:n}=t,a=n?.plan??null,i=ms(a?.metadata)??ms(s.metadata),r=n?.questions??[],c=r.filter(d=>d.status==="pending"),u=n?.sourceRefs??[],f=n?.checkRefs??[],p=n?.state??"planning";return e.jsxs(e.Fragment,{children:[e.jsx(B,{title:"Create State",children:e.jsx(Ve,{rows:[["State",U(p)],["Operation",s.operation],["Surface",U(s.surface)],["Command",s.command],["Agent",s.targetAgent.displayName??s.targetAgent.agentId??"Model will decide"],["Agent ID",s.targetAgent.agentId??"Pending"],["Default action",s.targetAgent.defaultActionKey??a?.defaultChatAction.key??"Pending"],["Adapter",U(s.adapter.kind)],["Turn",t.turnId??"Pending"]]})}),e.jsx(B,{title:"Plan",children:a?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"goal-details-summary",children:a.summary}),e.jsx(Ve,{rows:[["Objective",a.objective],["Context",a.capturedContextSummary],["Status",U(a.status)],["Plan ID",a.id],["Goal ID",a.goalId],["Approval",a.approvalId??"Pending"],["Approved",a.approvedAt??"Not approved"]]})]}):c.length?e.jsx("p",{className:"goal-details-summary",children:"Waiting for answers before the model finalizes the Create plan."}):e.jsx("p",{className:"goal-details-summary",children:"The model is preparing the Create plan."})}),i?e.jsxs(B,{title:"Action Shape",children:[e.jsx(Ve,{rows:[["Mode",i.label],["Default action",i.defaultActionKey??"None"],["Direct action",i.directActionHint??"None planned"],["Artifacts",i.artifactPolicy]]}),e.jsx("p",{className:"goal-details-note",children:i.detail})]}):null,r.length?e.jsx(B,{title:"Questions",children:e.jsx("div",{className:"goal-details-list",children:r.map(d=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:d.title}),e.jsx("span",{className:`goal-details-inline-state ${d.status}`,children:U(d.status)})]}),e.jsx("p",{children:d.prompt}),d.answer?e.jsxs("small",{children:["Answer: ",d.answer.label??d.answer.value]}):d.options.length?e.jsxs("small",{children:["Options: ",d.options.map(g=>g.label).join(", ")]}):null]},d.id))})}):null,a?.requirements.length?e.jsx(B,{title:"Setup Requirements",children:e.jsx("div",{className:"goal-details-list",children:a.requirements.map(d=>e.jsxs("article",{className:"goal-details-list-item",children:[e.jsxs("div",{children:[e.jsx("strong",{children:d.name}),e.jsx("span",{className:`goal-details-inline-state ${d.status}`,children:U(d.status)})]}),e.jsxs("small",{children:[U(d.kind),d.detail?`: ${d.detail}`:""]})]},`${d.kind}:${d.name}`))})}):null,a?.sourcePlan.length?e.jsx(B,{title:"Source Plan",children:e.jsx(rt,{refs:a.sourcePlan.map(d=>({id:`${d.operation}:${d.path}`,primary:d.path,secondary:`${U(d.operation)}: ${d.reason}`}))})}):null,a?.checks.length?e.jsx(B,{title:"Checks",children:e.jsx(rt,{refs:a.checks.map(d=>({id:d.name,primary:d.name,secondary:`${d.required?"Required":"Optional"}: ${d.command}`}))})}):null,u.length||f.length?e.jsx(B,{title:"Run Refs",children:e.jsx(rt,{refs:[...u.map(d=>({id:`source:${d}`,primary:d,secondary:"Source ref"})),...f.map(d=>({id:`check:${d}`,primary:d,secondary:"Check ref"}))]})}):null,e.jsx(Ta,{request:s,snapshot:n}),n?.blockedReason?e.jsx(B,{title:"Blocked",children:e.jsxs("div",{className:"goal-details-alert",children:[e.jsx(Ut,{size:15}),e.jsx("span",{children:n.blockedReason})]})}):null,e.jsx(B,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify({request:s,snapshot:n},null,2)})]})})]})}function Ta({request:t,snapshot:s}){const n=[...t.context.attachments.map(r=>({id:`attachment:${r.id??r.name}`,primary:r.name,secondary:r.ref??r.mediaType??"Attachment"})),...t.context.apps.map(r=>({id:`app:${r.id}`,primary:r.name,secondary:r.required?"Required app context":"Optional app context"})),...t.context.tools.map(r=>({id:`tool:${r.name}`,primary:r.name,secondary:r.outputSummary??r.inputSummary??"Tool context"})),...t.context.targetRepoAssumptions.map(r=>({id:`target:${r}`,primary:r,secondary:"Target assumption"}))],a=s?.workflowCapture,i=a?[...a.files.map(r=>({id:`workflow-file:${r}`,primary:r,secondary:"Captured file"})),...a.outputArtifacts.map(r=>({id:`workflow-artifact:${r}`,primary:r,secondary:"Output artifact"})),...a.traceRefs.map(r=>({id:`workflow-trace:${r}`,primary:r,secondary:"Trace"}))]:[];return!n.length&&!i.length?null:e.jsx(B,{title:"Context",children:e.jsx(rt,{refs:[...n,...i]})})}function Ma({goalRuntime:t,subagentRuntime:s,onRunSubagentLifecycleAction:n}){return e.jsxs(e.Fragment,{children:[t?e.jsxs(B,{title:"Goal",children:[e.jsx("p",{className:"goal-details-summary",children:t.objective}),e.jsx(Ve,{rows:[["Status",t.actionLabel],["Runtime",t.timeLabel],["Detail",t.detail]]})]}):null,s?e.jsx(za,{runtime:s,onRunSubagentLifecycleAction:n}):null,e.jsx(B,{title:"Raw State",children:e.jsxs("details",{className:"goal-details-raw",children:[e.jsx("summary",{children:"Show structured payload"}),e.jsx("pre",{children:JSON.stringify({goalRuntime:t,subagentRuntime:s},null,2)})]})})]})}function za({runtime:t,onRunSubagentLifecycleAction:s}){const[n,a]=o.useState(null),[i,r]=o.useState(null),c=async(u,f)=>{if(!s)return;const p=`${u}:${f}`;a(p),r(null);try{await s({runId:u,action:f})}catch(d){r(d instanceof Error?d.message:String(d))}finally{a(d=>d===p?null:d)}};return e.jsxs(e.Fragment,{children:[e.jsxs(B,{title:"Subagents",children:[e.jsx(Ve,{rows:[["Background check",Va(t)],["Latest update",Ha(t)],["Active",String(t.activeCount)],["Blocked",String(t.blockedCount)],["Failed",String(lt(t,["failed","failed_with_artifacts"]))],["Cancelled",String(lt(t,["cancelled"]))],["Unresolved",String(t.unresolvedCount)],["Terminal",String(t.terminalCount)],["Archived",String(t.archivedCount)],["Review submitted",String(t.submittedCount)],["Review revision",String(t.needsRevisionCount)],["Review user input",String(t.needsUserInputCount)],["Review failed artifacts",String(t.failedWithArtifactsCount)],["Review accepted",String(t.acceptedCount)],["Required active",String(t.requiredActiveCount)],["Required submitted",String(t.requiredSubmittedForReviewCount)],["Required revision",String(t.requiredNeedsRevisionCount)],["Required user input",String(t.requiredNeedsUserInputCount)],["Required blocking",String(t.requiredBlockingCount)],["Required failed",String(lt(t,["failed","failed_with_artifacts"],!0))],["Required cancelled",String(lt(t,["cancelled"],!0))],["Required accepted",String(t.requiredAcceptedCount)],["Required terminal",String(t.requiredTerminalCount)],["Required archived",String(t.requiredArchivedCount)],["Required unresolved",String(t.requiredUnresolvedCount)],["Usage",Qa(t.usage.totalTokens,t.usage.requestCount)],["Evidence",String(t.evidenceRefs.length)],["Checks",String(t.testsRunCount)]]}),t.blockers.length>0?e.jsx("ul",{className:"goal-details-list compact",children:t.blockers.slice(0,4).map(u=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${u.status}`,children:u.status}),e.jsxs("div",{children:[e.jsx("strong",{children:Ke(u.roleId)}),e.jsx("p",{children:u.message})]})]},`${u.runId}:${u.message}`))}):null,e.jsx("ul",{className:"goal-details-list",children:t.runs.slice(0,8).map(u=>e.jsxs("li",{className:"goal-details-list-item",children:[e.jsx("span",{className:`goal-details-inline-state ${u.status}`,children:u.status}),e.jsxs("div",{children:[e.jsx("strong",{children:Ke(u.roleId)}),e.jsx("p",{children:u.objective}),u.report?.summary?e.jsx("small",{children:u.report.summary}):null,s?e.jsx(Wa,{pendingAction:n,run:u,onRun:c}):null]})]},u.id))}),i?e.jsxs("div",{className:"goal-details-alert",children:[e.jsx(Ut,{size:15}),e.jsx("span",{children:i})]}):null]}),t.finalResults.length>0?e.jsx(Ia,{results:t.finalResults}):null,t.taskGraph.nodes.length>0?e.jsx(Ga,{runtime:t}):null]})}function Ia({results:t}){return e.jsx(B,{title:"Child Results",children:e.jsx("ol",{className:"goal-details-task-graph",children:t.slice(0,6).map(s=>e.jsxs("li",{className:"goal-details-task-node",children:[e.jsxs("div",{className:"goal-details-task-node-header",children:[e.jsx("span",{className:`goal-details-inline-state ${s.status}`,children:s.status}),e.jsxs("div",{children:[e.jsx("strong",{children:Ke(s.roleId)}),e.jsx("small",{children:s.objective})]})]}),e.jsx("p",{children:s.summary}),e.jsxs("div",{className:"goal-details-task-node-meta",children:[e.jsx("span",{children:s.required?"Required":"Optional"}),e.jsxs("span",{children:[s.refs.length," refs"]}),e.jsxs("span",{children:[s.testsRun.length+s.validationAttempts.length," checks"]}),e.jsxs("span",{children:[s.blockers.length," blockers"]}),e.jsx("span",{children:s.confidence?`${U(s.confidence)} confidence`:"Confidence unknown"}),e.jsxs("span",{children:[U(s.packetQualityStatus)," packet"]}),e.jsx("span",{children:s.independentReviewRecommended?"Independent review recommended":"Parent review"})]}),s.findings.length>0?e.jsxs("small",{children:["Findings: ",le(s.findings,3)]}):null,s.changedFiles.length>0?e.jsxs("small",{children:["Files: ",le(s.changedFiles,4)]}):null,s.testsRun.length>0?e.jsxs("small",{children:["Tests: ",le(s.testsRun,3)]}):null,s.validationAttempts.length>0?e.jsxs("small",{children:["Validation: ",le(s.validationAttempts,2)]}):null,ws(s)?e.jsxs("small",{children:["Packet evidence: ",ws(s)]}):null,s.reviewerRoutingReasons.length>0?e.jsxs("small",{children:["Review routing: ",le(s.reviewerRoutingReasons.map(U),3)]}):null,s.refs.length>0?e.jsxs("small",{children:["Refs: ",le(s.refs.map(Za),4)]}):null,s.blockers.length>0?e.jsxs("small",{children:["Blockers: ",le(s.blockers,3)]}):null,s.workspaceRetention?e.jsxs("small",{children:["Workspace: ",Ya(s.workspaceRetention)]}):null,s.importantMessages.length>0?e.jsxs("small",{children:["Messages: ",le(s.importantMessages.map(Xa),2)]}):null]},s.runId))})})}function Wa({pendingAction:t,run:s,onRun:n}){const a=Oa(s);return a.length===0?null:e.jsx("div",{className:"goal-details-actions",children:a.map(i=>{const r=`${s.id}:${i}`,c=t===r;return e.jsx("button",{type:"button",disabled:!!t,onClick:()=>{n(s.id,i)},children:c?"Working...":Ba(i)},i)})})}function Oa(t){const s=[],n=Ua(t),a=qa(t);return n&&s.push("cleanup"),a&&s.push("archive"),s}function Ba(t){return t==="cleanup"?"Clean":t==="archive"?"Archive":"Clean + archive"}function Ua(t){if(!Ls(t))return!1;const s=He(t.metadata);if(!s?.subagentWorkspace&&!s?.workspaceHandoff)return!1;const n=He(s.lifecycleCleanup),a=He(n?.workspaceCleanup),i=_s(a?.status);return i!=="removed"&&i!=="deleted"&&i!=="retained"&&i!=="skipped"}function qa(t){if(!t.childSessionId||!Ls(t))return!1;const s=He(He(t.metadata)?.childSessionArchive),n=_s(s?.status);return n!=="archived"&&n!=="already_archived"}function Ls(t){return t.status==="accepted"||t.status==="completed"||t.status==="failed_with_artifacts"||t.status==="failed"||t.status==="cancelled"||t.status==="superseded"||t.review?.status==="accepted"}function Va(t){if(!t.watcher)return"Not checked";const s=t.watcher.wakeQueued?"parent wake queued":t.watcher.wakePolicy==="not_waking_parent_for_routine_tick"?"routine check":t.watcher.wakePolicy?U(t.watcher.wakePolicy):"no parent wake",n=t.watcher.staleCount>0?` · ${t.watcher.staleCount} stale`:"";return`${Ds(t.watcher.checkedAt)} · ${s}${n}`}function Ha(t){const s=t.latestMeaningfulUpdate;return s?`${Ke(s.roleId)} ${s.status}: ${s.message}`:"No structured update"}function lt(t,s,n=!1){const a=new Set(s);return t.runs.filter(i=>(!n||i.required)&&a.has(i.status)).length}function Ga({runtime:t}){const s=new Map;for(const n of t.taskGraph.edges){const a=s.get(n.toRunId)??[];a.push(n),s.set(n.toRunId,a)}return e.jsx(B,{title:"Task Graph",children:e.jsx("ol",{className:"goal-details-task-graph",children:t.taskGraph.nodes.map(n=>{const a=s.get(n.runId)??[];return e.jsxs("li",{className:"goal-details-task-node",children:[e.jsxs("div",{className:"goal-details-task-node-header",children:[e.jsx("span",{className:`goal-details-inline-state ${n.status}`,children:n.status}),e.jsxs("div",{children:[e.jsx("strong",{children:Ke(n.roleId)}),e.jsxs("small",{children:[n.modelLabel," · ",n.isolationLabel]})]})]}),e.jsx("p",{children:n.objective}),e.jsxs("div",{className:"goal-details-task-node-meta",children:[e.jsx("span",{children:n.required?"Required":"Optional"}),e.jsxs("span",{children:[n.evidenceCount," evidence"]}),e.jsxs("span",{children:[n.testsRunCount," checks"]}),e.jsxs("span",{children:[n.blockerCount," blockers"]})]}),a.length>0?e.jsx("div",{className:"goal-details-task-edges",children:a.slice(0,3).map(i=>e.jsx("span",{children:Ka(i.fromRunId,i.label,t.sessionId)},i.id))}):null,n.summary?e.jsx("small",{children:n.summary}):null]},n.runId)})})})}function Ka(t,s,n){return t===`parent:${n}`?`Parent ${s.toLowerCase()}`:t.startsWith("parent:")?`Parent ${s.toLowerCase()}`:`${t} ${s.toLowerCase()}`}function Qa(t,s){if(t<=0&&s<=0)return"0 tokens";const n=`${s} ${s===1?"request":"requests"}`;return`${Ja(t)} tokens · ${n}`}function Ke(t){return t.slice(0,1).toUpperCase()+t.slice(1).replace(/[-_]+/g," ")}function Za(t){return`${t.kind}: ${t.label}`}function Xa(t){return`${U(t.kind)}: ${t.body}`}function ws(t){const s=t.packetQualityEvidence,n=[t.packetQualityStatus!=="reviewable"?U(t.packetQualityStatus):null,s.finalSummaryPresent?null:"summary missing",s.requestedValidationCommandCount>0&&s.validationAttemptCount+s.testsRunCount===0?"validation missing":null,s.failedValidationCount>0?`${s.failedValidationCount} failed validation`:null,s.unvalidatedWorkspaceChanges?"unvalidated workspace changes":null,s.changedFileCount>0?`${s.changedFileCount} changed ${s.changedFileCount===1?"file":"files"}`:null].filter(Boolean);return n.length>0?le(n,4):null}function Ya(t){const s=t.expiresAt?`until ${Ds(t.expiresAt)}`:"for inspection",n=t.trigger?` · ${U(t.trigger)}`:"";return`retained ${s}${n}`}function le(t,s){const n=t.slice(0,s),a=t.length-n.length;return a>0?`${n.join(", ")} +${a}`:n.join(", ")}function Ja(t){if(t<1e3)return String(t);if(t>=1e6){const n=t/1e6;return`${ks(n,n<10?2:1)}M`}const s=t/1e3;return`${ks(s,s<10?1:0)}k`}function Ds(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:s.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function ks(t,s){return t.toFixed(s).replace(/\.0+$/,"").replace(/(\.\d*?)0+$/,"$1")}function ei(){return e.jsxs("div",{className:"goal-details-empty",children:[e.jsx(Ge,{size:18}),e.jsx("span",{children:"No active Goal or Create workflow."})]})}function B({children:t,title:s}){return e.jsxs("section",{className:"goal-details-section",children:[e.jsx("h2",{children:s}),t]})}function Ve({rows:t}){return e.jsx("dl",{className:"goal-details-grid",children:t.map(([s,n])=>e.jsxs("div",{children:[e.jsx("dt",{children:s}),e.jsx("dd",{children:n})]},s))})}function rt({refs:t}){return e.jsx("ul",{className:"goal-details-ref-list",children:t.map(s=>e.jsxs("li",{children:[e.jsx("code",{title:s.primary,children:s.primary}),e.jsx("span",{children:s.secondary})]},s.id))})}function He(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function _s(t){return typeof t=="string"&&t.trim()?t.trim():null}function U(t){return t.split(/[_-]/g).filter(Boolean).map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(" ")}function ti(t){return t==="ready_local"||t==="published_hosted"?"success":t==="blocked"||t==="failed"||t==="cancelled"?"danger":t==="awaiting_questions"||t==="awaiting_plan_approval"?"warning":"active"}function si({sandboxId:t,connection:s}){const[n,a]=o.useState(null),[i,r]=o.useState([]),[c,u]=o.useState(null),[f,p]=o.useState(null),[d,g]=o.useState(null),[w,y]=o.useState(null),_=n?.integrationLeases??[],T=o.useMemo(()=>i.filter(x=>x.status==="active"),[i]),A=o.useMemo(()=>ai(n),[n]),F=o.useCallback(async()=>{if(!s){g("OpenPond App server is not connected.");return}if(!t){a(null),r([]),g(null);return}u("summary"),g(null);try{const x=await z.sandbox(s,t),N=await z.integrationConnections(s,ys(x.sandbox));a(x.sandbox),r(N.connections),y(null)}catch(x){g(x instanceof Error?x.message:String(x))}finally{u(null)}},[s,t]),K=o.useCallback(async()=>{if(!(!s||!n)){p("load"),y(null);try{const[x,N]=await Promise.all([z.integrationConnections(s,ys(n)),z.sandboxIntegrationLeases(s,n.id)]);r(x.connections),a(N.sandbox)}catch(x){y(x instanceof Error?x.message:String(x))}finally{p(null)}}},[s,n]),Q=o.useCallback(async x=>{if(!s||!n)return;const N=ft(x.provider),M=N?pt(N):null,L=M?.leasePolicy.allowedCapabilityIds??[];if(!N||!M?.leasePolicy.leaseable||L.length===0){y(`${te(x.provider)} cannot be attached to this sandbox.`);return}p(`attach:${x.id}`),y(null);try{const R=await z.attachSandboxIntegrationConnection(s,n.id,{connectionId:x.id,provider:x.provider,capabilities:L,...x.scopes.length>0?{scopes:x.scopes}:{},...M.leasePolicy.defaultTtlSeconds?{ttlSeconds:M.leasePolicy.defaultTtlSeconds}:{},required:!1});a(R.sandbox)}catch(R){y(R instanceof Error?R.message:String(R))}finally{p(null)}},[s,n]),H=o.useCallback(async x=>{if(!(!s||!n)){p(`remove:${x}`),y(null);try{const N=await z.removeSandboxIntegrationLease(s,n.id,x);a(N.sandbox)}catch(N){y(N instanceof Error?N.message:String(N))}finally{p(null)}}},[s,n]);return o.useEffect(()=>{F()},[F]),t?e.jsxs("div",{className:"sandbox-summary-tab",children:[e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Sandbox"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[n?e.jsx("span",{children:n.state}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh summary","aria-label":"Refresh summary",disabled:c!==null,onClick:()=>{F()},children:c==="summary"?e.jsx(Fe,{className:"spinning",size:14}):e.jsx(Bt,{size:14})})]})]}),d?e.jsx("div",{className:"sandbox-workspace-error",children:d}):null,n?e.jsxs("dl",{className:"sandbox-workspace-kv",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Sandbox"}),e.jsx("dd",{children:Ss(n.id)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Runtime"}),e.jsx("dd",{children:n.runtimeDriver})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Spend"}),e.jsxs("dd",{children:[Mt(n.reservation.capturedUsd)," / ",Mt(n.budget.maxUsd)]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Reservation"}),e.jsx("dd",{children:n.reservation.status})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Idle cleanup"}),e.jsx("dd",{children:n.quotas?.idleTimeoutSeconds?`${Math.round(n.quotas.idleTimeoutSeconds/60)} min`:"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Updated"}),e.jsx("dd",{children:Ts(n.updatedAt)})]}),A?e.jsxs("div",{children:[e.jsx("dt",{children:"Receipt"}),e.jsxs("dd",{children:[Ss(A.id)," / ",Mt(A.totalUsd)]})]}):null]}):e.jsxs("div",{className:"sandbox-workspace-loading",children:[c==="summary"?e.jsx(Fe,{className:"spinning",size:16}):null,e.jsx("span",{children:c==="summary"?"Loading sandbox":"Sandbox unavailable"})]})]}),e.jsxs("section",{className:"sandbox-workspace-section",children:[e.jsxs("div",{className:"sandbox-workspace-heading",children:[e.jsx("h3",{children:"Integrations"}),e.jsxs("div",{className:"sandbox-workspace-heading-actions",children:[e.jsx("span",{children:_.length}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Refresh integrations","aria-label":"Refresh integrations",disabled:f!==null||!n,onClick:()=>{K()},children:f==="load"?e.jsx(Fe,{className:"spinning",size:14}):e.jsx(Bt,{size:14})})]})]}),w?e.jsx("div",{className:"sandbox-workspace-error",children:w}):null,_.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:_.map(x=>e.jsxs("div",{className:"sandbox-workspace-integration-row",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:te(x.provider)}),e.jsxs("small",{children:[x.required?"required":"optional"," / ",ri(x)," / ",ni(x)]})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:`Revoke ${te(x.provider)} lease`,"aria-label":`Revoke ${te(x.provider)} lease`,disabled:f!==null,onClick:()=>{H(x.leaseId)},children:f===`remove:${x.leaseId}`?e.jsx(Fe,{className:"spinning",size:14}):e.jsx(Wn,{size:14})}),e.jsxs("div",{className:"sandbox-workspace-chip-row",children:[x.capabilities.slice(0,5).map(N=>e.jsx("span",{children:li(x.provider,N)},N)),x.capabilities.length>5?e.jsxs("span",{children:["+",x.capabilities.length-5]}):null]})]},x.leaseId))}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No active integration leases."}),T.length>0?e.jsx("div",{className:"sandbox-workspace-integration-list",children:T.map(x=>{const N=_.some(R=>R.provider===x.provider),L=ii(x)?.leasePolicy.allowedCapabilityIds.length??0;return e.jsxs("div",{className:"sandbox-workspace-integration-row compact",children:[e.jsxs("div",{className:"sandbox-workspace-integration-main",children:[e.jsx("span",{children:oi(x)}),e.jsx("small",{children:ci(x,L)})]}),e.jsx("button",{type:"button",className:"diff-icon-button",title:N?`${te(x.provider)} already attached`:`Attach ${te(x.provider)}`,"aria-label":N?`${te(x.provider)} already attached`:`Attach ${te(x.provider)}`,disabled:N||f!==null||L===0,onClick:()=>{Q(x)},children:f===`attach:${x.id}`?e.jsx(Fe,{className:"spinning",size:14}):e.jsx(On,{size:14})})]},x.id)})}):e.jsx("p",{className:"sandbox-workspace-empty",children:"No connected accounts available."})]})]}):e.jsx("div",{className:"sandbox-summary-tab",children:e.jsx("p",{className:"sandbox-workspace-empty",children:"No sandbox is attached yet."})})}function ys(t){return{status:"active"}}function ni(t){return t.proxyUrl?"runtime proxy available":"metadata only, no runtime proxy"}function ai(t){return t?.receipts?.at(-1)??null}function ii(t){const s=ft(t.provider);return s?pt(s):null}function te(t){const s=ft(t),n=s?pt(s):null;return n?n.label:t==="microsoft_teams"?"Microsoft Teams":t?t.replace(/_/g," "):"Integration"}function li(t,s){const n=ft(t);return(n?pt(n):null)?.capabilities.find(i=>i.id===s)?.label??s}function ri(t){return t.expiresAt?`expires ${Ts(t.expiresAt)}`:"active"}function oi(t){const s=t.providerAccountName?.trim();return s?`${te(t.provider)} / ${s}`:te(t.provider)}function ci(t,s){const n=[];return t.providerWorkspaceName&&n.push(t.providerWorkspaceName),n.push(`${s} lease ${s===1?"capability":"capabilities"}`),t.scopes.length>0&&n.push(`${t.scopes.length} ${t.scopes.length===1?"scope":"scopes"}`),n.join(" / ")}function Ss(t){return t.length>10?`${t.slice(0,8)}...`:t}function Ts(t){if(!t)return"-";const s=new Date(t);return Number.isNaN(s.valueOf())?"-":new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function Mt(t){const s=Number(t??0);return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:s>=10?2:4}).format(Number.isFinite(s)?s:0)}function di({summary:t}){const s=fa(t.taskset),n=t.taskset.learningSignals.demonstrations.filter(c=>c.approved).length,a=t.taskset.tasks.filter(c=>c.split==="frozen_eval").length,i=t.plan?.recipe.method==="sft"?t.plan.recipe:null,r=pa(t.taskset,t.plan);return e.jsxs("div",{className:"training-sidebar-summary",children:[e.jsxs("header",{children:[e.jsx("h2",{children:ha(t.taskset.name)}),e.jsx("span",{children:t.job?ma(t.job.status):t.taskset.readiness?.ready?"Ready to train":"Needs review"})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Run"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Primary recommendation",value:s.toUpperCase()}),e.jsx(O,{label:"Training stage",value:r}),e.jsx(O,{label:"Base model",value:i?.baseModel.id??"Not selected"}),e.jsx(O,{label:"Compute",value:t.plan?xa(t.plan.destinationId):"Not selected"}),e.jsx(O,{label:"Started",value:ga(t.job?.startedAt??null)}),e.jsx(O,{label:"Duration",value:ba(t.job?.startedAt??null,t.job?.completedAt??null)})]})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Data"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Training examples",value:String(n)}),e.jsx(O,{label:"Test examples",value:String(a)}),e.jsx(O,{label:"Chats",value:String(t.taskset.sourceRefs.length)})]})]}),i?e.jsxs("section",{children:[e.jsx("h3",{children:"Recipe"}),e.jsxs("dl",{children:[e.jsx(O,{label:"LoRA rank",value:String(i.lora.rank)}),e.jsx(O,{label:"Learning rate",value:String(i.optimizer.learningRate)}),e.jsx(O,{label:"Steps",value:String(i.optimizer.maxSteps)}),e.jsx(O,{label:"Sequence length",value:String(i.dataset.maxSequenceLength)})]})]}):null,e.jsxs("section",{children:[e.jsx("h3",{children:"Result"}),e.jsxs("dl",{children:[e.jsx(O,{label:"Adapter",value:t.lineage?`${r} ready`:"Not created"}),e.jsx(O,{label:"Evaluation",value:t.lineage?.frozenEvaluationArtifactId?"Completed":"Not completed"}),e.jsx(O,{label:"Artifacts",value:String(t.artifacts.length)})]})]})]})}function O({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function ui(t){const s=Ns("","","folder");for(const n of t){const a=n.endsWith("/"),i=n.split("/").filter(Boolean);if(i.length===0)continue;let r=s,c="";for(let u=0;u<i.length;u+=1){const f=i[u];c=c?`${c}/${f}`:f;const p=!a&&u===i.length-1?"file":"folder",d=`${p}:${f}`;let g=r.childMap.get(d);g||(g=Ns(f,c,p),r.childMap.set(d,g),r.children.push(g)),r=g}}return Ms(s.children)}function Ns(t,s,n){return{name:t,path:s,type:n,children:[],childMap:new Map}}function Ms(t){return t.sort((s,n)=>s.type!==n.type?s.type==="folder"?-1:1:s.name.localeCompare(n.name)).map(s=>({name:s.name,path:s.path,type:s.type,children:Ms(s.children)}))}function fi({changedByPath:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,onOpenFile:i,onToggleFolder:r}){const c=o.useMemo(()=>ui(a),[a]);return e.jsxs("div",{className:"workspace-file-tree-view",children:[e.jsxs("div",{className:"workspace-file-tree-header",children:[e.jsx(ot,{size:14}),e.jsx("strong",{title:n??void 0,children:n?n.split("/").at(-1):"Files"}),e.jsx("span",{children:a.length})]}),e.jsx("div",{className:"workspace-file-tree",children:c.map(u=>e.jsx(zs,{changedByPath:t,expandedFolderPaths:s,node:u,rootPath:n,onOpenFile:i,onToggleFolder:r},`${u.type}:${u.path}`))})]})}function zs({changedByPath:t,depth:s=0,expandedFolderPaths:n,node:a,rootPath:i,onOpenFile:r,onToggleFolder:c}){const u=i?`${i}/${a.path}`:a.path,f=a.type==="folder"&&n.has(u),p=t.get(u),d=2+s*11;return a.type==="folder"?e.jsxs("div",{className:"workspace-file-tree-node",children:[e.jsxs("button",{type:"button",className:"workspace-file-tree-row folder","aria-expanded":f,style:{paddingLeft:d},onClick:()=>c(u),children:[f?e.jsx(ot,{size:14}):e.jsx(Bn,{size:14}),e.jsx("span",{children:a.name})]}),f&&a.children.map(g=>e.jsx(zs,{changedByPath:t,depth:s+1,expandedFolderPaths:n,node:g,rootPath:i,onOpenFile:r,onToggleFolder:c},`${g.type}:${g.path}`))]}):e.jsxs("button",{type:"button",className:`workspace-file-tree-row file ${p?"changed":""}`,style:{paddingLeft:d},onClick:()=>r(u),children:[e.jsx(Ra,{size:13}),e.jsx("span",{children:a.name}),p&&e.jsxs("small",{children:[e.jsxs("span",{className:"diff-addition",children:["+",p.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",p.deletions]})]})]})}function pi({diff:t,expandedFolderPaths:s,rootPath:n,repoFiles:a,onOpenFile:i,onToggleFolder:r}){const c=t?.files??[],u=o.useMemo(()=>new Map(c.map(d=>[d.path,d])),[c]),f=n?.replace(/^\/+|\/+$/g,"")||null,p=o.useMemo(()=>{if(!f)return a;const d=`${f}/`;return a.filter(g=>g.startsWith(d)).map(g=>g.slice(d.length)).filter(Boolean)},[f,a]);return e.jsx("div",{className:"workspace-diff-files-view",children:e.jsx(fi,{changedByPath:u,expandedFolderPaths:s,rootPath:f,repoFiles:p,onOpenFile:i,onToggleFolder:r})})}function hi({collapsed:t,editorControlsVisible:s,hideWhiteSpace:n,loadFullFiles:a,renderMarkdown:i,wordDiffs:r,wordWrap:c,onClose:u,onCopyGitApply:f,onRefresh:p,onToggleCollapsed:d,onToggleEditorControlsVisible:g,onToggleHideWhiteSpace:w,onToggleLoadFullFiles:y,onToggleRenderMarkdown:_,onToggleWordDiffs:T,onToggleWordWrap:A}){return e.jsxs("div",{className:"workspace-diff-options-menu",role:"menu",children:[e.jsx(ie,{icon:e.jsx(Bt,{size:14}),label:"Refresh",onClick:p,onClose:u}),e.jsx(ie,{checked:c,icon:e.jsx(Un,{size:14}),label:"Enable word wrap",onClick:A,onClose:u}),e.jsx(ie,{checked:t,icon:e.jsx(ya,{size:14}),label:"Collapse all diffs",onClick:d,onClose:u}),e.jsx("div",{className:"workspace-diff-menu-divider"}),e.jsx(ie,{checked:s,icon:e.jsx(Fa,{size:14}),label:"Show editor controls",onClick:g,onClose:u}),e.jsx(ie,{checked:i,icon:e.jsx(As,{size:14}),label:"Render Markdown",onClick:_,onClose:u}),e.jsx(ie,{checked:!a,icon:e.jsx(Ge,{size:14}),label:"Show diffs first",onClick:y,onClose:u}),e.jsx(ie,{checked:r,icon:e.jsx(wa,{size:14}),label:"Enable word diffs",onClick:T,onClose:u}),e.jsx(ie,{checked:n,icon:e.jsx(qn,{size:14}),label:"Hide white space",onClick:w,onClose:u}),e.jsx(ie,{icon:e.jsx(Vn,{size:14}),label:"Copy git apply command",onClick:f,onClose:u})]})}function ie({checked:t,icon:s,label:n,onClick:a,onClose:i}){return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{a?.(),i()},children:[s,e.jsx("span",{children:n}),t&&e.jsx(Hn,{size:14})]})}function mi({addMenuOpen:t,expanded:s,filteredFiles:n,dirtyFilePaths:a,openFiles:i,goalDetailsAvailable:r,searchOpen:c,searchQuery:u,selectedPath:f,sideChatTabs:p=[],summaryAvailable:d,sourceStatus:g,sourceSwitcher:w,visibleTab:y,onCloseFileTab:_,onCloseSideChat:T,onCloseSearch:A,onOpenFile:F,onOpenBrowser:K,onOpenSearch:Q,onOpenSideChat:H,onSearchQueryChange:x,onSelectFile:N,onSelectFiles:M,onSelectGoal:L,onSelectSummary:R,onSelectSideChat:q,onToggleAddMenu:I,onToggleExpanded:Z}){const D=o.useRef(null);o.useEffect(()=>{if(!t&&!c)return;function v(){t&&I(),c&&A()}function X(G){D.current?.contains(G.target)||v()}function Qe(G){G.key==="Escape"&&v()}return document.addEventListener("pointerdown",X),document.addEventListener("keydown",Qe),()=>{document.removeEventListener("pointerdown",X),document.removeEventListener("keydown",Qe)}},[t,A,I,c]);function W(v){if(v.key==="Escape"){A();return}v.key==="Enter"&&n[0]&&F(n[0])}return e.jsxs("div",{className:"workspace-diff-topbar",children:[e.jsxs("div",{className:"workspace-diff-tabs",role:"tablist","aria-label":"Right sidebar views",children:[r?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${y==="goal"?"active":""}`,role:"tab","aria-selected":y==="goal",onClick:L,children:[e.jsx(Ge,{size:14}),e.jsx("span",{children:"Goal"})]}):null,d&&R?e.jsxs("button",{type:"button",className:`workspace-diff-tab ${y==="summary"?"active":""}`,role:"tab","aria-selected":y==="summary",onClick:R,children:[e.jsx(vs,{size:14}),e.jsx("span",{children:"Summary"})]}):null,e.jsxs("button",{type:"button",className:`workspace-diff-tab ${y==="files"?"active":""}`,role:"tab","aria-selected":y==="files",onClick:M,children:[e.jsx(ot,{size:14}),e.jsx("span",{children:"Files"})]}),i.map(v=>e.jsxs("div",{className:`workspace-diff-tab file ${y==="file"&&f===v.path?"active":""}`,children:[e.jsxs("button",{type:"button",className:"workspace-diff-tab-main",role:"tab","aria-selected":y==="file"&&f===v.path,title:v.path,onClick:()=>N(v.path),children:[e.jsx(Ge,{className:"workspace-diff-tab-icon",size:13}),a.has(v.path)&&e.jsx("span",{className:"workspace-diff-tab-dirty","aria-hidden":"true"}),e.jsx("span",{children:v.path.split("/").pop()})]}),e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${v.path}`,onClick:X=>_(v.path,X),children:e.jsx(xs,{size:12})})]},v.path)),p.map(v=>e.jsxs("div",{className:"workspace-diff-tab right-chat-tab",children:[e.jsx("button",{type:"button",className:"workspace-diff-tab-main",role:"tab","aria-selected":!1,title:v.title,onClick:()=>q?.(v.id),children:e.jsx("span",{children:v.title})}),T?e.jsx("button",{type:"button",className:"workspace-diff-tab-close",title:`Close ${v.title}`,"aria-label":`Close ${v.title}`,onClick:X=>{X.stopPropagation(),T(v.id)},children:e.jsx(xs,{size:12})}):null]},v.id)),e.jsxs("div",{className:"workspace-diff-add-anchor",ref:D,children:[e.jsx("button",{type:"button",className:`workspace-diff-add-tab ${t||c?"active":""}`,title:"Add","aria-label":"Add to right sidebar",onClick:I,children:e.jsx(Gn,{size:15})}),t&&e.jsxs("div",{className:"workspace-diff-add-menu",role:"menu",children:[H?e.jsxs("button",{type:"button",role:"menuitem",onClick:H,children:[e.jsx(Kn,{size:14}),e.jsx("span",{children:"New task"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:M,children:[e.jsx(ot,{size:14}),e.jsx("span",{children:"Files"}),e.jsx("kbd",{})]}),d&&R?e.jsxs("button",{type:"button",role:"menuitem",onClick:R,children:[e.jsx(vs,{size:14}),e.jsx("span",{children:"Summary"}),e.jsx("kbd",{})]}):null,e.jsxs("button",{type:"button",role:"menuitem",onClick:Q,children:[e.jsx(Qn,{size:14}),e.jsx("span",{children:"Open file"}),e.jsx("kbd",{children:"Ctrl+P"})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:K,children:[e.jsx(Zn,{size:14}),e.jsx("span",{children:"Browser"}),e.jsx("kbd",{children:"Ctrl+I"})]})]}),c&&e.jsxs("div",{className:"workspace-file-search-popover",children:[e.jsx("input",{autoFocus:!0,placeholder:"Search files",value:u,onChange:v=>x(v.target.value),onKeyDown:W}),e.jsx("span",{children:"Files"}),e.jsx("div",{className:"workspace-file-search-results",children:n.length===0?e.jsx("small",{children:"Type to search for files"}):n.map(v=>e.jsx("button",{type:"button",onClick:()=>F(v),children:v},v))})]})]})]}),w||g?e.jsxs("div",{className:"workspace-diff-source-bar","aria-label":"Workspace source",children:[w?e.jsx("div",{className:"workspace-diff-source-toggle",role:"group","aria-label":"File source",children:w.options.map(v=>e.jsx("button",{type:"button",className:w.value===v.value?"active":"","aria-pressed":w.value===v.value,onClick:()=>w.onChange(v.value),children:v.label},v.value))}):null,g?e.jsx("span",{className:`workspace-diff-source-status ${g.tone}`,children:g.label}):null]}):null,e.jsx("button",{type:"button",className:"diff-icon-button",title:s?"Restore files panel":"Expand files panel","aria-label":s?"Restore files panel":"Expand files panel",onClick:Z,children:s?e.jsx(Xn,{size:14}):e.jsx(Yn,{size:14})})]})}function xi({canCheckActiveFile:t,canSaveActiveFile:s,collapsed:n,editorControlsVisible:a,editorDiagnosticStatus:i,editorDiagnosticsChecking:r,hideWhiteSpace:c,loadFullFiles:u,menuOpen:f,renderMarkdown:p,showEditorCommandBar:d,showRenderMarkdownToggle:g,splitView:w,wordDiffs:y,wordWrap:_,onCopyGitApply:T,onEditorCheck:A,onEditorRedo:F,onEditorSave:K,onEditorUndo:Q,onRefresh:H,onToggleCollapsed:x,onToggleEditorControlsVisible:N,onToggleHideWhiteSpace:M,onToggleLoadFullFiles:L,onToggleMenu:R,onToggleRenderMarkdown:q,onToggleSplitView:I,onToggleWordDiffs:Z,onToggleWordWrap:D}){return e.jsx("div",{className:"workspace-diff-toolbar",children:e.jsxs("div",{className:"workspace-diff-toolbar-actions",children:[e.jsxs("div",{className:"workspace-diff-menu-anchor",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Diff options","aria-haspopup":"menu","aria-expanded":f,onClick:()=>R(),children:e.jsx(Jn,{size:15})}),f&&e.jsx(hi,{collapsed:n,editorControlsVisible:a,hideWhiteSpace:c,loadFullFiles:u,renderMarkdown:p,wordDiffs:y,wordWrap:_,onClose:()=>R(!1),onCopyGitApply:T,onRefresh:H,onToggleCollapsed:x,onToggleEditorControlsVisible:N,onToggleHideWhiteSpace:M,onToggleLoadFullFiles:L,onToggleRenderMarkdown:q,onToggleWordDiffs:Z,onToggleWordWrap:D})]}),d&&e.jsxs("div",{className:"workspace-editor-command-bar","aria-label":"Editor controls",children:[e.jsx("button",{type:"button",className:"diff-icon-button",title:"Save file","aria-label":"Save file",disabled:!s,onClick:K,children:e.jsx(ja,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Undo","aria-label":"Undo",onClick:Q,children:e.jsx(La,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Redo","aria-label":"Redo",onClick:F,children:e.jsx(Aa,{size:14})}),e.jsx("button",{type:"button",className:"diff-icon-button",title:"Check file","aria-label":"Check file",disabled:!t,onClick:A,children:r?e.jsx(Fe,{className:"spinning",size:14}):e.jsx(gs,{size:14})}),i&&e.jsxs("span",{className:`workspace-editor-diagnostic-chip ${i.severity}`,children:[i.severity==="error"||i.severity==="warning"||i.severity==="unavailable"?e.jsx(Ut,{size:13}):e.jsx(gs,{size:13}),e.jsx("span",{children:i.label})]})]}),g&&e.jsx("button",{type:"button",className:`diff-icon-button ${p?"active":""}`,title:p?"Show Markdown source":"Render Markdown","aria-label":p?"Show Markdown source":"Render Markdown","aria-pressed":p,onClick:q,children:e.jsx(As,{size:14})}),e.jsx("button",{type:"button",className:`diff-icon-button ${w?"active":""}`,title:w?"Show unified diff":"Show split diff","aria-label":w?"Show unified diff":"Show split diff","aria-pressed":w,onClick:I,children:e.jsx(Na,{size:14})})]})})}const gi={cjs:"typescript",css:"css",html:"html",js:"typescript",json:"json",jsx:"typescript",md:"markdown",mjs:"typescript",py:"python",sh:"shell",ts:"typescript",tsx:"typescript",yaml:"yaml",yml:"yaml"};function qt(t){const s=t.split("/").pop()?.toLowerCase()??"";if(s==="dockerfile")return"shell";if(s==="readme"||s==="readme.md")return"markdown";const n=s.includes(".")?s.split(".").pop()??"":"";return gi[n]??"text"}function bi(t,s){return t?s==="markdown"?ji(t):s==="json"?ge(t,/("(?:\\.|[^"\\])*"(?=\s*:)|"(?:\\.|[^"\\])*"|[-]?\b\d+(?:\.\d+)?\b|\btrue\b|\bfalse\b|\bnull\b|[{}[\]:,])/g):s==="css"?ge(t,/(\/\*.*?\*\/|#[\da-fA-F]{3,8}\b|--[\w-]+|[.#]?[\w-]+(?=\s*:)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b\d+(?:\.\d+)?(?:px|rem|em|%|vh|vw)?\b|[{}():;,])/g):s==="html"?ge(t,/(<!--.*?-->|<\/?[\w-]+|[\w:-]+(?==)|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[<>/=])/g):s==="shell"?ge(t,/(#.*$|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:cd|cp|export|git|npm|pnpm|bun|yarn|rm|mkdir|test|if|then|fi|for|do|done|echo)\b|\$[\w_]+|&&|\|\||[|&;=])/g):s==="python"?ge(t,/(#.*$|"""[\s\S]*?"""|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:class|def|return|if|elif|else|for|while|try|except|finally|with|as|import|from|None|True|False|async|await|lambda|yield)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|.:,()[\]{}]+)/g):ge(t,/(\/\/.*$|\/\*.*?\*\/|`(?:\\.|[^`\\])*`|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\b(?:abstract|as|async|await|boolean|break|case|catch|class|const|continue|default|else|enum|export|extends|false|finally|for|from|function|if|import|in|interface|let|new|null|number|of|return|string|switch|throw|true|try|type|undefined|void|while)\b|\b[A-Z][\w]*\b|\b\d+(?:\.\d+)?\b|[+\-*/%=<>!&|?:.,()[\]{}]+)/g):[{text:" ",kind:"plain"}]}function ji(t){return/^\s{0,3}#{1,6}\s/.test(t)?[{text:t,kind:"keyword"}]:/^\s*[-*+]\s/.test(t)?[{text:t,kind:"property"}]:ge(t,/(`[^`]+`|\*\*[^*]+\*\*|\[[^\]]+\]\([^)]+\)|https?:\/\/\S+)/g)}function vi(t){return/^(\/\/|#|\/\*|<!--)/.test(t)?"comment":/^["'`]/.test(t)?"string":/^[-]?\d/.test(t)||/^#[\da-fA-F]{3,8}\b/.test(t)?"number":/^\b[A-Z]/.test(t)?"type":/^[.#]?[\w-]+$/.test(t)&&t.includes("-")?"property":/^(?:[{}()[\],.:;<>/=+\-*&|!?%]+)$/.test(t)?"operator":/^(?:--|\$)/.test(t)?"property":"keyword"}function ge(t,s){const n=[];let a=0;for(const i of t.matchAll(s)){const r=i.index??0;r>a&&n.push({text:t.slice(a,r),kind:"plain"});const c=i[0];if(n.push({text:c,kind:vi(c)}),a=r+c.length,/^(\/\/|#|<!--)/.test(c))break}return a<t.length&&n.push({text:t.slice(a),kind:"plain"}),n.length>0?n:[{text:t,kind:"plain"}]}function ct({language:t,text:s}){return e.jsx(e.Fragment,{children:bi(s,t).map((n,a)=>e.jsx("span",{className:`syntax-token ${n.kind}`,children:n.text},`${a}-${n.text}`))})}const wi=`
3
+
4
+ [file truncated]`,ki=o.lazy(()=>ia(()=>import("./WorkspaceMonacoEditor-BBqimG5X.js").then(t=>t.jc),__vite__mapDeps([0,1,2,3]),import.meta.url)),zt=6,yi=18,xe=22,Cs=44,Si=160,Rs=12;function dt({path:t,workspaceName:s,workspaceRootPath:n,onSelectPath:a}){const i=Ps(t,n),r=sa(i),c=r?Ni(i):s?.trim()||"Workspace",f=(r&&c!=="/"&&i.startsWith(`${c}/`)?i.slice(c.length+1):i).split("/").filter(Boolean),p=!!(a&&!r);return e.jsxs("span",{className:"workspace-file-breadcrumbs",title:r?i:`${c} > ${i}`,children:[a&&!r?e.jsx("button",{type:"button",onClick:()=>a(null),children:c}):e.jsx("span",{children:c}),f.map((d,g)=>{const w=g===f.length-1,y=f.slice(0,g+1).join("/");return e.jsxs("span",{className:"workspace-file-breadcrumb-segment",children:[e.jsx(na,{size:13}),a&&p&&!w?e.jsx("button",{type:"button",onClick:()=>a(y),children:d}):e.jsx("span",{children:d})]},`${g}-${d}`)})]})}function Ni(t){const s=/^[A-Za-z]:\//.exec(t);return s?s[0].slice(0,-1):"/"}function Ci({collapsed:t=!1,diagnostics:s=[],draftContent:n,editable:a=!1,editorRef:i,error:r,file:c,hideWhiteSpace:u=!1,imageSrc:f,loading:p,loadFullFiles:d,onOpenImage:g,onSelectBreadcrumbPath:w,onDraftContentChange:y,onLspAction:_,onSave:T,renderMarkdown:A,saveError:F,saving:K=!1,splitView:Q=!1,wordDiffs:H=!1,wordWrap:x,workspaceName:N,workspaceRootPath:M}){const L=n??c.content??"",R=o.useMemo(()=>L.split(`
5
+ `).slice(0,800),[L]),q=qt(c.path),I=n!=null||c.content!=null,Z=L.endsWith(wi),D=A&&I&&Wt(c.path),W=I&&ea(c.path)&&Ai(L);return f?e.jsxs("div",{className:"workspace-file-preview",children:[e.jsx("div",{className:"workspace-diff-file-heading",children:e.jsxs("div",{children:[e.jsx(dt,{path:c.path,workspaceName:N,workspaceRootPath:M,onSelectPath:w}),e.jsxs("span",{className:"diff-addition",children:["+",c.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",c.deletions]})]})}),e.jsx("div",{className:"workspace-file-image-stage",children:e.jsx("button",{type:"button",className:"workspace-file-image-button","aria-label":`Open image preview for ${c.path}`,onClick:g,children:e.jsx("img",{alt:c.path,decoding:"async",src:f})})})]}):!d&&c.patch||!I&&c.patch?Q?e.jsx($i,{collapsed:t,file:c,hideWhiteSpace:u,onSelectBreadcrumbPath:w,wordDiffs:H,wordWrap:x,workspaceName:N,workspaceRootPath:M}):e.jsx(Ri,{collapsed:t,file:c,hideWhiteSpace:u,wordWrap:x,workspaceName:N,workspaceRootPath:M,onSelectBreadcrumbPath:w}):e.jsxs("div",{className:`workspace-file-preview ${x?"wrap":""}`,children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(dt,{path:c.path,workspaceName:N,workspaceRootPath:M,onSelectPath:w}),e.jsxs("span",{className:"diff-addition",children:["+",c.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",c.deletions]})]}),K?e.jsx("span",{className:"workspace-file-save-state",children:"Saving"}):null,F?e.jsx("span",{className:"workspace-file-save-error",title:F,children:"Save failed"}):null]}),I?D?e.jsx("div",{className:"workspace-markdown-preview",children:e.jsx(ta,{content:L})}):W?e.jsx(Fi,{file:c,contentBase64:L}):a&&!Z?e.jsx(o.Suspense,{fallback:e.jsx("div",{className:"workspace-diff-code-empty",children:"Loading editor"}),children:e.jsx(ki,{diagnostics:s,filePath:c.path,onChange:v=>y?.(v),onLspAction:_,onSave:()=>T?.(),ref:i,value:L,wordWrap:x})}):e.jsx("div",{className:"workspace-file-code",children:R.map((v,X)=>e.jsxs("div",{className:"workspace-file-code-row",children:[e.jsx("span",{children:X+1}),e.jsx("code",{children:e.jsx(ct,{language:q,text:v||" "})})]},`${X}-${v}`))}):e.jsx("div",{className:"workspace-diff-code-empty",children:p?"Loading file content":r??"No file content available."})]})}function Ri({collapsed:t=!1,file:s,hideWhiteSpace:n=!1,wordWrap:a,workspaceName:i,workspaceRootPath:r,onSelectBreadcrumbPath:c}){const u=o.useMemo(()=>Ws(s.patch,n),[s.patch,n]),f=qt(s.path);return e.jsxs("div",{className:`workspace-diff-preview ${a?"wrap":""}`,children:[e.jsx("div",{className:"workspace-diff-file-heading",children:e.jsxs("div",{children:[e.jsx(dt,{path:s.path,workspaceName:i??null,workspaceRootPath:r,onSelectPath:c}),e.jsxs("span",{className:"diff-addition",children:["+",s.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",s.deletions]})]})}),t?e.jsx("div",{className:"workspace-diff-code-empty",children:"Diff collapsed"}):e.jsx(Is,{ariaLabel:`${s.path} diff`,className:"workspace-diff-code",emptyMessage:"No patch available.",rows:u,renderRow:(p,d)=>p.kind==="spacer"?e.jsx("div",{className:"workspace-diff-spacer",role:"row",children:p.label},`${p.label}-${d}`):e.jsxs("div",{className:`workspace-diff-code-row ${p.kind}`,role:"row",children:[e.jsx("span",{className:"workspace-diff-line-number",role:"cell",children:p.newLine||p.oldLine}),e.jsx("code",{role:"cell",children:e.jsx(ct,{language:f,text:p.newContent||p.oldContent||" "})})]},`${p.oldLine}-${p.newLine}-${d}`),wordWrap:a})]})}function $i({collapsed:t,file:s,hideWhiteSpace:n,wordDiffs:a,wordWrap:i,workspaceName:r,workspaceRootPath:c,onSelectBreadcrumbPath:u}){const f=o.useMemo(()=>Ws(s.patch,n),[s.patch,n]),p=qt(s.path);return e.jsxs("div",{className:`workspace-diff-preview split ${i?"wrap":""} ${a?"word-diffs":""}`,children:[e.jsxs("div",{className:"workspace-diff-file-heading",children:[e.jsxs("div",{children:[e.jsx(dt,{path:s.path,workspaceName:r,workspaceRootPath:c,onSelectPath:u}),e.jsxs("span",{className:"diff-addition",children:["+",s.additions]}),e.jsxs("span",{className:"diff-deletion",children:["-",s.deletions]})]}),e.jsx(aa,{size:14})]}),t?e.jsx("div",{className:"workspace-diff-code-empty",children:"Diff collapsed"}):e.jsx(Is,{ariaLabel:`${s.path} split diff`,className:"workspace-split-code",emptyMessage:"No patch available.",rows:f,renderRow:(d,g)=>d.kind==="spacer"?e.jsx("div",{className:"workspace-diff-spacer split",role:"row",children:d.label},`${d.label}-${g}`):e.jsxs("div",{className:`workspace-split-row ${d.kind}`,role:"row",children:[e.jsx("span",{className:"workspace-diff-line-number old",role:"cell",children:d.oldLine}),e.jsx("code",{className:"old",role:"cell",children:e.jsx(ct,{language:p,text:d.oldContent||" "})}),e.jsx("span",{className:"workspace-diff-line-number new",role:"cell",children:d.newLine}),e.jsx("code",{className:"new",role:"cell",children:e.jsx(ct,{language:p,text:d.newContent||" "})})]},`${d.oldLine}-${d.newLine}-${g}`),wordWrap:i})]})}function Fi({file:t,contentBase64:s}){const n=o.useMemo(()=>{const a=Pi(s);if(!a)return null;const i=new Blob([new Uint8Array(a)],{type:Ei(t.path)});return URL.createObjectURL(i)},[s,t.path]);return o.useEffect(()=>()=>{n&&URL.revokeObjectURL(n)},[n]),n?e.jsxs("div",{className:"workspace-document-preview",children:[e.jsxs("div",{className:"workspace-document-preview-card",children:[e.jsx("strong",{children:t.path.split("/").pop()}),e.jsx("span",{children:"Word document"}),e.jsx("a",{href:n,download:t.path.split("/").pop()||"document",children:"Download document"})]}),e.jsx("iframe",{src:n,title:`${t.path} preview`})]}):e.jsx("div",{className:"workspace-diff-code-empty",children:"Document preview unavailable."})}function Ei(t){return/\.docx$/i.test(t)?"application/vnd.openxmlformats-officedocument.wordprocessingml.document":"application/msword"}function Ai(t){return t.length>0&&/^[A-Za-z0-9+/=\s]+$/.test(t)}function Pi(t){try{const s=atob(t.replace(/\s/g,"")),n=new Uint8Array(s.length);for(let a=0;a<s.length;a+=1)n[a]=s.charCodeAt(a);return n}catch{return null}}function Is({ariaLabel:t,className:s,emptyMessage:n,rows:a,renderRow:i,wordWrap:r}){const c=!r&&a.length>Si,{endIndex:u,offsetTop:f,scrollRef:p,startIndex:d,totalHeight:g}=Li(a.length,c);return a.length===0?e.jsx("div",{className:s,role:"table","aria-label":t,children:e.jsx("div",{className:"workspace-diff-code-empty",children:n})}):c?e.jsx("div",{className:`${s} virtualized`,ref:p,role:"table","aria-label":t,"aria-rowcount":a.length,children:e.jsx("div",{className:"workspace-diff-virtual-spacer",style:{height:g},children:e.jsx("div",{className:"workspace-diff-virtual-window",style:{transform:`translateY(${f}px)`},children:a.slice(d,u).map((w,y)=>i(w,d+y))})})}):e.jsx("div",{className:s,role:"table","aria-label":t,children:a.map(i)})}function Li(t,s){const n=o.useRef(null),[a,i]=o.useState({height:xe*Cs,scrollTop:0}),r=o.useCallback(()=>{const p=n.current;p&&i({height:p.clientHeight||xe*Cs,scrollTop:p.scrollTop})},[]);if(o.useEffect(()=>{if(!s)return;const p=n.current;if(!p)return;r();let d=0;const g=()=>{if(typeof window>"u"){r();return}window.cancelAnimationFrame(d),d=window.requestAnimationFrame(r)};p.addEventListener("scroll",g,{passive:!0});const w=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>g());return w?.observe(p),()=>{p.removeEventListener("scroll",g),w?.disconnect(),typeof window<"u"&&window.cancelAnimationFrame(d)}},[s,r]),!s)return{endIndex:t,offsetTop:0,scrollRef:n,startIndex:0,totalHeight:t*xe};const c=Math.ceil(a.height/xe),u=Math.max(0,Math.floor(a.scrollTop/xe)-Rs);return{endIndex:Math.min(t,u+c+Rs*2),offsetTop:u*xe,scrollRef:n,startIndex:u,totalHeight:t*xe}}function Ws(t,s){if(!t.trim())return[];const n=[];let a=0,i=0,r=null,c=null,u=!1,f=[];function p(){n.push(...Di(f)),f=[]}function d(){u&&(p(),r=a,c=i,u=!1)}for(const g of t.split(`
6
+ `)){const w=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(g);if(w){d();const T=Number(w[1]),A=Number(w[2]);if(r!==null&&c!==null){const F=Math.max(T-r,A-c,0);F>0&&n.push({kind:"spacer",label:Os(F)})}a=T,i=A,u=!0;continue}if(g.startsWith("diff --git")||g.startsWith("index ")||g.startsWith("--- ")||g.startsWith("+++ ")||!u||g.startsWith("\\ No newline"))continue;const y=g.slice(1)||" ";if(s&&!y.trim())continue;if(g.startsWith("+")){p(),n.push({kind:"addition",oldLine:"",newLine:String(i||""),oldContent:"",newContent:y}),i+=1;continue}if(g.startsWith("-")){p(),n.push({kind:"deletion",oldLine:String(a||""),newLine:"",oldContent:y,newContent:""}),a+=1;continue}const _=g.startsWith(" ")?g.slice(1)||" ":g||" ";s&&!_.trim()||(f.push({kind:"context",oldLine:String(a||""),newLine:String(i||""),oldContent:_,newContent:_}),a+=1,i+=1)}return d(),n}function Di(t){if(t.length<yi)return t;const s=t.length-zt*2;return s<=0?t:[...t.slice(0,zt),{kind:"spacer",label:Os(s)},...t.slice(-zt)]}function Os(t){return`${t} unmodified ${t===1?"line":"lines"}`}const ut=`
7
+
8
+ [file truncated]`,_i="openpond.sandboxSourceReadback.v1";async function Ti(t,s,n,a=[]){let i;try{i=await z.sandboxDownloadFile(t,s,n,{maxBytes:256*1024})}catch(c){const u=c instanceof Error?c.message:String(c);if(!Mi(u))throw c;const f=Wi(a,s,n);if(f)return f;const p=!!Vt(a,s)?.artifact,d=await z.sandbox(t,s).catch(()=>null);throw new Error(zi(n,d?.sandbox??null,u,{hasReadbackArtifact:p}))}const r=i.file.isBinary?i.file.contentsBase64||null:`${i.contents}${i.file.truncated?ut:""}`;return{path:i.file.path,status:"",additions:0,deletions:0,patch:"",content:r}}function Mi(t){return t.includes("sandbox_not_ready")&&t.includes("placement_stale")||t.includes("sandbox_not_running")}function zi(t,s,n="sandbox_not_ready:placement_stale",a={}){const i=s?Oi(s):null,r=t||"this file";if(a.hasReadbackArtifact)return`Sandbox file content is unavailable because the stopped runtime placement is stale. The latest source checkpoint has a saved readback artifact, but ${r} was not captured as text. Resume the sandbox to inspect it. ${n}`;if(!i)return`Sandbox file content is unavailable because the stopped runtime placement is stale. Resume the sandbox to inspect ${r}. ${n}`;const c=i.preservedSha?i.preservedSha.slice(0,12):null,u=i.sourceRef?` (${i.sourceRef})`:"";return`Sandbox file content is unavailable because the stopped runtime placement is stale. The latest source checkpoint is saved${c?` at ${c}`:""}${u}, but this Desktop app cannot read file bodies from preserved source refs yet. Resume the sandbox to inspect ${r}.`}function Ii(t,s){if(!s)return null;const n=Vt(t,s);if(!n)return null;const a=Us(n.artifact),i=new Map;for(const u of Ht(a))i.set(u.path,u);for(const u of qs(n.artifact)){const f=Bs(n.artifact,u.path);f&&i.set(u.path,f)}const r=[...i.values()].sort((u,f)=>u.path.localeCompare(f.path)),c=[...new Set(r.map(u=>u.path))].sort((u,f)=>u.localeCompare(f));return{appId:s,repoPath:"",initialized:!0,dirty:!1,filesChanged:r.length,additions:r.reduce((u,f)=>u+f.additions,0),deletions:r.reduce((u,f)=>u+f.deletions,0),repoFiles:c,files:r,error:null,updatedAt:Ee(se(n.artifact)?.createdAt)??n.event.timestamp}}function Wi(t,s,n){if(!s)return null;const a=Vt(t,s);return a?Bs(a.artifact,n):null}function Vt(t,s){for(let n=t.length-1;n>=0;n-=1){const a=t[n];if(a?.name!=="workspace_action_result")continue;const i=se(a.data),r=se(i?.sourcePreservation),c=se(r?.sourceReadbackArtifact);if(c&&c.schemaVersion===_i&&c.sandboxId===s)return{artifact:c,event:a}}return null}function Bs(t,s){const n=Ht(Us(t)).find(r=>r.path===s),a=qs(t).find(r=>r.path===s);if(!n&&!a)return null;const i=typeof a?.content=="string"?`${a.content}${a.truncated?ut:""}`:null;return{path:a?.path??n?.path??s,status:n?.status??"M",additions:n?.additions??0,deletions:n?.deletions??0,patch:n?.patch??"",content:i}}function Us(t){const s=se(t.patch);return typeof s?.text=="string"?s.text:""}function qs(t){return(Array.isArray(t.files)?t.files:[]).map(n=>{const a=se(n),i=Ee(a?.path);return i?{path:i,...typeof a?.content=="string"?{content:a.content}:{},...a?.truncated===!0?{truncated:!0}:{}}:null}).filter(n=>!!n)}function Oi(t){const s=se(t.metadata)??{},n=se(s.sourcePreservation)??se(s.sourcePreserve),a=se(s.sourceChangeDetection),i=Ee(n?.preservedSha)??Ee(a?.preservedSha)??null,r=Ee(n?.sourceRef)??Ee(a?.sourceRef)??(typeof t.repoRef=="string"?t.repoRef:null);return!i&&!r?null:{preservedSha:i,sourceRef:r}}function se(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:null}function Ee(t){return typeof t=="string"&&t.trim()?t.trim():null}async function Bi(t,s,n,a){const i=await z.sandboxUploadFile(t,s,{path:n,contents:a});return await z.preserveSandboxSource(t,s,{message:"Auto-preserve source after right sidebar save"}),{path:i.file.path,status:"M",additions:0,deletions:0,patch:"",content:a}}function Ui(t){return t.filter(s=>s.type==="file").map(s=>s.path).sort((s,n)=>s.localeCompare(n))}function qi(t,s){const n=new Map;for(const a of Ht(t?.diff??""))n.set(a.path,a);for(const a of Vi(s?.porcelain??""))n.has(a.path)||n.set(a.path,a);return[...n.values()].sort((a,i)=>a.path.localeCompare(i.path))}function Ht(t){const s=[];let n=null;const a=()=>{n&&(s.push({path:n.path,status:n.status,additions:n.additions,deletions:n.deletions,patch:n.patchLines.join(`
9
+ `),content:null}),n=null)};for(const i of t.split(`
10
+ `)){if(i.startsWith("diff --git ")){a(),n={path:Gi(i)??"changed-file",status:"M",additions:0,deletions:0,patchLines:[i]};continue}if(n){if(n.patchLines.push(i),i.startsWith("+++ ")){const r=$s(i.slice(4));r&&(n.path=r);continue}if(i.startsWith("--- ")){const r=$s(i.slice(4));r&&n.path==="changed-file"&&(n.path=r);continue}i.startsWith("new file mode ")&&(n.status="A"),i.startsWith("deleted file mode ")&&(n.status="D"),i.startsWith("rename to ")&&(n.status="R",n.path=i.slice(10).trim()||n.path),i.startsWith("+")&&!i.startsWith("+++")&&(n.additions+=1),i.startsWith("-")&&!i.startsWith("---")&&(n.deletions+=1)}}return a(),s}function Vi(t){const s=[];for(const n of t.split(`
11
+ `)){if(!n.trim())continue;const a=Hi(n);a&&s.push({path:a,status:n.slice(0,2).trim()||"M",additions:0,deletions:0,patch:"",content:null})}return s}function Hi(t){const s=t.slice(3).trim();return s?s.split(" -> ").pop()?.trim()||s:null}function Gi(t){const s=/^diff --git a\/(.+) b\/(.+)$/.exec(t.trim());return s?.[2]??s?.[1]??null}function $s(t){const s=t.trim();return!s||s==="/dev/null"?null:s.startsWith("a/")||s.startsWith("b/")?s.slice(2):s}const Vs="openpond.workspace.editorControlsVisible";function Ki(){try{return window.localStorage.getItem(Vs)==="true"}catch{return!1}}function Qi(t){try{window.localStorage.setItem(Vs,String(t))}catch{}}function Zi({activeDiagnostics:t,activeServers:s,editorDiagnosticsChecking:n,editorLspEnabled:a,showEditorCommandBar:i}){if(!i)return null;if(!a)return{label:"LSP off",severity:"unavailable"};if(n)return{label:"Checking",severity:"info"};const r=t.filter(p=>p.severity==="error").length;if(r>0)return{label:`${r} error${r===1?"":"s"}`,severity:"error"};const c=t.filter(p=>p.severity==="warning").length;if(c>0)return{label:`${c} warning${c===1?"":"s"}`,severity:"warning"};const u=t.length;if(u>0)return{label:`${u} note${u===1?"":"s"}`,severity:"info"};if(!s)return null;const f=s.find(p=>p.status!=="connected");return f?{label:f.id==="none"?"No LSP":`${f.id} unavailable`,severity:"unavailable"}:{label:"No issues",severity:"none"}}const Fs=3e3,Xi=2e3,Es=[],Yi=[];function cl({appId:t,workspaceKind:s,connection:n,runtimeEvents:a,diff:i,editorPreferences:r,loading:c,workspaceName:u,workspaceInitialized:f,workspaceError:p,expanded:d,fileRootPath:g,openFileRequest:w,sideChatTabs:y,sourceSwitcher:_,tabRequest:T,viewState:A,onRefresh:F,onResizeStart:K,onToggleExpanded:Q,onOpenBrowser:H,onViewStateChange:x,onCloseSideChat:N,onOpenSideChat:M,onSelectSideChat:L,goalDetails:R,sandboxFileSource:q,trainingSummary:I}){return e.jsx(nl,{appId:t,workspaceKind:s,connection:n,runtimeEvents:a??[],diff:i,editorPreferences:r??null,loading:c,workspaceName:u,workspaceInitialized:f,workspaceError:p,expanded:d,fileRootPath:g??null,openFileRequest:w,sideChatTabs:y??[],sourceSwitcher:_??null,tabRequest:T??null,viewState:A??null,onRefresh:F,onResizeStart:K,onToggleExpanded:Q,onOpenBrowser:H,onViewStateChange:x,onCloseSideChat:N,onOpenSideChat:M,onSelectSideChat:L,goalDetails:R??null,sandboxFileSource:q??null,trainingSummary:I??null})}function Ji(t,s,n,a){return t&&s?.content!=null?{...t,content:s.content}:s&&!t&&It(s)?s:t&&It(t)?t:s&&It(s)?s:t??s??n??Ot(a)}function It(t){return!!(t.patch||t.content!=null)}function el({changedFiles:t,checkpointStatus:s,dirty:n,error:a,loading:i,preservedReadback:r,sandboxMode:c,sourcePending:u}){if(u)return{label:"sandbox pending",tone:"loading"};if(i)return{label:"refreshing",tone:"loading"};if(c&&r&&s)return s;if(a)return{label:"status unavailable",tone:"error"};if(c&&s?.tone==="error"||c&&s&&!n&&t===0)return s;if(n||t>0){const f=Math.max(1,t),p=f===1?"change":"changes";return{label:c?`${f} unpreserved ${p}`:`${f} local ${p}`,tone:"dirty"}}return{label:c?"sandbox clean":"local clean",tone:"clean"}}function tl(t,s){if(!s)return null;for(let n=t.length-1;n>=0;n-=1){const a=t[n];if(a?.name!=="workspace_action_result")continue;const i=a.data&&typeof a.data=="object"&&!Array.isArray(a.data)?a.data:null,r=i?.sourcePreservation&&typeof i.sourcePreservation=="object"&&!Array.isArray(i.sourcePreservation)?i.sourcePreservation:null;if(r?.attempted===!0&&r.sandboxId===s)return r.ok!==!0?{label:"checkpoint failed",tone:"error"}:r.preserved===!0?{label:"checkpoint saved",tone:"clean"}:{label:"checkpoint clean",tone:"clean"}}return null}function sl(t){const s=t.split("/").filter(Boolean);return s.map((n,a)=>s.slice(0,a+1).join("/"))}function nl({appId:t,workspaceKind:s,connection:n,runtimeEvents:a,diff:i,editorPreferences:r,loading:c,workspaceName:u,workspaceInitialized:f,workspaceError:p,expanded:d,fileRootPath:g,openFileRequest:w,sideChatTabs:y,sourceSwitcher:_,tabRequest:T,viewState:A,onRefresh:F,onResizeStart:K,onToggleExpanded:Q,onOpenBrowser:H,onViewStateChange:x,onCloseSideChat:N,onOpenSideChat:M,onSelectSideChat:L,goalDetails:R,sandboxFileSource:q,trainingSummary:I}){const Z=A??ua(),[D,W]=o.useState(Z.activeTab),[v,X]=o.useState(!1),[Qe,G]=o.useState(!1),[Hs,ne]=o.useState(!1),[ht,Gt]=o.useState(""),[Y,Ze]=o.useState(()=>[...Z.openFilePaths]),[b,je]=o.useState(Z.selectedPath),[Kt,Gs]=o.useState(!1),[Qt,Ks]=o.useState(!1),[ve,Qs]=o.useState(!1),[mt,Zs]=o.useState(!0),[Zt,Xs]=o.useState(Ki),[Xt,Ys]=o.useState(!1),[Yt,Js]=o.useState(!1),[Jt,en]=o.useState(!1),[ee,Xe]=o.useState({}),[re,Ae]=o.useState({}),[tn,xt]=o.useState(()=>new Set),[Pe,Le]=o.useState(null),[sn,gt]=o.useState(!1),[nn,De]=o.useState(null),[es,bt]=o.useState({}),[an,jt]=o.useState({}),[ln,vt]=o.useState(null),[rn,_e]=o.useState(null),[on,Te]=o.useState(null),[wt,kt]=o.useState(null),[cn,Me]=o.useState({}),[Ye,yt]=o.useState(null),[Je,et]=o.useState(null),[tt,st]=o.useState(null),J=r??ca.editor,ts=o.useRef(ee),St=o.useRef(Tt(Z)),Nt=o.useRef(Tt(Z)),ss=o.useRef(null),Ct=o.useRef(F),ae=o.useRef(!1),ze=o.useRef(null),Ie=o.useRef(0),oe=o.useRef(null),We=o.useRef(null),E=q?.sandboxId?.trim()||null,S=!!q,we=!!I||S&&!!E,nt=S?`sandbox:${E??"pending"}`:`workspace:${t??"none"}`,ns=S?!!E:!!t,as=o.useRef(nt),ce=!!(R?.createRuntime||R?.goalRuntime||R?.subagentRuntime),ke=o.useCallback(async(l={})=>{if(S){if(!n){Le(null),De("OpenPond App server is not connected.");return}if(!E){Le(null),De(null);return}l.silent||gt(!0);try{const[h,m,k]=await Promise.allSettled([z.sandboxFiles(n,E,{recursive:!0,maxEntries:Xi}),z.sandboxGitStatus(n,E),z.sandboxGitDiff(n,E,{})]);if(h.status==="rejected")throw h.reason;const $=Ui(h.value.files),j=m.status==="fulfilled"?m.value.status:null,C=k.status==="fulfilled"?k.value.diff:null,P=qi(C,j),qe=P.reduce((Dt,_t)=>Dt+_t.additions,0),In=P.reduce((Dt,_t)=>Dt+_t.deletions,0);Le({appId:E,repoPath:"",initialized:!0,dirty:j?!j.clean:P.length>0,filesChanged:P.length,additions:qe,deletions:In,repoFiles:$,files:P,error:null,updatedAt:new Date().toISOString()}),De(null)}catch(h){Le(null),De(h instanceof Error?h.message:String(h))}finally{l.silent||gt(!1)}}},[n,E,S]),is=o.useMemo(()=>Ii(a,E),[a,E]),ls=!!(Pe&&((Pe.files?.length??0)>0||(Pe.repoFiles?.length??0)>0)),dn=S&&!ls&&!!is,de=S?ls?Pe:is??Pe:i,at=de?.repoPath??null,un=o.useMemo(()=>tl(a,E),[a,E]),ye=de?.files??Es,rs=de?.files??Es,ue=o.useMemo(()=>new Map(rs.map(l=>[l.path,l])),[rs]),fe=o.useMemo(()=>new Map(ye.map(l=>[l.path,l])),[ye]),Se=de?.repoFiles??(ye.length>0?ye.map(l=>l.path):Yi),Ne=o.useMemo(()=>ye.filter(l=>!la(l,Se)),[Se,ye]),Ce=o.useMemo(()=>tt&&!Se.includes(tt)?[tt,...Se]:Se,[Se,tt]),os=o.useMemo(()=>Y.map(l=>ue.get(l)??ee[l]??fe.get(l)??Ot(l)),[ue,fe,ee,Y]),it=o.useMemo(()=>{const l={};for(const h of Y){if(me(h))continue;const m=ue.get(h)??ee[h]??fe.get(h)??Ot(h);m.content!=null&&(l[h]=m.content)}return l},[ue,fe,ee,Y]),Re=o.useMemo(()=>{const l=new Set;for(const[h,m]of Object.entries(re))m.content!==m.savedContent&&l.add(h);return l},[re]),fn=o.useMemo(()=>{const l=ht.trim().toLowerCase(),h=Ce;return l?h.filter(m=>m.toLowerCase().includes(l)):h},[Ce,ht]),Rt=o.useMemo(()=>({activeTab:D,openFilePaths:Y,selectedPath:b}),[D,Y,b]);o.useEffect(()=>{ts.current=ee},[ee]),o.useEffect(()=>{ze.current=Ye},[Ye]),o.useEffect(()=>{Ae(l=>{let h=!1;const m={...l},k=new Set(Y),$=i?.updatedAt?Date.parse(i.updatedAt):null;for(const[j,C]of Object.entries(m))k.has(j)||C.content!==C.savedContent||(delete m[j],h=!0);for(const[j,C]of Object.entries(it)){const P=m[j];if(!P){m[j]={content:C,savedContent:C},h=!0;continue}if(P.content===P.savedContent&&P.savedContent!==C){if(P.savedAt&&($===null||$<P.savedAt))continue;m[j]={content:C,savedContent:C},h=!0}}return h?m:l})},[i?.updatedAt,it,Y]),o.useEffect(()=>{Ct.current=F},[F]),o.useEffect(()=>{if(!A)return;const l=ra(A,at);bs(St.current,l)||(St.current=l,Nt.current=l,W(l.activeTab),Ze(l.openFilePaths),je(l.selectedPath))},[A,at]),o.useEffect(()=>{if(bs(Nt.current,Rt))return;const l=Tt(Rt);Nt.current=l,St.current=l,x?.(l)},[Rt,x]),o.useEffect(()=>{S||!n||!t||!f||i||p||ae.current||(ae.current=!0,Promise.resolve(Ct.current({silent:!0})).catch(()=>{}).finally(()=>{ae.current=!1}))},[t,n,i,S,p,f]),o.useEffect(()=>(as.current!==nt&&(as.current=nt,oe.current?.abort(new Error("lsp_diagnostics_source_changed")),oe.current=null,Ze([]),je(null),Xe({}),Ae({}),xt(new Set),Le(null),De(null),gt(!1),bt({}),jt({}),vt(null),_e(null),Te(null),kt(null),Me({}),yt(null),et(null),st(null)),()=>{oe.current?.abort(new Error("lsp_diagnostics_unmounted")),oe.current=null}),[nt]),o.useEffect(()=>{!w||ss.current===w.id||ns&&(ss.current=w.id,$t(w.path))},[ns,w]),o.useEffect(()=>{if(!S||(ke(),!n||!E))return;let l=!1;async function h(){if(!(l||ae.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){ae.current=!0;try{await ke({silent:!0})}finally{ae.current=!1}}}const m=window.setInterval(()=>{h()},Fs),k=()=>{h()};return window.addEventListener("focus",k),()=>{l=!0,window.clearInterval(m),window.removeEventListener("focus",k)}},[n,ke,E,S]),o.useEffect(()=>{if(S||!n||!t||!f)return;let l=!1;async function h(){if(!(l||ae.current)&&!(typeof document<"u"&&document.visibilityState==="hidden")){ae.current=!0;try{await Ct.current({silent:!0})}catch{}finally{ae.current=!1}}}const m=window.setInterval(()=>{h()},Fs),k=()=>{h()};return window.addEventListener("focus",k),()=>{l=!0,window.clearInterval(m),window.removeEventListener("focus",k)}},[t,n,S,f]),o.useEffect(()=>{if(S||!n||!t||s==="local_project"){st(null);return}let l=!1;return z.workspaceTemplateConfig(n,t).then(h=>{l||st(h.exists?h.configPath??oa:null)}).catch(()=>{l||st(null)}),()=>{l=!0}},[t,n,S,s]),o.useEffect(()=>{!b||Ce.includes(b)||Y.includes(b)||je(Ne[0]?.path??null)},[Ne,Y,Ce,b]),o.useEffect(()=>{R?.active&&ce&&W("goal")},[R?.active,ce]),o.useEffect(()=>{T&&W(T.tab)},[T]),o.useEffect(()=>{!ce&&D==="goal"&&W("files")},[D,ce]),o.useEffect(()=>{!we&&D==="summary"&&W("files")},[D,we]);const V=D==="file"?b:null;o.useEffect(()=>{if(!n||!V)return;if(me(V)){Te(null),_e(j=>j===V?null:j);return}const l=wt?.path===V,h=Oe(V);if(!l&&(h?.content!=null||h?.patch&&!ve)){Te(null),_e(j=>j===V?null:j);return}let m=!1;const k=ts.current[V];return k?.content==null&&(ve||!k?.patch)&&_e(V),Te(null),(S?E?Ti(n,E,V,a):Promise.reject(new Error(q?.emptyMessage??"No sandbox filesystem is available.")):t?z.workspaceFile(n,t,V):Promise.reject(new Error("Workspace files are unavailable."))).then(j=>{m||Xe(C=>{const P=C[j.path];return P?.content===j.content&&P.patch===j.patch&&P.status===j.status?C:{...C,[j.path]:j}})}).catch(j=>{m||Te(j instanceof Error?j.message:String(j))}).finally(()=>{m||(_e(j=>j===V?null:j),kt(j=>j&&j.id===wt?.id&&j.path===V?null:j))}),()=>{m=!0}},[D,t,n,wt,ve,a,q?.emptyMessage,E,S,V]);function $t(l){const h=Ps(l,at);h&&(Xe(m=>{if(!(h in m))return m;const k={...m};return delete k[h],k}),kt({id:Date.now(),path:h}),Ze(m=>m.includes(h)?m:[...m,h]),je(h),W("file"),!S&&n&&t&&me(h)&&et(h),G(!1),ne(!1),Gt(""))}const pn=o.useCallback(()=>{Xs(l=>{const h=!l;return Qi(h),h})},[]),Oe=l=>Ji(ue.get(l),ee[l],fe.get(l),l),hn=o.useCallback((l,h)=>{Ae(m=>{const k=m[l],$=k?.savedContent??it[l]??Oe(l).content??"";return{...m,[l]:{content:h,savedContent:$,savedAt:k?.savedAt}}}),Me(m=>{if(!(l in m))return m;const k={...m};return delete k[l],k})},[ue,fe,ee,it]),$e=o.useCallback(async(l,h={})=>{if(S||!n||!t||me(l))return;const m=Oe(l),k=h.content??re[l]?.content??m.content??void 0;if(k?.endsWith(ut))return;const $=Ie.current+1;Ie.current=$,oe.current?.abort(new Error("lsp_diagnostics_superseded"));const j=new AbortController;oe.current=j,vt(l);try{const C=await z.workspaceLspTouch(n,t,{path:l,content:k,waitForDiagnostics:h.waitForDiagnostics??!0},{signal:j.signal});if($!==Ie.current)return;bt(P=>({...P,[C.path]:C.diagnostics})),jt(P=>({...P,[C.path]:C.servers}))}catch(C){if(j.signal.aborted||$!==Ie.current)return;const P=C instanceof Error?C.message:String(C);bt(qe=>({...qe,[l]:[]})),jt(qe=>({...qe,[l]:[{id:"lsp",root:"",status:"error",message:P}]}))}finally{if(oe.current===j&&(oe.current=null),j.signal.aborted)return;$===Ie.current&&vt(C=>C===l?null:C)}},[t,n,ue,fe,re,ee,S]),mn=o.useCallback(async l=>{if(S||!n||!t)throw new Error("Workspace LSP is unavailable.");return z.workspaceLspAction(n,t,l)},[t,n,S]),Be=o.useCallback(async l=>{if(!n||!t&&!E||ze.current===l)return;const h=re[l];if(!h||h.content===h.savedContent)return;const m=h.content,k=Date.now();ze.current=l,yt(l),Me($=>{if(!(l in $))return $;const j={...$};return delete j[l],j});try{const $=S?await Bi(n,E,l,m):await z.saveWorkspaceFile(n,t,{path:l,content:m});Xe(j=>({...j,[$.path]:$})),Ae(j=>{const C=j[l];return C?{...j,[l]:{content:C.content,savedContent:m,savedAt:k}}:j}),J.languageServers!=="off"&&J.checkOnSave&&await $e(l,{content:m,waitForDiagnostics:!0}),S?await ke({silent:!0}):await F({silent:!0})}catch($){Me(j=>({...j,[l]:$ instanceof Error?$.message:String($)}))}finally{ze.current===l&&(ze.current=null),yt($=>$===l?null:$)}},[J.checkOnSave,J.languageServers,t,n,re,F,$e,ke,E,S]),cs=b?Oe(b):null,pe=b?re[b]?.content??cs?.content??null:null,xn=!!(cs?.patch&&!ve),Ft=!!(D==="file"&&!xn&&b&&pe!=null&&!me(b)&&!(mt&&Wt(b))&&!pe.endsWith(ut));o.useEffect(()=>{if(J.languageServers==="off"||!J.diagnosticsWhileEditing||!b||!Ft||pe==null)return;const l=window.setTimeout(()=>{$e(b,{content:pe,waitForDiagnostics:!0})},700);return()=>window.clearTimeout(l)},[J.diagnosticsWhileEditing,J.languageServers,$e,pe,Ft,b]),o.useEffect(()=>{function l(h){!(h.ctrlKey||h.metaKey)||h.key.toLowerCase()!=="s"||D!=="file"||!b||(h.preventDefault(),Re.has(b)&&Be(b))}return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[D,Re,Be,b]);const gn=o.useCallback(()=>{b&&(We.current?We.current.save():Be(b))},[Be,b]),bn=o.useCallback(()=>{We.current?.undo()},[]),jn=o.useCallback(()=>{We.current?.redo()},[]),vn=o.useCallback(()=>{b&&J.languageServers!=="off"&&$e(b,{content:pe??void 0,waitForDiagnostics:!0})},[J.languageServers,$e,pe,b]);function wn(l,h){if(h.stopPropagation(),!(Re.has(l)&&!window.confirm(`Discard unsaved changes to ${l}?`))&&(Re.has(l)&&(Ae(m=>{if(!(l in m))return m;const k={...m};return delete k[l],k}),Me(m=>{if(!(l in m))return m;const k={...m};return delete k[l],k})),Ze(m=>m.filter(k=>k!==l)),b===l)){const m=os.find(k=>k.path!==l)??null;je(m?.path??Ne[0]?.path??null),m||W("files")}}function kn(){W("files"),G(!1),ne(!1)}function yn(l){xt(h=>{const m=new Set(h);return m.has(l)?m.delete(l):m.add(l),m})}function Sn(l){l&&xt(h=>{const m=new Set(h);for(const k of sl(l))m.add(k);return m}),W("files"),G(!1),ne(!1)}function Nn(){const h=`git apply <<'PATCH'
12
+ ${Ne.map(m=>m.patch).filter(Boolean).join(`
13
+ `)}
14
+ PATCH`;navigator.clipboard?.writeText(h)}const Cn=Ne.length>0,Rn=Ce.length>0,$n=Y.length>0,Fn=ce||we||Cn||Rn||$n,he=D==="goal"&&ce?"goal":D==="summary"&&we?"summary":D==="file"&&b?"file":"files",En=he==="files"?"No files to show":"No local changes",An=s==="local_project"&&!f&&!p,ds=S?sn:c,Et=S?nn:p,Pn=el({changedFiles:de?.filesChanged??Ne.length,checkpointStatus:un,dirty:!!de?.dirty,error:Et,loading:ds,preservedReadback:dn,sandboxMode:S,sourcePending:S&&!E}),Ln=ds?"Loading workspace files":Et||(S&&!E?q?.emptyMessage??"No sandbox filesystem is available.":An?"Loading workspace files":f?En:"No local files to show"),Dn=!S&&b&&me(b)?b:null,_n=!S&&Je&&me(Je)?Je:null,At=js(n,t,Dn),us=js(n,t,_n),fs=he==="file"?b:null,Tn=!!(fs&&Wt(fs)),ps=b?es[b]??[]:[],hs=b?an[b]??null:null,Pt=!!(b&&ln===b),Lt=Zt&&Ft,Ue=!S&&J.languageServers!=="off",Mn=o.useMemo(()=>Zi({activeDiagnostics:ps,activeServers:hs,editorDiagnosticsChecking:Pt,editorLspEnabled:Ue,showEditorCommandBar:Lt}),[ps,hs,Pt,Ue,Lt]),zn=o.useCallback(async l=>{if(!n)throw new Error("OpenPond server connection is unavailable.");await z.runSubagentLifecycleAction(n,l.runId,{action:l.action,reason:"User requested from Goal details."}),await F({silent:!0})},[n,F]);return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:`workspace-diff-panel ${d?"expanded":""}`,"aria-label":"Workspace diffs",children:[!d&&e.jsx("div",{className:"workspace-diff-resize-handle",role:"separator","aria-orientation":"vertical","aria-label":"Resize diff panel",onPointerDown:K}),e.jsx(mi,{addMenuOpen:Qe,expanded:d,filteredFiles:fn,openFiles:os,dirtyFilePaths:Re,goalDetailsAvailable:ce,searchOpen:Hs,searchQuery:ht,selectedPath:b,sideChatTabs:y,summaryAvailable:we,sourceStatus:Pn,sourceSwitcher:_,visibleTab:he,onCloseFileTab:wn,onCloseSideChat:N,onCloseSearch:()=>ne(!1),onOpenFile:$t,onOpenBrowser:()=>{G(!1),ne(!1),H()},onOpenSearch:()=>{G(!1),ne(!0)},onOpenSideChat:M?()=>{G(!1),ne(!1),M()}:void 0,onSearchQueryChange:Gt,onSelectFile:l=>{je(l),W("file")},onSelectFiles:kn,onSelectGoal:()=>W("goal"),onSelectSummary:()=>{W("summary"),G(!1),ne(!1)},onSelectSideChat:L,onToggleAddMenu:()=>{G(l=>!l),ne(!1)},onToggleExpanded:Q}),he==="goal"&&ce?e.jsx(Da,{createRuntime:R?.createRuntime??null,goalRuntime:R?.goalRuntime??null,subagentRuntime:R?.subagentRuntime??null,onRunSubagentLifecycleAction:n?zn:void 0}):he==="summary"&&we?I?e.jsx(di,{summary:I}):e.jsx(si,{sandboxId:E,connection:n}):Fn?e.jsxs(e.Fragment,{children:[e.jsx(xi,{canSaveActiveFile:!!(b&&Re.has(b)&&Ye!==b),canCheckActiveFile:Ue,collapsed:Qt,editorControlsVisible:Zt,editorDiagnosticStatus:Mn,editorDiagnosticsChecking:Pt,hideWhiteSpace:Yt,loadFullFiles:ve,menuOpen:v,renderMarkdown:mt,showEditorCommandBar:Lt,showRenderMarkdownToggle:Tn,splitView:Jt,wordDiffs:Xt,wordWrap:Kt,onCopyGitApply:Nn,onEditorCheck:vn,onEditorRedo:jn,onEditorSave:gn,onEditorUndo:bn,onRefresh:()=>{S?ke():F()},onToggleCollapsed:()=>Ks(l=>!l),onToggleEditorControlsVisible:pn,onToggleHideWhiteSpace:()=>Js(l=>!l),onToggleLoadFullFiles:()=>Qs(l=>!l),onToggleMenu:l=>X(h=>l??!h),onToggleRenderMarkdown:()=>Zs(l=>!l),onToggleSplitView:()=>en(l=>!l),onToggleWordDiffs:()=>Ys(l=>!l),onToggleWordWrap:()=>Gs(l=>!l)}),he==="files"&&e.jsx(pi,{diff:de,expandedFolderPaths:tn,rootPath:g,repoFiles:Ce,onOpenFile:$t,onToggleFolder:yn}),he==="file"&&b&&e.jsx(Ci,{diagnostics:Ue?es[b]??[]:[],draftContent:re[b]?.content,editorRef:We,editable:!At,error:on,file:Oe(b),collapsed:Qt,hideWhiteSpace:Yt,imageSrc:At,loading:rn===b,loadFullFiles:ve,saveError:cn[b]??null,saving:Ye===b,onOpenImage:()=>{At&&et(b)},onDraftContentChange:l=>hn(b,l),onLspAction:Ue?mn:void 0,onSave:()=>{Be(b)},onSelectBreadcrumbPath:Sn,renderMarkdown:mt,splitView:Jt,wordDiffs:Xt,wordWrap:Kt,workspaceName:u,workspaceRootPath:at})]}):e.jsx("div",{className:"workspace-diff-empty",children:e.jsx("span",{children:Ln})})]}),e.jsx(da,{open:!!us,src:us,title:Je??"",onClose:()=>et(null)})]})}export{cl as WorkspaceDiffPanel};