openpond 0.0.32 → 0.0.34
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.
- package/dist/chunks/{app-layer-CUQQUVJS.js → app-layer-UQQNF5VZ.js} +3 -3
- package/dist/chunks/{apps-TAYMUCWX.js → apps-7NSC56K5.js} +3 -3
- package/dist/chunks/{chunk-W2DJR3FA.js → chunk-2GCNPJMD.js} +1 -1
- package/dist/chunks/{chunk-GYZYZGKS.js → chunk-5MM3P5KY.js} +2 -2
- package/dist/chunks/{chunk-E5RVRUJB.js → chunk-B5CFIWWU.js} +1 -1
- package/dist/chunks/{chunk-FQW3AQVJ.js → chunk-BZPAW4JY.js} +31 -0
- package/dist/chunks/{chunk-5RHZKQRK.js → chunk-E3RLJ5XT.js} +2 -2
- package/dist/chunks/{chunk-3UOLQG6N.js → chunk-EBCLEJRO.js} +1 -1
- package/dist/chunks/{chunk-D264OHTR.js → chunk-F6FFL3AA.js} +2 -2
- package/dist/chunks/{chunk-PJXJ2HRT.js → chunk-G7XOSECC.js} +33 -0
- package/dist/chunks/{chunk-EONKWOLU.js → chunk-HGZ3O4TS.js} +2 -2
- package/dist/chunks/{chunk-DCNAXREU.js → chunk-JVTACGKD.js} +3 -3
- package/dist/chunks/{chunk-Y4F4XD5V.js → chunk-MMDKFTJB.js} +1 -1
- package/dist/chunks/{chunk-4HQURM3N.js → chunk-TF234YN4.js} +1 -1
- package/dist/chunks/{chunk-3ZJIEA5F.js → chunk-U4TUOBXO.js} +1 -1
- package/dist/chunks/{chunk-4M4WAORL.js → chunk-UASXM3RR.js} +4 -4
- package/dist/chunks/{chunk-OXQG773T.js → chunk-V7SHAMUN.js} +33 -33
- package/dist/chunks/{chunk-Q5MZCRJA.js → chunk-ZDEBKTWR.js} +1 -1
- package/dist/chunks/{chunk-XADW35CL.js → chunk-ZRNFOHFH.js} +3 -3
- package/dist/chunks/{cli-WW5BVN5Z.js → cli-4ETE5RS2.js} +4 -4
- package/dist/chunks/{cli-ZOCP7X5M.js → cli-VEDK2B42.js} +6 -6
- package/dist/chunks/{core-commands-SYGK7K57.js → core-commands-J3IQGQOL.js} +4 -4
- package/dist/chunks/{extend-Q5HZ7TMA.js → extend-3F3LLDOF.js} +9 -9
- package/dist/chunks/{harness-ZPBPQVAS.js → harness-JER7P6MJ.js} +3 -3
- package/dist/chunks/{help-3V3TRQNX.js → help-75NFCYJ4.js} +1 -1
- package/dist/chunks/{opchat-OUPMEFE5.js → opchat-UT5V7MR2.js} +5 -5
- package/dist/chunks/{organizations-5CSLBDAW.js → organizations-ERKRLVNQ.js} +4 -4
- package/dist/chunks/{profile-OQYSXHOG.js → profile-A3CUSDIF.js} +7 -7
- package/dist/chunks/{project-agent-TBTWOUJF.js → project-agent-FCV5HPYT.js} +6 -6
- package/dist/chunks/{sandbox-command-HCHPY7KW.js → sandbox-command-L2QPIWZ5.js} +4 -4
- package/dist/chunks/{sandbox-template-PNTOZ6W3.js → sandbox-template-XOIWROEK.js} +5 -5
- package/dist/chunks/{src-C6MXLDYQ.js → src-ENVQ7ARM.js} +2 -2
- package/dist/chunks/{src-GZT4UX6I.js → src-V4FUQNHR.js} +676 -462
- package/dist/chunks/{teams-bot-CQ76XI6T.js → teams-bot-OR3ZJHQ5.js} +3 -3
- package/dist/chunks/{workspaces-DHVVOTVR.js → workspaces-L73SRLPA.js} +2 -2
- package/dist/cli.js +10 -10
- package/dist/web/assets/{AppsView-CF2g-7FH.js → AppsView-CLjjVkjr.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-lUsLUl20.js → BrowserSidebar-CkNO8723.js} +1 -1
- package/dist/web/assets/{CloudWorkView-BnfGW4OV.js → CloudWorkView-Cu_VqkaD.js} +1 -1
- package/dist/web/assets/{CommandMenu-BsS4Bgb6.js → CommandMenu-DWtdkvmq.js} +1 -1
- package/dist/web/assets/{CommunityView-C8qVOwlp.js → CommunityView-f03qOTER.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-C_LIpfSq.js → ComposerCreateImproveStrip-CZpiQJsJ.js} +1 -1
- package/dist/web/assets/{GetStartedView-Du533wOh.js → GetStartedView-CLMmryTG.js} +1 -1
- package/dist/web/assets/LabsRoute-BwR2g71k.js +4 -0
- package/dist/web/assets/{NewProjectDialog-DH7wA1z9.js → NewProjectDialog-PrbA4fL6.js} +1 -1
- package/dist/web/assets/{ProfileSettingsSection-D7JvMZdW.js → ProfileSettingsSection-CD_x_V8d.js} +1 -1
- package/dist/web/assets/SettingsView-BMmlKvlB.js +63 -0
- package/dist/web/assets/SettingsView-CAPf81v3.css +1 -0
- package/dist/web/assets/{TeamChatView-D_CE7br9.js → TeamChatView-B5SlhDso.js} +2 -2
- package/dist/web/assets/{TerminalOverlay-CC-VDSlp.js → TerminalOverlay-DaGfEprz.js} +1 -1
- package/dist/web/assets/TrainingComputeDialog-BFY6E0yU.js +1 -0
- package/dist/web/assets/{TrainingCreationPanel-NFCoaBUI.js → TrainingCreationPanel-Cp66gMed.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-BWEmVFjM.js → TrainingDraftPanel-BX5CCqlO.js} +1 -1
- package/dist/web/assets/{WorkspaceDiffPanel-SlLlGZM1.js → WorkspaceDiffPanel-D7ZEbryF.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-BAoMBTVD.js → WorkspaceEnvironmentMenu-D4DmAJaS.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-CVIFrzyl.js → WorkspaceGitDialogs-DHOfJxbL.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-0trp0-TI.js → WorkspaceMonacoEditor-C0fDue2d.js} +3 -3
- package/dist/web/assets/{boxes-CFihgX2z.js → boxes-CXLqRF98.js} +1 -1
- package/dist/web/assets/{create-pipeline-request-AJWLMTyw.js → create-pipeline-request-C26NOc7v.js} +1 -1
- package/dist/web/assets/{cssMode-HvqfCFyP.js → cssMode-DmtwKUVm.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-C5mUmACv.js → git-commit-horizontal-CDDZl4iA.js} +1 -1
- package/dist/web/assets/{htmlMode-C8btgUt-.js → htmlMode-Box0EOm1.js} +1 -1
- package/dist/web/assets/index-BUyeKpY6.js +1 -0
- package/dist/web/assets/{index-D7Vr3zcV.js → index-CKmte5ok.js} +55 -55
- package/dist/web/assets/{info-D0xuy5IB.js → info-4Iy6BKvT.js} +1 -1
- package/dist/web/assets/{jsonMode-5zVz9G0X.js → jsonMode-g7t_3HFv.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-DxlSSL7c.js → lspLanguageFeatures-CwhFOYc9.js} +1 -1
- package/dist/web/assets/{monaco.contribution-BKpVvKK9.js → monaco.contribution-B-QC_ls9.js} +2 -2
- package/dist/web/assets/{monaco.contribution-B1pWWwqT.js → monaco.contribution-CW2ctrTm.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BXdXsSWI.js → monaco.contribution-CwMt3eHi.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CIjjzpUR.js → monaco.contribution-DGZAePHI.js} +2 -2
- package/dist/web/assets/{monitor-B4-9Shtp.js → monitor-DOVjBLkr.js} +1 -1
- package/dist/web/assets/{play-BJdhBqQE.js → play-DLCuESeG.js} +1 -1
- package/dist/web/assets/{python-CEK8J4w_.js → python-DRNmHcYd.js} +1 -1
- package/dist/web/assets/{refresh-cw-DE0u_nmZ.js → refresh-cw-JNUovwk4.js} +1 -1
- package/dist/web/assets/{reply-2MfLJ93n.js → reply-D4QvJyzE.js} +1 -1
- package/dist/web/assets/{save-CBIVKaf8.js → save-BR4O4UDP.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-CC73mtvA.js → toggleHighContrast-CrfdWIsV.js} +1 -1
- package/dist/web/assets/training-DeVTd0m8.css +1 -0
- package/dist/web/assets/{tsMode-Bhn9wr_1.js → tsMode-ZuV9go1B.js} +1 -1
- package/dist/web/assets/useComputeSettings-DUNS6uOl.js +1 -0
- package/dist/web/assets/useComputeSettings-R2Sw621I.css +1 -0
- package/dist/web/assets/{wifi-off-BKTqnqj0.js → wifi-off-XFVqsf4c.js} +1 -1
- package/dist/web/assets/{workers-C_adgrEg.js → workers-CJpO1Wzj.js} +1 -1
- package/dist/web/assets/{yaml-DDRAcADU.js → yaml-AQ4ok5ED.js} +1 -1
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/LabsRoute-yk8lNMQc.js +0 -3
- package/dist/web/assets/SettingsView-C9TgCaWG.js +0 -63
- package/dist/web/assets/SettingsView-DwbGu8Kj.css +0 -1
- package/dist/web/assets/index-DUqAiF57.js +0 -1
- package/dist/web/assets/training-BY8siNUK.css +0 -1
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{j as e,N as ke,r as c,b8 as Pt,z as Cn,A as In,a4 as Mn,b9 as Zt,S as zt,D as $t,ba as Rn,a as _s,bb as Es,bc as An,U as Ps,X as qe,a9 as Tn,bd as pt,M as $s,m as Xe,be as _n,bf as En,h as Ds,v as Ot,P as Pn,V as Fs,Z as $n,aI as Dn,Y as Ls,R as Bs,aT as zs,bg as Fn,bh as Ln}from"./index-D7Vr3zcV.js";import{P as Bn}from"./ProfileSettingsSection-D7JvMZdW.js";import{B as qt}from"./boxes-CFihgX2z.js";import{c as zn,e as De,g as On,f as xt,s as Vt,d as es,b as qn,j as Os}from"./training-model-data-BXUCzS0p.js";import{ComposerCreateImproveStrip as Vn}from"./ComposerCreateImproveStrip-C_LIpfSq.js";import{R as Un}from"./refresh-cw-DE0u_nmZ.js";import"./git-commit-horizontal-C5mUmACv.js";import"./play-BJdhBqQE.js";/* empty css */const Nt=8,ts=24,Gn=2;function Hn(t){const s=Wn(t);if(s.length){const a=ts+s.reduce((r,o)=>r+Nt+Ge(o.content),0),l=s.filter(r=>r.role==="assistant").map(r=>Nt+Ge(r.content));return{renderedTokens:a,maximumAssistantTargetTokens:Math.max(0,...l),assistantTargetCount:l.length}}const n=Qn(t.input),i=Yn(t.expectedOutput);return{renderedTokens:ts+Ge(n)+Ge(i),maximumAssistantTargetTokens:Nt+Ge(i),assistantTargetCount:i?1:0}}function Kn(t,s={}){const n=s.minimum??64,i=s.maximum??4096,a=t.tasks.filter(l=>l.split==="train").reduce((l,r)=>Math.max(l,Hn(r).renderedTokens),0);return a<=n?n:Math.min(i,2**Math.ceil(Math.log2(a)))}function Wn(t){const s=[...ss(t.input.messages),...ss(t.expectedOutput?.messages)],n=[],i=new Map,a=l=>{const r=typeof l=="string"&&l?l:`missing_${i.size+1}`;return i.has(r)||i.set(r,`call_${i.size+1}`),i.get(r)};for(const l of s){if(!ct(l))continue;const r=l.role,o=l.content;if(r==="tool"){n.push({role:"user",content:mt({content:typeof o=="string"?o:"",tool_call_id:a(l.tool_call_id),type:"tool_result"})});continue}if(r==="assistant"&&Array.isArray(l.tool_calls)&&l.tool_calls.length){for(const u of l.tool_calls)!ct(u)||!ct(u.function)||(n.push({role:"assistant",content:mt({arguments:Jn(u.function.arguments),name:u.function.name??null,type:"tool_call"})}),a(u.id));typeof o=="string"&&o&&n.push({role:"assistant",content:o});continue}(r==="system"||r==="user"||r==="assistant")&&typeof o=="string"&&o&&n.push({role:r,content:o})}return n}function ss(t){return Array.isArray(t)?t:[]}function Jn(t){if(typeof t!="string")return{};try{return JSON.parse(t)}catch{return{malformed_arguments:t}}}function mt(t){return JSON.stringify(Dt(t))}function Dt(t){return Array.isArray(t)?t.map(Dt):ct(t)?Object.fromEntries(Object.keys(t).sort().map(s=>[s,Dt(t[s])])):t}function Qn(t){return typeof t.prompt=="string"?t.prompt:mt(t)}function Yn(t){return t?typeof t.text=="string"?t.text:mt(t):""}function Ge(t){return Math.ceil(t.length/Gn)}function ct(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function Xn({section:t="all",payload:s,connection:n,onPayload:i,onError:a,onToast:l,onSkillCommand:r,overviewContent:o}){return e.jsx("section",{className:"profile-view","aria-label":t==="agents"?"Agents":"Profile",children:e.jsx(Bn,{section:t,payload:s,connection:n,onPayload:i,onError:a,onToast:l,onSkillCommand:r,overviewContent:o})})}function Zn({candidates:t,onRescan:s,onSelect:n}){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:t.length?"Review repeated workflows":"No repeated workflows found"}),e.jsx("p",{children:t.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."})]}),t.length?e.jsx("div",{className:"training-candidate-options",children:t.map(i=>e.jsxs("button",{type:"button",onClick:()=>n(i),children:[e.jsxs("span",{children:[e.jsx("strong",{children:i.title}),e.jsx("small",{children:i.summary})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Supporting chats"}),e.jsx("dd",{children:i.evidence.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Confidence"}),e.jsxs("dd",{children:[Math.round(i.scorecard.overall*100),"%"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Preliminary"}),e.jsx("dd",{children:i.recommendation.tactic.replaceAll("_"," ")})]})]})]},i.id))}):null]}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button secondary",type:"button",onClick:s,children:t.length?"Scan again":"Change scan"})})]})}function ea({chatPreview:t,chatCount:s,config:n,estimate:i,onConfigChange:a,onCancel:l,onScan:r,run:o,scanning:u}){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 chats in scope"}),e.jsx("p",{children:"OpenPond groups repeated work across completed chats on this device. The next step shows candidate workflows and their supporting chats; nothing is sent to an authoring model until you choose a candidate and approve disclosure."})]}),e.jsxs("dl",{className:"training-automatic-scope-summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Chats in scope"}),e.jsx("dd",{children:s})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Messages"}),e.jsx("dd",{children:i.measuredChats===s?i.messageCount:"Estimating…"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Approximate tokens"}),e.jsx("dd",{children:i.measuredChats===s?sa(i.estimatedTokens):"Estimating…"})]})]}),e.jsxs("section",{className:"training-automatic-chat-preview","aria-label":"Recent chats in scope",children:[e.jsxs("div",{children:[e.jsx("h4",{children:"Recent chats"}),e.jsxs("span",{children:["Showing ",t.length," of ",s]})]}),t.length?e.jsx("ul",{children:t.map(h=>e.jsxs("li",{children:[e.jsx("strong",{children:h.title}),e.jsx("time",{dateTime:h.updatedAt,children:na(h.updatedAt)})]},h.id))}):e.jsx("p",{children:"No completed chats are available yet."}),e.jsx("small",{children:"Finding repeated work reads these chats locally. You will review the matching chats before any Taskset is authored."})]}),e.jsxs("details",{className:"training-automatic-options",children:[e.jsx("summary",{children:"Search options"}),e.jsxs("div",{children:[e.jsxs("label",{children:["Look back ",e.jsx("input",{type:"number",min:1,max:365,value:n.observationWindowDays,onChange:h=>a({...n,observationWindowDays:Number(h.target.value)})})," days"]}),e.jsxs("label",{children:["Minimum recurrence ",e.jsx("input",{type:"number",min:2,max:100,value:n.minimumRecurrence,onChange:h=>a({...n,minimumRecurrence:Number(h.target.value)})})]})]})]}),o&&["queued","running","cancelling"].includes(o.status)?e.jsxs("div",{className:"training-miner-progress",role:"status",children:[e.jsxs("div",{children:[e.jsx("strong",{children:ta(o)}),e.jsxs("span",{children:[o.progress.processedSources," of ",o.progress.totalSources||s," chats · ",o.progress.candidatesFound," candidates",o.progress.skippedSources?` · ${o.progress.skippedSources} skipped`:""]})]}),e.jsx("progress",{max:Math.max(1,o.progress.totalSources||s),value:o.progress.processedSources})]}):null,o?.status==="failed"?e.jsxs("p",{className:"training-empty",children:["Scan failed: ",o.error]}):null,o?.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:[u?e.jsx("button",{className:"training-button secondary",type:"button",disabled:o?.status==="cancelling",onClick:l,children:o?.status==="cancelling"?"Cancelling…":"Cancel scan"}):null,e.jsxs("button",{className:"training-button",type:"button",disabled:u||s===0,onClick:r,children:[u?e.jsx(ke,{className:"spin",size:14}):null,u?"Finding repeated work…":"Find repeated work"]})]})]})}function ta(t){return t.status==="queued"?"Preparing scan":t.status==="cancelling"?"Cancelling scan":t.progress.stage==="ingesting"?"Preparing local evidence":t.progress.stage==="clustering"?"Clustering repeated work":t.progress.stage==="persisting"?"Saving candidates":"Scanning local evidence"}function sa(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t>=1e4?0:1)}K`:`${(t/1e6).toFixed(t>=1e7?0:1)}M`}function na(t){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(t))}function aa({modelIds:t,value:s,onChange:n,onContinue:i}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"Choose a base model"}),e.jsx("p",{children:"Select the intended starting model. OpenPond checks method and provider compatibility again before any paid training launch."})]}),e.jsxs("div",{className:"training-base-model-card",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Base model"}),e.jsx("select",{"data-autofocus":!0,value:s,onChange:a=>n(a.target.value),children:t.map(a=>e.jsx("option",{value:a,children:ia(a)},a))})]}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:"Fireworks"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Parameterization"}),e.jsx("dd",{children:"LoRA"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Final confirmation"}),e.jsx("dd",{children:"Training page"})]})]})]}),e.jsx("p",{className:"training-start-note",children:"This records a preferred base for the Model draft. Individual SFT or RFT runs may override it at the explicit configuration and spend gate."}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",disabled:!s,onClick:i,children:"Continue"})})]})}function ia(t){return(t.split("/").filter(Boolean).at(-1)??t).replace(/(\d+)p(\d+)b/gi,"$1.$2B").replace(/(\d+)b/gi,"$1B").replaceAll("-"," ").replace(/\b\w/g,n=>n.toUpperCase())}function la({state:t,selectedTasksetId:s,busy:n,onChange:i,onCreate:a}){const l=oa(t),r=l.find(o=>o.id===s)??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:"Choose a Dataset"}),e.jsx("p",{children:"Use an approved Dataset as the immutable training and Eval boundary for this Model."})]}),e.jsxs("div",{className:"training-existing-dataset-list",role:"radiogroup","aria-label":"Available Datasets",children:[l.map(o=>{const u=o.id===s;return e.jsxs("button",{"aria-checked":u,className:u?"selected":void 0,role:"radio",type:"button",onClick:()=>i(o.id),children:[e.jsx("span",{className:"training-existing-dataset-icon",children:e.jsx(qt,{size:17})}),e.jsxs("span",{children:[e.jsx("strong",{children:o.name}),e.jsx("small",{children:o.objective})]}),e.jsx(ra,{taskset:o})]},o.id)}),l.length?null:e.jsx("div",{className:"training-empty training-existing-dataset-empty",children:"No reusable Datasets are ready yet. Create a Dataset from the Lab menu, then return here."})]}),r?e.jsx("p",{className:"training-existing-dataset-note",children:"The Dataset remains reusable and unchanged. Creating the Model stores the preferred base Model on the Model draft."}):null]}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",disabled:!r||n,type:"button",onClick:a,children:"Create model"})})]})}function ra({taskset:t}){return e.jsxs("span",{className:"training-existing-dataset-splits",children:[e.jsxs("span",{children:[kt(t,"train")," train"]}),e.jsxs("span",{children:[kt(t,"validation")," validation"]}),e.jsxs("span",{children:[kt(t,"frozen_eval")," frozen Eval"]})]})}function kt(t,s){return t.tasks.filter(n=>n.split===s).length}function oa(t){return t?t.tasksets.filter(s=>s.readiness?.ready).sort((s,n)=>n.updatedAt.localeCompare(s.updatedAt)||s.name.localeCompare(n.name)):[]}function da({creation:t,resourceIntent:s="workproduct",sources:n,training:i,onCreationChange:a}){const[l,r]=c.useState(""),o=t.proposal,[u,h]=c.useState(o?.name??"");if(c.useEffect(()=>h(o?.name??""),[o?.name]),!o)return null;const d=o.diagnosis,j=s==="dataset"?"dataset":ca(t),f=new Map(n.map(k=>[k.id,k])),p=o.proposedExamples.filter(k=>k.split==="train"),S=o.proposedExamples.filter(k=>k.split!=="train"),m=t.materializedTasksetId?i.payload?.graderAuditReports.find(k=>k.tasksetId===t.materializedTasksetId)??null:null,N=o.trainingPath?.primaryMethod??o.proposedMethod;async function b(){const k=l.trim();if(!k)return;const T=await i.actions.chatCreation(t.id,k);T&&(r(""),a(T))}async function v(){if(!o)return;const k=Pt(u,o.name);if(!k||k===o.name)return;const T=await i.actions.renameCreation(t.id,k);T&&(h(T.proposal?.name??k),a(T))}return e.jsxs("div",{className:"training-recommendation-review",children:[e.jsxs("section",{className:"training-setup-section training-setup-model",children:[e.jsxs("div",{className:"training-setup-section-heading",children:[e.jsx("span",{className:"training-setup-step-number",children:"1"}),e.jsx("strong",{children:j==="dataset"?"Dataset":"Model"}),e.jsxs("small",{children:[ut(j)," · ",ua(d.intervention)]})]}),e.jsxs("label",{className:"training-recommendation-name",children:[e.jsx("span",{children:j==="dataset"?"Dataset name":j==="model"?"Model name":"Workproduct name"}),e.jsx("input",{value:u,maxLength:100,onChange:k=>h(k.target.value),onBlur:()=>{v()},onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),v())}}),e.jsx("small",{children:"Five words maximum. The full capability stays in the description."})]}),e.jsx("p",{className:"training-recommendation-objective",children:o.objective}),j==="model"&&t.request.preferredBaseModelId?e.jsxs("p",{className:"training-recommendation-base-model",children:[e.jsx("span",{children:"Preferred base"}),e.jsx("strong",{children:pa(t.request.preferredBaseModelId)})]}):null]}),e.jsxs("details",{className:"training-setup-section",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"training-setup-step-number",children:"2"}),e.jsx("strong",{children:"Dataset & Evals"}),e.jsxs("small",{children:[p.length," train · ",S.length," eval · ",o.proposedGraders.length," grader",o.proposedGraders.length===1?"":"s"]})]}),e.jsxs("div",{className:"training-recommendation-detail-body",children:[e.jsxs("dl",{className:"training-recommendation-facts",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Chat seeds"}),e.jsx("dd",{children:t.request.sourceIds.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Training examples"}),e.jsx("dd",{children:p.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Evaluation examples"}),e.jsx("dd",{children:S.length})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Grader"}),e.jsx("dd",{children:m?m.passed?"Passed":"Failed":o.proposedGraders.length?"Runs after creation":"Not proposed"})]})]}),o.proposedExamples.length?e.jsx("div",{className:"training-proposed-examples",children:o.proposedExamples.map(k=>e.jsxs("article",{children:[e.jsxs("div",{children:[e.jsx("strong",{children:k.split==="frozen_eval"?"Evaluation":k.split==="train"?"Training":ut(k.split)}),e.jsx("span",{children:ut(k.origin.replaceAll("_"," "))})]}),e.jsx("p",{children:k.inputPrompt}),e.jsx("small",{children:f.get(k.sourceId)?.title??"Selected chat"})]},k.id))}):e.jsx("p",{children:"No training examples are proposed for this recommendation."}),o.proposedGraders.length?e.jsxs("div",{className:"training-proposed-evaluation",children:[e.jsx("strong",{children:"Grader summary"}),e.jsxs("p",{children:[o.proposedGraders.map(k=>k.label).join(", ")," · ",m?m.passed?"executed successfully":"execution failed":"execution pending Taskset creation"]})]}):null,o.warnings.length&&t.state!=="recommendation_ready"?e.jsx("ul",{className:"training-recommendation-warnings",children:o.warnings.map(k=>e.jsx("li",{children:k},k))}):null]})]}),e.jsxs("details",{className:"training-setup-section",open:!0,children:[e.jsxs("summary",{children:[e.jsx("span",{className:"training-setup-step-number",children:"3"}),e.jsx("strong",{children:"Recommended training"}),e.jsx("small",{children:ns(N)})]}),e.jsxs("div",{className:"training-recommendation-detail-body training-path-review",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:["Primary · ",ns(N)]}),e.jsx("p",{children:d.rationale.join(" ")||d.summary})]}),o.trainingPath?.bootstrap?e.jsxs("div",{children:[e.jsx("strong",{children:"Optional precursor · Supervised / SFT"}),e.jsxs("p",{children:[o.trainingPath.bootstrap.demonstrationRefs.length," reviewed demonstration",o.trainingPath.bootstrap.demonstrationRefs.length===1?"":"s",". ",o.trainingPath.bootstrap.limitations.join(" ")]})]}):null,e.jsx("p",{className:"training-setup-spend-note",children:"Creating the model saves this Dataset and recommendation locally. Paid provider training starts later from the model’s Training page, where method, budget, and export are reviewed explicitly."})]})]}),e.jsxs("details",{className:"training-setup-section",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"training-setup-step-number",children:"4"}),e.jsx("strong",{children:"Behavior & context"}),e.jsxs("small",{children:[d.stableBehavior.length," stable behavior",d.stableBehavior.length===1?"":"s"]})]}),e.jsxs("div",{className:"training-recommendation-detail-body",children:[e.jsx("h4",{children:"What it should learn"}),d.stableBehavior.length?e.jsx("ul",{children:d.stableBehavior.map(k=>e.jsx("li",{children:k},k))}):e.jsx("p",{children:d.summary}),d.changingKnowledge.length||d.requiredContext.length?e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Keep in context"}),e.jsx("ul",{children:[...d.changingKnowledge,...d.requiredContext].map(k=>e.jsx("li",{children:k},k))})]}):null]})]}),e.jsxs("details",{className:"training-setup-section",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"training-setup-step-number",children:"5"}),e.jsx("strong",{children:"Advanced"}),e.jsx("small",{children:"Technical method · revise"})]}),e.jsxs("div",{className:"training-recommendation-detail-body training-recommendation-revision",children:[e.jsxs("p",{children:["Technical method: ",ha(N)]}),t.state==="recommendation_ready"||!d.trainingEligible?e.jsxs("div",{className:"training-recommendation-guidance",children:[e.jsx("strong",{children:"Why this is not ready for a Dataset"}),e.jsx("ul",{children:o.warnings.map(k=>e.jsx("li",{children:k},k))})]}):null,e.jsx("textarea",{value:l,onChange:k=>r(k.target.value),placeholder:"Explain what should change"}),e.jsx("button",{className:"training-button secondary",type:"button",disabled:!l.trim()||!!i.busyAction,onClick:()=>{b()},children:"Revise"})]})]})]})}function ca(t){return t.request.targetIntent.kind?t.request.targetIntent.kind:t.proposal?.diagnosis.trainingEligible?"model":t.proposal?.diagnosis.intervention==="retrieval"?"configuration":"agent"}function ua(t){return{no_training:"No training",prompting:"Prompt or agent instructions",retrieval:"Retrieval",sft:"SFT",preference:"Preference tuning",grpo_rft:"RFT",sdft_opsd:"Distillation",sdpo:"SDPO",agentic_rl:"Agentic RL"}[t]}function ut(t){return t&&`${t[0].toUpperCase()}${t.slice(1)}`}function ns(t){return t==="grpo"?"Reinforcement / RFT":t==="sft"?"Supervised / SFT":t==="preference"?"Preference":ut(t.replaceAll("_"," "))}function ha(t){return t==="grpo"?"GRPO optimizer":t==="sft"?"SFT":t.toUpperCase()}function pa(t){return t.split("/").filter(Boolean).at(-1)??t}function ma({busy:t,createLabel:s="Create Taskset",creation:n,editDataLabel:i="Add chats",onAddChats:a,onClose:l,onCreateTaskset:r,onCreationChange:o,resourceIntent:u="workproduct",sources:h,training:d}){const j=n.state==="awaiting_materialization_approval",f=n.state==="recommendation_ready"&&n.proposal?.diagnosis.trainingEligible===!0;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"training-dialog-scroll-body",children:e.jsx(da,{creation:n,resourceIntent:u,sources:h,training:d,onCreationChange:o})}),e.jsxs("div",{className:"training-dialog-actions",children:[f?e.jsx("button",{className:"training-button secondary",type:"button",disabled:t,onClick:a,children:i}):null,e.jsx("button",{className:"training-button secondary",type:"button",onClick:l,children:j?"Cancel":"Done"}),j?e.jsxs("button",{className:"training-button",type:"button",disabled:t,onClick:r,children:[t?e.jsx(ke,{className:"spin",size:14}):null,s]}):null]})]})}function ga({authoringModel:t,authoringProvider:s,authoringReasoningEffort:n,busy:i,disclosurePending:a,estimatesBySessionId:l,matchingSessionCount:r,mode:o,objective:u,onObjectiveChange:h,onAnalyze:d,onApproveDisclosure:j,onAuthoringModelChange:f,onAuthoringProviderChange:p,onAuthoringReasoningEffortChange:S,onDeclineDisclosure:m,onSearchChange:N,onLoadMore:b,onReturnToRecommendation:v,onToggleSession:k,onToggleVisible:T,providerSettings:L,recommendationAvailable:X,search:q,searchError:x,searchHasMore:E,searchIndexedChats:re,searchIndexing:D,searchLoading:Y,searchTotalChats:H,selectedEntries:_,selectedEstimate:J,selectedSessionIds:se,targetLabel:B="model",visibleSessions:ae}){const ie=c.useMemo(()=>Cn(L,{enabledOnly:!0}),[L]),z=c.useMemo(()=>In(s,L),[s,L]),ge=Mn(s,t,L),A=se.size,fe=ae.length>0&&ae.every(P=>se.has(P.sessionId)),K=ae.filter(P=>!se.has(P.sessionId)),U=A>0||o==="manual"&&!!u.trim(),W=J.measuredChats===A,le=A>0&&W&&J.estimatedTokens>Zt,ue=B==="dataset",oe=B==="model",F=oe||ue,je=ue||oe?"Build the Dataset":"Review supporting chats",de=o==="automated"?F?"Confirm the chats that demonstrate this repeated workflow. Only selected chats seed the Dataset.":"Approve the chats that support this repeated workflow.":F?"Describe the capability, then optionally add successful chats. OpenPond can propose generated training and evaluation examples when no chats are selected.":"Describe the capability, then add successful examples, corrections, reviewer choices, or outcome-bearing runs.";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:je}),e.jsx("p",{children:de})]}),o==="manual"?e.jsxs("label",{className:"training-objective-field training-dataset-capability",children:[e.jsx("span",{children:"Capability"}),e.jsx("textarea",{"data-autofocus":!0,required:!0,value:u,disabled:i||a,placeholder:`Describe what this ${B} should do reliably`,onChange:P=>h(P.target.value)})]}):u?e.jsxs("div",{className:"training-evidence-objective",children:[e.jsx("span",{children:"Capability"}),e.jsx("strong",{children:u})]}):null,e.jsxs("fieldset",{className:"training-evidence-fields",disabled:i||a,children:[e.jsxs("div",{className:"training-dataset-source-heading",children:[e.jsx("span",{children:F?"Chat seeds":"Supporting chats"}),o==="manual"&&F?e.jsx("small",{children:"Optional"}):null]}),e.jsxs("div",{className:"training-source-toolbar",children:[e.jsxs("label",{className:"training-search",children:[e.jsx(zt,{size:14}),e.jsx("input",{value:q,onChange:P=>N(P.target.value),placeholder:"Search chats"})]}),e.jsx("button",{className:"training-text-button",type:"button",disabled:!ae.length,onClick:T,children:fe?"Clear visible":"Select visible"})]}),e.jsxs("div",{className:"training-source-result-count",children:[e.jsxs("span",{children:["Showing ",ae.length," of ",r," matching chats"]}),D?e.jsxs("span",{children:["Indexing messages ",re," of ",H]}):null]}),e.jsxs("div",{className:"training-source-options",onScroll:P=>{const Z=P.currentTarget;E&&!Y&&Z.scrollHeight-Z.scrollTop-Z.clientHeight<72&&b()},children:[_.length?e.jsx("div",{className:"training-selected-chat-group",children:_.map(P=>e.jsx(as,{entry:P,checked:!0,estimatesBySessionId:l,onToggleSession:k,showSnippet:!!q.trim()},P.sessionId))}):null,K.map(P=>e.jsx(as,{entry:P,checked:!1,estimatesBySessionId:l,onToggleSession:k,showSnippet:!!q.trim()},P.sessionId)),Y?e.jsxs("div",{className:"training-chat-search-state",children:[e.jsx(ke,{className:"spin",size:15}),e.jsx("span",{children:ae.length?"Loading more chats…":"Searching chats…"})]}):null,x?e.jsx("p",{className:"training-empty",children:x}):null,!Y&&!x&&!ae.length?e.jsx("p",{className:"training-empty",children:D?"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($t,{compact:!0,placement:"bottom",label:"Provider",value:s,options:ie,disabled:i,onChange:P=>p(P)}),ge?e.jsx(Rn,{disabled:i,model:t,modelOptions:z,placement:"bottom",reasoningEffort:n,onModelChange:f,onReasoningEffortChange:S}):e.jsx($t,{compact:!0,placement:"bottom",label:"Model",value:t,options:z,disabled:i,onChange:f})]})]})]}),a?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:[s," / ",t]})," will receive raw excerpts from ",A," selected chat",A===1?"":"s",", ",J.messageCount," messages, and approximately ",Qe(J.estimatedTokens)," tokens. Unselected local chats and the local search index are not sent."]})]}):null,le?e.jsxs("div",{className:"training-banner error",role:"alert",children:["Selected evidence is about ",Qe(J.estimatedTokens)," tokens. Hosted Taskset authoring accepts up to ",Qe(Zt)," raw-evidence tokens; choose fewer chats or selected turns."]}):null]}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("span",{className:"training-selection-count",children:A===0?"No supporting chats selected":J.measuredChats===A?e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[A," chat",A===1?"":"s"]}),e.jsxs("span",{children:[J.messageCount," messages"]}),e.jsxs("span",{children:["About ",Qe(J.estimatedTokens)," tokens"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{children:[A," chat",A===1?"":"s"]}),e.jsx("span",{children:"Estimating…"})]})}),a?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:i,onClick:m,children:"Change evidence"}),e.jsxs("button",{className:"training-button",type:"button",disabled:i||!W||le,onClick:j,children:[i?e.jsx(ke,{className:"spin",size:14}):null,"Approve and analyze"]})]}):X?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:i,onClick:d,children:"Reanalyze changes"}),e.jsx("button",{className:"training-button",type:"button",onClick:v,children:"Return to recommendation"})]}):e.jsxs("button",{className:"training-button",type:"button",disabled:!U||i||le||A>0&&!W,onClick:d,children:[i?e.jsx(ke,{className:"spin",size:14}):null,A>0?"Review data access":F?"Build Dataset":"Review setup"]})]})]})}function as({checked:t,entry:s,estimatesBySessionId:n,onToggleSession:i,showSnippet:a}){return e.jsxs("label",{children:[e.jsx("input",{className:"training-chat-checkbox",type:"checkbox",checked:t,onChange:l=>i(s.sessionId,l.target.checked)}),e.jsxs("span",{children:[e.jsx("strong",{children:s.title}),a&&s.snippet?e.jsx("span",{className:"training-chat-search-snippet",children:s.snippet}):null,e.jsxs("small",{children:[new Date(s.updatedAt).toLocaleString(),e.jsx(xa,{estimate:n[s.sessionId]})]})]})]})}function xa({estimate:t}){return t?e.jsxs("span",{className:"training-chat-estimate",children:[e.jsxs("span",{children:[t.messageCount," messages"]}),e.jsxs("span",{children:["About ",Qe(t.estimatedTokens)," tokens"]})]}):e.jsx("span",{className:"training-chat-estimate",children:e.jsx("span",{children:"Estimating…"})})}function Qe(t){return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t>=1e4?0:1)}K`:`${(t/1e6).toFixed(t>=1e7?0:1)}M`}const is=[{id:"automated",title:"Automated",description:"Review repeated work in chats and recommend what, if anything, should be trained.",icon:zt},{id:"manual",title:"Manual",description:"Start from a capability you already want the model to learn.",icon:_s},{id:"existing_dataset",title:"Existing Dataset",description:"Create the Model from a reviewed Dataset without changing its tasks, graders, or held-out Evals.",icon:qt}];function fa({mode:t,allowExistingDataset:s=!1,targetLabel:n="model",onChange:i,onContinue:a}){const l=s?is:is.filter(r=>r.id!=="existing_dataset");return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"Choose a setup"}),e.jsx("p",{children:"Start from repeated work or define the capability yourself. OpenPond recommends the training method after reviewing the Dataset."})]}),e.jsx("div",{"aria-label":`How to start a new ${n}`,className:"training-method-options training-start-mode-options",role:"radiogroup",children:l.map(r=>{const o=r.icon,u=r.id===t;return e.jsxs("button",{type:"button",role:"radio","aria-checked":u,className:u?"selected":"",onClick:()=>i(r.id),onDoubleClick:a,children:[e.jsx(o,{size:17}),e.jsx("strong",{children:r.title})]},r.id)})}),e.jsx("p",{className:"training-start-mode-description",children:t?l.find(r=>r.id===t)?.description:`Choose how to define this ${n}.`}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",disabled:!t,onClick:a,children:"Continue"})})]})}const ls=20,St="accounts/fireworks/models/qwen3-8b";function He({defaultModel:t,initialCreation:s=null,initialObjective:n,initialSessionIds:i=[],onClose:a,onModelCreatedFromTaskset:l,onTasksetCreated:r,preferences:o,providerSettings:u,reasoningEffort:h,resourceIntent:d="workproduct",sessions:j,sources:f,training:p,targetIntent:S={kind:"model",id:null,displayName:null,operation:"create"}}){const m=Es(o,t),N=f.filter(g=>s?.request.sourceIds.includes(g.id)).map(g=>g.sessionId),[b,v]=c.useState(()=>ja(s)),[k,T]=c.useState(s?.request.entryMode??null),L=k==="automated"||k==="manual"?k:null,[X,q]=c.useState(s?.request.objective??n??""),[x,E]=c.useState(s?.request.preferredBaseModelId??St),[re,D]=c.useState(null),[Y,H]=c.useState(s?.request.candidateId??null),[_,J]=c.useState(s?.request.analysisModel?.providerId??m.providerId),[se,B]=c.useState(s?.request.analysisModel?.modelId??m.modelId),[ae,ie]=c.useState(s?.request.analysisReasoningEffort??h),[z,ge]=c.useState(""),[A,fe]=c.useState([]),[K,U]=c.useState(0),[W,le]=c.useState(!1),[ue,oe]=c.useState(!1),[F,je]=c.useState(null),[de,P]=c.useState(!1),[Z,ee]=c.useState(0),[Te,Se]=c.useState(0),[R,O]=c.useState(0),Q=c.useRef(0),[V,Fe]=c.useState(()=>new Set([...i,...N])),[he,C]=c.useState({}),[w,te]=c.useState(s),[pe,me]=c.useState(!1),[xe,G]=c.useState(!1),[et,we]=c.useState(null),[tt,Ce]=c.useState(!1),[_e,y]=c.useState(null),[ne,Ee]=c.useState([]),[Ae,sn]=c.useState(()=>p.payload?.minerConfig??Na()),Kt=c.useRef(null),Wt=c.useRef(null),Jt=c.useMemo(()=>new Set(f.filter(g=>{const I=g.metadata.workflowSignature;return g.metadata.frontierBaseline===!0||I==="cross-system-operations"||typeof I=="string"&&I.startsWith("baseline:")||!!g.metadata.crossSystemOperations}).map(g=>g.sessionId)),[f]),Ie=c.useMemo(()=>j.filter(g=>!g.systemKind&&!g.hiddenFromDefaultSidebar&&g.status!=="active"&&!Jt.has(g.id)),[Jt,j]),Qt=c.useMemo(()=>new Map(j.map(g=>[g.id,g])),[j]),jt=c.useMemo(()=>new Map(f.map(g=>[g.sessionId,g])),[f]),st=c.useMemo(()=>Ie.slice(0,500).map(g=>({sessionId:g.id,title:g.title,updatedAt:g.updatedAt})),[Ie]),bt=c.useMemo(()=>[...V].flatMap(g=>{const I=A.find(Ne=>Ne.sessionId===g);if(I)return[I];const M=Qt.get(g);if(M)return[{sessionId:g,title:M.title,updatedAt:M.updatedAt,snippet:null}];const $=jt.get(g);return $?[{sessionId:g,title:$.title,updatedAt:$.occurredAt,snippet:null}]:[]}),[A,V,Qt,jt]),vt=c.useMemo(()=>[...new Set([...bt,...A].map(g=>g.sessionId))].filter(g=>!he[g]).join(`
|
|
2
|
-
`),[he,A,bt]),ze=c.useMemo(()=>p.payload?.minerRuns.find(g=>g.id===_e)??null,[_e,p.payload?.minerRuns]),nn=tt||!!(ze&&["queued","running","cancelling"].includes(ze.status)),Ve=xe||tt||!!p.busyAction,Ue=d==="workproduct"&&S.kind==="model",nt=c.useMemo(()=>{const g=p.payload?.destinations.find(I=>I.destinationId==="fireworks");return g?.modelAllowlist.length?g.modelAllowlist:[St]},[p.payload?.destinations]);c.useEffect(()=>q(s?.request.objective??n??""),[s?.id,n]),c.useEffect(()=>{nt.includes(x)||E(nt[0]??St)},[nt,x]),c.useEffect(()=>{if(b!=="automatic_scope"||_e)return;const g=p.payload?.minerRuns.find(I=>["queued","running","cancelling"].includes(I.status));g&&y(g.id)},[_e,b,p.payload?.minerRuns]),c.useEffect(()=>{if(!An(b,ze))return;const g=new Set(ze.candidateIds);Ee(p.payload?.candidates.filter(I=>g.has(I.id))??[]),v("automatic_candidates")},[ze,b,p.payload?.candidates]),c.useEffect(()=>(Wt.current=document.activeElement instanceof HTMLElement?document.activeElement:null,()=>Wt.current?.focus()),[]),c.useEffect(()=>{const g=window.requestAnimationFrame(()=>{Kt.current?.querySelector("[data-autofocus], [aria-label^='Back']")?.focus()});return()=>window.cancelAnimationFrame(g)},[b]),c.useEffect(()=>{b==="evidence"&&(fe([]),U(0),le(!1),je(null))},[z,b]),c.useEffect(()=>{if(b!=="evidence")return;const g=Q.current+1;Q.current=g,oe(!0),je(null);const I=window.setTimeout(()=>{p.actions.searchChats(z,st,0,ls).then(M=>{Q.current===g&&(fe(M.entries),U(M.total),le(M.hasMore),P(M.indexing),ee(M.indexedChats),Se(M.totalChats))}).catch(M=>{Q.current===g&&(fe([]),U(0),le(!1),P(!1),je(M instanceof Error?M.message:String(M)))}).finally(()=>{Q.current===g&&oe(!1)})},220);return()=>window.clearTimeout(I)},[st,z,R,b,p.actions]),c.useEffect(()=>{if(b!=="evidence"||!z.trim()||!de)return;const g=window.setTimeout(()=>O(I=>I+1),1500);return()=>window.clearTimeout(g)},[z,de,b]);const an=c.useCallback(async()=>{if(ue||!W)return;const g=Q.current,I=A.length;oe(!0);try{const M=await p.actions.searchChats(z,st,I,ls);if(Q.current!==g)return;fe($=>{const Ne=new Set($.map(yt=>yt.sessionId));return[...$,...M.entries.filter(yt=>!Ne.has(yt.sessionId))]}),U(M.total),le(M.hasMore),P(M.indexing),ee(M.indexedChats),Se(M.totalChats)}catch(M){Q.current===g&&je(M instanceof Error?M.message:String(M))}finally{Q.current===g&&oe(!1)}},[st,z,A.length,W,ue,p.actions]);c.useEffect(()=>{const g=Object.fromEntries(f.flatMap(I=>{const M=typeof I.metadata.messageCount=="number"?I.metadata.messageCount:null,$=typeof I.metadata.estimatedTokens=="number"?I.metadata.estimatedTokens:null;return M===null||$===null?[]:[[I.sessionId,{messageCount:M,estimatedTokens:$}]]}));Object.keys(g).length&&C(I=>({...g,...I}))},[f]),c.useEffect(()=>{if(b!=="evidence"||!vt)return;let g=!1;const I=window.setTimeout(()=>{p.actions.estimateSources(vt.split(`
|
|
3
|
-
`)).then(M=>{g||C($=>({...$,...Object.fromEntries(M.map(Ne=>[Ne.sessionId,{messageCount:Ne.messageCount,estimatedTokens:Ne.estimatedTokens}]))}))}).catch(()=>{})},200);return()=>{g=!0,window.clearTimeout(I)}},[b,p.actions,vt]),c.useEffect(()=>{if(b!=="automatic_scope"||!Ie.length)return;const g=Ie.map(M=>M.id).filter(M=>!he[M]);if(!g.length)return;let I=!1;return p.actions.estimateSources(g).then(M=>{I||C($=>({...$,...Object.fromEntries(M.map(Ne=>[Ne.sessionId,{messageCount:Ne.messageCount,estimatedTokens:Ne.estimatedTokens}]))}))}).catch(()=>{}),()=>{I=!0}},[Ie,he,b,p.actions]);const ln=c.useMemo(()=>ds([...V],he),[he,V]),rn=c.useMemo(()=>ds(Ie.map(g=>g.id),he),[Ie,he]);function on(g){g!==k&&k!==null&&me(!0),T(g)}function dn(){if(Ue){v("base_model");return}Yt()}function Yt(){if(k==="existing_dataset"){v("existing_dataset");return}L==="automated"&&v("automatic_scope"),L==="manual"&&v("evidence")}async function cn(){if(!(!re||!l)){G(!0),we(null);try{const g=await p.actions.createModelFromTaskset(re,x);if(!g)throw new Error(p.error??"OpenPond could not create the Model from this Dataset.");const I=p.payload?.tasksets.find(M=>M.id===re);if(!I)throw new Error("The selected Dataset could not be reloaded.");await l(I,g)}catch(g){we(g instanceof Error?g.message:String(g))}finally{G(!1)}}}function un(g){g!==X&&me(!0),q(g)}function hn(g){me(!0),J(g),B(I=>Tn(g,I,u))}function pn(g){me(!0),B(g)}function mn(g){me(!0),ie(g)}function gn(){me(!0),Fe(g=>{const I=new Set(g),M=A.length>0&&A.every($=>I.has($.sessionId));for(const $ of A)M?I.delete($.sessionId):I.add($.sessionId);return I})}function xn(g,I){me(!0),Fe(M=>{const $=new Set(M);return I?$.add(g):$.delete(g),$})}async function fn(){const g=[],I=[];for(const M of V){const $=jt.get(M);$?g.push($):I.push(M)}if(I.length){const M=await p.actions.addSources(I);if(!M)throw new Error("OpenPond could not attach the selected evidence. Review the training error and try again.");g.push(...M)}if(g.length!==V.size)throw new Error("Some selected evidence could not be resolved. Reselect the chats before continuing.");return g}async function jn(){Ce(!0);try{const g={...Ae,enabled:!0},I=await p.actions.runMiner([],Ie.map(M=>M.id),g);I&&y(I.id)}finally{Ce(!1)}}async function bn(){_e&&await p.actions.cancelMinerRun(_e)}function vn(g){const I=new Set(g.evidence.flatMap($=>$.sourceRefIds)),M=f.filter($=>I.has($.id)).map($=>$.sessionId);Fe(new Set(M)),H(g.id),q(g.title),me(!0),v("evidence")}async function yn(){G(!0),we(null);try{const g=await fn(),I=w?.request.sourceIds.length===0?w.request.createImproveRunId:null;if(w&&!I&&pe&&!["cancelled","failed","ready"].includes(w.state)){const $=w;await p.actions.cancelCreation($.id)}const M=await p.actions.startCreation(g.map($=>$.id),{surface:L==="automated"?"task_candidate":"training_page",mode:"defaults",entryMode:L??"manual",resourceIntent:d,objective:X.trim()||void 0,methodHint:null,preferredBaseModelId:Ue?x:null,candidateId:Y,analysisModel:{providerId:_,modelId:se},analysisReasoningEffort:ae,createImproveRunId:I,targetIntent:S});if(!M)throw new Error("OpenPond could not start Taskset authoring.");te(M),me(!1),M.state!=="awaiting_disclosure_approval"&&v("recommendation")}catch(g){we(g instanceof Error?g.message:String(g))}finally{G(!1)}}async function Nn(){if(!(!w||w.state!=="awaiting_disclosure_approval")){G(!0);try{const g=await p.actions.approveDisclosure(w.id,!0);if(!g)return;te(g),v("recommendation")}finally{G(!1)}}}async function kn(){if(!(!w||w.state!=="failed")){G(!0),we(null);try{const g=await p.actions.retryCreation(w.id);if(!g)throw new Error(p.error??"OpenPond could not retry Taskset authoring.");te(g),v("recommendation")}catch(g){we(g instanceof Error?g.message:String(g))}finally{G(!1)}}}async function Xt(){w?.state==="awaiting_disclosure_approval"&&await p.actions.approveDisclosure(w.id,!1),te(null),me(!0)}function Sn(){b==="base_model"?v("start"):b==="existing_dataset"?v("base_model"):b==="automatic_scope"?v(Ue?"base_model":"start"):b==="automatic_candidates"?v("automatic_scope"):b==="evidence"?(w?.state==="awaiting_disclosure_approval"&&Xt(),v(L==="automated"?"automatic_candidates":Ue?"base_model":"start")):b==="recommendation"&&v("evidence")}async function at(){const g=w;g&&!["cancelled","failed","ready"].includes(g.state)&&await p.actions.cancelCreation(g.id),a()}async function wn(){if(!(!w||w.state!=="awaiting_materialization_approval")){we(null);try{const g=await p.actions.materialize(w.id,!0);if(!g)throw new Error("OpenPond could not materialize the approved Taskset.");te(g),g.state==="ready"&&await r(g)}catch(g){we(g instanceof Error?g.message:String(g))}}}return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:()=>{at()},children:e.jsxs("section",{ref:Kt,className:`training-dialog training-run-dialog ${b==="start"?"training-run-start-step":"training-run-workflow-step"}`,role:"dialog","aria-modal":"true","aria-label":rs(S,d),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),at())},onMouseDown:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{className:"training-run-dialog-title",children:[b!=="start"?e.jsx("button",{"data-autofocus":!0,type:"button","aria-label":ya(b),onClick:Sn,children:e.jsx(Ps,{size:16})}):null,e.jsx("h2",{children:b==="recommendation"?va(S,d):rs(S,d)})]}),e.jsx("button",{type:"button","aria-label":"Close",onClick:()=>{at()},children:e.jsx(qe,{size:16})})]}),b==="start"?e.jsx(fa,{allowExistingDataset:Ue&&!!l,mode:k,targetLabel:os(S,d),onChange:on,onContinue:dn}):b==="base_model"?e.jsx(aa,{modelIds:nt,value:x,onChange:E,onContinue:Yt}):b==="existing_dataset"?e.jsx(la,{busy:Ve,selectedTasksetId:re,state:p.payload,onChange:D,onCreate:()=>{cn()}}):b==="automatic_scope"?e.jsx(ea,{chatPreview:Ie.slice(0,6).map(g=>({id:g.id,title:g.title,updatedAt:g.updatedAt})),chatCount:Ie.length,config:Ae,estimate:rn,onCancel:()=>{bn()},onConfigChange:sn,onScan:()=>{jn()},run:ze,scanning:nn}):b==="automatic_candidates"?e.jsx(Zn,{candidates:ne,onRescan:()=>{y(null),v("automatic_scope")},onSelect:vn}):b==="evidence"&&L?e.jsx(ga,{authoringModel:se,authoringProvider:_,authoringReasoningEffort:ae,busy:Ve,disclosurePending:w?.state==="awaiting_disclosure_approval",estimatesBySessionId:he,matchingSessionCount:K,mode:L,objective:X,onObjectiveChange:un,onAnalyze:()=>{yn()},onApproveDisclosure:()=>{Nn()},onAuthoringModelChange:pn,onAuthoringProviderChange:hn,onAuthoringReasoningEffortChange:mn,onDeclineDisclosure:()=>{Xt()},onSearchChange:ge,onLoadMore:()=>{an()},onReturnToRecommendation:()=>v("recommendation"),onToggleSession:xn,onToggleVisible:gn,providerSettings:u,recommendationAvailable:!!w?.proposal&&!pe,search:z,searchError:F,searchHasMore:W,searchIndexedChats:Z,searchIndexing:de,searchLoading:ue,searchTotalChats:Te,selectedEntries:bt,selectedEstimate:ln,selectedSessionIds:V,targetLabel:os(S,d),visibleSessions:A}):b==="recommendation"&&w?.proposal?e.jsx(ma,{busy:Ve,creation:w,onAddChats:()=>v("evidence"),onClose:()=>{at()},onCreateTaskset:()=>{wn()},onCreationChange:te,sources:f,training:p,createLabel:d==="dataset"?"Create Dataset":S.kind==="model"?"Create model":void 0,editDataLabel:d==="dataset"?"Edit sources":S.kind==="model"?"Edit Dataset":void 0,resourceIntent:d}):b==="recommendation"&&w?.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:w.blockingQuestions[0]?.prompt??w.blockedReason??"Add supporting evidence before authoring continues."})]})}),e.jsx("div",{className:"training-dialog-actions",children:e.jsx("button",{className:"training-button",type:"button",onClick:()=>v("evidence"),children:d==="dataset"?"Edit sources":S.kind==="model"?"Edit Dataset":"Add chats"})})]}):b==="recommendation"&&w?.state==="failed"?e.jsxs("div",{className:"training-evidence-required",children:[e.jsxs("div",{className:"training-dialog-scroll-body",children:[e.jsxs("div",{className:"training-run-step-heading",children:[e.jsx("h3",{children:"Analysis failed"}),e.jsx("p",{children:ba(w.blockedReason)})]}),X?e.jsxs("div",{className:"training-evidence-objective",children:[e.jsx("span",{children:"Capability"}),e.jsx("strong",{children:X})]}):null,e.jsx("p",{className:"training-empty",children:"Retry keeps the exact approved evidence, model, and disclosure receipt. Change evidence starts a new review if the selection is too large or no longer representative."})]}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:Ve,onClick:()=>v("evidence"),children:"Change evidence"}),e.jsxs("button",{className:"training-button",type:"button",disabled:Ve,onClick:()=>{kn()},children:[xe?e.jsx(ke,{className:"spin",size:14}):null,"Retry approved evidence"]})]})]}):e.jsx("div",{className:"training-recommendation-loading",children:w?.state==="failed"?e.jsxs(e.Fragment,{children:[e.jsx("h3",{children:"Analysis failed"}),e.jsx("p",{children:w.blockedReason})]}):e.jsxs(e.Fragment,{children:[e.jsx(ke,{className:"spin",size:18}),e.jsx("p",{children:"Preparing the recommendation…"})]})}),et?e.jsx("div",{className:"training-banner error",role:"alert",children:et}):null]})})}function ja(t){return t?t.state==="awaiting_disclosure_approval"?"evidence":"recommendation":"start"}function ba(t){return t?t.trim().toLowerCase()==="terminated"?"OpenPond Chat closed the Taskset authoring stream before a proposal was returned. No Taskset was created.":t:"The authoring model did not return a proposal."}function rs(t,s){return s==="dataset"?"New Dataset":t.kind==="agent"?t.operation==="improve"?`Improve ${t.displayName??"agent"}`:"New agent":t.kind==="model"?"New model":"New change"}function os(t,s){return s==="dataset"?"dataset":t.kind==="agent"?"agent":t.kind==="model"?"model":"workproduct"}function va(t,s){return s==="dataset"?"Review Dataset":t.kind==="model"?"Review model":t.kind==="agent"?t.operation==="improve"?"Review agent change":"Review agent":"Review change"}function ds(t,s){let n=0,i=0,a=0;for(const l of t){const r=s[l];r&&(a+=1,n+=r.messageCount,i+=r.estimatedTokens)}return{messageCount:n,estimatedTokens:i,measuredChats:a}}function ya(t){return t==="base_model"?"Back to setup":t==="existing_dataset"?"Back to base model":t==="automatic_scope"?"Back to start mode":t==="automatic_candidates"?"Back to scan scope":t==="evidence"?"Back to start mode":"Back to Dataset"}function Na(){return{schemaVersion:"openpond.taskMinerConfig.v1",enabled:!1,localOnly:!0,observationWindowDays:30,minimumRecurrence:3,clustering:"hybrid_deterministic_first",consentRequired:!0}}function qs({lineage:t,taskset:s,training:n,onChat:i,onClose:a}){const[l,r]=c.useState(!1),u=c.useMemo(()=>(n.payload?.servingSessions??[]).filter(S=>S.modelArtifactLineageId===t.id).sort((S,m)=>m.updatedAt.localeCompare(S.updatedAt)),[t.id,n.payload?.servingSessions])[0]??null,h=u&&["starting","ready","stopping"].includes(u.state)?u:null,d=!!n.busyAction;c.useEffect(()=>{!l||u?.state!=="ready"||(i(pt({modelId:t.id,taskset:s})),a())},[t.id,i,a,u?.state,l,s]);async function j(){r(!0),await n.actions.startModelServing(t.id)||r(!1)}async function f(S){r(!1),await n.actions.stopModelServing(S.id)}function p(){i(pt({modelId:t.id,taskset:s})),a()}return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:d?void 0:a,children:e.jsxs("section",{"aria-label":`Use ${s.name}`,"aria-modal":"true",className:"training-dialog training-model-use-dialog",role:"dialog",onMouseDown:S=>S.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Use model"}),e.jsx("p",{children:s.name})]}),e.jsx("button",{"aria-label":"Close model use",disabled:d,type:"button",onClick:a,children:e.jsx(qe,{size:16})})]}),e.jsxs("div",{className:"training-model-use-summary",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Compute"}),e.jsx("strong",{children:"1× H100"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Rate"}),e.jsx("strong",{children:"$7.00/hour"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Idle stop"}),e.jsx("strong",{children:"5 minutes"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Hard stop"}),e.jsx("strong",{children:"10 minutes · $1.17 max"})]})]}),t.promotable?null:e.jsx("p",{className:"training-model-use-warning",children:"This run did not pass its frozen Eval. Chat is available for inspection, but the model cannot be promoted."}),u?e.jsx(ka,{session:u}):e.jsx("p",{className:"training-model-use-note",children:"Start a temporary Fireworks deployment, attach this LoRA, then open a chat. OpenPond tears it down on idle, at the hard limit, or when you press Stop."}),n.error?e.jsx("div",{className:"training-banner error",children:n.error}):null,e.jsxs("div",{className:"training-dialog-actions",children:[h?e.jsx("button",{className:"training-button secondary",disabled:d||h.state==="stopping",type:"button",onClick:()=>{f(h)},children:h.state==="stopping"?"Stopping…":"Stop serving"}):e.jsx("button",{className:"training-button secondary",disabled:d,type:"button",onClick:a,children:"Cancel"}),u?.state==="ready"?e.jsxs("button",{className:"training-button",disabled:d,type:"button",onClick:p,children:[e.jsx($s,{size:14}),"Chat now"]}):h?.state==="starting"?e.jsxs("button",{className:"training-button",disabled:!0,type:"button",children:[e.jsx(ke,{className:"spin",size:14}),"Starting…"]}):e.jsxs("button",{className:"training-button",disabled:d,type:"button",onClick:()=>{j()},children:[d&&l?e.jsx(ke,{className:"spin",size:14}):null,"Start & chat"]})]})]})})}function ka({session:t}){const s=t.state==="starting"?"Starting Fireworks serving":t.state==="ready"?"Ready to chat":t.state==="stopping"?"Stopping Fireworks serving":t.state==="stopped"?"Serving stopped":"Serving failed",n=`$${t.estimatedCostUsd.toFixed(4)}`;return e.jsxs("div",{className:`training-model-serving-status ${t.state}`,children:[e.jsxs("div",{children:[e.jsx("strong",{children:s}),e.jsxs("span",{children:["Estimated serving cost ",n]})]}),t.state==="starting"||t.state==="stopping"?e.jsx("div",{className:"training-model-serving-progress","aria-label":s,children:e.jsx("span",{})}):null,t.stoppedAt?e.jsxs("small",{children:["Stopped ",new Date(t.stoppedAt).toLocaleString(),t.stopReason?` · ${Sa(t.stopReason)}`:""]}):null,t.error?e.jsx("small",{className:"error",children:t.error}):null]})}function Sa(t){return t==="idle"?"idle limit":t==="duration"?"10-minute limit":t==="budget"?"cost limit":t==="restart_cleanup"?"app restart cleanup":t==="startup_error"?"startup error":t==="shutdown"?"app shutdown":"stopped by user"}const wa=new Set(["planning","awaiting_questions","awaiting_plan_approval","paused","applying_source","running_checks","evaluating","awaiting_promotion","opening_pull_request","pull_request_open","reconciling_release","pushing_hosted","running_hosted_checks"]);function Ca(t){const{connection:s,profileId:n}=t,[i,a]=c.useState([]),[l,r]=c.useState(!1),[o,u]=c.useState(null),h=c.useRef(null),d=c.useCallback(()=>{if(!s)return Promise.resolve(null);if(h.current)return h.current;r(!0);const f=Xe.listCreateImproveRuns(s,{profileId:n,limit:500}).then(p=>(a(p.runs),u(null),p.runs)).catch(p=>(u(p instanceof Error?p.message:String(p)),null)).finally(()=>{h.current===f&&(h.current=null),r(!1)});return h.current=f,f},[s,n]);c.useEffect(()=>{if(!s){a([]),u(null);return}d()},[s,n,d]);const j=c.useMemo(()=>i.some(f=>wa.has(f.state)),[i]);return c.useEffect(()=>{if(!s)return;let f=!0,p=null;const S=async()=>{await d(),f&&(p=window.setTimeout(()=>{S()},j?1e3:15e3))};return p=window.setTimeout(()=>{S()},j?1e3:15e3),()=>{f=!1,p!==null&&window.clearTimeout(p)}},[s,j,d]),{runs:i,loading:l,error:o,refresh:d}}function ce({title:t,actions:s,children:n}){return e.jsxs("section",{className:"training-detail-section",children:[e.jsxs("div",{className:"training-detail-section-heading",children:[e.jsx("h2",{children:t}),s?e.jsx("div",{children:s}):null]}),e.jsx("div",{className:"training-detail-section-panel",children:n})]})}const Ia=64,Ma=4096;function wt(t,s=Ma){return Kn(t,{minimum:Ia,maximum:s})}const cs=["q_proj","k_proj","v_proj","o_proj","gate_proj","up_proj","down_proj"],ht="accounts/fireworks/models/qwen3-8b",Ke=3,it=9.99,Ct=32768;function Ra({connection:t,taskset:s,modelId:n=null,destinations:i,initialMethod:a,preferredBaseModelId:l=null,busy:r,onClose:o,onStart:u,onPrepare:h,onConfirmPrepared:d}){const j=s.readiness?.trainingPath??null,f=j?.primaryMethod??Ta(s),p=j?.bootstrap??null,S=_a(s),m=a&&S.includes(a)?a:f==="grpo"?"grpo":"sft",b=i.find(y=>y.destinationId==="fireworks"&&y.available&&y.methods.includes(m))?.destinationId??i.find(y=>y.destinationId==="local_cpu_fixture"&&y.available)?.destinationId??i.find(y=>y.available&&y.destinationId!=="export")?.destinationId??"local_cpu_fixture",[v,k]=c.useState(b),[T,L]=c.useState(null),X=i.find(y=>y.destinationId==="fireworks")?.modelAllowlist??[],q=l&&X.includes(l)?l:us(X),[x,E]=c.useState(b==="fireworks"?q:"openpond/tiny-cpu-gpt2-fixture"),[re,D]=c.useState("automatic"),[Y,H]=c.useState(()=>m==="grpo"?Math.min(10,Math.max(1,s.tasks.filter(y=>y.split==="train").length)):2),[_,J]=c.useState(()=>wt(s,b==="fireworks"?Ct:void 0)),[se,B]=c.useState(b==="fireworks"?8:2),[ae,ie]=c.useState(()=>We(x)),[z,ge]=c.useState(!1),[A,fe]=c.useState(Ke),[K,U]=c.useState(7),[W,le]=c.useState(8),[ue,oe]=c.useState(4),[F,je]=c.useState(m),[de,P]=c.useState(null),Z=i.find(y=>y.destinationId===v)??null,ee=F==="sft"&&f!=="sft"&&p?.method==="sft",Te=s.learningSignals.demonstrations.filter(y=>y.approved).length,Se=s.tasks.filter(y=>y.split==="frozen_eval").length,R=c.useMemo(()=>T?.inventory?.devices.filter(y=>y.available)??[],[T?.inventory?.devices]),O=c.useMemo(()=>T?.inventory?.models.filter(y=>y.trainingCompatible&&y.modelId&&y.revision&&y.tokenizerRevision&&y.chatTemplateHash)??[],[T?.inventory?.models]),Q=O.find(y=>y.modelId===x)??null,V=v==="fireworks",Fe=!V||z&&A>=Ke&&A<=it&&Number.isInteger(K)&&K>=1&&K<=30,he=F==="sft"||F==="grpo"&&V,C=s.capabilities.compatibleMethods.includes(F)||p?.method===F,w=!!(s.readiness?.ready&&he&&Z?.available&&Z.methods.includes(F)&&C&&Fe),te=s.readiness?.ready?he?Z?.methods.includes(F)?Z?.unavailableReason??(V&&!z?"Approve the bounded train-split export before launching Fireworks.":V&&(A<Ke||A>it)?`Set a Fireworks cap from $${Ke.toFixed(2)} through $${it.toFixed(2)}.`:V&&(!Number.isInteger(K)||K<1||K>30)?"Choose a provider retention record from 1 through 30 days.":null):`${It(v)} does not execute ${F.toUpperCase()}.`:`${F.toUpperCase()} is the primary recommendation but no compatible execution backend is available here.${p?" Choose the optional SFT trajectory bootstrap to run the local precursor.":""}`:"The Taskset must pass environment, grader, and data readiness before training.",pe=Aa({method:F,taskset:s,destinationId:v,baseModelId:x,maxSteps:Y,sequenceLength:_,rank:se,learningRate:ae,model:Q,rolloutGroupSize:W,rolloutConcurrency:ue}),me={exportApproved:V?z:!0,maximumCostUsd:V?A:0,retentionDays:V?K:null,region:null},xe=JSON.stringify({modelId:n,destinationId:v,recipe:pe,approval:me}),G=de?.configurationKey===xe?de.value:null;c.useEffect(()=>{if(!t)return;let y=!0;return Xe.computeState(t).then(ne=>{if(!y)return;L(ne),D(ne.settings.defaultDeviceIds[0]??"automatic");const Ee=ne.inventory?.models.find(Ae=>Ae.modelId==="HuggingFaceTB/SmolLM2-135M-Instruct"&&Ae.trainingCompatible);v!=="fireworks"&&Ee?.modelId&&(E(Ee.modelId),ie(We(Ee.modelId)))}).catch(()=>{}),()=>{y=!1}},[t,v]);async function et(){if(!w)return;if(V&&!G){const ne=await h(v,pe,me);ne&&P({configurationKey:xe,value:ne});return}(V&&G?await d(G,A):await u(v,pe,me))&&o()}function we(y){if(k(y),y==="fireworks"){const ne=i.find(Ae=>Ae.destinationId==="fireworks")?.modelAllowlist??[],Ee=l&&ne.includes(l)?l:us(ne);E(Ee),ie(We(Ee)),B(8),F==="grpo"&&H(Math.min(10,Math.max(1,s.tasks.filter(Ae=>Ae.split==="train").length))),J(Math.max(512,wt(s,Ct)));return}E("openpond/tiny-cpu-gpt2-fixture"),ie(We("openpond/tiny-cpu-gpt2-fixture")),B(2),J(wt(s))}function tt(y){if(je(y),P(null),y==="grpo"){H(Math.min(10,Math.max(1,s.tasks.filter(ne=>ne.split==="train").length)));return}H(2)}const Ce=G?.plan.estimatedCostUsd??null,_e=r?G?"Launching…":V?"Preparing…":"Starting…":G&&Ce!=null?`Launch $${Ce.toFixed(2)} job`:V?"Prepare exact quote":"Start training";return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:r?void 0:o,children:e.jsxs("section",{className:"training-dialog training-start-dialog",role:"dialog","aria-modal":"true","aria-label":"Start training",onMouseDown:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Start training"}),e.jsx("p",{children:s.name})]}),e.jsx("button",{type:"button","aria-label":"Close start training",disabled:r,onClick:o,children:e.jsx(qe,{size:16})})]}),e.jsx("div",{className:"training-method-tabs",role:"tablist","aria-label":"Training method",children:S.map(y=>e.jsxs("button",{"aria-selected":y===F,className:y===F?"active":"",disabled:r,role:"tab",type:"button",onClick:()=>tt(y),children:[e.jsx("span",{children:zn(y)}),e.jsx("strong",{children:De(y)})]},y))}),e.jsxs("div",{className:"training-start-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Base model"}),e.jsx("select",{value:x,disabled:r,onChange:y=>{const ne=y.target.value;E(ne),ie(We(ne))},children:V?(Z?.modelAllowlist.length?Z.modelAllowlist:[ht]).map(y=>e.jsx("option",{value:y,children:hs(y)},y)):e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"openpond/tiny-cpu-gpt2-fixture",children:"Tiny CPU correctness fixture"}),O.map(y=>e.jsxs("option",{value:y.modelId??y.id,children:[y.name," · ",ps(y.sizeBytes)]},y.id))]})})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Compute"}),e.jsx("select",{value:v,disabled:r,onChange:y=>we(y.target.value),children:i.filter(y=>!["custom","runpod_byoc","export"].includes(y.destinationId)).map(y=>e.jsxs("option",{value:y.destinationId,disabled:!y.available,children:[It(y.destinationId),y.available?"":` — ${y.unavailableReason??"Unavailable"}`]},y.destinationId))})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Device"}),e.jsxs("select",{value:re,disabled:r||v!=="local_cpu_fixture",onChange:y=>D(y.target.value),children:[e.jsx("option",{value:"automatic",children:"Automatic"}),R.map(y=>e.jsx("option",{value:y.id,children:y.name},y.id))]})]})]}),V?e.jsxs("fieldset",{className:"training-provider-approval",children:[e.jsx("legend",{children:"Provider approval"}),e.jsxs("label",{className:"training-provider-consent",children:[e.jsx("input",{type:"checkbox",checked:z,disabled:r,onChange:y=>ge(y.target.checked)}),e.jsx("span",{children:"Export only the approved train split to Fireworks. Frozen Eval cases and grader secrets stay in OpenPond."})]}),e.jsxs("div",{className:"training-start-fields",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Maximum provider spend (USD)"}),e.jsx("input",{"aria-label":"Maximum provider spend (USD)",type:"number",min:Ke,max:it,step:.01,value:A,disabled:r,onChange:y=>fe(y.target.valueAsNumber)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Retention record (days)"}),e.jsx("input",{"aria-label":"Retention record (days)",type:"number",min:1,max:30,step:1,value:K,disabled:r,onChange:y=>U(y.target.valueAsNumber)})]})]}),e.jsx("p",{className:"training-start-note",children:"Approval is bound server-side to the signed-in OpenPond account at launch."}),F==="grpo"?e.jsxs("p",{className:"training-start-note",children:["RFT requires a public HTTPS callback ending in ",e.jsx("code",{children:"/v1/training/fireworks/rft"}),". Launch fails closed before provider upload when it is missing or invalid."]}):null]}):null,e.jsxs("dl",{className:"training-start-summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Training data"}),e.jsx("dd",{children:F==="grpo"?`${s.tasks.filter(y=>y.split==="train").length} approved train prompts`:`${Te} approved example${Te===1?"":"s"}`})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Evaluation"}),e.jsxs("dd",{children:[Se," test example",Se===1?"":"s"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:Ce==null?"Estimate":"Exact quote"}),e.jsx("dd",{children:v==="local_cpu_fixture"?Q?`$0 · ${Y} steps × ${_} tokens · 15-minute hard stop`:"$0 · 2-minute hard stop":V?Ce==null?`Prepare a provider-validated quote · hard cap $${Number.isFinite(A)?A.toFixed(2):"—"}`:`$${Ce.toFixed(2)} · hard cap $${A.toFixed(2)}`:"Provided before approval"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{children:V?"Portable output imported into app-managed storage":T?.settings.modelStorePath??"App-managed local storage"})]})]}),G?e.jsxs("section",{className:"training-prepared-confirmation","aria-label":"Confirm paid training launch",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Ready to launch"}),e.jsx("span",{children:"The quote and prepared data are fixed to this confirmation."})]}),e.jsxs("dl",{className:"training-start-summary",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{children:G.approvalActor??"Local user"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Provider"}),e.jsx("dd",{children:It(G.plan.destinationId)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{children:hs(G.plan.recipe.method==="sft"||G.plan.recipe.method==="grpo"?G.plan.recipe.baseModel.id:"")})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Method"}),e.jsxs("dd",{children:[De(G.plan.recipe.method)," · ",G.plan.recipe.parameterization.toUpperCase()]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Quote"}),e.jsx("dd",{children:Ce==null?"Unavailable":`$${Ce.toFixed(2)}`})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Maximum"}),e.jsxs("dd",{children:["$",A.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Retention"}),e.jsxs("dd",{children:[G.plan.dataPolicy.retentionDays," days"]})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Prepared data"}),e.jsxs("dd",{children:[ps(G.bundle.totalSizeBytes)," · verified"]})]})]}),e.jsx("p",{children:"No Fireworks dataset or job exists until you launch."})]}):null,ee&&p?e.jsxs("div",{className:"training-bootstrap-limitations",children:[e.jsx("strong",{children:"Supervised precursor"}),e.jsx("p",{children:"This SFT run teaches the approved tool trajectories. It does not replace reinforcement training."}),e.jsx("ul",{children:p.limitations.map(y=>e.jsx("li",{children:y},y))})]}):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:F==="grpo"?"Prompts per update":"Steps"}),e.jsx("input",{type:"number",min:1,max:1e3,value:Y,onChange:y=>H(y.target.valueAsNumber||1)})]}),e.jsxs("label",{children:[e.jsx("span",{children:F==="grpo"?"Prompt length":"Sequence length"}),e.jsx("input",{type:"number",min:16,max:V?Ct:4096,value:_,onChange:y=>J(y.target.valueAsNumber||64)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"LoRA rank"}),e.jsx("input",{type:"number",min:1,max:256,value:se,onChange:y=>B(y.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:ae,onChange:y=>{const ne=y.target.valueAsNumber;Number.isFinite(ne)&&ie(ne)}})]}),F==="grpo"?e.jsxs(e.Fragment,{children:[e.jsxs("label",{children:[e.jsx("span",{children:"Rollouts per prompt"}),e.jsx("input",{type:"number",min:2,max:16,value:W,onChange:y=>le(y.target.valueAsNumber||8)})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Concurrent rollouts"}),e.jsx("input",{type:"number",min:1,max:16,value:ue,onChange:y=>oe(y.target.valueAsNumber||4)})]})]}):null]})]}),w?Z?.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:te??"This setup is unavailable."}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:r,onClick:o,children:"Cancel"}),e.jsx("button",{className:"training-button",type:"button",disabled:r||!w,onClick:()=>{et()},children:_e})]})]})})}function Aa(t){return t.method==="grpo"&&t.destinationId==="fireworks"?{schemaVersion:"openpond.rftRecipe.v1",method:"grpo",parameterization:"lora",baseModel:{id:t.baseModelId,revision:"fireworks-managed-model-resource-v1",tokenizerRevision:"fireworks-provider-managed",chatTemplateHash:"fireworks-qwen3-chat-v1"},dataset:{trainSplit:"train",validationSplit:"frozen_eval",maxPromptTokens:t.sequenceLength},lora:{rank:t.rank},rollout:{groupSize:t.rolloutGroupSize,concurrency:t.rolloutConcurrency,maxTurns:15,maxOutputTokens:Math.min(2048,t.sequenceLength),temperature:.8,topP:.95,seed:17},optimizer:{learningRate:t.learningRate,maxSteps:t.maxSteps},reward:{graderId:"cross-system-exact-verifier",graderHash:"server-derived-grader-hash",environmentId:"cross-system-operations",environmentVersion:En,toolContractHash:_n},resourceLimits:{wallTimeMs:18e4,maxRollouts:Math.max(t.rolloutGroupSize,t.taskset.tasks.filter(s=>s.split==="train").length*t.rolloutGroupSize),maxPayloadBytes:1e6}}:t.destinationId==="fireworks"?{schemaVersion:"openpond.sftRecipe.v1",method:"sft",parameterization:"lora",baseModel:{id:t.baseModelId,revision:"fireworks-managed-model-resource-v1",tokenizerRevision:"fireworks-provider-managed",chatTemplateHash:"fireworks-qwen3-chat-v1"},dataset:{trainSplit:"train",validationSplit:"frozen_eval",completionOnly:!0,maxSequenceLength:t.sequenceLength},lora:{rank:t.rank,alpha:t.rank*2,dropout:.05,targetModules:cs},optimizer:{learningRate:t.learningRate,epochs:1,maxSteps:t.maxSteps,batchSize:1,gradientAccumulationSteps:1,seed:17},resourceLimits:{cpuThreads:1,memoryBytes:1e9,wallTimeMs:36e5}}:!t.model?.modelId||!t.model.revision||!t.model.tokenizerRevision||!t.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:t.sequenceLength},lora:{rank:t.rank,alpha:t.rank*2,dropout:0,targetModules:["c_attn"]},optimizer:{learningRate:t.learningRate,epochs:1,maxSteps:t.maxSteps,batchSize:1,gradientAccumulationSteps:1,seed:17},resourceLimits:{cpuThreads:4,memoryBytes:2e9,wallTimeMs:12e4}}:{schemaVersion:"openpond.sftRecipe.v1",method:"sft",parameterization:"lora",baseModel:{id:t.model.modelId,revision:t.model.revision,tokenizerRevision:t.model.tokenizerRevision,chatTemplateHash:t.model.chatTemplateHash},dataset:{trainSplit:"train",validationSplit:"frozen_eval",completionOnly:!0,maxSequenceLength:t.sequenceLength},lora:{rank:t.rank,alpha:t.rank*2,dropout:.05,targetModules:cs},optimizer:{learningRate:t.learningRate,epochs:1,maxSteps:t.maxSteps,batchSize:1,gradientAccumulationSteps:1,seed:17},resourceLimits:{cpuThreads:4,memoryBytes:8e9,wallTimeMs:9e5}}}function We(t){return t==="openpond/tiny-cpu-gpt2-fixture"?.01:2e-4}function Ta(t){const s=t.metadata.trainingMethod;return typeof s=="string"&&s!=="none"?s:t.readiness?.recommendedMethod&&t.readiness.recommendedMethod!=="none"?t.readiness.recommendedMethod:"sft"}function _a(t){const s=new Set;for(const i of t.capabilities.compatibleMethods)(i==="sft"||i==="grpo")&&s.add(i);t.readiness?.trainingPath?.bootstrap?.method==="sft"&&s.add("sft"),t.readiness?.trainingPath?.primaryMethod==="grpo"&&s.add("grpo");const n=[];return s.has("sft")&&n.push("sft"),s.has("grpo")&&n.push("grpo"),n.length?n:["sft"]}function It(t){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"}[t]??t.replaceAll("_"," ")}function us(t){return t.includes(ht)?ht:t[0]??ht}function hs(t){return t==="accounts/fireworks/models/qwen3-8b"?"Qwen3 8B · Fireworks managed LoRA":t==="accounts/fireworks/models/qwen3-0p6b"?"Qwen3 0.6B · Fireworks managed LoRA":t.split("/").at(-1)??t}function ps(t){return t==null?"size unknown":t<1024?`${t} B`:t<1024**2?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(0)} MB`}const Ea=new Set(["released","rejected","ready","ready_local","published_hosted","cancelled"]);function Vs(t){const s=new Map,n=Pa(t.runs,t.training),i=new Date(0).toISOString();for(const a of t.profile?.agents??[]){const l=Pe("agent",a.id);s.set(l,{key:l,kind:"agent",id:a.id,name:a.name||a.id,description:a.enabled?"Enabled Profile Agent":"Disabled Profile Agent",status:a.enabled?"Ready":"Disabled",updatedAt:t.profile?.lastCheck?.checkedAt??i,path:a.path,enabled:a.enabled,runIds:[],conversationId:null,tasksetId:null,frontierBaselineRunId:null,trainingRunCount:0,evaluationStatus:"not_run",useActionId:`${a.id}.chat`})}for(const a of t.profile?.skills??[]){const l=Pe("skill",a.name);s.set(l,{key:l,kind:"skill",id:a.name,name:a.name,description:a.description,status:a.validationStatus==="valid"?"Ready":a.validationStatus,updatedAt:i,path:a.path,enabled:a.enabled,runIds:[],conversationId:null,tasksetId:null,frontierBaselineRunId:null,trainingRunCount:0,evaluationStatus:"not_run",useActionId:null})}for(const a of On(t.training)){if(a.taskset.metadata.resourceIntent==="dataset"&&!a.latestPlan&&!a.localModel)continue;const l=t.runs.filter(h=>h.target.kind==="model"&&h.tasksetRef?.id===a.taskset.id).sort((h,d)=>d.updatedAt.localeCompare(h.updatedAt))[0]??null,r=l?.target.kind==="model"?n.get(l.id)??l.target.id??l.id:a.latestPlan?.modelId??a.taskset.id,o=Pe("model",r),u=s.get(o);s.set(o,{key:o,kind:"model",id:r,name:Pt(l?.target.displayName??a.name,"New model"),description:a.taskset.objective,status:a.status,updatedAt:a.updatedAt,path:`tasksets/${a.taskset.id}`,enabled:a.localModel?a.localModel.status==="imported"&&a.localModel.promotable:null,runIds:l?[...new Set([...u?.runIds??[],l.id])]:u?.runIds??[],conversationId:null,tasksetId:a.taskset.id,frontierBaselineRunId:null,trainingRunCount:Math.max(u?.trainingRunCount??0,a.runCount),evaluationStatus:a.latestJob?.metadata.frozenEvaluationComplete===!0?a.latestJob.metadata.frozenEvaluationThresholdPassed===!0?"passed":"failed":"not_run",useActionId:null})}for(const a of t.runs){if(a.target.kind==="configuration"||a.target.kind==="unselected"||a.target.kind==="model"&&!a.tasksetRef&&["cancelled","failed","rejected"].includes(a.state))continue;const l=a.target.kind,r=a.target.kind==="model"?n.get(a.id)??a.target.id??a.id:a.target.id??a.id,o=Pe(l,r),u=s.get(o),h=a.target.displayName??u?.name??La(a),d=l==="model"?Pt(h,"New model"):h;s.set(o,{key:o,kind:l,id:r,name:d,description:u?.description??a.objective,status:Ba(a),updatedAt:gs(u?.updatedAt,a.updatedAt),path:u?.path??a.plan?.sourcePlan[0]?.path??null,enabled:u?.enabled??null,runIds:[...new Set([...u?.runIds??[],a.id])],conversationId:a.scope.conversationId??u?.conversationId??null,tasksetId:a.target.kind==="model"?a.tasksetRef?.id??u?.tasksetId??null:null,frontierBaselineRunId:u?.frontierBaselineRunId??null,trainingRunCount:u?.trainingRunCount??0,evaluationStatus:za(a)??u?.evaluationStatus??"not_run",useActionId:u?.useActionId??null})}for(const a of t.training?.frontierBaselineRuns??[]){const l=Da(a,t.runs);if(!l)continue;const r=[...s.values()].find(h=>h.runIds.includes(l));if(!r)continue;const o=r.tasksetId?t.training?.tasksets.find(h=>h.id===r.tasksetId)??null:null;if(o&&!$a(a,o))continue;const u=r.frontierBaselineRunId?t.training?.frontierBaselineRuns.find(h=>h.id===r.frontierBaselineRunId)??null:null;u&&u.updatedAt>=a.updatedAt||s.set(r.key,{...r,updatedAt:gs(r.updatedAt,a.updatedAt),frontierBaselineRunId:a.id})}return[...s.values()].sort((a,l)=>{const r=Number(ms(a,t.runs))-Number(ms(l,t.runs));return r!==0?-r:l.updatedAt.localeCompare(a.updatedAt)||a.name.localeCompare(l.name)})}function Pa(t,s){const n=new Map,i=s?.plans??[],a=s?.jobs??[],l=s?.models??[],r=new Map(i.map(h=>[h.id,h])),o=new Map(a.map(h=>[h.id,h])),u=new Map;for(const h of t){if(h.target.kind!=="model"||!h.tasksetRef)continue;const d=u.get(h.tasksetRef.id)??[];d.push(h),u.set(h.tasksetRef.id,d)}for(const[h,d]of u){const j=new Set;for(const m of i)m.tasksetId===h&&m.modelId&&j.add(m.modelId);for(const m of l)m.tasksetId===h&&m.modelId&&j.add(m.modelId);if(j.size>1)continue;const f=d.filter(m=>m.target.kind!=="model"?!1:m.target.trainingPlanId||m.target.trainingJobId||m.target.artifactId?!0:i.some(N=>N.tasksetId===h&&N.modelId===(m.target.id??m.id)));if(!f.length)continue;const S=[...j][0]??null??[...f].sort((m,N)=>N.updatedAt.localeCompare(m.updatedAt))[0].target.id??f[0].id;for(const m of f){if(m.target.kind!=="model")continue;const N=(m.target.trainingPlanId?r.get(m.target.trainingPlanId):null)??(m.target.trainingJobId?r.get(o.get(m.target.trainingJobId)?.planId??""):null);N?.modelId&&N.modelId!==S||n.set(m.id,S)}}return n}function $a(t,s){if(["queued","running","cancelling"].includes(t.status))return!0;const n=new Set(s.sourceRefs.map(i=>i.id));return t.sourceIds.length===n.size&&t.sourceIds.every(i=>n.has(i))}function Da(t,s){if(t.createImproveRunId&&s.some(i=>i.id===t.createImproveRunId&&i.target.kind==="model"))return t.createImproveRunId;if(t.sourceIds.length===0)return null;const n=new Set(t.sourceIds);return s.find(i=>i.target.kind==="model"&&[...n].every(a=>i.sourceRefs.includes(a)))?.id??null}function Pe(t,s){return`${t}:${s}`}function Fa(t){return t==="agent"?"Agents":t==="skill"?"Skills":t==="extension"?"Extensions":"Models"}function Us(t,s){const n=new Set(t.runIds);return s.filter(i=>n.has(i.id)).sort((i,a)=>a.updatedAt.localeCompare(i.updatedAt))}function ms(t,s){const n=new Set(t.runIds);return s.some(i=>n.has(i.id)&&!Ea.has(i.state))}function La(t){return`${t.operation==="improve"?"Improve":"Create"} ${t.target.kind}`}function Ba(t){return t.state.replaceAll("_"," ")}function za(t){const s=t.evaluationReceipts.filter(n=>n.subject==="candidate"||n.subject==="post_release");return s.length?s.some(n=>n.status==="failed"||n.status==="blocked"||n.publishGate==="failed")?"failed":s.every(n=>n.status==="passed"&&n.publishGate!=="failed")?"passed":null:null}function gs(t,s){return t&&t.localeCompare(s)>=0?t:s}function Oa({agentId:t,evals:s,onAttach:n,onCreate:i}){const a=c.useMemo(()=>s.filter(o=>o.agentId===null||o.agentId===t),[t,s]),[l,r]=c.useState(a[0]?.id??"");return c.useEffect(()=>{a.some(o=>o.id===l)||r(a[0]?.id??"")},[a,l]),e.jsxs("div",{className:"labs-eval-actions",children:[e.jsxs("button",{className:"training-button secondary",type:"button",onClick:i,children:[e.jsx(Ds,{size:13}),"Create Eval"]}),a.length?e.jsxs(e.Fragment,{children:[e.jsx($t,{compact:!0,searchable:!0,label:"Existing Eval",options:a.map(o=>({value:o.id,label:o.name,shortLabel:o.name,description:o.path})),value:l,onChange:r}),e.jsx("button",{className:"training-button secondary",disabled:!l,type:"button",onClick:()=>n(l),children:"Attach"})]}):null]})}function be({label:t,value:s=t}){return e.jsx("span",{className:`labs-status-badge ${Gs(s)}`,children:t})}function Gs(t){const s=t.trim().toLowerCase().replaceAll("_"," ");return s.includes("ready")||s.includes("passed")||s.includes("succeeded")||s.includes("published")||s.includes("released")||s.includes("merged")||s.includes("imported")?"positive":s.includes("planning")||s.includes("applying")||s.includes("running")||s.includes("evaluating")||s.includes("pushing")?"info":s.includes("awaiting")||s.includes("paused")||s.includes("pr open")||s.includes("blocked")||s.includes("review")||s.includes("dirty")||s.includes("pending")?"warning":s.includes("failed")||s.includes("rejected")||s.includes("closed")||s.includes("error")||s.includes("disabled")?"negative":"neutral"}function Ft({decorative:t=!1,label:s,size:n="default",tone:i,value:a=s}){return e.jsx("span",{"aria-hidden":t||void 0,"aria-label":t?void 0:s,className:`labs-status-dot ${i??Gs(a)} ${n}`,role:t?void 0:"status",title:s})}function qa({candidate:t,diff:s,error:n,run:i,onApplyCandidate:a,onOpenFiles:l,onRejectCandidate:r}){const[o,u]=c.useState(null),d=c.useMemo(()=>i.evaluationReceipts.filter(N=>N.candidateId===t.id),[t.id,i.evaluationReceipts]).filter(N=>N.subject==="candidate"),f=d.length>0&&d.every(N=>N.status==="passed"&&N.publishGate!=="failed")&&(i.state==="awaiting_promotion"||i.state==="blocked"&&!!i.localProfileCommit),p=i.state==="reconciling_release",S=s?.filesChanged??t.git?.changedPaths.length??0;async function m(N,b){if(!o){u(N);try{await b()}finally{u(null)}}}return e.jsxs("div",{className:"labs-change-page",children:[e.jsxs("dl",{className:"labs-change-facts",children:[e.jsx(Mt,{label:"Base",value:xs(t.git?.baseCommit)}),e.jsx(Mt,{label:"Change",value:xs(t.git?.headCommit)}),e.jsx(Mt,{label:"Branch",value:t.git?.branch??"—"})]}),i.blockedReason?e.jsx("div",{className:"labs-change-message negative",children:i.blockedReason}):null,e.jsxs("div",{className:"labs-change-timeline",children:[e.jsx("article",{className:"labs-change-timeline-item",children:e.jsxs("div",{className:"labs-change-card",children:[e.jsx("header",{className:"labs-change-card-header",children:e.jsx("span",{className:"labs-change-timeline-label",children:"Request"})}),e.jsxs("div",{className:"labs-change-card-body",children:[e.jsx("h3",{children:i.objective}),e.jsx("p",{children:"This is the behavior the candidate is trying to improve."})]})]})}),e.jsx("article",{className:"labs-change-timeline-item",children:e.jsxs("div",{className:"labs-change-card",children:[e.jsxs("header",{className:"labs-change-card-header",children:[e.jsx("span",{className:"labs-change-timeline-label",children:"Changes"}),e.jsx("span",{children:Lt(S)})]}),e.jsxs("div",{className:"labs-change-card-body",children:[e.jsx("h3",{children:"Drafted candidate"}),e.jsx("p",{children:Va(t,s,n)})]}),e.jsx("footer",{className:"labs-change-card-footer end",children:e.jsx("button",{className:"training-button secondary",disabled:!!n,title:n??void 0,type:"button",onClick:l,children:n?"Files unavailable":`Files${S?` (${S})`:""}`})})]})}),e.jsx("article",{className:"labs-change-timeline-item",children:e.jsxs("div",{className:"labs-change-card",children:[e.jsxs("header",{className:"labs-change-card-header",children:[e.jsx("span",{className:"labs-change-timeline-label",children:"Evals"}),e.jsx("span",{children:Ua(d)})]}),e.jsx("div",{className:"labs-change-evals",children:d.length?d.map(N=>e.jsxs("div",{className:"labs-change-eval",children:[e.jsxs("div",{children:[e.jsx("strong",{children:N.summary??"Candidate Evals"}),e.jsxs("span",{children:[N.summaryCounts?`${N.summaryCounts.passed}/${N.summaryCounts.total} passed`:N.status," · ","publish gate ",N.publishGate.replaceAll("_"," ")]})]}),e.jsx(be,{label:N.status,value:N.status})]},N.id)):e.jsx("div",{className:"labs-change-empty",children:"Candidate Evals have not finished yet."})})]})}),e.jsx("article",{className:"labs-change-timeline-item",children:e.jsxs("div",{className:"labs-change-card",children:[e.jsx("header",{className:"labs-change-card-header",children:e.jsx("span",{className:"labs-change-timeline-label",children:"Merge"})}),e.jsxs("div",{className:"labs-change-card-body",children:[e.jsx("h3",{children:"Apply this change to the Profile"}),e.jsx("p",{children:"Merging creates a local Git commit and then runs the active Agent Evals again."})]}),e.jsxs("footer",{className:"labs-change-card-footer",children:[e.jsxs("span",{className:"labs-change-footer-status",children:[e.jsx(Ft,{label:fs(i),value:i.state}),fs(i)]}),e.jsxs("div",{className:"labs-change-actions",children:[e.jsx("button",{className:"training-button secondary",disabled:!!o||p||i.state!=="awaiting_promotion",type:"button",onClick:()=>{m("reject",()=>r(i,t.id))},children:o==="reject"?"Rejecting":"Reject"}),e.jsx("button",{className:"training-button",disabled:!f||!!o||p,type:"button",onClick:()=>{m("apply",()=>a(i,t.id))},children:p||o==="apply"?"Merging":i.state==="blocked"?"Re-run Evals":"Merge change"})]})]})]})})]})]})}function Mt({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{title:s,children:s})]})}function xs(t){return t?t.slice(0,12):"—"}function Lt(t){return`${t} ${t===1?"file":"files"}`}function Va(t,s,n){if(n)return n;const i=s?.filesChanged??t.git?.changedPaths.length??0;return i?s?`${Lt(i)} drafted · +${s.additions} −${s.deletions}`:`${Lt(i)} drafted in the candidate branch. Open Files to review the diff.`:"The candidate branch is ready, but no file summary is available yet."}function Ua(t){if(!t.length)return"Waiting for candidate Evals";const s=t.reduce((i,a)=>({passed:i.passed+(a.summaryCounts?.passed??0),tests:i.tests+(a.summaryCounts?.total??0)}),{passed:0,tests:0});return s.tests>0?`${s.passed}/${s.tests} Evals passed`:`${t.filter(i=>i.status==="passed").length}/${t.length} Eval receipts passed`}function fs(t){return t.state==="awaiting_promotion"?"Ready to merge":t.state==="reconciling_release"?"Merging":t.state==="released"?"Merged":t.state==="rejected"?"Rejected":t.state==="blocked"?t.localProfileCommit?"Needs verification":"Blocked":t.state.replaceAll("_"," ")}function Ga({runs:t,onReview:s}){return t.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table labs-agent-change-history",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Change"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Evals"}),e.jsx("th",{children:"Updated"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("button",{type:"button",onClick:()=>s(n),children:[e.jsx("strong",{children:n.objective}),e.jsx("span",{children:Ka(n)})]})}),e.jsx("td",{children:e.jsx(be,{label:n.state.replaceAll("_"," "),value:n.state})}),e.jsx("td",{children:Ha(n)}),e.jsx("td",{children:xt(n.updatedAt)})]},n.id))})]})}):e.jsx("div",{className:"training-run-placeholder",children:"No changes yet."})}function Ha(t){const s=[...t.candidates].reverse().find(a=>a.target.kind===t.target.kind);if(!s)return"—";const n=t.evaluationReceipts.filter(a=>a.candidateId===s.id&&a.subject==="candidate"),i=n.reduce((a,l)=>({passed:a.passed+(l.summaryCounts?.passed??0),tests:a.tests+(l.summaryCounts?.total??0)}),{passed:0,tests:0});return i.tests>0?`${i.passed}/${i.tests} passed`:n[0]?.status??"Not run"}function Ka(t){return`${`${t.target.kind[0].toUpperCase()}${t.target.kind.slice(1)}`} ${t.operation==="improve"?"improvement":"creation"}`}function Wa({receipts:t}){const[s,n]=c.useState(!1);if(!t.length)return e.jsx("div",{className:"training-run-placeholder",children:"No on-policy rollout receipts were recorded for this run."});const i=[...t].sort((l,r)=>r.updatedAt.localeCompare(l.updatedAt)),a=s?i:i.slice(0,24);return e.jsxs("div",{className:"training-rollout-receipts",children:[t.length>24?e.jsxs("div",{className:"training-rollout-receipt-controls",children:[e.jsx("span",{children:s?`Showing all ${t.length} receipts`:`Showing latest ${a.length} of ${t.length} receipts`}),e.jsx("button",{className:"training-text-button",type:"button",onClick:()=>n(l=>!l),children:s?"Show latest 24":`Show all ${t.length}`})]}):null,a.map(l=>e.jsxs("details",{children:[e.jsxs("summary",{children:[e.jsx("span",{children:Ja(l.providerTrace.rolloutId)}),e.jsx("strong",{children:l.status}),e.jsx("em",{children:l.reward.eligible&&l.reward.raw!=null?l.reward.raw.toFixed(3):l.failureClass??"not reward eligible"})]}),e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(Me,{label:"Correlation",value:l.correlationId}),e.jsx(Me,{label:"Task",value:l.taskId}),e.jsx(Me,{label:"Policy",value:l.policy.modelId}),e.jsx(Me,{label:"Checkpoint",value:l.policy.checkpointId??"Provider initial policy"}),e.jsx(Me,{label:"Environment",value:`${l.environment.id}@${l.environment.version}`}),e.jsx(Me,{label:"World",value:`${l.environment.worldId} · ${l.environment.worldHash}`}),e.jsx(Me,{label:"Raw reward",value:l.reward.raw==null?"Not eligible":String(l.reward.raw)}),e.jsx(Me,{label:"Components",value:JSON.stringify(l.reward.components)}),e.jsx(Me,{label:"Outcome",value:l.verifier?.outcome??l.failureClass??"Pending"}),e.jsx(Me,{label:"Trace",value:`${l.providerTrace.experimentId}/${l.providerTrace.rolloutId}`})]})]},l.id))]})}function Me({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Ja(t){return t.replace(/^lineage_/,"").slice(0,18)}function Qa({detail:t,loading:s}){if(s&&!t)return e.jsx("div",{className:"training-run-placeholder",children:"Loading evaluation results…"});const n=t?.evaluation;return n?e.jsxs("div",{className:"training-run-evaluation",children:[e.jsxs("div",{className:"training-metric-summary",children:[e.jsx(lt,{label:"Base score",value:js(n.base.meanScore)}),e.jsx(lt,{label:"Trained score",value:js(n.trained.meanScore)}),e.jsx(lt,{label:"Score change",value:Za(n.meanScoreDelta)}),e.jsx(lt,{label:"Trained pass rate",value:Xa(n.trained.passRate)})]}),n.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,n.trained.count>0&&n.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:n.examples.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("details",{children:[e.jsx("summary",{children:i.taskId}),e.jsx(Ya,{input:i.input,baseOutput:i.baseOutput,trainedOutput:i.trainedOutput,baseGrade:i.baseGrade,trainedGrade:i.trainedGrade})]})}),e.jsx("td",{children:bs(i.baseGrade)}),e.jsx("td",{children:bs(i.trainedGrade)}),e.jsx("td",{children:ei(i.baseGrade,i.trainedGrade)})]},i.taskId))})]})})]}):e.jsx("div",{className:"training-run-placeholder",children:"No scored evaluation results are available for this run."})}function Ya({input:t,baseOutput:s,trainedOutput:n,baseGrade:i,trainedGrade:a}){const l=[...new Set([...i?.feedback??[],...a?.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(t,null,2)})]}),s?e.jsxs("div",{children:[e.jsx("span",{children:"Base output"}),e.jsx("pre",{children:JSON.stringify(s,null,2)})]}):null,n?e.jsxs("div",{children:[e.jsx("span",{children:"Trained output"}),e.jsx("pre",{children:JSON.stringify(n,null,2)})]}):null,l.length?e.jsxs("div",{children:[e.jsx("span",{children:"Grader feedback"}),e.jsx("p",{children:l.join(" ")})]}):null]})}function lt({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("span",{children:t}),e.jsx("strong",{children:s})]})}function js(t){return t==null?"Not recorded":t.toFixed(3)}function Xa(t){return t==null?"Not recorded":`${Math.round(t*100)}%`}function Za(t){return t==null?"Not comparable":`${t>=0?"+":""}${t.toFixed(3)}`}function bs(t){return t?.status==="unavailable"?"Unavailable":t?.score==null?"Not scored":t.score.toFixed(3)}function ei(t,s){if(!s)return"Not evaluated";if(s.status==="unavailable")return"Unavailable";if(!t||t.score==null||s.score==null)return s.passed?"Passed":"Failed";const n=s.score-t.score;return Math.abs(n)<5e-4?"No change":n>0?`Improved ${n.toFixed(3)}`:`Regressed ${Math.abs(n).toFixed(3)}`}const vs=[{key:"loss",label:"Loss",format:Re},{key:"reward",label:"Reward",format:Re},{key:"policyLoss",label:"Policy loss",format:Re},{key:"advantageLoss",label:"Advantage loss",format:Re},{key:"learningRate",label:"Learning rate",format:oi},{key:"gradientNorm",label:"Gradient norm",format:Re},{key:"meanTokenAccuracy",label:"Token accuracy",format:di},{key:"entropy",label:"Entropy",format:Re},{key:"memoryBytes",label:"Memory",format:Hs}];function ti({detail:t,loading:s,error:n}){const i=c.useMemo(()=>li(t?.stepMetrics??[]),[t?.stepMetrics]),a=c.useMemo(()=>vs.filter(p=>i.some(S=>S[p.key]!=null)),[i]),[l,r]=c.useState("loss"),o=a.find(p=>p.key===l)??a[0]??vs[0],u=i.flatMap(p=>p[o.key]==null?[]:[{step:p.step,value:p[o.key]}]),h=t?ni(t):{};if(s&&!t)return e.jsx("div",{className:"training-run-placeholder",children:"Loading training metrics…"});if(n&&!t)return e.jsx("div",{className:"training-run-placeholder error",children:n});if(!t)return e.jsx("div",{className:"training-run-placeholder",children:"Select a training run to inspect its metrics."});const d=t.job.metadata.trainingMethod==="grpo",j=i.flatMap(p=>p.reward==null?[]:[p.reward]),f=i.flatMap(p=>p.loss==null?[]:[p.loss]);return e.jsxs("div",{className:"training-run-metrics",children:[e.jsxs("div",{className:"training-metric-summary",children:[e.jsx(Le,{label:d?"Optimizer updates":"Steps",value:d?ii(t,i):h.steps??ai(i)}),d?e.jsxs(e.Fragment,{children:[e.jsx(Le,{label:"Latest reward",value:j.length?Re(j.at(-1)):null}),e.jsx(Le,{label:"Best reward",value:j.length?Re(Math.max(...j)):null}),e.jsx(Le,{label:"Recorded points",value:j.length||null})]}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{label:"Final loss",value:h.trainLoss==null?f.at(-1)==null?null:Re(f.at(-1)):Re(h.trainLoss)}),e.jsx(Le,{label:"Peak memory",value:ri(t.stepMetrics)}),e.jsx(Le,{label:"Adapter parameters",value:h.adapterParameterCount==null?null:h.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(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":p.key===o.key,className:p.key===o.key?"active":"",onClick:()=>r(p.key),children:p.label},p.key))}),e.jsx(si,{label:o.label,points:u,format:o.format})]}):e.jsx("div",{className:"training-run-placeholder",children:"This earlier run recorded its final result but not per-step Trainer logs."})]})}function si({label:t,points:s,format:n}){const l={top:20,right:20,bottom:58,left:64},r=s.map(v=>v.value),o=Math.min(...r),u=Math.max(...r),h=u-o||Math.max(Math.abs(u)*.1,1e-9),d=o-h*.08,j=u+h*.08,f=s[0]?.step??0,p=s.at(-1)?.step??f+1,S=Math.max(1,p-f),m=v=>l.left+(v-f)/S*(760-l.left-l.right),N=v=>l.top+(j-v)/(j-d)*(270-l.top-l.bottom),b=s.map((v,k)=>`${k?"L":"M"}${m(v.step).toFixed(2)},${N(v.value).toFixed(2)}`).join(" ");return e.jsx("figure",{className:"training-line-chart","aria-label":`${t} by optimizer step`,children:e.jsxs("svg",{viewBox:"0 0 760 270",role:"img","aria-labelledby":`metric-${t.replaceAll(" ","-")}`,children:[e.jsx("title",{id:`metric-${t.replaceAll(" ","-")}`,children:`${t} by optimizer step`}),[0,.25,.5,.75,1].map(v=>{const k=l.top+v*(270-l.top-l.bottom),T=j-v*(j-d);return e.jsxs("g",{children:[e.jsx("line",{className:"training-chart-grid",x1:l.left,x2:760-l.right,y1:k,y2:k}),e.jsx("text",{className:"training-chart-label",x:l.left-10,y:k+4,textAnchor:"end",children:n(T)})]},v)}),e.jsx("line",{className:"training-chart-axis",x1:l.left,x2:760-l.right,y1:270-l.bottom,y2:270-l.bottom}),e.jsx("path",{className:"training-chart-line",d:b}),s.map(v=>e.jsx("circle",{className:"training-chart-point",cx:m(v.step),cy:N(v.value),r:"3",children:e.jsx("title",{children:`Step ${v.step}: ${n(v.value)}`})},`${v.step}-${v.value}`)),e.jsx("text",{className:"training-chart-label",x:l.left,y:236,textAnchor:"middle",children:f}),e.jsx("text",{className:"training-chart-label",x:760-l.right,y:236,textAnchor:"middle",children:p}),e.jsx("text",{className:"training-chart-label axis-title",x:(l.left+760-l.right)/2,y:261,textAnchor:"middle",children:"Optimizer step"})]})})}function Le({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("span",{children:t}),e.jsx("strong",{children:s??"Not recorded"})]})}function ni(t){const s=[...t.events].reverse().find(n=>n.type==="metric"&&n.payload.metricKind!=="sft_step"&&(typeof n.payload.trainLoss=="number"||typeof n.payload.steps=="number"));return Object.fromEntries(Object.entries(s?.payload??{}).filter(n=>typeof n[1]=="number"))}function ai(t){const s=t.at(-1);return s?`${s.step} of ${s.maxSteps}`:null}function ii(t,s){const n=t.job.metadata.optimizerUpdatesObserved,i=typeof n=="number"&&Number.isFinite(n)?n:0,a=s.at(-1)?.step??0;return Math.max(i,a)||null}function li(t){const s=new Map;for(const n of t)s.set(n.step,n);return[...s.values()].sort((n,i)=>n.step-i.step)}function ri(t){const s=t.flatMap(n=>n.memoryBytes==null?[]:[n.memoryBytes]);return s.length?Hs(Math.max(...s)):null}function Re(t){return new Intl.NumberFormat(void 0,{maximumFractionDigits:4}).format(t)}function oi(t){return t===0?"0":t.toExponential(2)}function di(t){return`${(t*100).toFixed(1)}%`}function Hs(t){return`${(t/1024**3).toFixed(2)} GB`}const ci=new Set(["queued","starting","running","cancelling","reconciling"]);function ui(t,s,n){const[i,a]=c.useState(null),[l,r]=c.useState(!1),[o,u]=c.useState(null),h=c.useCallback(async()=>{if(!t||!s)return null;r(!0);try{const d=await Xe.trainingRunDetail(t,s);return a(d),u(null),d}catch(d){return u(d instanceof Error?d.message:String(d)),null}finally{r(!1)}},[t,s]);return c.useEffect(()=>{a(null),u(null),!(!t||!s)&&h()},[t,s,h]),c.useEffect(()=>{if(!t||!s||!n||!ci.has(n))return;const d=window.setInterval(()=>{h()},2e3);return()=>window.clearInterval(d)},[t,s,n,h]),{detail:i,error:o,loading:l,refresh:h}}function Ze(t,s,n){if(!n)return[];const i=s.filter(r=>r.target.kind==="model"&&r.target.id===t.id),a=new Set(i.flatMap(r=>r.target.kind==="model"&&r.target.trainingPlanId?[r.target.trainingPlanId]:[])),l=new Set(i.flatMap(r=>r.tasksetRef?[r.tasksetRef.id]:[]));return t.tasksetId&&l.add(t.tasksetId),n.plans.filter(r=>r.modelId===t.id||a.has(r.id)||r.modelId===null&&l.has(r.tasksetId)).sort((r,o)=>o.createdAt.localeCompare(r.createdAt))}function Ut(t,s,n){if(!n)return[];const i=new Set(Ze(t,s,n).map(a=>a.id));return n.jobs.filter(a=>i.has(a.planId)).sort((a,l)=>l.createdAt.localeCompare(a.createdAt))}function hi(t,s,n){if(!n)return[];const i=new Set(Ze(t,s,n).map(a=>a.tasksetId));for(const a of s)a.target.kind==="model"&&a.target.id===t.id&&a.tasksetRef&&i.add(a.tasksetRef.id);return t.tasksetId&&i.add(t.tasksetId),n.tasksets.filter(a=>i.has(a.id))}function Oe(t,s,n){if(!n)return[];const i=Ze(t,s,n),a=new Map(i.map(d=>[d.id,d])),l=Ut(t,s,n),r=new Map(l.map(d=>[d.id,d])),o=Ks(t,s,n),u=new Set(l.map(d=>d.id));return n.models.filter(d=>d.modelId===t.id||u.has(d.jobId)).sort((d,j)=>d.importedAt.localeCompare(j.importedAt)).map((d,j)=>{const f=r.get(d.jobId)??null;return{lineage:d,number:j+1,job:f,plan:f?a.get(f.planId)??null:null,taskset:n.tasksets.find(p=>p.id===d.tasksetId)??null,current:o?.modelArtifactLineageId===d.id}}).sort((d,j)=>j.number-d.number)}function Ks(t,s,n){if(!n)return null;const i=new Set(s.flatMap(a=>a.target.kind==="model"&&a.target.id===t.id&&a.tasksetRef?[a.tasksetRef.id]:[]));return t.tasksetId&&i.add(t.tasksetId),n.modelBindings.filter(a=>a.status==="active"&&a.role==="chat_manual"&&(a.roleTargetId===t.id||i.has(a.roleTargetId))).sort((a,l)=>l.promotedAt.localeCompare(a.promotedAt))[0]??null}function pi({workproduct:t,runs:s,training:n,onOpenDataset:i,onOpenEntry:a,onToast:l}){const r=n.payload,o=c.useMemo(()=>Ut(t,s,r),[s,r,t]),u=c.useMemo(()=>Oe(t,s,r),[s,r,t]),h=c.useMemo(()=>Ze(t,s,r),[s,r,t]),d=c.useMemo(()=>new Map(h.map(m=>[m.id,m])),[h]),j=c.useMemo(()=>Ws(o,u),[o,u]),f=Ks(t,s,r);async function p(m){const N=u.find(v=>v.lineage.id===m);if(!N?.lineage.promotable||!window.confirm(`Set Version ${N.number} as active for ${t.name}?`))return;const b=await n.actions.bindModel(N.lineage.id,"chat_manual",t.id);l(b?`Version ${N.number} is now active.`:"The active Version could not be changed.",b?"success":"error")}async function S(m,N){const b=await n.actions.setModelPinned(m,N);l(b?N?"Version pinned.":"Version unpinned.":"Version pin could not be changed.",b?"success":"error")}return j.length?e.jsx("section",{className:"labs-model-version-index","aria-label":"Versions",children:e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table labs-model-versions-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Version"}),e.jsx("th",{children:"Training"}),e.jsx("th",{children:"Dataset"}),e.jsx("th",{children:"Training status"}),e.jsx("th",{children:"Evaluation"}),e.jsx("th",{children:"Version status"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:j.map(m=>{const N=m.version?.plan??(m.job?d.get(m.job.planId)??null:null),b=m.version?.taskset??r?.tasksets.find(T=>T.id===N?.tasksetId)??null,v=m.version,k=v&&f?.modelArtifactLineageId===v.lineage.id;return e.jsxs("tr",{onClick:()=>a(m.key),children:[e.jsx("td",{children:e.jsxs("button",{className:"labs-version-row-button",type:"button",onClick:()=>a(m.key),children:[e.jsx("strong",{children:v?`Version ${v.number}`:"No output"}),e.jsx("small",{children:ji(v?.lineage.id??m.job?.id??m.key)})]})}),e.jsx("td",{children:De(N?.recipe.method)}),e.jsx("td",{children:b?e.jsx("button",{className:"labs-version-dataset-link",type:"button",onClick:T=>{T.stopPropagation(),i(b.id)},children:b.name}):"Unavailable"}),e.jsx("td",{children:e.jsx(be,{label:m.job?Vt(m.job.status):"Imported",value:m.job?.status??"completed"})}),e.jsx("td",{children:e.jsx(gi,{version:v})}),e.jsx("td",{children:e.jsx(xi,{version:v})}),e.jsx("td",{children:xt(v?.lineage.importedAt??m.job?.updatedAt??"")}),e.jsx("td",{children:v?e.jsxs("div",{className:"training-table-actions",children:[e.jsx("button",{"aria-pressed":v.lineage.pinned||!!k,className:"labs-version-icon-button",disabled:!!k,title:k?"The active Version stays pinned":v.lineage.pinned?"Unpin Version":"Pin Version",type:"button",onClick:T=>{T.stopPropagation(),S(v.lineage.id,!v.lineage.pinned)},children:e.jsx(Pn,{size:14})}),v.current?null:e.jsx("button",{className:"training-button secondary",disabled:!v.lineage.promotable,type:"button",onClick:T=>{T.stopPropagation(),p(v.lineage.id)},children:"Activate"}),e.jsx("button",{"aria-label":`Download Version ${v.number}`,className:"labs-version-icon-button",type:"button",onClick:T=>{T.stopPropagation(),n.actions.downloadModelPackage(v.lineage.id)},children:e.jsx(Ot,{size:14})})]}):null})]},m.key)})})]})})}):e.jsx("div",{className:"training-run-placeholder",children:"No training attempts yet."})}function mi({connection:t,selectedEntryKey:s,workproduct:n,runs:i,training:a,onBack:l,onOpenDataset:r,onUseVersion:o}){const u=a.payload,h=c.useMemo(()=>Ut(n,i,u),[i,u,n]),d=c.useMemo(()=>Oe(n,i,u),[i,u,n]),j=c.useMemo(()=>Ze(n,i,u),[i,u,n]),f=c.useMemo(()=>new Map(j.map(L=>[L.id,L])),[j]),S=c.useMemo(()=>Ws(h,d),[h,d]).find(L=>L.key===s)??null,m=S?.job??null,N=S?.version??null,b=N?.plan??(m?f.get(m.planId)??null:null),v=N?.taskset??u?.tasksets.find(L=>L.id===b?.tasksetId)??null,k=ui(t,m?.id??null,m?.status??null),T=m?u?.rolloutReceipts.filter(L=>L.jobId===m.id)??[]:[];return S?e.jsxs("div",{className:"labs-model-version-detail",children:[e.jsx("button",{className:"settings-secondary compact labs-model-version-back",type:"button",onClick:l,children:"Back to versions"}),e.jsxs(ce,{title:N?`Version ${N.number}`:`${De(b?.recipe.method)} attempt`,actions:N?e.jsxs("div",{className:"training-table-actions",children:[v?e.jsxs("button",{className:"training-button secondary",disabled:!N.lineage.promotable,title:N.lineage.promotable?"Chat with this Version":"Chat is unavailable because this Version did not pass evaluation.",type:"button",onClick:()=>o(N.lineage.id),children:[e.jsx($s,{size:14}),"Chat"]}):null,e.jsxs("button",{className:"training-button secondary",type:"button",onClick:()=>{a.actions.downloadModelPackage(N.lineage.id)},children:[e.jsx(Ot,{size:14}),"Download LoRA"]})]}):null,children:[e.jsxs("dl",{className:"labs-inline-facts",children:[e.jsx(ve,{label:"Training status",value:m?Vt(m.status):"Imported"}),e.jsx(ve,{label:"Version status",value:N?N.current?"Active":"Available":"Not created"}),e.jsx(ve,{label:"Training",value:De(b?.recipe.method)}),e.jsx(ve,{label:"Base model",value:fi(b)}),e.jsx(ve,{label:"Dataset",value:v?.name??"Unavailable"}),e.jsx(ve,{label:"Compute",value:b?es(b.destinationId):m?es(m.destinationId):"Not recorded"}),e.jsx(ve,{label:"Duration",value:m?qn(m.startedAt,m.completedAt):"Not recorded"}),e.jsx(ve,{label:"Output",value:N?`Version ${N.number}`:"No Version"})]}),v?e.jsxs("button",{className:"labs-version-dataset-link labs-version-detail-dataset",type:"button",onClick:()=>r(v.id),children:["Open ",v.name]}):null,m?.error?e.jsx("p",{className:"labs-training-error",children:m.error}):null]}),m?e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:b?.recipe.method==="grpo"?"Rollout scores":"Training metrics",children:e.jsx(ti,{detail:k.detail,error:k.error,loading:k.loading})}),e.jsx(ce,{title:"Evaluation",children:e.jsx(Qa,{detail:k.detail,loading:k.loading})}),b?.recipe.method==="grpo"?e.jsx(ce,{title:"Rollout traces",children:e.jsx(Wa,{receipts:T})}):null]}):null,e.jsx(ce,{title:"Configuration",children:e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(ve,{label:"Training attempt",value:m?.id??"Provider import"}),e.jsx(ve,{label:"Dataset",value:v?.name??"Unavailable"}),e.jsx(ve,{label:"Prepared data",value:m?.bundleHash??"Provider managed"}),e.jsx(ve,{label:"Version ID",value:N?.lineage.id??"No Version created"})]})})]}):e.jsxs("div",{className:"labs-model-version-detail",children:[e.jsx("button",{className:"settings-secondary compact",type:"button",onClick:l,children:"Back to versions"}),e.jsx("div",{className:"training-run-placeholder",children:"This training attempt is no longer available."})]})}function Ws(t,s){const n=new Map(s.flatMap(l=>l.job?[[l.job.id,l]]:[])),i=t.map(l=>({key:`job:${l.id}`,job:l,version:n.get(l.id)??null})),a=new Set(t.map(l=>l.id));for(const l of s)l.job&&a.has(l.job.id)||i.push({key:`version:${l.lineage.id}`,job:l.job,version:l});return i.sort((l,r)=>ys(r).localeCompare(ys(l)))}function ys(t){return t.version?.lineage.importedAt??t.job?.updatedAt??t.job?.createdAt??""}function gi({version:t}){const s=t?t.lineage.promotable?"Passed":t.lineage.frozenEvaluationArtifactId?"Failed":"Not run":"No output",n=t?t.lineage.promotable?"passed":t.lineage.frozenEvaluationArtifactId?"failed":"not_run":"not_run";return e.jsx(be,{label:s,value:n})}function xi({version:t}){return e.jsx(be,{label:t?t.current?"Active":"Available":"Not created",value:t?t.current?"current":"ready":"not_run"})}function fi(t){return!t||t.recipe.method!=="sft"&&t.recipe.method!=="grpo"?"Not recorded":t.recipe.baseModel.id.split("/").at(-1)??t.recipe.baseModel.id}function ji(t){return t.replace(/^(?:training_job_|lineage_)(?:fireworks_)?(?:artifact_)?/,"").slice(0,12)}function ve({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function bi({state:t,initialTasksetId:s,onClose:n,onContinue:i}){const a=c.useMemo(()=>(t?.tasksets??[]).filter(f=>f.readiness?.ready).sort((f,p)=>p.updatedAt.localeCompare(f.updatedAt)),[t?.tasksets]),[l,r]=c.useState(s&&a.some(f=>f.id===s)?s:a[0]?.id??""),o=a.find(f=>f.id===l)??null,u=o?Ns(o):[],[h,d]=c.useState(o?.readiness?.recommendedMethod==="grpo"?"grpo":"sft"),j=u.includes(h)?h:u[0]??"sft";return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:n,children:e.jsxs("section",{"aria-label":"New version","aria-modal":"true",className:"training-dialog labs-new-version-dialog",role:"dialog",onMouseDown:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"New version"}),e.jsx("p",{children:"Choose the immutable Dataset revision and training method."})]}),e.jsx("button",{"aria-label":"Close New version",type:"button",onClick:n,children:e.jsx(qe,{size:16})})]}),e.jsxs("div",{className:"labs-new-version-step",children:[e.jsx("span",{className:"labs-new-version-step-number",children:"1"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Dataset"}),e.jsx("p",{children:"Every run keeps the exact selected revision and Eval boundary."})]})]}),e.jsxs("label",{className:"labs-new-version-select",children:[e.jsx("span",{children:"Dataset revision"}),e.jsx("select",{value:l,onChange:f=>{const p=f.target.value;r(p);const S=a.find(N=>N.id===p),m=S?Ns(S):[];d(m.includes(j)?j:m[0]??"sft")},children:a.map(f=>e.jsxs("option",{value:f.id,children:[f.name," · revision ",f.revision]},f.id))})]}),o?e.jsxs("dl",{className:"labs-inline-facts labs-new-version-dataset-facts",children:[e.jsx(rt,{label:"Training",value:String(Rt(o,"train"))}),e.jsx(rt,{label:"Validation",value:String(Rt(o,"validation"))}),e.jsx(rt,{label:"Frozen Eval",value:String(Rt(o,"frozen_eval"))}),e.jsx(rt,{label:"Graders",value:String(o.graders.length)})]}):e.jsx("div",{className:"training-run-placeholder",children:"No ready Dataset is available. Create or finish a Dataset first."}),e.jsxs("div",{className:"labs-new-version-step",children:[e.jsx("span",{className:"labs-new-version-step-number",children:"2"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Training method"}),e.jsx("p",{children:"SFT and RFT create Versions of the same Model."})]})]}),e.jsx("div",{"aria-label":"Version training method",className:"labs-method-tabs",role:"tablist",children:u.map(f=>e.jsxs("button",{"aria-selected":f===j,className:f===j?"active":"",role:"tab",type:"button",onClick:()=>d(f),children:[e.jsx("span",{children:f==="grpo"?"Reinforcement":"Supervised"}),e.jsx("strong",{children:De(f)})]},f))}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{className:"training-button",disabled:!o||u.length===0,type:"button",onClick:()=>{o&&i({taskset:o,method:j})},children:"Continue"})]})]})})}function Ns(t){const s=new Set;for(const n of t.capabilities.compatibleMethods)(n==="sft"||n==="grpo")&&s.add(n);return t.readiness?.trainingPath?.bootstrap?.method==="sft"&&s.add("sft"),t.readiness?.trainingPath?.primaryMethod==="grpo"&&s.add("grpo"),["sft","grpo"].filter(n=>s.has(n))}function Rt(t,s){return t.tasks.filter(n=>n.split===s).length}function rt({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function vi({run:t,onAnswerQuestion:s,onApplyCandidate:n,onApprove:i,onCancel:a,onOpenPullRequest:l,onPause:r,onOpenConversation:o,onReconcilePullRequest:u,onRejectCandidate:h,onRetry:d,onResume:j,onRevise:f}){const p=t.state==="blocked"?"Review blocker":t.state==="failed"?"Review failure":"View progress",S=t.target.kind==="agent"&&["blocked","failed","cancelled"].includes(t.state);return e.jsxs("div",{className:"labs-run-decision",children:[e.jsx(Vn,{runtime:{run:t,onAnswerQuestion:s,onApplyCandidate:n,onApprove:i,onCancel:a,onOpenPullRequest:l,onPause:r,onReconcilePullRequest:u,onRejectCandidate:h,onResume:j,onRevise:f}}),t.scope.conversationId||S?e.jsxs("div",{className:"labs-run-decision-actions",children:[t.scope.conversationId?e.jsx("button",{className:"training-button secondary",type:"button",onClick:()=>o(t.scope.conversationId),children:p}):null,S?e.jsx("button",{className:"training-button",type:"button",onClick:d,children:"Try again"}):null]}):null]})}function yi({run:t,showOutcomes:s=!0}){const{completedTasks:n,currentTask:i,totalTasks:a}=t.progress,l=i?`${ks(i.family)} · ${i.worldId}`:t.progress.stage==="complete"?"Baseline complete":ks(t.progress.stage);return e.jsxs("div",{className:"labs-training-run-progress-wrap","aria-live":ki(t)?"polite":"off",children:[e.jsxs("div",{className:"labs-training-run-progress",children:[e.jsxs("progress",{max:Math.max(1,a),value:n,children:[n," of ",a," tasks"]}),e.jsxs("small",{children:[n," / ",a," · ",l]})]}),s?e.jsxs("span",{className:"labs-training-run-verdicts",children:[t.progress.outcomes.correct," exact · ",t.progress.outcomes.incorrect," incorrect ·"," ",t.progress.outcomes.parseFailure," format ·"," ",t.progress.outcomes.infrastructureFailure," infrastructure"]}):null]})}function Ni(t){return t.status==="queued"?"Queued":t.status==="cancelling"?"Cancelling":t.status==="cancelled"?"Cancelled":t.status==="succeeded"?"Baseline ready":t.status==="failed"?"Baseline failed":t.progress.stage==="preparing"?"Preparing baseline":t.progress.stage==="persisting"?"Saving baseline":"Running baseline"}function ki(t){return["queued","running","cancelling"].includes(t.status)}function ks(t){return t.replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}const Si=new Set(["released","rejected","ready","ready_local","published_hosted","blocked","failed","cancelled"]),Js=new Set(["queued","starting","running","cancelling","reconciling"]);function Qs(t){const s=t.runs[0]??null,n=s?.state==="blocked"&&s.candidates.some(a=>!!a.git?.worktreePath&&["draft","checking"].includes(a.status))?s:null,i=t.runs.find(a=>!Si.has(a.state))??null;if(t.workproduct.kind==="model"&&t.taskset){const a=Os(t.training,t.taskset.id)[0]??null;if(a&&Js.has(a.status))return Ss({taskset:t.taskset,training:t.training,latestRun:s,fallbackStatus:t.workproduct.status})}if(n)return At(n);if(i)return At(i);if(t.workproduct.kind==="model"){const a=t.workproduct.frontierBaselineRunId?t.training?.frontierBaselineRuns.find(l=>l.id===t.workproduct.frontierBaselineRunId)??null:null;return a?wi(a):!t.taskset&&s&&["failed","blocked","cancelled"].includes(s.state)?At(s):Ss({taskset:t.taskset,training:t.training,latestRun:s,fallbackStatus:t.workproduct.status})}return t.workproduct.kind==="agent"?{statusLabel:t.workproduct.status,statusValue:t.workproduct.status,action:{kind:"start_agent_change",label:"Improve agent"},runId:s?.id??null,conversationId:s?.scope.conversationId??null}:s?.scope.conversationId?{statusLabel:t.workproduct.status,statusValue:t.workproduct.status,action:{kind:"open_conversation",label:"Open chat"},runId:s.id,conversationId:s.scope.conversationId}:{statusLabel:t.workproduct.status,statusValue:t.workproduct.status,action:null,runId:s?.id??null,conversationId:s?.scope.conversationId??null}}function wi(t){return{statusLabel:Ni(t),statusValue:t.status,action:{kind:t.status==="succeeded"?"open_data":"open_evals",label:t.status==="succeeded"?"Review data":"View baseline"},runId:null,conversationId:null}}function At(t){const s={statusLabel:Ci(t.state),statusValue:t.state,runId:t.id,conversationId:t.scope.conversationId};if(t.state==="awaiting_questions")return{...s,action:{kind:"review_run",label:"Review questions"}};if(t.state==="awaiting_plan_approval")return{...s,action:{kind:"review_run",label:"Review plan"}};if(t.state==="awaiting_promotion")return{...s,action:{kind:"review_run",label:"Review candidate"}};if(t.state==="pull_request_open")return{...s,action:{kind:"review_run",label:"Review change"}};if(t.state==="paused")return{...s,action:{kind:"resume_run",label:"Resume"}};if(t.state==="blocked"){const n=t.candidates.some(i=>!!i.git?.worktreePath&&["draft","checking"].includes(i.status));return{...s,action:n?{kind:"resume_run",label:"Continue candidate"}:t.target.kind==="agent"?{kind:"start_agent_change",label:"Try again"}:t.scope.conversationId?{kind:"open_conversation",label:"Review blocker"}:null}}return t.state==="failed"?{...s,action:t.scope.conversationId?{kind:"open_conversation",label:"Review failure"}:null}:{...s,action:t.scope.conversationId?{kind:"open_conversation",label:"View progress"}:null}}function Ss(t){const s=t.latestRun?.scope.conversationId??null;if(!t.taskset)return{statusLabel:"Creating data",statusValue:"planning",action:s?{kind:"open_conversation",label:"View progress"}:null,runId:t.latestRun?.id??null,conversationId:s};const i=Os(t.training,t.taskset.id)[0]??null,a=t.training?.models.find(l=>l.tasksetId===t.taskset.id&&l.status==="imported")??null;return i&&Js.has(i.status)?{statusLabel:Vt(i.status),statusValue:i.status,action:{kind:"open_training",label:"View run"},runId:t.latestRun?.id??null,conversationId:s}:i?.status==="failed"?{statusLabel:"Training failed",statusValue:"failed",action:{kind:"open_training",label:"Review failure"},runId:t.latestRun?.id??null,conversationId:s}:i?.status==="succeeded"?i.metadata.frozenEvaluationComplete===!0&&i.metadata.frozenEvaluationThresholdPassed!==!0?{statusLabel:"Evaluation failed",statusValue:"failed",action:{kind:"open_training",label:"Review results"},runId:t.latestRun?.id??null,conversationId:s}:{statusLabel:a?i.metadata.frozenEvaluationThresholdPassed===!0?"Model ready":"Evaluation pending":"Collecting model",statusValue:a&&i.metadata.frozenEvaluationThresholdPassed===!0?"ready":"running",action:{kind:"open_training",label:"Review results"},runId:t.latestRun?.id??null,conversationId:s}:t.taskset.readiness?.ready?{statusLabel:"Ready to train",statusValue:"ready",action:{kind:"start_training",label:"Start training"},runId:t.latestRun?.id??null,conversationId:s}:{statusLabel:"Needs review",statusValue:"needs_review",action:{kind:"open_data",label:"Review data"},runId:t.latestRun?.id??null,conversationId:s}}function Ci(t){return{planning:"Planning",awaiting_questions:"Needs answers",awaiting_plan_approval:"Plan ready",paused:"Paused",applying_source:"Applying changes",running_checks:"Running checks",evaluating:"Evaluating",awaiting_promotion:"Candidate ready",opening_pull_request:"Opening review",pull_request_open:"Review open",reconciling_release:"Merging change",released:"Released",rejected:"Rejected",ready:"Ready",ready_local:"Ready",pushing_hosted:"Syncing",running_hosted_checks:"Verifying hosted",published_hosted:"Published",blocked:"Blocked",failed:"Failed",cancelled:"Cancelled"}[t]}const ws={chat_manual:"Default chat model",agent:"Agent runtime",extension:"Extension runtime",authoring_optimizer:"Authoring / optimizer"};function Ii({lineage:t,state:s,training:n,onToast:i}){const[a,l]=c.useState("chat_manual"),[r,o]=c.useState("default"),[u,h]=c.useState(null),[d,j]=c.useState(""),f=c.useMemo(()=>s?.modelBindings.find(x=>x.status==="active"&&x.role===a&&x.roleTargetId===r.trim())??null,[a,r,s?.modelBindings]),p=f?s?.models.find(x=>x.id===f.modelArtifactLineageId)??null:null,m=(t?.frozenEvaluationArtifactId?s?.artifacts.find(x=>x.id===t.frozenEvaluationArtifactId)??null:null)?.metadata.evaluationComplete===!1;if(!t)return e.jsx("div",{className:"training-run-placeholder",children:"Promotion is available after a verified artifact is imported."});const N=t,b=!!n.busyAction,v=N.status==="imported"&&N.promotable&&!!r.trim(),k=f?.modelArtifactLineageId===N.id;async function T(){const x=await n.actions.bindModel(N.id,a,r.trim());h(null),i(x?"Model binding activated.":"Couldn’t activate Model binding.",x?"success":"error")}async function L(){const x=d.trim();if(!x)return;const E=await n.actions.rejectModel(N.id,x);h(null),i(E?"Model candidate rejected.":"Couldn’t reject Model candidate.",E?"success":"error")}async function X(){const x=await n.actions.evaluateJob(N.jobId);h(null),i(x?"Frozen evaluation completed.":"Couldn’t complete frozen evaluation.",x?"success":"error")}async function q(){if(!f)return;const x=await n.actions.rollbackModelBinding(f.id);i(x?"Model binding rolled back.":"Couldn’t roll back Model binding.",x?"success":"error")}return e.jsxs("div",{className:"training-promotion",children:[e.jsxs("div",{className:"training-promotion-status",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Promotion gate"}),e.jsx("strong",{children:t.promotable?"Passed":"Blocked"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Selected role"}),e.jsx("strong",{children:p?Tt(p.id):"No active binding"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Rollback target"}),e.jsx("strong",{children:f?.rollbackTargetBindingId?Tt(f.rollbackTargetBindingId):"None"})]})]}),e.jsxs("div",{className:"training-promotion-controls",children:[e.jsxs("label",{children:[e.jsx("span",{children:"Role"}),e.jsx("select",{value:a,onChange:x=>{const E=x.target.value;l(E),o(E==="chat_manual"?"default":"")},children:Object.entries(ws).map(([x,E])=>e.jsx("option",{value:x,children:E},x))})]}),e.jsxs("label",{children:[e.jsx("span",{children:"Role target"}),e.jsx("input",{value:r,placeholder:a==="agent"?"agent id":a==="extension"?"extension id":"default",onChange:x=>o(x.target.value)})]}),e.jsxs("div",{className:"training-promotion-actions",children:[m?e.jsx("button",{className:"training-button secondary",type:"button",disabled:b,onClick:()=>h("evaluate"),children:"Run evaluation"}):null,k?e.jsx("button",{className:"training-button secondary",type:"button",disabled:b,onClick:()=>{q()},children:"Roll back"}):e.jsx("button",{className:"training-button",type:"button",disabled:b||!v,onClick:()=>h("bind"),children:f?"Replace binding":"Bind model"}),e.jsx("button",{className:"training-button danger",type:"button",disabled:b||t.status==="rejected"||k,onClick:()=>h("reject"),children:"Reject"})]})]}),t.promotable?null:e.jsx("p",{className:"training-promotion-note",children:m?"The artifact remains inspectable. Its prior evaluation was blocked by provider infrastructure and recorded no quality result.":"The artifact remains inspectable, but it cannot be bound until its frozen-evaluation threshold passes."}),u?e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:()=>!b&&h(null),children:e.jsxs("section",{className:"training-dialog training-promotion-dialog",role:"dialog","aria-modal":"true","aria-label":u==="bind"?"Confirm Model binding":u==="evaluate"?"Run frozen evaluation":"Reject Model candidate",onMouseDown:x=>x.stopPropagation(),children:[e.jsx("div",{className:"training-dialog-header",children:e.jsxs("div",{children:[e.jsx("h2",{children:u==="bind"?"Activate this Model binding?":u==="evaluate"?"Run frozen evaluation?":"Reject this Model candidate?"}),e.jsx("p",{children:u==="bind"?`${ws[a]} · ${r.trim()}`:u==="evaluate"?"Temporary Fireworks deployments are deleted after the base and trained runs.":"The artifact and evaluation evidence are retained."})]})}),u==="bind"?e.jsx("p",{children:f?`The current binding ${Tt(f.modelArtifactLineageId)} becomes the recorded rollback target.`:"This is an explicit activation; training success alone never changes runtime selection."}):u==="reject"?e.jsxs("label",{className:"training-promotion-reason",children:[e.jsx("span",{children:"Reason"}),e.jsx("textarea",{autoFocus:!0,value:d,onChange:x=>j(x.target.value)})]}):e.jsx("p",{children:"OpenPond first validates both deployment shapes without spending, then runs the approved frozen Taskset through the stateful tool harness. Runtime is capped at 10 minutes and the conservative deployment ceiling is $1.17 within the existing training approval."}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("button",{className:"training-button secondary",type:"button",disabled:b,onClick:()=>h(null),children:"Cancel"}),e.jsx("button",{className:`training-button ${u==="reject"?"danger":""}`,type:"button",disabled:b||u==="reject"&&!d.trim(),onClick:()=>{u==="bind"?T():u==="evaluate"?X():L()},children:b?"Applying…":u==="bind"?"Activate binding":u==="evaluate"?"Run evaluation":"Reject candidate"})]})]})}):null]})}function Tt(t){return t.replace(/^lineage_/,"").replace(/^model_binding_/,"").slice(0,16)}function Mi(t){for(const s of t){const n=s.metadata.preferredBaseModelId;if(typeof n=="string"&&n.trim())return n}return null}function Ri(t){return[...t.candidates].reverse().find(s=>!!s.git?.headCommit)??null}function Ai(t){return t?t.state==="released"?"positive":t.state==="blocked"||t.state==="failed"||t.state==="rejected"?"negative":t.state==="reconciling_release"?"info":"warning":"neutral"}function Ti({workproduct:t,profile:s}){if(t.kind==="agent"){const n=s?.agents.find(i=>i.id===t.id)??null;return e.jsx(ce,{title:"Agent",children:e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(ye,{label:"Enabled",value:n?.enabled?"Yes":"No"}),e.jsx(ye,{label:"Source",value:n?.path??t.path??"Draft"}),e.jsx(ye,{label:"Default action",value:`${t.id}.chat`}),e.jsx(ye,{label:"Profile checks",value:s?.lastCheck?.status??"Not run"})]})})}if(t.kind==="skill"){const n=s?.skills.find(i=>i.name===t.id)??null;return e.jsxs(ce,{title:"Skill",children:[e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(ye,{label:"Enabled",value:n?.enabled?"Yes":"No"}),e.jsx(ye,{label:"Validation",value:n?.validationStatus??"Draft"}),e.jsx(ye,{label:"Source hash",value:n?.sourceHash??"Not available"}),e.jsx(ye,{label:"Characters",value:n?String(n.charCount):"Not available"})]}),n?.validationMessages.length?e.jsx("ul",{className:"labs-validation-list",children:n.validationMessages.map(i=>e.jsx("li",{children:i},i))}):null]})}return t.kind==="extension"?e.jsx(ce,{title:"Extension",children:e.jsx("div",{className:"training-run-placeholder",children:"Runtime bindings arrive with the Extension phase."})}):null}function _i({runs:t,selectedRun:s,onSelectedRunIdChange:n}){return e.jsx(ce,{title:"Activity",children:t.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table labs-activity-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Run"}),e.jsx("th",{children:"Operation"}),e.jsx("th",{children:"State"}),e.jsx("th",{children:"Revision"}),e.jsx("th",{children:"Updated"})]})}),e.jsx("tbody",{children:t.map(i=>e.jsxs("tr",{className:i.id===s?.id?"selected":void 0,onClick:()=>n(i.id),children:[e.jsx("td",{children:ft(i.id)}),e.jsx("td",{children:i.operation}),e.jsx("td",{children:e.jsx(be,{label:i.state.replaceAll("_"," "),value:i.state})}),e.jsx("td",{children:i.revision}),e.jsx("td",{children:xt(i.updatedAt)})]},i.id))})]})}):e.jsx("div",{className:"training-run-placeholder",children:"No Create/Improve activity yet."})})}function Ei({profileEvals:t,run:s,workproduct:n}){const i=s?.evaluationReceipts??[],a=[...new Set([...s?.context.evalRefs??[],...i.flatMap(r=>r.evalRefs)])],l=n.kind==="agent"?t.filter(r=>r.agentId===null||r.agentId===n.id):[];return!i.length&&!l.length&&!a.length?e.jsx("div",{className:"training-run-placeholder",children:"No Eval receipts yet."}):e.jsxs("div",{className:"labs-eval-summary",children:[l.length?e.jsxs("div",{className:"labs-source-evals",children:[e.jsx("strong",{children:"Available Evals"}),e.jsx("ul",{children:l.map(r=>e.jsxs("li",{children:[e.jsx("span",{children:r.name}),e.jsx("code",{children:r.path})]},r.id))})]}):null,a.length?e.jsxs("div",{className:"labs-source-evals",children:[e.jsx("strong",{children:"Used for this change"}),e.jsx("ul",{children:a.map(r=>e.jsx("li",{children:e.jsx("code",{children:r})},r))})]}):null,i.length?e.jsxs("div",{className:"labs-eval-receipts",children:[e.jsx("strong",{children:"Eval receipts"}),e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Receipt"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Evals"}),e.jsx("th",{children:"Summary"})]})}),e.jsx("tbody",{children:i.map(r=>e.jsxs("tr",{children:[e.jsx("td",{children:ft(r.id)}),e.jsx("td",{children:e.jsx(be,{label:r.status})}),e.jsx("td",{children:r.evalRefs.length}),e.jsx("td",{children:r.summary??"No summary"})]},r.id))})]})})]}):null]})}function Pi({runs:t,selectedRun:s,taskset:n,training:i,trainingState:a,onToast:l}){const r=(n?a?.models.filter(d=>d.tasksetId===n.id)??[]:[]).sort((d,j)=>j.importedAt.localeCompare(d.importedAt)),o=new Map(a?.jobs.map(d=>[d.id,d])??[]),u=new Map(a?.plans.map(d=>[d.id,d])??[]),h=new Map(a?.artifacts.map(d=>[d.id,d])??[]);return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"labs-detail-copy labs-version-storage-copy",children:"OpenPond automatically saves provider weights in app-managed local storage. Download LoRA creates a portable copy for moving or sharing the adapter."}),e.jsxs("dl",{className:"labs-inline-facts",children:[e.jsx($e,{label:"Create/Improve runs",value:String(t.length)}),e.jsx($e,{label:"Candidates",value:String(s?.candidates.length??0)}),e.jsx($e,{label:"Profile commit",value:s?.localProfileCommit??"Not released"}),e.jsx($e,{label:"Model artifacts",value:String(r.length)})]}),r.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Version"}),e.jsx("th",{children:"Method"}),e.jsx("th",{children:"Storage"}),e.jsx("th",{children:"Frozen Eval"}),e.jsx("th",{children:"Imported"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Download"})})]})}),e.jsx("tbody",{children:r.map((d,j)=>{const f=o.get(d.jobId),p=f?u.get(f.planId):null,S=h.get(d.artifactId)??null,m=S?$i(S.path):null;return e.jsxs("tr",{children:[e.jsxs("td",{className:"labs-version-name",children:[e.jsx("strong",{children:j===0?"Latest":`Prior ${j}`}),e.jsx("small",{children:ft(d.id)})]}),e.jsx("td",{children:De(p?.recipe.method)}),e.jsxs("td",{className:"labs-version-storage",children:[e.jsx("strong",{children:m?"Saved locally":"Unavailable"}),m?e.jsx("code",{title:S?.path,children:m}):null]}),e.jsx("td",{children:d.promotable?"Passed":d.frozenEvaluationArtifactId?"Failed":"Not run"}),e.jsx("td",{children:xt(d.importedAt)}),e.jsx("td",{children:e.jsxs("button",{className:"training-button secondary",type:"button",onClick:()=>{i.actions.downloadModelPackage(d.id)},children:[e.jsx(Ot,{size:14}),"Download LoRA"]})})]},d.id)})})]})}):e.jsx("div",{className:"training-run-placeholder",children:"Model versions appear after the first adapter is imported."}),r[0]?e.jsxs("div",{className:"labs-version-promotion",children:[e.jsx("h3",{children:"Promotion & bindings"}),e.jsx(Ii,{lineage:r[0],state:a,training:i,onToast:l})]}):null]})}function $i(t){return t.replace(/[/\\][^/\\]+$/,"").replace(/^\/home\/[^/]+/,"~")}function $e({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function ye({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function ft(t){return t.replace(/^(create_improve|training_job|agent_candidate|model_candidate)_/,"").slice(0,14)}function Ys(t){return t&&`${t[0].toUpperCase()}${t.slice(1).replaceAll("_"," ")}`}function Di(t,s,n){return t==="changes"?s?["Changes",n?`Change ${n.slice(0,8)}`:`Change ${ft(s)}`]:["Changes"]:[Ys(t)]}function Fi(t,s,n){const i=n.git?.changedPaths??[],a=i[0]??null,l=t.path?.trim().replace(/^\.\/+|\/+$/g,"")??"";if(!l)return{fileRootPath:null,initialPath:a};const r=l.split("/").filter(Boolean);r.at(-1)?.includes(".")&&r.pop();const o=r.join("/");if(!o)return{fileRootPath:null,initialPath:a};const u=o.startsWith("profiles/")?o:`profiles/${s?.activeProfile??"default"}/${o}`,h=i.find(d=>d===u||d.startsWith(`${u}/`))??null;return h?{fileRootPath:u,initialPath:h}:{fileRootPath:null,initialPath:a}}function Li(t){return t?t.state==="awaiting_promotion"?"Change pending review":t.state==="released"?"Change merged":`Change ${t.state.replaceAll("_"," ")}`:"No change status"}function Bi({workproduct:t,runs:s,profile:n,training:i,connection:a,onOpenConversation:l,onLocationChange:r,onRenameAgent:o,onStartAgentChange:u,onOpenDataset:h,onToast:d,onAnswerQuestion:j,candidateReview:f,onApprove:p,onCancel:S,onChatWithModel:m,onApplyCandidate:N,onCandidateReviewChange:b,onOpenCandidateFiles:v,onOpenPullRequest:k,onPause:T,onReconcilePullRequest:L,onRejectCandidate:X,onResume:q,onRevise:x}){const E=c.useMemo(()=>Us(t,s),[s,t]),[re,D]=c.useState(E[0]?.id??""),[Y,H]=c.useState(null),[_,J]=c.useState("overview"),[se,B]=c.useState(null),[ae,ie]=c.useState(!1),[z,ge]=c.useState(null),[A,fe]=c.useState(null),K=E.find(R=>R.id===re)??E[0]??null,U=Y?E.find(R=>R.id===Y)??null:null,W=U?Ri(U):null,le=Fa(t.kind),ue=W?.git?.headCommit??null,oe=c.useMemo(()=>t.kind==="model"?se?["Version details"]:[]:Di(_,Y,ue),[_,ue,Y,se,t.kind]),F=t.tasksetId?i.payload?.tasksets.find(R=>R.id===t.tasksetId)??null:null,je=t.kind==="agent"?n?.agents.some(R=>R.id===t.id)??!1:!1,de=Qs({workproduct:t,runs:E,taskset:F,training:i.payload}),P=de.runId??E[0]?.id??"",Z=E.some(R=>R.id===re),ee=Y?E.some(R=>R.id===Y):!0,Te=[["overview","Overview"],["changes","Changes"],["evals","Evals"],["versions","Versions"],["configuration","Configuration"]];c.useEffect(()=>{b(null),D(P),H(null),B(null),J("overview")},[t.key]),c.useEffect(()=>{re&&Z||D(P)},[P,Z,re]),c.useEffect(()=>{ee||H(null)},[ee]),c.useEffect(()=>{if(_==="changes"&&U&&W){const R=Fi(t,n,W);b({run:U,candidate:W,fileRootPath:R.fileRootPath,initialPath:R.initialPath});return}b(null)},[_,b,n,W,U,t]),c.useEffect(()=>{r({kind:t.kind,kindLabel:le,workproductLabel:t.name,sectionLabels:oe})},[le,oe,r,t.kind,t.name]),c.useEffect(()=>()=>b(null),[b]);function Se(R){const O=Oe(t,s,i.payload).find(Q=>Q.lineage.id===R);if(O?.taskset){if(O.job?.destinationId==="fireworks"){ge(R);return}m(pt({modelId:R,taskset:O.taskset}))}}return e.jsxs("div",{className:"training-model-detail labs-workproduct-detail",children:[e.jsxs("header",{className:"training-model-detail-header labs-workproduct-detail-header",children:[e.jsx("div",{children:e.jsxs("div",{className:"labs-workproduct-name-row",children:[e.jsx("h1",{children:t.name}),e.jsx(Ft,{label:de.statusLabel,value:de.statusValue})]})}),t.kind==="model"?e.jsx("div",{className:"labs-workproduct-header-actions",children:e.jsx("button",{className:"training-button",type:"button",onClick:()=>ie(!0),children:"New version"})}):t.kind==="agent"?e.jsxs("div",{className:"labs-workproduct-header-actions",children:[e.jsx("button",{className:"training-button",type:"button",onClick:()=>u(t.id),children:"Improve agent"}),je?e.jsxs("button",{className:"settings-secondary compact",type:"button",onClick:o,children:[e.jsx(_s,{size:14}),e.jsx("span",{children:"Rename"})]}):null]}):null]}),t.kind!=="model"?e.jsx("div",{className:"training-detail-tabs",role:"tablist","aria-label":"Workproduct detail",children:Te.map(([R,O])=>e.jsxs("button",{className:_===R?"active":void 0,"aria-selected":_===R,role:"tab",type:"button",onClick:()=>{J(R),R==="changes"&&H(null)},children:[O,R==="changes"?e.jsx(Ft,{decorative:!0,label:Li(E[0]??null),size:"small",tone:Ai(E[0]??null)}):null]},R))}):null,e.jsx("div",{className:"training-detail-sections",children:t.kind==="model"?se?e.jsx(mi,{connection:a,runs:s,selectedEntryKey:se,training:i,workproduct:t,onBack:()=>B(null),onOpenDataset:h,onUseVersion:Se}):e.jsx(pi,{runs:s,training:i,workproduct:t,onOpenDataset:h,onOpenEntry:B,onToast:d}):_==="overview"?e.jsxs(ce,{title:"Overview",children:[e.jsxs("dl",{className:"labs-inline-facts",children:[e.jsx($e,{label:"Type",value:Ys(t.kind)}),e.jsx($e,{label:"Status",value:de.statusLabel}),e.jsx($e,{label:"ID",value:t.id}),e.jsx($e,{label:"Path",value:t.path??"Managed artifact"})]}),e.jsx("p",{className:"labs-detail-copy",children:t.description})]}):_==="changes"&&!U?e.jsx("div",{className:"labs-change-index",children:e.jsx(Ga,{runs:E,onReview:R=>{D(R.id),H(R.id)}})}):_==="changes"&&U&&W?e.jsx(qa,{candidate:W,diff:f.diff,error:f.error,run:U,onApplyCandidate:(R,O)=>N({run:R},O),onOpenFiles:v,onRejectCandidate:(R,O)=>X({run:R},O)}):_==="changes"&&U?e.jsxs("div",{className:"labs-change-run-detail",children:[e.jsxs("article",{className:"labs-change-card",children:[e.jsxs("header",{className:"labs-change-card-header",children:[e.jsx("span",{className:"labs-change-timeline-label",children:"Request"}),e.jsx(be,{label:U.state.replaceAll("_"," "),value:U.state})]}),e.jsx("div",{className:"labs-change-card-body",children:e.jsx("h3",{children:U.objective})})]}),e.jsx(vi,{run:U,onAnswerQuestion:j,onApplyCandidate:N,onApprove:p,onCancel:S,onOpenConversation:l,onOpenPullRequest:k,onPause:T,onReconcilePullRequest:L,onRejectCandidate:X,onResume:q,onRetry:()=>u(t.id,U.objective),onRevise:x})]}):_==="evals"?e.jsx(ce,{title:"Evals",actions:t.kind==="agent"?e.jsx(Oa,{agentId:t.id,evals:n?.evals??[],onCreate:()=>u(t.id,`Create an Eval for ${t.name}. Describe the behavior this Eval should specify: `),onAttach:R=>u(t.id,`--eval ${JSON.stringify(R)} Improve ${t.name} using this existing Eval: `)}):null,children:e.jsx(Ei,{profileEvals:n?.evals??[],run:K,workproduct:t})}):_==="versions"?e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:"Versions",children:e.jsx(Pi,{runs:E,selectedRun:K,taskset:F,training:i,trainingState:i.payload,onToast:d})}),e.jsx(_i,{runs:E,selectedRun:K,onSelectedRunIdChange:D})]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:"Connections",children:e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(ye,{label:"Profile",value:n?.activeProfile??"default"}),e.jsx(ye,{label:"Conversation",value:K?.scope.conversationId??"Not linked"}),e.jsx(ye,{label:"Project",value:K?.scope.projectId??"Not linked"}),e.jsx(ye,{label:"Source authority",value:K?.adapter.sourceAuthority??"Profile"})]})}),e.jsx(Ti,{workproduct:t,profile:n})]})}),ae?e.jsx(bi,{initialTasksetId:F?.id??null,state:i.payload,onClose:()=>ie(!1),onContinue:R=>{ie(!1),fe(R)}}):null,A?e.jsx(Ra,{busy:["prepare-training","start-prepared-training","start-training"].includes(i.busyAction??""),connection:a,destinations:i.payload?.destinations??[],initialMethod:A.method,modelId:t.id,preferredBaseModelId:Mi(E),taskset:A.taskset,onClose:()=>fe(null),onPrepare:(R,O,Q)=>i.actions.prepareTraining({modelId:t.id,tasksetId:A.taskset.id,destinationId:R,recipe:O,exportApproved:Q.exportApproved,retentionDays:Q.retentionDays,region:Q.region}),onConfirmPrepared:async(R,O)=>!!await i.actions.startPreparedTraining({planId:R.plan.id,bundleId:R.bundle.id,maximumCostUsd:O}),onStart:async(R,O,Q)=>!!await i.actions.startTraining({modelId:t.id,tasksetId:A.taskset.id,destinationId:R,recipe:O,...Q})}):null,z?(()=>{const R=Oe(t,s,i.payload).find(O=>O.lineage.id===z);return R?.taskset?e.jsx(qs,{lineage:R.lineage,taskset:R.taskset,training:i,onChat:m,onClose:()=>ge(null)}):null})():null]})}function zi({activeTab:t,children:s,suggestionCount:n,showHeader:i=!0,onTabChange:a,onCreateAgent:l,onCreateDataset:r,onCreateModel:o}){const[u,h]=c.useState(!1),d=c.useRef(null);return c.useEffect(()=>{if(!u)return;function j(p){d.current?.contains(p.target)||h(!1)}function f(p){p.key==="Escape"&&h(!1)}return document.addEventListener("pointerdown",j),document.addEventListener("keydown",f),()=>{document.removeEventListener("pointerdown",j),document.removeEventListener("keydown",f)}},[u]),e.jsxs("section",{className:"labs-route","aria-label":"Lab",children:[i?e.jsxs("header",{className:"labs-header",children:[e.jsx("div",{className:"labs-header-navigation",children:e.jsxs("nav",{className:"labs-primary-tabs",role:"tablist","aria-label":"Lab sections",children:[e.jsx("button",{"aria-selected":t==="workproducts",className:t==="workproducts"?"active":void 0,role:"tab",type:"button",onClick:()=>a("workproducts"),children:"Home"}),e.jsx("button",{"aria-selected":t==="datasets",className:t==="datasets"?"active":void 0,role:"tab",type:"button",onClick:()=>a("datasets"),children:"Datasets"}),e.jsxs("button",{"aria-selected":t==="suggestions",className:t==="suggestions"?"active":void 0,role:"tab",type:"button",onClick:()=>a("suggestions"),children:["Suggestions",n>0?e.jsx("span",{children:n}):null]})]})}),e.jsx("div",{className:"labs-header-actions",children:e.jsxs("div",{className:"labs-create-anchor",ref:d,children:[e.jsx("button",{className:"labs-create-button",type:"button","aria-expanded":u,"aria-haspopup":"menu","aria-label":"Create workproduct",title:"Create workproduct",onClick:()=>h(j=>!j),children:e.jsx(Ds,{size:15})}),u?e.jsxs("div",{className:"labs-create-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{h(!1),l()},children:[e.jsx(Fs,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:"New agent"}),e.jsx("small",{children:"Describe the agent in the shared Create flow."})]})]}),e.jsxs("button",{disabled:!0,type:"button",role:"menuitem",children:[e.jsx($n,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:"New skill"}),e.jsx("small",{children:"Coming soon"})]})]}),e.jsxs("button",{disabled:!0,type:"button",role:"menuitem",children:[e.jsx(Dn,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:"New extension"}),e.jsx("small",{children:"Coming soon"})]})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{h(!1),o()},children:[e.jsx(Ls,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:"New model"}),e.jsx("small",{children:"Build the data and Evals, then choose training."})]})]}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{h(!1),r()},children:[e.jsx(qt,{size:15}),e.jsxs("span",{children:[e.jsx("strong",{children:"New Dataset"}),e.jsx("small",{children:"Create a reusable Taskset without creating a Model."})]})]})]}):null]})})]}):null,e.jsx("div",{className:"labs-panel",children:s})]})}function Oi({agentId:t,currentName:s,onClose:n,onRename:i}){const[a,l]=c.useState(s),[r,o]=c.useState(!1),[u,h]=c.useState(null),d=a.trim().replace(/\s+/g," "),j=d===s.trim().replace(/\s+/g," ");c.useEffect(()=>{l(s),o(!1),h(null)},[t,s]),c.useEffect(()=>{function p(S){S.key==="Escape"&&!r&&n()}return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[r,n]);async function f(p){if(p.preventDefault(),!(!d||j||r)){o(!0),h(null);try{await i(d),n()}catch(S){h(S instanceof Error?S.message:String(S))}finally{o(!1)}}}return e.jsx("div",{className:"labs-rename-backdrop",role:"presentation",onMouseDown:p=>{p.target===p.currentTarget&&!r&&n()},children:e.jsxs("section",{"aria-label":`Rename ${s}`,"aria-modal":"true",className:"labs-rename-dialog",role:"dialog",children:[e.jsxs("header",{children:[e.jsx("span",{className:"labs-rename-dialog-icon",children:e.jsx(Fs,{size:16})}),e.jsxs("div",{children:[e.jsx("h2",{children:"Rename agent"}),e.jsx("p",{children:"Change the display name without changing the stable agent ID."})]}),e.jsx("button",{"aria-label":"Close rename agent",disabled:r,type:"button",onClick:n,children:e.jsx(qe,{size:16})})]}),e.jsxs("form",{onSubmit:p=>{f(p)},children:[e.jsxs("label",{children:[e.jsx("span",{children:"Display name"}),e.jsx("input",{autoFocus:!0,maxLength:80,value:a,onChange:p=>l(p.currentTarget.value)})]}),e.jsxs("div",{className:"labs-rename-agent-id",children:[e.jsx("span",{children:"Agent ID"}),e.jsx("code",{children:t})]}),u?e.jsx("p",{className:"labs-rename-error",role:"alert",children:u}):null,e.jsxs("footer",{children:[e.jsx("button",{disabled:r,type:"button",onClick:n,children:"Cancel"}),e.jsx("button",{disabled:!d||j||r,type:"submit",children:r?"Renaming…":"Rename"})]})]})]})})}function qi({taskset:t,busyAction:s,onPreview:n,onApprove:i,onToast:a}){const[l,r]=c.useState(null),[o,u]=c.useState(!1),h=Ui(t),d=t.learningSignals.demonstrations.filter(m=>m.approved&&m.metadata.exampleOrigin==="expert_authored").length,j=s==="preview-expert-bootstrap",f=s==="approve-expert-bootstrap";async function p(){u(!0);const m=await n();if(m){r(m);return}u(!1),a("Couldn’t load the expert trajectories.","error")}async function S(){if(!l)return;const m=await i(l.previewHash);if(!m){a("The expert trajectories were not approved.","error");return}u(!1),a(`${m.approval.trajectoryCount} expert trajectories approved by ${m.approval.approvedBy}.`,"success")}return e.jsxs(e.Fragment,{children:[e.jsx(ce,{title:"SFT bootstrap data",actions:e.jsx("button",{className:"training-button secondary",disabled:j||f,type:"button",onClick:()=>{p()},children:h?"Review trajectories":j?"Loading…":"Review expert trajectories"}),children:e.jsxs("div",{className:"labs-expert-bootstrap-summary",children:[e.jsxs("div",{children:[e.jsx(be,{label:h?"Approved":"Review required",value:h?"ready":"needs_review"}),e.jsx("p",{children:h?`${d} deterministic train-split trajectories are approved for the optional SFT bootstrap.`:"Five deterministic train-split trajectories are available. Failed model outputs remain excluded."})]}),h?e.jsxs("dl",{className:"labs-inline-facts",children:[e.jsx(Ye,{label:"Approved by",value:h.approvedBy}),e.jsx(Ye,{label:"Taskset revision",value:String(t.revision)})]}):null]})}),o?e.jsx(Vi,{approving:f,loading:j,preview:l,onApprove:()=>{S()},onClose:()=>{f||u(!1)}}):null]})}function Vi({preview:t,loading:s,approving:n,onApprove:i,onClose:a}){return e.jsx("div",{className:"training-dialog-backdrop",role:"presentation",onMouseDown:n?void 0:a,children:e.jsxs("section",{"aria-label":"Review expert trajectories","aria-modal":"true",className:"training-dialog labs-expert-bootstrap-dialog",role:"dialog",onMouseDown:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"training-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:"Review expert trajectories"}),e.jsx("p",{children:"These examples were executed in the deterministic synthetic environment and passed the exact verifier. Approval is bound to the signed-in OpenPond account."})]}),e.jsx("button",{"aria-label":"Close",disabled:n,type:"button",onClick:a,children:"×"})]}),e.jsx("div",{className:"training-dialog-scroll-body labs-expert-trajectory-list",children:s||!t?e.jsx("div",{className:"training-run-placeholder",children:"Generating and verifying the review set…"}):e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"labs-inline-facts labs-expert-preview-facts",children:[e.jsx(Ye,{label:"Taskset revision",value:String(t.tasksetRevision)}),e.jsx(Ye,{label:"Trajectories",value:String(t.tasks.length)}),e.jsx(Ye,{label:"Review state",value:t.status==="approved"?"Approved":"Pending"})]}),t.tasks.map(l=>e.jsxs("details",{className:"labs-expert-trajectory",children:[e.jsxs("summary",{children:[e.jsxs("span",{children:[e.jsx("strong",{children:Gi(l.family)}),e.jsxs("small",{children:[l.toolCallCount," tool calls · exact reward ",l.reward.toFixed(3)]})]}),e.jsx("span",{"aria-hidden":"true",children:"›"})]}),e.jsxs("div",{className:"labs-expert-trajectory-body",children:[e.jsxs("section",{children:[e.jsx("h3",{children:"Prompt"}),e.jsx("p",{children:l.prompt})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Tool sequence"}),e.jsx("div",{className:"training-pills",children:l.toolNames.map((r,o)=>e.jsx("span",{children:r},`${l.trajectoryId}-${r}-${o}`))})]}),e.jsxs("section",{children:[e.jsx("h3",{children:"Verified answer"}),e.jsx("pre",{children:l.finalAnswer})]}),e.jsxs("details",{className:"labs-expert-messages",children:[e.jsxs("summary",{children:["View ",l.messageCount," training messages"]}),e.jsx("pre",{children:JSON.stringify(l.messages,null,2)})]})]})]},l.trajectoryId))]})}),e.jsxs("div",{className:"training-dialog-actions",children:[e.jsx("span",{className:"labs-expert-approval-note",children:"Train split only · failed policy outputs excluded"}),e.jsx("button",{className:"training-button secondary",disabled:n,type:"button",onClick:a,children:"Close"}),t?.status!=="approved"?e.jsx("button",{className:"training-button",disabled:!t||s||n,type:"button",onClick:i,children:n?"Approving…":`Approve ${t?.tasks.length??0} trajectories`}):null]})]})})}function Ui(t){const s=Cs(t.metadata.expertBootstrap),n=Cs(s.approval);return n.status!=="approved"||typeof n.approvedBy!="string"||typeof n.approvedAt!="string"||typeof n.previewHash!="string"||typeof n.trajectoryCount!="number"?null:n}function Ye({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}function Gi(t){return t.split("_").map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join(" ")}function Cs(t){return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}const Hi=[{id:"train",label:"Training"},{id:"validation",label:"Validation"},{id:"frozen_eval",label:"Frozen Eval"}],_t=10;function Ki({taskset:t,onOpenFiles:s}){const n=c.useMemo(()=>al(t.tasks.map(m=>m.split)),[t.tasks]),i=n.get("train")?"train":t.tasks[0]?.split??"train",[a,l]=c.useState(i==="test"?"frozen_eval":i),[r,o]=c.useState(!1),u=c.useMemo(()=>new Map(t.sourceRefs.map(m=>[m.id,m])),[t.sourceRefs]),h=t.tasks.filter(m=>m.split===a),d=r?h:h.slice(0,_t),j=t.sourceRefs.filter(Gt).length,f=t.sourceRefs.filter(m=>m.turnIds.length>0).length,p=t.sourceRefs.filter(m=>m.metadata.containsCustomerData===!0).length,S=t.learningSignals.demonstrations.filter(m=>m.approved).length;return e.jsxs(e.Fragment,{children:[e.jsxs(ce,{title:"Dataset",actions:e.jsx("button",{className:"training-button secondary",type:"button",onClick:s,children:"Open files"}),children:[e.jsx("p",{className:"labs-detail-copy labs-dataset-summary",children:Ji({syntheticSources:j,chatSources:f,customerSources:p,sourceCount:t.sourceRefs.length})}),e.jsxs("dl",{className:"labs-inline-facts",children:[e.jsx(Be,{label:"Training",value:String(n.get("train")??0)}),e.jsx(Be,{label:"Validation",value:String(n.get("validation")??0)}),e.jsx(Be,{label:"Frozen Eval",value:String(n.get("frozen_eval")??0)}),e.jsx(Be,{label:"Approved demonstrations",value:String(S)})]})]}),e.jsxs(ce,{title:"Examples",children:[e.jsx("div",{className:"labs-method-tabs labs-dataset-tabs",role:"tablist","aria-label":"Dataset splits",children:Hi.map(m=>e.jsxs("button",{"aria-selected":a===m.id,className:a===m.id?"active":"",role:"tab",type:"button",onClick:()=>{l(m.id),o(!1)},children:[m.label,e.jsx("span",{children:n.get(m.id)??0})]},m.id))}),e.jsxs("div",{className:"labs-dataset-examples",children:[d.map((m,N)=>e.jsx(Wi,{index:N,source:m.sourceRefs.map(b=>u.get(b)).find(Boolean)??null,task:m},m.id)),h.length>_t?e.jsx("button",{className:"training-button secondary labs-dataset-show-all",type:"button",onClick:()=>o(m=>!m),children:r?`Show first ${_t}`:`Show all ${h.length}`}):null]})]})]})}function Wi({index:t,source:s,task:n}){const i=Qi(n),a=Xi(n),l=Yi(n),r=s?tl(s):"Source unavailable",o=Zi(n,s),u=el(n,s);return e.jsxs("details",{className:"labs-dataset-example",children:[e.jsxs("summary",{children:[e.jsx("span",{className:"labs-dataset-example-index",children:String(t+1).padStart(2,"0")}),e.jsxs("span",{className:"labs-dataset-example-title",children:[e.jsx("strong",{children:i}),e.jsx("small",{children:[o,u,r].filter(Boolean).join(" · ")})]}),e.jsx(be,{label:nl(n.split),value:n.split})]}),e.jsxs("div",{className:"labs-dataset-example-body",children:[e.jsxs("section",{children:[e.jsx("h3",{children:"Prompt"}),e.jsx("p",{children:i})]}),e.jsxs("section",{children:[e.jsx("h3",{children:n.split==="frozen_eval"?"Expected result":"Approved answer"}),n.split==="frozen_eval"?e.jsx("p",{children:"The answer stays held out and is only opened by the Eval runner."}):e.jsx("pre",{children:l??"No approved answer is attached."})]}),a.length?e.jsxs("section",{children:[e.jsx("h3",{children:"Tool trajectory"}),e.jsx("div",{className:"training-pills",children:a.map((h,d)=>e.jsx("span",{children:h},`${h}:${d}`))})]}):null,e.jsxs("section",{children:[e.jsx("h3",{children:"Source"}),e.jsxs("p",{children:[e.jsx("strong",{children:s?.title??"Source unavailable"})," — ",sl(s)]})]}),e.jsxs("details",{className:"labs-dataset-example-advanced",children:[e.jsx("summary",{children:"Technical details"}),e.jsxs("dl",{className:"training-configuration-list",children:[e.jsx(Be,{label:"Task",value:n.id}),e.jsx(Be,{label:"Source",value:s?.id??"Unavailable"}),e.jsx(Be,{label:"Cluster",value:n.clusterKey})]})]})]})]})}function Ji(t){if(t.sourceCount>0&&t.syntheticSources===t.sourceCount&&t.chatSources===0&&t.customerSources===0)return`This dataset contains ${t.sourceCount} generated scenarios. It uses no raw chats or customer data.`;const s=[`${t.sourceCount} source${t.sourceCount===1?"":"s"}`,`${t.chatSources} chat${t.chatSources===1?"":"s"}`,`${t.syntheticSources} generated scenario${t.syntheticSources===1?"":"s"}`];return t.customerSources===0?s.push("no sources marked as customer data"):s.push(`${t.customerSources} source${t.customerSources===1?"":"s"} marked as customer data`),`This dataset contains ${s.join(", ")}.`}function Qi(t){return typeof t.input.prompt=="string"?t.input.prompt:"Untitled dataset example"}function Yi(t){if(!t.expectedOutput)return null;if(typeof t.expectedOutput.text=="string")return t.expectedOutput.text;const s=Array.isArray(t.expectedOutput.messages)?t.expectedOutput.messages:[];for(const n of[...s].reverse())if(n&&typeof n=="object"&&"content"in n&&typeof n.content=="string")return n.content;return null}function Xi(t){if(!t.expectedOutput||!Array.isArray(t.expectedOutput.messages))return[];const s=[];for(const n of t.expectedOutput.messages){if(!n||typeof n!="object"||!("tool_calls"in n))continue;const i=Array.isArray(n.tool_calls)?n.tool_calls:[];for(const a of i){if(!a||typeof a!="object"||!("function"in a))continue;const l=a.function;l&&typeof l=="object"&&"name"in l&&typeof l.name=="string"&&s.push(l.name)}}return s}function Zi(t,s){const n=s?.metadata.crossSystemOperations;if(n&&typeof n=="object"&&"taskFamily"in n){const a=n.taskFamily;if(typeof a=="string")return gt(a)}const i=t.tags.find(a=>!["synthetic","structured-tool-trajectory"].includes(a));return i?gt(i):null}function el(t,s){const n=s?.metadata.crossSystemOperations;if(n&&typeof n=="object"&&"worldDifficulty"in n){const i=n.worldDifficulty;if(typeof i=="string")return gt(i)}return t.clusterKey.match(/_(easy|medium|hard)$/)?.[1]??null}function Gt(t){return t.metadata.syntheticSpecification===!0}function tl(t){return Gt(t)?"Generated scenario":t.turnIds.length>0?"Chat":"Imported source"}function sl(t){return t?Gt(t)&&t.metadata.containsCustomerData===!1?"generated locally from a deterministic specification; no customer content is attached.":t.turnIds.length>0?`${t.turnIds.length} approved chat turn${t.turnIds.length===1?"":"s"} are attached.`:"an approved imported source is attached.":"The referenced source could not be loaded."}function nl(t){return t==="frozen_eval"?"Frozen Eval":gt(t)}function gt(t){return t.replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,s=>s.toUpperCase())}function al(t){const s=new Map;for(const n of t)s.set(n,(s.get(n)??0)+1);return s}function Be({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("dt",{children:t}),e.jsx("dd",{children:s})]})}const Bt=10;function il({state:t,runs:s,selectedId:n,onSelectedIdChange:i,onCreate:a,onOpenFiles:l,training:r,onToast:o}){const[u,h]=c.useState(""),[d,j]=c.useState(1),f=t?.tasksets??[],p=f.find(b=>b.id===n)??null,S=c.useMemo(()=>{const b=u.trim().toLowerCase();return b?f.filter(v=>[v.name,v.objective,v.id].some(k=>k.toLowerCase().includes(b))):f},[u,f]),m=S.slice((d-1)*Bt,d*Bt),N=c.useMemo(()=>{const b=new Map;if(!t)return b;const v=Vs({profile:null,training:t,runs:s}).filter(k=>k.kind==="model");for(const k of v)for(const T of hi(k,s,t))b.set(T.id,(b.get(T.id)??0)+1);return b},[s,t]);return p?e.jsxs("div",{className:"labs-flat-body labs-datasets-page",children:[e.jsxs("div",{className:"labs-dataset-detail-heading",children:[e.jsx("button",{"aria-label":"Back to Datasets",className:"labs-back-button",type:"button",onClick:()=>i(null),children:e.jsx(Ps,{size:15})}),e.jsxs("div",{children:[e.jsx("h1",{children:p.name}),e.jsx("p",{children:p.objective})]}),e.jsx(be,{label:ll(p),value:p.status})]}),e.jsx(Ki,{taskset:p,onOpenFiles:()=>l(p.id)}),p.metadata.flagship==="cross-system-operations"?e.jsx(qi,{busyAction:r.busyAction,taskset:p,onApprove:b=>r.actions.approveExpertBootstrap(p.id,b),onPreview:()=>r.actions.previewExpertBootstrap(p.id),onToast:o}):null]}):e.jsxs("div",{className:"labs-flat-body labs-datasets-page",children:[e.jsx("div",{className:"labs-resource-actions",children:e.jsx("button",{className:"training-button",type:"button",onClick:a,children:"Create Dataset"})}),e.jsx("div",{className:"labs-workproduct-toolbar",children:e.jsxs("label",{className:"labs-search",children:[e.jsx(zt,{size:14}),e.jsx("input",{"aria-label":"Search Datasets",placeholder:"Search Datasets",value:u,onChange:b=>{h(b.target.value),j(1)}})]})}),e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table labs-datasets-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Dataset"}),e.jsx("th",{children:"Training"}),e.jsx("th",{children:"Validation"}),e.jsx("th",{children:"Frozen Eval"}),e.jsx("th",{children:"Graders"}),e.jsx("th",{children:"Models"}),e.jsx("th",{children:"Updated"})]})}),e.jsx("tbody",{children:m.map(b=>{const v=N.get(b.id)??0;return e.jsxs("tr",{children:[e.jsx("td",{children:e.jsxs("button",{className:"labs-workproduct-link",type:"button",onClick:()=>i(b.id),children:[e.jsx("strong",{children:b.name}),e.jsx("span",{children:b.objective})]})}),e.jsx("td",{children:Et(b,"train")}),e.jsx("td",{children:Et(b,"validation")}),e.jsx("td",{children:Et(b,"frozen_eval")}),e.jsx("td",{children:b.graders.length}),e.jsx("td",{children:v||"—"}),e.jsx("td",{children:rl(b.updatedAt)})]},b.id)})})]})}),m.length?null:e.jsx("div",{className:"labs-table-empty",children:"No Datasets match this view."}),e.jsx(ol,{page:d,total:S.length,onChange:j})]})}function Et(t,s){return t.tasks.filter(n=>n.split===s).length}function ll(t){return t.readiness?.ready?"Ready":t.status==="ready"?"Needs Evals":t.status.replaceAll("_"," ").replace(/^./,s=>s.toUpperCase())}function rl(t){const s=new Date(t);return Number.isFinite(s.getTime())?s.toLocaleDateString(void 0,{month:"short",day:"numeric"}):"—"}function ol({page:t,total:s,onChange:n}){const i=Math.max(1,Math.ceil(s/Bt));return i===1?null:e.jsxs("nav",{className:"labs-pagination","aria-label":"Dataset pages",children:[e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>n(t-1),children:"Previous"}),e.jsxs("span",{children:[t," of ",i]}),e.jsx("button",{type:"button",disabled:t>=i,onClick:()=>n(t+1),children:"Next"})]})}function dl({enabled:t,items:s,runs:n,nextScanAt:i,scanRunning:a,scanStartedAt:l,scanning:r,savingEnabled:o,error:u,onEnabledChange:h,onPatchStatus:d,onOpenSession:j}){const[f,p]=c.useState("all"),[S,m]=c.useState("all"),[N,b]=c.useState("all"),[v,k]=c.useState("all"),[T,L]=c.useState("all"),[X,q]=c.useState(()=>Date.now());c.useEffect(()=>{const B=window.setInterval(()=>q(Date.now()),1e3);return()=>window.clearInterval(B)},[]);const x=c.useMemo(()=>s.filter(B=>!(f!=="all"&&B.status!==f||S!=="all"&&B.severity!==S||N!=="all"&&en(B)!==N)),[s,S,N,f]),E=c.useMemo(()=>n.filter(B=>!(v!=="all"&&B.status!==v||T!=="all"&&B.trigger!==T||N!=="all"&&!B.evidenceSources.includes(N))),[v,T,n,N]),re=c.useMemo(()=>x.filter(B=>B.status==="active"),[x]),D=c.useMemo(()=>x.filter(B=>B.status!=="active"),[x]),Y=f==="all"||f==="active",H=f==="all"||f!=="active",_=r||a,J=`${f}:${S}:${N}`,se=`${v}:${T}:${N}`;return e.jsxs("section",{className:"insights-view","aria-label":"Insights",children:[e.jsxs("section",{className:"insights-scan-preference","aria-label":"Observation scanning",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Observation scanning"}),e.jsx("span",{children:"Periodically review selected work, failures, and corrections for signals. It stays off until you turn it on."})]}),e.jsxs("div",{className:"insights-scan-controls",children:[e.jsxs("span",{className:`insights-scan-countdown ${_?"running":""}`,children:[e.jsx("span",{className:"insights-scan-dot","aria-hidden":"true"}),t?fl(i,X,_):"Scanning is off"]}),e.jsx("button",{"aria-pressed":t,className:t?"active":void 0,disabled:o||_,type:"button",onClick:()=>{h(!t)},children:o?"Saving":t?"On":"Turn on"})]})]}),e.jsxs("div",{className:"insights-filters","aria-label":"Insight filters",children:[e.jsx(Je,{label:"Observation status",options:cl,value:f,onChange:p}),e.jsx(Je,{label:"Severity",options:ul,value:S,onChange:m}),e.jsx(Je,{label:"Source",options:hl,value:N,onChange:b}),e.jsx(Je,{label:"Run status",options:pl,value:v,onChange:k}),e.jsx(Je,{label:"Run trigger",options:ml,value:T,onChange:L})]}),_?e.jsxs("div",{className:"insights-active-scan",role:"status",children:[e.jsx("span",{className:"insights-scan-dot","aria-hidden":"true"}),e.jsxs("div",{children:[e.jsx("strong",{children:"Active scan"}),e.jsx("span",{children:l?`Started ${Ht(l)}`:"Scanning insights now"})]})]}):null,u?e.jsx("div",{className:"insights-error",children:u}):null,e.jsx(gl,{runs:E,paginationKey:se,onOpenSession:j}),Y?e.jsx(Is,{title:"Active",emptyText:"No active Create/Improve insights match the filters.",items:re,paginationKey:J,onPatchStatus:d,onOpenSession:j}):null,H?e.jsx(Is,{title:"Recent",emptyText:"No resolved or dismissed insights match the filters.",items:D,paginationKey:J,onPatchStatus:d,onOpenSession:j}):null]})}const cl=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"resolved",label:"Resolved"},{value:"dismissed",label:"Dismissed"}],ul=[{value:"all",label:"All"},{value:"blocker",label:"Blocker"},{value:"concern",label:"Concern"},{value:"nit",label:"Nit"}],hl=[{value:"all",label:"All"},{value:"create_edit",label:"Create/Improve"},{value:"stuck_turn",label:"Stuck turns"},{value:"tool_failure",label:"Tools"},{value:"abandoned_goal",label:"Goals"},{value:"user_correction",label:"Corrections"},{value:"unresolved_conversation",label:"Unresolved"},{value:"usage_anomaly",label:"Usage"}],pl=[{value:"all",label:"All"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"skipped",label:"Skipped"}],ml=[{value:"all",label:"All"},{value:"manual",label:"Manual"},{value:"interval",label:"Interval"},{value:"startup",label:"Startup"},{value:"slash_command",label:"Slash"}];function Je({label:t,options:s,value:n,onChange:i}){return e.jsxs("label",{className:"insights-filter-group",children:[e.jsx("span",{children:t}),e.jsx("select",{value:n,onChange:a=>i(a.target.value),children:s.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]})}function Is({title:t,emptyText:s,items:n,paginationKey:i,onPatchStatus:a,onOpenSession:l}){const r=Xs(n,i);return e.jsxs("section",{className:"insights-section",children:[e.jsx("h2",{children:t}),n.length===0?e.jsx("p",{className:"insights-empty",children:s}):e.jsxs("div",{className:"insights-table-frame",children:[e.jsx("div",{className:"insights-table-scroll",children:e.jsxs("table",{className:"insights-table insights-observations-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Severity"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Observation"}),e.jsx("th",{scope:"col",children:"Updated"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:r.pageItems.map(o=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx("span",{className:`insights-severity ${o.severity}`,children:xl(o.severity)})}),e.jsx("td",{children:e.jsxs("div",{className:"insights-status-stack",children:[e.jsx("span",{children:o.status}),e.jsx("small",{children:vl(en(o))})]})}),e.jsx("td",{children:e.jsxs("div",{className:"insights-copy",children:[e.jsx("strong",{children:o.title}),e.jsx("span",{children:o.summary})]})}),e.jsx("td",{className:"insights-time",children:Ht(o.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{className:"insights-actions",children:[Ms(o.payload.sessionId)?e.jsx("button",{type:"button",className:"insights-text-action",onClick:()=>l(Ms(o.payload.sessionId)),children:"Source"}):null,o.lastRunSessionId?e.jsx("button",{type:"button",className:"insights-text-action",onClick:()=>l(o.lastRunSessionId),children:"Run"}):null,o.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",title:"Resolve observation","aria-label":"Resolve observation",onClick:()=>{a(o.id,"resolved")},children:e.jsx(Bs,{size:15})}),e.jsx("button",{type:"button",title:"Dismiss observation","aria-label":"Dismiss observation",onClick:()=>{a(o.id,"dismissed")},children:e.jsx(qe,{size:15})})]}):e.jsx("button",{type:"button",title:"Reopen observation","aria-label":"Reopen observation",onClick:()=>{a(o.id,"active")},children:e.jsx(Un,{size:15})})]})})]},o.id))})]})}),e.jsx(Zs,{label:t,...r})]})]})}function gl({runs:t,paginationKey:s,onOpenSession:n}){const i=Xs(t,s);return e.jsxs("section",{className:"insights-section",children:[e.jsx("h2",{children:"Runs"}),t.length===0?e.jsx("p",{className:"insights-empty",children:"No Insights runs yet."}):e.jsxs("div",{className:"insights-table-frame",children:[e.jsx("div",{className:"insights-table-scroll",children:e.jsxs("table",{className:"insights-table insights-runs-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",children:"Trigger"}),e.jsx("th",{scope:"col",children:"Status"}),e.jsx("th",{scope:"col",children:"Model"}),e.jsx("th",{scope:"col",children:"Summary"}),e.jsx("th",{scope:"col",children:"Completed"}),e.jsx("th",{scope:"col",children:"Actions"})]})}),e.jsx("tbody",{children:i.pageItems.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:jl(a.trigger)}),e.jsx("td",{className:"insights-status",children:a.status}),e.jsx("td",{className:"insights-status",children:bl(a)}),e.jsx("td",{children:e.jsxs("div",{className:"insights-copy",children:[e.jsx("strong",{children:a.summary??`${a.findingCount} finding${a.findingCount===1?"":"s"}`}),e.jsxs("span",{children:[a.createdCount," new / ",a.updatedCount," updated / ",a.resolvedCount," resolved"]})]})}),e.jsx("td",{className:"insights-time",children:Ht(a.completedAt??a.startedAt)}),e.jsx("td",{children:e.jsx("div",{className:"insights-actions",children:e.jsx("button",{type:"button",className:"insights-text-action",onClick:()=>n(a.sessionId),children:"Open run"})})})]},a.turnId))})]})}),e.jsx(Zs,{label:"Runs",...i})]})]})}const ot=10;function Xs(t,s){const[n,i]=c.useState(0);c.useEffect(()=>i(0),[s]);const a=Math.max(1,Math.ceil(t.length/ot)),l=Math.min(n,a-1),r=l*ot;return{pageItems:t.slice(r,r+ot),pageIndex:l,pageCount:a,pageStart:r,pageSize:ot,totalItems:t.length,onPageChange:i}}function Zs({label:t,pageIndex:s,pageCount:n,pageStart:i,pageSize:a,totalItems:l,onPageChange:r}){return e.jsxs("nav",{className:"insights-pagination","aria-label":`${t} pagination`,children:[e.jsxs("span",{children:[i+1,"–",Math.min(i+a,l)," of ",l]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",disabled:s===0,onClick:()=>r(s-1),children:"Previous"}),e.jsxs("span",{children:["Page ",s+1," of ",n]}),e.jsx("button",{type:"button",disabled:s>=n-1,onClick:()=>r(s+1),children:"Next"})]})]})}function xl(t){return t==="blocker"?"Blocker":t==="concern"?"Concern":"Nit"}function fl(t,s,n){if(n)return"Scanning now";if(!t)return"Next scan not scheduled";const i=new Date(t).getTime();if(Number.isNaN(i))return"Next scan not scheduled";const a=i-s;if(a<=0)return"Next scan starting soon";const l=Math.ceil(a/6e4);return`${l} minute${l===1?"":"s"} till next scan`}function jl(t){return t==="slash_command"?"Slash command":t==="startup"?"Startup":t==="interval"?"Interval":"Manual"}function bl(t){return t.modelRef?`${t.modelRef.providerId} / ${t.modelRef.modelId}`:"Default"}function en(t){const s=t.payload.evidenceSource;return s==="create_edit"||s==="stuck_turn"||s==="tool_failure"||s==="abandoned_goal"||s==="user_correction"||s==="unresolved_conversation"||s==="usage_anomaly"?s:"create_edit"}function vl(t){return t==="stuck_turn"?"Stuck turn":t==="tool_failure"?"Tool failures":t==="abandoned_goal"?"Abandoned goal":t==="user_correction"?"Corrections":t==="unresolved_conversation"?"Unresolved chat":t==="usage_anomaly"?"Usage":"Create/Improve"}function Ms(t){return typeof t=="string"&&t.trim()?t:null}function Ht(t){const s=new Date(t);return Number.isNaN(s.getTime())?t:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(s)}function yl({training:t,defaultModel:s,preferences:n,reasoningEffort:i,onPlanStarted:a}){const l=t.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."})]}),l.length?e.jsx("div",{className:"training-card-grid",children:l.map(r=>e.jsx(Nl,{candidate:r,candidates:l,training:t,defaultModel:s,preferences:n,reasoningEffort:i,onPlanStarted:a},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 Nl({candidate:t,candidates:s,training:n,defaultModel:i,preferences:a,reasoningEffort:l,onPlanStarted:r}){const[o,u]=c.useState(""),h=s.filter(j=>j.id!==t.id&&j.status!=="retired");async function d(){const j=await n.actions.createCandidate(t.id,a.creationMode,Es(a,i),l);j&&(j.state==="awaiting_disclosure_approval"&&a.autoApproveEvidence&&await n.actions.approveDisclosure(j.id,!0),r())}return e.jsxs("article",{className:"training-card",children:[e.jsxs("div",{className:"training-card-heading",children:[e.jsx("strong",{children:t.title}),e.jsx("span",{className:"training-pill",children:t.recommendation.tactic.replaceAll("_"," ")})]}),e.jsx("p",{children:t.summary}),e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Frequency"}),e.jsx("dd",{children:dt(t.scorecard.frequency)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Verifiable"}),e.jsx("dd",{children:dt(t.scorecard.verifiability)})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Signal"}),e.jsx("dd",{children:dt(t.scorecard.signalQuality)})]})]}),e.jsxs("details",{className:"training-evidence",children:[e.jsx("summary",{children:"Evidence and recommendation"}),e.jsx("p",{children:t.recommendation.reasons.join(" ")}),t.recommendation.blockers.map(j=>e.jsx("p",{className:"training-draft-warning",children:j},j)),e.jsx("ul",{children:t.evidence.map(j=>e.jsxs("li",{children:[e.jsx("strong",{children:j.kind.replaceAll("_"," ")})," — ",j.summary," (",dt(j.confidence),")"]},j.id))})]}),e.jsxs("div",{className:"training-inline-actions",children:[e.jsx("button",{className:"training-button",type:"button",disabled:!!n.busyAction,onClick:()=>{d()},children:"Create plan"}),e.jsx("button",{className:"training-text-button",type:"button",onClick:()=>{n.actions.patchCandidate(t.id,{status:"rejected"})},children:"Reject"}),e.jsx("button",{className:"training-text-button",type:"button",onClick:()=>{n.actions.patchCandidate(t.id,{status:"dismissed"})},children:"Dismiss"})]}),h.length?e.jsxs("div",{className:"training-merge-row",children:[e.jsxs("select",{"aria-label":`Merge ${t.title} into`,value:o,onChange:j=>u(j.target.value),children:[e.jsx("option",{value:"",children:"Merge into…"}),h.map(j=>e.jsx("option",{value:j.id,children:j.title},j.id))]}),e.jsx("button",{className:"training-text-button",type:"button",disabled:!o,onClick:()=>{n.actions.patchCandidate(t.id,{mergeIntoId:o})},children:"Merge"})]}):null]})}function dt(t){return`${Math.round(t*100)}%`}const kl=10,Sl=new Date(0).toISOString();function wl({insights:t,suggestionsView:s,training:n,onSuggestionsViewChange:i,onPlanStarted:a}){return e.jsxs("section",{className:"labs-suggestions-page","aria-label":"Suggestions",children:[e.jsxs("div",{className:"labs-subtabs",role:"tablist","aria-label":"Suggestion types",children:[e.jsxs("button",{"aria-selected":s==="observations",className:s==="observations"?"active":void 0,role:"tab",type:"button",onClick:()=>i("observations"),children:["Observations"," ",e.jsx("span",{children:t.items.filter(l=>l.status==="active").length})]}),e.jsxs("button",{"aria-selected":s==="suggestions",className:s==="suggestions"?"active":void 0,role:"tab",type:"button",onClick:()=>i("suggestions"),children:["AI suggestions"," ",e.jsx("span",{children:n.training.payload?.candidates.length??0})]})]}),e.jsx("div",{className:"labs-suggestions-body",children:s==="observations"?e.jsx(dl,{...t}):e.jsx(yl,{training:n.training,defaultModel:n.defaultModel,preferences:n.preferences,reasoningEffort:n.reasoningEffort,onPlanStarted:a})})]})}function Cl({frontierBaselineRuns:t,items:s,loading:n,progressionByKey:i,showType:a,onSelect:l,onUseAgent:r,onUseModel:o,onUseSkill:u}){if(n)return e.jsxs("div",{className:"labs-table-empty",children:[e.jsx(ke,{className:"spin",size:16})," Loading workproducts…"]});if(!s.length)return e.jsx("div",{className:"labs-table-empty",children:"No workproducts match this view."});const h=new Map(t.map(d=>[d.id,d]));return e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:`training-data-table labs-workproducts-table${a?"":" models-only"}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[a?e.jsx("th",{children:"Type"}):null,e.jsx("th",{children:"Name"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Training"}),e.jsx("th",{children:"Evals"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Open"})})]})}),e.jsx("tbody",{children:s.map(d=>{const j=i.get(d.key),f=d.frontierBaselineRunId?h.get(d.frontierBaselineRunId)??null:null;return e.jsxs("tr",{onClick:()=>l(d.key),children:[a?e.jsx("td",{className:"labs-workproduct-type",children:Tl(d.kind)}):null,e.jsx("td",{children:e.jsxs("button",{className:f?"labs-workproduct-link labs-training-run-name":"labs-workproduct-link",type:"button",onClick:()=>l(d.key),children:[e.jsx("strong",{children:d.name}),e.jsx("span",{children:d.description}),f?e.jsx(yi,{run:f,showOutcomes:!1}):null]})}),e.jsx("td",{children:e.jsx(be,{label:j?.statusLabel??d.status,value:j?.statusValue??d.status})}),e.jsx("td",{className:"labs-workproduct-training",children:Ml(d)}),e.jsx("td",{className:"labs-workproduct-evals",children:Rl(d)}),e.jsx("td",{className:"labs-workproduct-updated",children:d.updatedAt===Sl?"—":tn(d.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{className:"labs-workproduct-actions",children:[d.kind==="skill"?e.jsx("button",{className:"settings-secondary compact labs-workproduct-use",type:"button",onClick:p=>{p.stopPropagation(),u(d.name)},children:"Use"}):d.kind==="agent"&&d.useActionId?e.jsx("button",{className:"settings-secondary compact labs-workproduct-use",type:"button",onClick:p=>{p.stopPropagation(),r(d.useActionId)},children:"Use"}):d.kind==="model"&&d.enabled!==null?e.jsx("button",{className:"settings-secondary compact labs-workproduct-use",type:"button",disabled:!d.enabled,title:d.enabled?"Start a bounded chat session with this model":"Chat is available after a version passes frozen evaluation",onClick:p=>{p.stopPropagation(),o(d.id)},children:"Chat"}):null,e.jsx(zs,{size:15})]})})]},d.key)})})]})})}function Il({items:t,loading:s,runs:n,state:i,onSelect:a,onUseModel:l}){return s?e.jsxs("div",{className:"labs-table-empty",children:[e.jsx(ke,{className:"spin",size:16})," Loading Models…"]}):t.length?e.jsx("div",{className:"training-table-wrap",children:e.jsxs("table",{className:"training-data-table labs-models-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Model"}),e.jsx("th",{children:"Active"}),e.jsx("th",{children:"Eval"}),e.jsx("th",{children:"Versions"}),e.jsx("th",{children:"Updated"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Actions"})})]})}),e.jsx("tbody",{children:t.map(r=>{const o=Oe(r,n,i),u=o.find(d=>d.current)??null,h=o[0]??null;return e.jsxs("tr",{onClick:()=>a(r.key),children:[e.jsx("td",{children:e.jsxs("button",{className:"labs-workproduct-link",type:"button",onClick:()=>a(r.key),children:[e.jsx("strong",{children:r.name}),e.jsx("span",{children:r.description})]})}),e.jsx("td",{children:u?`Version ${u.number} · ${De(u.plan?.recipe.method)}`:"Not selected"}),e.jsx("td",{children:e.jsx(be,{label:h?h.lineage.promotable?"Passed":h.lineage.frozenEvaluationArtifactId?"Failed":"Not run":"Not run",value:h?.lineage.promotable?"passed":h?.lineage.frozenEvaluationArtifactId?"failed":"not_run"})}),e.jsx("td",{children:o.length}),e.jsx("td",{children:tn(r.updatedAt)}),e.jsx("td",{children:e.jsxs("div",{className:"labs-workproduct-actions",children:[e.jsx("button",{className:"settings-secondary compact labs-workproduct-use",disabled:!u,title:u?"Chat with the active Version":"Set a passing Version active before Chat",type:"button",onClick:d=>{d.stopPropagation(),l(r.id)},children:"Chat"}),e.jsx(zs,{size:15})]})})]},r.key)})})]})}):e.jsx("div",{className:"labs-table-empty",children:"No Models yet."})}function Ml(t){if(t.kind!=="model")return e.jsx("span",{className:"labs-workproduct-na",title:"Training not applicable",children:"—"});const s=`${t.trainingRunCount} training ${t.trainingRunCount===1?"run":"runs"}`;return e.jsxs("span",{className:`labs-workproduct-indicator${t.trainingRunCount>0?" active":""}`,title:s,children:[e.jsx(Ls,{"aria-hidden":"true",size:15}),e.jsx("strong",{"aria-hidden":"true",children:t.trainingRunCount}),e.jsx("span",{className:"sr-only",children:s})]})}function Rl(t){const s=t.evaluationStatus==="passed"?{icon:e.jsx(Bs,{"aria-hidden":"true",size:16}),label:"Evals passed",tone:"positive"}:t.evaluationStatus==="failed"?{icon:e.jsx(Fn,{"aria-hidden":"true",size:16}),label:"Evals failed",tone:"negative"}:{icon:e.jsx(Ln,{"aria-hidden":"true",size:16}),label:"Evals not run",tone:"neutral"};return e.jsxs("span",{className:`labs-workproduct-indicator ${s.tone}`,title:s.label,children:[s.icon,e.jsx("span",{className:"sr-only",children:s.label})]})}function tn(t){const s=new Date(t),n=new Date;return s.toDateString()===n.toDateString()?new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}).format(s):new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",...s.getFullYear()===n.getFullYear()?{}:{year:"2-digit"}}).format(s)}function Al({page:t,total:s,onChange:n}){const i=Math.max(1,Math.ceil(s/kl));return i<=1?null:e.jsxs("nav",{className:"labs-pagination","aria-label":"Pagination",children:[e.jsx("button",{type:"button",disabled:t<=1,onClick:()=>n(t-1),children:"Previous"}),e.jsxs("span",{children:[t," of ",i]}),e.jsx("button",{type:"button",disabled:t>=i,onClick:()=>n(t+1),children:"Next"})]})}async function Rs(t,s,n,i){if(s.onLaunchHandled(s.launchRequest?.id??0),!t.materializedTasksetId)return;s.onSelectedTasksetIdChange(t.materializedTasksetId),s.onDetailTasksetIdChange(t.materializedTasksetId);const l=(await n())?.find(r=>r.id===t.request.createImproveRunId);i(Pe("model",l?.target.kind==="model"?l.target.id??l.id:t.materializedTasksetId))}function As(t,s){return t.request.objective?.trim()||t.proposal?.objective.trim()||t.proposal?.name.trim()||s}function Tl(t){return t&&`${t[0].toUpperCase()}${t.slice(1).replaceAll("_"," ")}`}function _l(t){return t?[...t.jobs.map(s=>`job:${s.id}:${s.status}`),...t.models.map(s=>`model:${s.id}:${s.status}:${s.artifactId}:${s.jobId}`)].sort().join("|"):""}const Ts=10;function ql({closeDetailKind:t,closeDetailRequestId:s,insights:n,onAnswerQuestion:i,onApplyCandidate:a,onApprove:l,onCancel:r,candidateReview:o,onCandidateReviewChange:u,onCreateAgent:h,onDetailOpenChange:d,onImproveAgent:j,onNewModel:f,onOpenPullRequest:p,onOpenCandidateFiles:S,onOpenRunConversation:m,onPause:N,onReconcilePullRequest:b,onRejectCandidate:v,onResume:k,onRevise:T,onUseAgent:L,openSuggestionsRequestId:X,profileView:q,training:x}){const E=q.payload?.profile??null,re=E?.activeProfile??"default",D=Ca({connection:q.connection,profileId:re}),Y=c.useMemo(()=>_l(x.training.payload),[x.training.payload]),[H,_]=c.useState("workproducts"),[J,se]=c.useState("observations"),[B,ae]=c.useState(1),[ie,z]=c.useState(null),[ge,A]=c.useState(null),[fe,K]=c.useState(!1),[U,W]=c.useState(!1),[le,ue]=c.useState(null),[oe,F]=c.useState(null),[je,de]=c.useState(null),[P,Z]=c.useState(null),ee=c.useMemo(()=>Vs({profile:E,training:x.training.payload,runs:D.runs}),[D.runs,E,x.training.payload]),Te=c.useMemo(()=>{const C=new Map((x.training.payload?.tasksets??[]).map(w=>[w.id,w]));return new Map(ee.map(w=>[w.key,Qs({workproduct:w,runs:Us(w,D.runs),taskset:w.tasksetId?C.get(w.tasksetId)??null:null,training:x.training.payload})]))},[D.runs,x.training.payload,ee]),Se=c.useMemo(()=>ee.filter(C=>C.kind!=="model"),[ee]),R=c.useMemo(()=>ee.filter(C=>C.kind==="model"),[ee]),O=ee.find(C=>C.key===ie)??null,Q=n.items.filter(C=>C.status==="active").length+(x.training.payload?.candidates.length??0);c.useEffect(()=>{Y&&D.refresh()},[D.refresh,Y]),c.useEffect(()=>{X<=0||(se("observations"),_("suggestions"))},[X]),c.useEffect(()=>{ie&&!ee.some(C=>C.key===ie)&&z(null)},[ie,ee]),c.useEffect(()=>{if(!(s<=0)){if(z(null),t==="dataset"){A(null),_("datasets");return}_("workproducts")}},[t,s]),c.useEffect(()=>{if(H==="datasets"){d(ge?{kind:"dataset",kindLabel:"Datasets",workproductLabel:x.training.payload?.tasksets.find(C=>C.id===ge)?.name??"Dataset",sectionLabels:[]}:null);return}if(H!=="workproducts"){d(null);return}O||d(null)},[H,d,O,ge,x.training.payload?.tasksets]),c.useEffect(()=>()=>d(null),[d]);function V(C){z(null),ae(1),A(null),_(C)}function Fe(C,w=""){const te=ee.find(pe=>pe.kind==="agent"&&pe.id===C);Z({agentId:C,agentName:te?.name??C,initialObjective:w.trim()})}function he(C){const w=ee.find(xe=>xe.kind==="model"&&xe.id===C);if(!w)return;const te=Oe(w,D.runs,x.training.payload),pe=te.find(xe=>xe.current)??te.find(xe=>xe.lineage.promotable)??null;if(!pe?.taskset)return;if(x.training.payload?.jobs.find(xe=>xe.id===pe.lineage.jobId)?.destinationId==="fireworks"){de(pe.lineage.id);return}x.onChatWithModel(pt({modelId:pe.lineage.id,taskset:pe.taskset}))}return e.jsxs(zi,{activeTab:H,showHeader:!O&&!ge,suggestionCount:Q,onTabChange:V,onCreateAgent:()=>K(!0),onCreateDataset:()=>W(!0),onCreateModel:f,children:[H==="suggestions"?e.jsx(wl,{insights:n,suggestionsView:J,training:x,onSuggestionsViewChange:se,onPlanStarted:()=>_("workproducts")}):H==="datasets"?e.jsx(il,{runs:D.runs,selectedId:ge,state:x.training.payload,training:x.training,onToast:(C,w)=>q.onToast?.(C,w)??0,onSelectedIdChange:A,onCreate:()=>W(!0),onOpenFiles:C=>{x.onSelectedTasksetIdChange(C),x.onOpenTasksetFiles()}}):O?e.jsx(Bi,{connection:q.connection,profile:E,runs:D.runs,training:x.training,workproduct:O,onAnswerQuestion:i,onApplyCandidate:a,onApprove:l,onCancel:r,candidateReview:o,onCandidateReviewChange:u,onChatWithModel:x.onChatWithModel,onOpenPullRequest:p,onOpenCandidateFiles:S,onOpenConversation:m,onLocationChange:d,onRenameAgent:()=>ue({id:O.id,name:O.name}),onOpenDataset:C=>{z(null),A(C),_("datasets")},onPause:N,onReconcilePullRequest:b,onRejectCandidate:v,onResume:k,onRevise:T,onStartAgentChange:(C,w)=>Fe(C,w??""),onToast:x.onToast}):e.jsxs("div",{className:"labs-flat-body",children:[D.error?e.jsx("div",{className:"training-banner error",children:D.error}):null,H==="workproducts"?e.jsx("div",{className:"labs-home-profile-controls",children:e.jsx(Xn,{...q,section:"controls"})}):null,e.jsx(Cl,{frontierBaselineRuns:x.training.payload?.frontierBaselineRuns??[],loading:D.loading&&!ee.length,items:Se.slice((B-1)*Ts,B*Ts),progressionByKey:Te,showType:!0,onSelect:z,onUseAgent:L,onUseModel:he,onUseSkill:C=>q.onSkillCommand?.(`$${C} `)}),e.jsx(Al,{page:B,total:Se.length,onChange:ae}),H==="workproducts"?e.jsxs("section",{className:"labs-home-models",children:[e.jsx("div",{className:"labs-section-heading",children:e.jsx("h2",{children:"Models"})}),e.jsx(Il,{loading:!1,items:R.slice(0,10),runs:D.runs,state:x.training.payload,onSelect:z,onUseModel:he})]}):null]}),x.launchRequest&&x.training.payload?e.jsx(He,{defaultModel:x.defaultModel,initialObjective:x.launchRequest.objective,initialSessionIds:x.launchRequest.initialSessionIds??[],localProjects:x.localProjects??[],onClose:()=>x.onLaunchHandled(x.launchRequest.id),onModelCreatedFromTaskset:async(C,w)=>{x.onLaunchHandled(x.launchRequest.id),x.onSelectedTasksetIdChange(C.id),x.onDetailTasksetIdChange(C.id),z(Pe("model",w.target.id??w.id)),_("workproducts"),await D.refresh()},onTasksetCreated:async C=>{await Rs(C,x,D.refresh,z),_("workproducts")},preferences:x.preferences,providerSettings:x.providerSettings,reasoningEffort:x.reasoningEffort,sessions:x.sessions,sources:x.training.payload.sources,training:x.training}):null,fe?e.jsx(He,{defaultModel:x.defaultModel,initialObjective:null,localProjects:x.localProjects??[],onClose:()=>K(!1),onTasksetCreated:async C=>{const w=As(C,"Create a useful Agent from the approved Taskset."),te=await h(w,C.request.createImproveRunId);await D.refresh(),_("workproducts"),z(Pe("agent",te.target.id??te.id)),K(!1)},preferences:x.preferences,providerSettings:x.providerSettings,reasoningEffort:x.reasoningEffort,sessions:x.sessions,sources:x.training.payload?.sources??[],targetIntent:{kind:"agent",id:null,displayName:null,operation:"create"},training:x.training}):null,U?e.jsx(He,{defaultModel:x.defaultModel,initialObjective:null,localProjects:x.localProjects??[],onClose:()=>W(!1),onTasksetCreated:async C=>{W(!1),z(null),_("datasets"),A(C.materializedTasksetId),await D.refresh()},preferences:x.preferences,providerSettings:x.providerSettings,reasoningEffort:x.reasoningEffort,resourceIntent:"dataset",sessions:x.sessions,sources:x.training.payload?.sources??[],targetIntent:{kind:null,id:null,displayName:null,operation:"create"},training:x.training}):null,P?e.jsx(He,{defaultModel:x.defaultModel,initialObjective:P.initialObjective,localProjects:x.localProjects??[],onClose:()=>Z(null),onTasksetCreated:async C=>{const w=As(C,P.initialObjective);await j(P.agentId,w,P.agentName,C.request.createImproveRunId),await D.refresh(),_("workproducts"),z(Pe("agent",P.agentId)),Z(null)},preferences:x.preferences,providerSettings:x.providerSettings,reasoningEffort:x.reasoningEffort,sessions:x.sessions,sources:x.training.payload?.sources??[],targetIntent:{kind:"agent",id:P.agentId,displayName:P.agentName,operation:"improve"},training:x.training}):null,oe?e.jsx(He,{defaultModel:x.defaultModel,initialCreation:oe,initialObjective:oe.request.objective,localProjects:x.localProjects??[],onClose:()=>F(null),onTasksetCreated:async C=>{await Rs(C,x,D.refresh,z),_("workproducts"),F(null)},preferences:x.preferences,providerSettings:x.providerSettings,reasoningEffort:x.reasoningEffort,sessions:x.sessions,sources:x.training.payload?.sources??[],targetIntent:oe.request.targetIntent,training:x.training}):null,je?(()=>{const C=x.training.payload?.models.find(te=>te.id===je),w=x.training.payload?.tasksets.find(te=>te.id===C?.tasksetId);return!C||!w?null:e.jsx(qs,{lineage:C,taskset:w,training:x.training,onChat:x.onChatWithModel,onClose:()=>de(null)})})():null,le?e.jsx(Oi,{agentId:le.id,currentName:le.name,onClose:()=>ue(null),onRename:async C=>{if(!q.connection)throw new Error("Connect OpenPond before renaming an agent.");q.onError(null),await Xe.profileAgentRename(q.connection,le.id,{name:C}),q.onPayload(await Xe.bootstrap(q.connection)),q.onToast?.(`Renamed agent to ${C}.`,"success")}}):null]})}export{ql as LabsRoute};
|