openpond 0.2.51 → 0.2.53
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/app-server.d.ts +1 -0
- package/dist/app-server.js +1 -1
- package/dist/chunks/{app-layer-RRFI27N4.js → app-layer-I7MZYVLL.js} +1 -1
- package/dist/chunks/{app-server-runtime-4YKIZB22.js → app-server-runtime-KZP2LB5X.js} +1 -1
- package/dist/chunks/{apps-NELJL377.js → apps-TM74FFQB.js} +1 -1
- package/dist/chunks/{chunk-OC6UWKBL.js → chunk-3LX6RU3C.js} +2 -2
- package/dist/chunks/{chunk-7YR6CBNU.js → chunk-4SHKI3BH.js} +1 -1
- package/dist/chunks/{chunk-7MXZJQS7.js → chunk-4TZHH5FC.js} +1 -1
- package/dist/chunks/{chunk-ZCWHVLJ4.js → chunk-5TNDPNS3.js} +1 -1
- package/dist/chunks/{chunk-42GOV5ZU.js → chunk-6JAN4RMN.js} +1 -1
- package/dist/chunks/{chunk-OE2VF6KU.js → chunk-6VF3Q6QJ.js} +1 -1
- package/dist/chunks/chunk-7ZG3IT7C.js +9 -0
- package/dist/chunks/{chunk-EPY7M5XS.js → chunk-AFUDIT36.js} +1 -1
- package/dist/chunks/{chunk-Q4H3NUVW.js → chunk-AH22RHPS.js} +2 -2
- package/dist/chunks/{chunk-DLZP22WV.js → chunk-FPUUZQUP.js} +1 -1
- package/dist/chunks/{chunk-O7VGFMDO.js → chunk-GCOUYYHG.js} +1 -1
- package/dist/chunks/{chunk-MASJQWA2.js → chunk-GXSTZBM6.js} +1 -1
- package/dist/chunks/{chunk-IOQUF34U.js → chunk-H2VT22JK.js} +1 -1
- package/dist/chunks/{chunk-TBNBCOW7.js → chunk-NHFGEVVH.js} +1 -1
- package/dist/chunks/{chunk-JCCU3VFK.js → chunk-PQHTZ5CP.js} +1 -1
- package/dist/chunks/{chunk-QJRXTIOC.js → chunk-USKE34VR.js} +1 -1
- package/dist/chunks/{chunk-2ZJJFBIA.js → chunk-USMZT5FZ.js} +12 -12
- package/dist/chunks/{chunk-KXEG7HCG.js → chunk-XGE2XI6M.js} +115 -114
- package/dist/chunks/{chunk-UBFRWC6I.js → chunk-YD55Z5H3.js} +1 -1
- package/dist/chunks/{chunk-RLZPX4YP.js → chunk-YJ4PNAST.js} +1 -1
- package/dist/chunks/{cli-ZLDLOKPL.js → cli-JVB345H2.js} +1 -1
- package/dist/chunks/{configuration-command-SA56RV5B.js → configuration-command-MATM4XR5.js} +1 -1
- package/dist/chunks/{connected-evidence-IVSQZYIB.js → connected-evidence-YDPGNHLP.js} +1 -1
- package/dist/chunks/{core-commands-W5IGIITV.js → core-commands-MTV4EKXY.js} +1 -1
- package/dist/chunks/{datasets-KSO2UG6R.js → datasets-CP3IT47T.js} +1 -1
- package/dist/chunks/{desktop-test-6HXFM7PO.js → desktop-test-IAZC5MAH.js} +1 -1
- package/dist/chunks/{dist-BLBZENVB.js → dist-SAABJU5F.js} +1 -1
- package/dist/chunks/{evaluation-coordination-MOFBXRXN.js → evaluation-coordination-EPHLZXYM.js} +1 -1
- package/dist/chunks/{experiment-improvements-TDHM6NEA.js → experiment-improvements-6JTOPA74.js} +1 -1
- package/dist/chunks/{experiments-HFPDFD4I.js → experiments-XHPFGECH.js} +1 -1
- package/dist/chunks/{extension-R373LYIB.js → extension-GX7DLW2X.js} +1 -1
- package/dist/chunks/{help-PEFQDDTA.js → help-WLKSACLZ.js} +1 -1
- package/dist/chunks/{hosted-experiment-improvement-NTYYSPQX.js → hosted-experiment-improvement-HAB3UE6A.js} +1 -1
- package/dist/chunks/{hosted-harness-runtime-FZZLWLBR.js → hosted-harness-runtime-YM23QNDK.js} +1 -1
- package/dist/chunks/{hosted-profile-candidate-LVNKOTKJ.js → hosted-profile-candidate-EOBGKQAS.js} +1 -1
- package/dist/chunks/{hosted-profile-compiler-JODGZCA7.js → hosted-profile-compiler-OZAOZ2ES.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-control-7B3RAZU2.js → hosted-profile-evaluation-control-RJ6XJZCS.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-inspection-FPCV42DD.js → hosted-profile-evaluation-inspection-SJIDXPHI.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-preparation-F2SPAEKK.js → hosted-profile-evaluation-preparation-26EI5LJR.js} +1 -1
- package/dist/chunks/{human-review-HRGGACEM.js → human-review-AAVMISBF.js} +1 -1
- package/dist/chunks/{import-RSAQ44GG.js → import-V3HUGRHR.js} +1 -1
- package/dist/chunks/{opchat-I7ZWJ5XK.js → opchat-QK43DXTY.js} +1 -1
- package/dist/chunks/{organizations-LFCZIH7E.js → organizations-SRPAWKC7.js} +1 -1
- package/dist/chunks/{profile-EPIX5QVK.js → profile-C6CQNVYE.js} +1 -1
- package/dist/chunks/{project-agent-DGOPMECP.js → project-agent-GZV5HNYI.js} +1 -1
- package/dist/chunks/{sandbox-command-Q5F6VUOS.js → sandbox-command-4TJXQTKT.js} +1 -1
- package/dist/chunks/{sandbox-template-7GICPIKJ.js → sandbox-template-BBGGPJMI.js} +1 -1
- package/dist/chunks/{src-DH5AQ4Z7.js → src-CR6UZYTX.js} +1 -1
- package/dist/chunks/src-P3VYLFLI.js +329 -0
- package/dist/chunks/{teams-bot-Z6RJGHME.js → teams-bot-7I4BAUVO.js} +1 -1
- package/dist/chunks/{workspaces-XIQNPAP7.js → workspaces-MFZ3OO6O.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/web/assets/App-CO2F717V.css +1 -0
- package/dist/web/assets/App-CuhaCsfb.js +235 -0
- package/dist/web/assets/{AppDialog-1iGodoot.js → AppDialog-BdusXgU0.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-udtBdWFn.js → AppTerminalPanel-C4uRpnBz.js} +2 -2
- package/dist/web/assets/{AppsView-DhKsU4yi.js → AppsView-BS1czXUP.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-BnOyqIQT.js → BrowserSidebar-Bl7V6YO2.js} +1 -1
- package/dist/web/assets/{CartesianChart-C24DAywn.js → CartesianChart-BstFbsdn.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-DgmOF5Fe.js → CollaborationTabs-B8YAf0c1.js} +1 -1
- package/dist/web/assets/{CommandMenu-CUNGtHwS.js → CommandMenu-DZct7zUJ.js} +1 -1
- package/dist/web/assets/{CommunityView-CE7qeJnr.js → CommunityView-CR0-W-uG.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-BixNsg2a.js → ComposerCreateImproveStrip-DR-Qo7b4.js} +1 -1
- package/dist/web/assets/{GetStartedView-B8gCwmBX.js → GetStartedView-xqQoMMei.js} +1 -1
- package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +1 -0
- package/dist/web/assets/{HostedModelLearningSettings-WUaqzNsa.js → HostedModelLearningSettings-De3i9wF4.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-Cx0kL69J.js → LabModelVersionDetailPage-DAY1MmqP.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-DRggqZ1j.js → LabSkillSidebar-DLnIgnry.js} +1 -1
- package/dist/web/assets/{LabsRoute-BujTZhqC.js → LabsRoute-CXJRJMhr.js} +4 -4
- package/dist/web/assets/{MainChatThread-CyA_644R.js → MainChatThread-BwAla81W.js} +2 -2
- package/dist/web/assets/MainPane-CakOBCHw.js +19 -0
- package/dist/web/assets/{MarkdownText-DJI5LwT0.js → MarkdownText-gJMuefaJ.js} +21 -21
- package/dist/web/assets/{NativeSkillSidebar-CkFpWxjd.js → NativeSkillSidebar-Dlxb8iOC.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-DXcRHHsu.js → NewExperienceSwitcher-DM-cqJ-K.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-gDzX_ZIJ.js → NewProjectDialog-Cu1q75gq.js} +1 -1
- package/dist/web/assets/{OutputsPage-J_k-_N82.js → OutputsPage-DiXMkasl.js} +1 -1
- package/dist/web/assets/{ProjectsPage-BsyZmvlg.js → ProjectsPage-DqiBHiCB.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-Bz8puMUB.js → RightChatPanelStack-VaOOmxwd.js} +1 -1
- package/dist/web/assets/{RightSidebarHomePanel-DmorYb6p.js → RightSidebarHomePanel-CeSFJM5s.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-BFDzQUyL.js → ScheduledWorkPage-D1jRQxFs.js} +1 -1
- package/dist/web/assets/{SettingsView-BB7wCdbr.js → SettingsView-RA9OXgcu.js} +3 -3
- package/dist/web/assets/{TeamChatView-CZ3b7rq2.js → TeamChatView-DM0adMtj.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-Ck43Qri3.js → TerminalOverlay-CFlH51DD.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-ejqPZm3g.js → TrainingCreationPanel-CgIBVGha.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-Cy2AQxxL.js → TrainingDraftPanel-Bbo3RRie.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-B7nyMItm.js → UsageSettingsSection-CSRjJUSa.js} +1 -1
- package/dist/web/assets/{WorkSidebarPanel-BfjAc097.js → WorkSidebarPanel-DwlEMEoG.js} +1 -1
- package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +14 -0
- package/dist/web/assets/{WorkspaceEnvironmentMenu-B-K9XgFB.js → WorkspaceEnvironmentMenu-Byjngd9V.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-BJVFx_L3.js → WorkspaceGitDialogs-Dgmg-6XG.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-p-FWMXoZ.js → WorkspaceMonacoEditor-BR4qxMgU.js} +3 -3
- package/dist/web/assets/{arrow-up-right-CFGI2YSt.js → arrow-up-right-H0pvnH2s.js} +1 -1
- package/dist/web/assets/{chunk-UHVJOMWN-BAlur2vw.js → chunk-UHVJOMWN-BqXRe639.js} +1 -1
- package/dist/web/assets/{clipboard-DIIxBort.js → clipboard-BZzZ82Bk.js} +1 -1
- package/dist/web/assets/{cloud-upload-BaQFNCTp.js → cloud-upload-CJPYPVl8.js} +1 -1
- package/dist/web/assets/{cssMode-6LOkSggB.js → cssMode-WC4Rg1l-.js} +1 -1
- package/dist/web/assets/{folder-open-DZSxfPtr.js → folder-open-sLZJxLQy.js} +1 -1
- package/dist/web/assets/{folder-plus-21v4D_Vx.js → folder-plus-C84wrpt_.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-CgGixL64.js → git-commit-horizontal-Cotm7KEC.js} +1 -1
- package/dist/web/assets/{htmlMode-B5uRraNd.js → htmlMode-C6oZGeaB.js} +1 -1
- package/dist/web/assets/{index-DOMrqhcz.js → index-BxWTVKtn.js} +2 -2
- package/dist/web/assets/index-dSmk3FLJ.css +1 -0
- package/dist/web/assets/{info-BGTcmow7.js → info-Dc81lEfw.js} +1 -1
- package/dist/web/assets/{jsonMode-D3m8N4Gi.js → jsonMode-BET4LQIn.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-DoyipLsB.js → lspLanguageFeatures-BPxA_-Kg.js} +1 -1
- package/dist/web/assets/{minimize-2-B01qSko4.js → minimize-2-Bs7MVN3C.js} +1 -1
- package/dist/web/assets/{monaco.contribution-Bc22foTx.js → monaco.contribution-7AUuf2NS.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BJyfaGX2.js → monaco.contribution-BH6kkO4b.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DuRhJ6zU.js → monaco.contribution-DFzEyaHi.js} +2 -2
- package/dist/web/assets/{monaco.contribution--U8v3jpa.js → monaco.contribution-DXzyQfVi.js} +2 -2
- package/dist/web/assets/{monitor-eZP8ZTHe.js → monitor-DXL019Wf.js} +1 -1
- package/dist/web/assets/{play-CGsWFR_B.js → play-CXkxUZeU.js} +1 -1
- package/dist/web/assets/{python-BNrLZWud.js → python-PzBkTjWx.js} +1 -1
- package/dist/web/assets/{save-BLgjrccP.js → save-DpezrtH2.js} +1 -1
- package/dist/web/assets/{square-CI1qNtvE.js → square-oy7f5Ce6.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-B_GcTCnw.js → toggleHighContrast-Cto-fOXm.js} +1 -1
- package/dist/web/assets/{tsMode-CmruH_ys.js → tsMode-BYA4LNc6.js} +1 -1
- package/dist/web/assets/{upload-DnlgGS2x.js → upload-C5YFNgtS.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BBhGUfK-.js → useLocalAgentSchedules-CnyTsqlf.js} +1 -1
- package/dist/web/assets/useProviderSettings-B_KeQjE5.js +5 -0
- package/dist/web/assets/{useSessionTurnCache-BwscKl5i.js → useSessionTurnCache-DICuJSJW.js} +1 -1
- package/dist/web/assets/{wifi-off-Dz-4EDCc.js → wifi-off-nzHj7JXp.js} +1 -1
- package/dist/web/assets/{workers-Bi9u46cp.js → workers-Dboaw6f_.js} +1 -1
- package/dist/web/assets/{yaml-DVTkiRnh.js → yaml-uuY5JmO8.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-7K72KS5C.js +0 -9
- package/dist/chunks/src-STK4YHBI.js +0 -329
- package/dist/web/assets/App-BI-uOpnP.js +0 -234
- package/dist/web/assets/App-DkH8CeoI.css +0 -1
- package/dist/web/assets/HostedModelLearningReview-CitgUNfC.js +0 -1
- package/dist/web/assets/MainPane-LaEtxydD.js +0 -19
- package/dist/web/assets/WorkspaceDiffPanel-D9hAV8l7.js +0 -14
- package/dist/web/assets/index-DJcUXSsN.css +0 -1
- package/dist/web/assets/useProviderSettings-DfhdkKdC.js +0 -5
- /package/dist/chunks/{chunk-XDMUD4FW.js → chunk-2JO2KWT3.js} +0 -0
- /package/dist/chunks/{chunk-XBCIBAXD.js → chunk-GS2NKNKG.js} +0 -0
package/dist/web/assets/{useLocalAgentSchedules-BBhGUfK-.js → useLocalAgentSchedules-CnyTsqlf.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as i}from"./index-
|
|
1
|
+
import{r as i}from"./index-BxWTVKtn.js";import{G as s}from"./App-CuhaCsfb.js";const m=5e3;function _(t){const[h,n]=i.useState([]),[y,r]=i.useState(!1),[p,l]=i.useState(null),[o,w]=i.useState(()=>new Set);i.useEffect(()=>{if(!t){n([]),l(null),r(!1);return}const e=t;let a=!1;async function d(S){if(!a){S&&r(!0);try{const g=await s.localAgentSchedules(e);if(a)return;n(g.schedules),l(null)}catch(g){a||l(f(g))}finally{!a&&S&&r(!1)}}}d(!0);const u=window.setInterval(()=>{d(!1)},m);return()=>{a=!0,window.clearInterval(u)}},[t]);async function A(){if(t){r(!0);try{const e=await s.syncLocalAgentSchedules(t);n(e.schedules),l(null)}catch(e){l(f(e))}finally{r(!1)}}}async function E(e){if(!(!t||o.has(e.id))){c(e.id,!0);try{await s.runLocalAgentSchedule(t,e.id);const a=await s.localAgentSchedules(t);n(a.schedules),l(null)}catch(a){l(f(a))}finally{c(e.id,!1)}}}async function L(e){if(!(!t||o.has(e.id))){c(e.id,!0);try{await s.patchLocalAgentSchedule(t,e.id,{enabled:!e.enabled});const a=await s.localAgentSchedules(t);n(a.schedules),l(null)}catch(a){l(f(a))}finally{c(e.id,!1)}}}function c(e,a){w(d=>{const u=new Set(d);return a?u.add(e):u.delete(e),u})}return{error:p,loading:y,pendingScheduleIds:o,refresh:A,run:E,schedules:h,toggle:L}}function f(t){return t instanceof Error?t.message:String(t)}export{_ as u};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{r as d,j as e}from"./index-BxWTVKtn.js";import{c as Ne,l as Pe,bl as G,al as oe,as as ce,an as de,ck as ke,z as ue,bs as Se,co as we,cp as Z,bo as Ee,X as Me,m as Ae,D as Oe,G as B,$ as se}from"./App-CuhaCsfb.js";import{S as De}from"./save-DpezrtH2.js";import{T as te}from"./MarkdownText-gJMuefaJ.js";const Re=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],F=Ne("key-round",Re);function $e(n){const i=d.useRef(null),f=d.useRef(n);return f.current=n,d.useEffect(()=>{const a=document.activeElement instanceof HTMLElement?document.activeElement:null,s=()=>[...i.current?.querySelectorAll('button:not(:disabled), input:not(:disabled), select:not(:disabled), a[href], [tabindex="0"]')??[]].filter(u=>u.getClientRects().length>0);s()[0]?.focus();const b=u=>{if(document.querySelector(".native-setup-terminal")||(u.key==="Escape"&&(u.preventDefault(),u.stopPropagation(),f.current()),u.key!=="Tab"))return;const l=s(),N=l[0],O=l.at(-1);u.shiftKey&&document.activeElement===N?(u.preventDefault(),O?.focus()):!u.shiftKey&&document.activeElement===O&&(u.preventDefault(),N?.focus())};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b),a?.isConnected&&a.focus()}},[]),i}const K=["codex","claude-code","grok-build","opencode"];function V(n){return["claude-code","grok-build","opencode"].includes(n)}const Te={codex:{executable:"codex",install:"https://developers.openai.com/codex/cli"},"claude-code":{executable:"claude",install:"https://code.claude.com/docs/en/setup"},"grok-build":{executable:"grok",install:"https://docs.x.ai/build/cli"},opencode:{executable:"opencode",install:"https://opencode.ai/docs"}},J=(n,i)=>JSON.stringify([n||"",i||""]);function le({connection:n,providerId:i,config:f,status:a,cachedModels:s,busy:b,onCheck:u}){const[l,N]=d.useState(null),[O,E]=d.useState(null),[x,_]=d.useState(null),[v,P]=d.useState(!1),[k,M]=d.useState(f.binaryPath??""),[j,D]=d.useState(f.sourceHome??""),t=d.useRef(null),p=d.useRef(null),y=d.useRef(u);y.current=u;const R=Te[i],S=J(f.binaryPath,f.sourceHome),A=J(k.trim(),j.trim())!==S,g=b||v||l!==null,w=d.useCallback(async c=>{t.current?.abort();const h=new AbortController;t.current=h;const $=setTimeout(()=>h.abort(new Error("Connection check timed out. Retry when the agent is available.")),45e3);P(!0),E(null);try{const z=await y.current(i,h.signal,c);t.current===h&&!h.signal.aborted&&_(z)}catch(z){t.current===h&&E(z instanceof Error?z.message:"Could not check the agent.")}finally{clearTimeout($),t.current===h&&(t.current=null,P(!1))}},[i]);d.useEffect(()=>{if(M(f.binaryPath??""),D(f.sourceHome??""),p.current===S){p.current=null;return}N(null),_(null),w()},[w,S,f.binaryPath,f.sourceHome,n?.serverUrl,n?.token]),d.useEffect(()=>()=>{const c=t.current;t.current=null,c?.abort()},[]);async function L(c){c.preventDefault(),!(!A||g)&&(p.current=J(k.trim(),j.trim()),await w({binaryPath:k.trim()||null,sourceHome:j.trim()||null}),p.current=null)}async function T(){if(!n||x?.status!=="needs_login")return;const c=new AbortController,h=setTimeout(()=>c.abort(),1e4);t.current?.abort(),t.current=c,P(!0),E(null);try{const $=await ue(n,`/v1/providers/${i}/native-setup`,{method:"POST",body:JSON.stringify({action:"login"}),signal:c.signal});t.current===c&&!c.signal.aborted&&N($.command)}catch($){t.current===c&&E($ instanceof Error?$.message:"Could not open native login.")}finally{clearTimeout(h),t.current===c&&(t.current=null,P(!1))}}const o=x?.settings.modelCaches[i]?.models??s,r=[...new Set(o.map(c=>Pe(c.displayName||c.id)))],m=O??x?.error;return e.jsxs("div",{className:"provider-dialog-body native-agent-setup",children:[e.jsxs("p",{children:["Uses your existing ",a.displayName," installation and login."]}),e.jsxs("div",{className:"native-connection-status",children:[e.jsx("div",{role:"status","aria-live":"polite",children:v?e.jsxs(e.Fragment,{children:[e.jsx(G,{size:16,className:"settings-spin"}),e.jsx("span",{children:"Checking connection…"})]}):x?.status==="ready"?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:16}),e.jsx("span",{children:f.enabled?"Connected":"Connected, disabled for chat"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ce,{size:16}),e.jsx("span",{children:x?.status==="missing"?"Installation not found":x?.status==="needs_login"?"Sign in required":"Connection needs attention"})]})}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:g||!n,onClick:()=>{w()},title:"Refresh connection","aria-label":"Refresh connection",children:[e.jsx(de,{size:14})," Refresh"]})]}),m?e.jsx("p",{role:"alert",children:m}):null,r.length?e.jsxs("section",{className:"native-model-section","aria-label":"Available models",children:[e.jsxs("div",{className:"native-model-heading",children:[e.jsx("h3",{children:"Models"}),e.jsxs("small",{children:[r.length," available"]})]}),e.jsx("div",{className:"native-model-list",tabIndex:0,"aria-label":"Models",role:"list",children:r.map(c=>e.jsx("span",{role:"listitem",children:c},c))}),e.jsx("small",{children:"Choose a model when starting a chat."})]}):null,x?.version?e.jsx("small",{className:"native-agent-version",children:x.version}):null,x?.status==="needs_login"?e.jsx("button",{type:"button",className:"settings-secondary",disabled:g||A||!n,title:A?"Save changes before signing in to a different installation":void 0,onClick:()=>{T()},children:"Sign in"}):null,x?.status==="missing"?e.jsxs("p",{children:[e.jsxs("a",{href:R.install,target:"_blank",rel:"noreferrer",children:["Install ",a.displayName]}),", then refresh this connection."]}):null,(O||x?.status==="unavailable")&&!v?e.jsx("button",{type:"button",className:"settings-secondary",disabled:g||!n,onClick:()=>{w()},children:"Retry"}):null,l&&n?e.jsx(ke,{connection:n,command:l,onComplete:()=>{N(null),w()},onClose:()=>{N(null),w()}}):null,V(i)?e.jsxs("details",{children:[e.jsx("summary",{children:"Advanced"}),e.jsxs("form",{className:"provider-card-form",onSubmit:c=>{L(c)},children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Executable"}),e.jsx("input",{value:k,placeholder:`${R.executable} from PATH, or an absolute path`,disabled:g,onChange:c=>M(c.currentTarget.value)})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Source home"}),e.jsx("input",{value:j,placeholder:"Use the agent's existing home",disabled:g,onChange:c=>D(c.currentTarget.value)})]}),A?e.jsx("button",{className:"settings-secondary",disabled:g||!n,children:"Save changes"}):null]})]}):null]})}const _e=[{value:"local_secret",label:"Saved key",description:"Encrypted on this machine"},{value:"env",label:"Environment variable",description:"Read by the local server"}],ze=120,Ue=new Set(["openai","xai","zai"]),Le=new Set(["chatgpt-subscription"]),Be="https://api.z.ai/api/coding/paas/v4";function ae(n){return n.split(/[\n,]/).map(i=>i.trim()).filter(Boolean)}function he(n){return n?n.available?"Ready":n.credential.connected?"Configured":n.credential.lastError||n.lastError?"Needs attention":n.id==="codex"?"Needs Codex login":V(n.id)?"Check connection":n.routing.localByok?"Needs key":n.enabled?"Enabled":"Off":"Unknown"}function pe(n){return n?n.available?"ready":n.credential.connected?"configured":n.credential.lastError||n.lastError||n.id==="codex"?"warning":"muted":"unknown"}function ie(n){return n.credential.connected?n.credential.redacted?n.credential.redacted:n.credential.source==="native_agent_login"?"Native login":n.credential.source==="chatgpt_subscription"?"ChatGPT subscription":n.credential.source:n.credential.lastError??"Not connected"}function Ge(n){return n?.trim().replace(/\/+$/,"")??""}function me(n,i){return n.id==="zai"&&Ge(i.providers.zai?.baseUrl)===Be}function Fe(n,i){return!n.credential.connected||!n.routing.localByok?"":n.credential.source==="native_agent_login"?"Native login":n.credential.source==="chatgpt_subscription"?"Subscription":me(n,i)?"Coding Plan key":"API key"}function Ve(n,i){const f=i.modelCaches[n.id];if(n.routing.localByok&&n.enabled&&!n.credential.connected||!n.enabled&&n.id!=="openpond")return"";const a=Math.max(f?.models.length??0,n.modelIds.length),s=n.defaultModel?Ee(n.defaultModel,i,n.id):"",b=a===1?"1 model":`${a} models`;return[Fe(n,i),f?b:"",s].filter(Boolean).join(" · ")}function He(n){return n!=="openpond"&&Z(n)}function fe(n){return n?Ue.has(n.id)||n.credentialModes.some(i=>Le.has(i)):!1}function Ke(n){return fe(n)?["api","subscription"]:["api"]}function re(n,i){return!n||!i||!fe(n)?"api":n.credential.source==="chatgpt_subscription"||me(n,i)?"subscription":"api"}function qe(n){if(!n)return"Never";const i=new Date(n);return Number.isNaN(i.getTime())?n:i.toLocaleString()}function Je(n,i,f=ze){const a=[],s=new Set,b=new Set(i.map(l=>l.trim()).filter(Boolean)),u=l=>{s.has(l.value)||a.length>=f||(s.add(l.value),a.push(l))};for(const l of n)b.has(l.value)&&u(l);for(const l of n)u(l);return a}function nn({checkNativeProvider:n,connection:i,account:f,codex:a,providers:s,providerBusy:b,validationMessage:u,deleteProviderCredential:l,loadProviderModels:N,refreshProviderModels:O,saveProviderConfig:E,saveProviderCredential:x,startOpenAiSubscriptionAuth:_,validateProvider:v}){const[P,k]=d.useState(null),M=K.filter(t=>s?.statuses[t]),j=P?s?.statuses[P]??null:null;function D(t,p){k(t),p&&N(t)}return e.jsxs("section",{className:"account-settings provider-connections-settings",children:[e.jsx("h1",{children:"Providers"}),e.jsxs("div",{className:"provider-connections-intro",children:[e.jsx("p",{children:"Manage your installed agents and login. Sync their conversations from Connections."}),e.jsx("button",{type:"button",className:"settings-secondary",onClick:()=>{Se({kind:"view",view:"apps"})},children:"Connections & apps"})]}),s?e.jsx("div",{className:"provider-connections-panel",children:M.length>0?e.jsx("div",{className:"provider-connections-grid",role:"list",children:M.map(t=>{const p=s.statuses[t],y=s.modelCaches[t],R=p.modelIds.length>0&&(y?.models.length??0)<p.modelIds.length,S=b?.startsWith(`${t}:`)??!1,A=He(t),g=t==="openpond"||!!s.providers[t]?.enabled;return e.jsxs("div",{className:"provider-connection-card",role:"listitem",children:[e.jsxs("div",{className:"provider-connection-identity",children:[e.jsx("strong",{children:p.displayName}),e.jsxs("label",{className:"provider-toggle","aria-label":`Enable ${p.displayName}`,children:[e.jsx("input",{type:"checkbox",checked:g,disabled:!A||S,onChange:w=>{E(t,{enabled:w.currentTarget.checked})}}),e.jsx("span",{})]})]}),e.jsxs("div",{className:`provider-connection-status ${pe(p)}`,children:[S?e.jsx(G,{size:13,className:"settings-spin"}):null,e.jsx("span",{children:he(p)})]}),e.jsx("p",{children:Ve(p,s)||(p.enabled?"Check your installation and sign in to use this agent.":"Enable this agent to use it in chats.")}),t==="codex"||t==="claude-code"?e.jsx(we,{connection:i,provider:t}):null,e.jsx("button",{type:"button",className:"settings-secondary",onClick:()=>{D(t,R)},children:"Manage"})]},t)})}):e.jsx("div",{className:"empty-account-list provider-manager-empty",children:e.jsx("strong",{children:"No agent providers available"})})}):null,u?e.jsxs("div",{className:"settings-footnote provider-validation-message",children:[e.jsx("span",{children:"Last validation"}),e.jsx("strong",{children:u})]}):null,P&&j&&s?e.jsx(Ze,{checkNativeProvider:n,connection:i,account:f,codex:a,providerId:P,providerBusy:b,settings:s,status:j,onClose:()=>k(null),onDeleteCredential:l,onRefreshModels:O,onSaveConfig:E,onSaveCredential:x,onStartOpenAiSubscriptionAuth:_,onValidate:v}):null]})}function Ze({checkNativeProvider:n,connection:i,account:f,codex:a,providerId:s,providerBusy:b,settings:u,status:l,onClose:N,onDeleteCredential:O,onRefreshModels:E,onSaveConfig:x,onSaveCredential:_,onStartOpenAiSubscriptionAuth:v,onValidate:P,conversationPanel:k}){const M=$e(N),[j,D]=d.useState("setup"),t=d.useId(),p=u.providers[s],y=u.modelCaches[s],R=d.useId(),S=d.useRef(s),A=Math.max(y?.models.length??0,l.modelIds.length),g=l.routing.localByok&&Z(s)&&s!=="codex"&&!V(s),w=d.useMemo(()=>g?Ke(l):[],[g,l]),L=w.includes("subscription"),[T,o]=d.useState(()=>re(l,u)),r=g&&T==="subscription"&&L,m=h=>`${R}-${h}-panel`,c=s==="codex"?"Codex app server":p?.baseUrl??(s==="openpond"?f?.chatApiBaseUrl:null)??"Not set";return d.useEffect(()=>{if(S.current!==s){S.current=s,o(re(l,u));return}g&&!w.includes(T)&&o("api")},[T,w,g,s,u,l]),e.jsx("div",{className:"git-dialog-backdrop provider-dialog-backdrop",role:"presentation",onMouseDown:N,children:e.jsxs("section",{ref:M,className:`git-dialog provider-details-dialog${k?" agent-setup-dialog":""}`,role:"dialog","aria-modal":"true","aria-label":`${l.displayName} provider details`,onMouseDown:h=>h.stopPropagation(),children:[e.jsx("button",{className:"git-dialog-close",type:"button",title:"Close","aria-label":"Close",onClick:N,children:e.jsx(Me,{size:16})}),e.jsxs("div",{className:"provider-dialog-header",children:[e.jsxs("div",{children:[e.jsx("h2",{children:l.displayName}),e.jsx("span",{children:K.includes(s)?"Installation and login":"API and subscription settings"})]}),e.jsx("div",{className:`provider-state-pill ${pe(l)}`,children:he(l)})]}),K.includes(s)&&p?e.jsxs("label",{className:"provider-chat-toggle",children:[e.jsxs("span",{className:"provider-toggle",children:[e.jsx("input",{type:"checkbox","aria-label":`Enable ${l.displayName} for chat`,checked:p.enabled,disabled:b!==null,onChange:h=>{x(s,{enabled:h.target.checked})}}),e.jsx("span",{"aria-hidden":"true"})]}),e.jsxs("span",{children:["Use ",l.displayName," for chats"]})]}):null,k?e.jsxs("div",{className:"surface-tabs provider-agent-tabs",role:"tablist","aria-label":"Agent settings",onKeyDown:h=>{if(h.key!=="ArrowLeft"&&h.key!=="ArrowRight")return;h.preventDefault();const $=j==="setup"?"sync":"setup";D($),h.currentTarget.querySelector(`#${CSS.escape(`${t}-${$}`)}`)?.focus()},children:[e.jsx("button",{type:"button",role:"tab",id:`${t}-setup`,"aria-controls":`${t}-setup-panel`,"aria-selected":j==="setup",tabIndex:j==="setup"?0:-1,onClick:()=>D("setup"),children:"Agent setup"}),e.jsx("button",{type:"button",role:"tab",id:`${t}-sync`,"aria-controls":`${t}-sync-panel`,"aria-selected":j==="sync",tabIndex:j==="sync"?0:-1,onClick:()=>D("sync"),children:"Conversation sync"})]}):null,e.jsxs("div",{hidden:j!=="setup",id:`${t}-setup-panel`,role:k?"tabpanel":void 0,"aria-labelledby":k?`${t}-setup`:void 0,children:[g?e.jsx("div",{className:"surface-tabs provider-mode-tabs",role:"tablist","aria-label":`${l.displayName} mode`,children:w.map(h=>e.jsx("button",{type:"button",role:"tab",id:`${R}-${h}`,className:T===h?"active":void 0,"aria-selected":T===h,"aria-controls":m(h),onClick:()=>o(h),children:h==="api"?"API":"Subscription"},h))}):null,K.includes(s)?null:e.jsxs("dl",{className:"provider-dialog-stats",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Credential"}),e.jsx("dd",{title:ie(l),children:ie(l)})]}),r?null:e.jsxs(e.Fragment,{children:[V(s)?null:e.jsxs("div",{children:[e.jsx("dt",{children:"Base URL"}),e.jsx("dd",{title:c,children:c})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsx("dd",{title:p?.defaultModel??l.defaultModel??void 0,children:p?.defaultModel??l.defaultModel??"Not set"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Models"}),e.jsxs("dd",{title:y?.lastError??void 0,children:[A," cached, ",qe(y?.fetchedAt)]})]})]}),s==="codex"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Account"}),e.jsx("dd",{title:a?.account?.email??void 0,children:a?.account?.label??a?.account?.email??"Not signed in"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Binary"}),e.jsx("dd",{title:a?.binaryPath??void 0,children:a?.binaryPath??"Not found"})]})]}):null,l.credential.lastError||y?.lastError||l.lastError?e.jsxs("div",{className:"provider-dialog-error",children:[e.jsx("dt",{children:"Error"}),e.jsx("dd",{title:l.credential.lastError??y?.lastError??l.lastError??void 0,children:l.credential.lastError??y?.lastError??l.lastError})]}):null]}),s==="codex"?e.jsxs(e.Fragment,{children:[p?e.jsx(le,{connection:i,providerId:s,config:p,status:l,cachedModels:y?.models??[],busy:b!==null,onCheck:n},s):null,e.jsxs("div",{className:"provider-dialog-body",children:[e.jsx("h3",{children:"ChatGPT with the OpenPond harness"}),e.jsx("p",{children:"Native Codex and the OpenPond harness keep their own connections. Choose the execution path in the model picker."}),e.jsx("p",{children:u.statuses.openai?.credential.connected?"OpenPond harness connected":"OpenPond harness not connected"}),e.jsx("button",{type:"button",className:"settings-secondary",disabled:b!==null,onClick:()=>{v("browser")},children:"Connect ChatGPT for OpenPond"}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:b!==null,onClick:()=>{x("openai",{enabled:!u.providers.openai?.enabled})},children:[u.providers.openai?.enabled?"Disable":"Enable"," OpenPond harness route"]})]})]}):V(s)&&p?e.jsx(le,{connection:i,providerId:s,config:p,status:l,cachedModels:y?.models??[],busy:b!==null,onCheck:n},s):g&&p&&y?e.jsx(We,{credentialTab:T,credentialTabsId:R,hasSubscriptionTab:L,providerId:s,providerBusy:b,settings:u,status:l,onDeleteCredential:O,onRefreshModels:E,onSaveConfig:x,onSaveCredential:_,onStartOpenAiSubscriptionAuth:v,onValidate:P}):l.routing.localByok&&!Z(s)?e.jsxs("div",{className:"provider-dialog-note",children:[e.jsx(ce,{size:15}),e.jsx("span",{children:"Adapter pending"})]}):null]}),j==="sync"?e.jsx("div",{role:"tabpanel",id:`${t}-sync-panel`,"aria-labelledby":`${t}-sync`,children:k}):null]})})}function We({credentialTab:n,credentialTabsId:i,hasSubscriptionTab:f,providerId:a,providerBusy:s,settings:b,status:u,onDeleteCredential:l,onRefreshModels:N,onSaveConfig:O,onSaveCredential:E,onStartOpenAiSubscriptionAuth:x,onValidate:_}){const v=b.providers[a],P=d.useMemo(()=>Ae(a,b),[a,b]),k=`provider-models-${a}`,M=d.useRef(a),[j,D]=d.useState(v.baseUrl??""),[t,p]=d.useState(v.defaultModel??""),[y,R]=d.useState(v.modelOverrides.join(`
|
|
2
|
+
`)),[S,A]=d.useState({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),[g,w]=d.useState("local_secret"),[L,T]=d.useState(""),[o,r]=d.useState(""),m=s===`${a}:config`,c=s===`${a}:credential`,h=s===`${a}:validate`,$=s===`${a}:models`,z=s==="openai:credential",be=a==="openai",ge=a==="xai",W=a==="zai",H=(C=>`${i}-${C}-panel`)(n),X=n==="subscription"&&f,q=n==="subscription"&&W?"coding-plan":"api",Y=q==="coding-plan"?"Coding Plan key":"API key",ve=u.credential.connected?q==="coding-plan"?"Replace saved plan key":"Replace saved key":Y,xe=q==="coding-plan"?"Save plan key":"Save key",Q=d.useMemo(()=>Je(P,[t,...ae(y)]),[t,P,y]),I=Math.max(0,P.length-Q.length);d.useEffect(()=>{if(M.current!==a){M.current=a,A({baseUrl:!1,defaultModel:!1,modelOverrides:!1}),D(v.baseUrl??""),p(v.defaultModel??""),R(v.modelOverrides.join(`
|
|
3
|
+
`));return}S.baseUrl||D(v.baseUrl??""),S.defaultModel||p(v.defaultModel??""),S.modelOverrides||R(v.modelOverrides.join(`
|
|
4
|
+
`))},[v.baseUrl,v.defaultModel,v.modelOverrides,S.baseUrl,S.defaultModel,S.modelOverrides,a]);const ee=g==="env"?!!o.trim():!!L.trim();async function je(C){C.preventDefault(),await O(a,{enabled:!0,baseUrl:j.trim()||null,defaultModel:t.trim()||null,modelOverrides:ae(y)}),A({baseUrl:!1,defaultModel:!1,modelOverrides:!1})}async function ye(C){if(C.preventDefault(),!!ee){if(g==="env"){await E(a,{source:"env",envVar:o.trim()});return}await E(a,{source:"local_secret",value:L}),T("")}}function ne({panel:C=!0}={}){return e.jsxs("form",{className:"provider-credential-panel",id:C?H:void 0,role:C?"tabpanel":void 0,"aria-labelledby":C?`${i}-${n}`:void 0,onSubmit:U=>{ye(U)},children:[e.jsxs("div",{className:"provider-card-grid credential-grid",children:[e.jsxs("div",{className:"settings-select-field",children:[e.jsx("span",{children:"Credential source"}),e.jsx(Oe,{value:g,disabled:c,label:"Credential source",options:_e,onChange:U=>w(U)})]}),g==="env"?e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Environment variable"}),e.jsx("input",{value:o,disabled:c,placeholder:"PROVIDER_API_KEY",onChange:U=>r(U.currentTarget.value)})]}):e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:Y}),e.jsx("input",{type:"password",value:L,disabled:c,placeholder:ve,autoComplete:"off",onChange:U=>T(U.currentTarget.value)})]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:c||!ee,children:[c?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(F,{size:14}),e.jsx("span",{children:c?"Saving":xe})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:c||!u.credential.connected,onClick:()=>{l(a)},children:e.jsx(te,{size:15})})]})]})}function Ce(){return be?e.jsxs("div",{className:"provider-subscription-panel",id:H,role:"tabpanel","aria-labelledby":`${i}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note codex-provider-note",children:[e.jsx(F,{size:15}),e.jsx("span",{children:"ChatGPT subscription auth opens OpenAI login and stores a refresh token locally. API keys remain available under the API tab for raw Platform billing."})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{type:"button",className:"settings-secondary",disabled:z,onClick:()=>{x("browser")},children:[z?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(F,{size:14}),e.jsx("span",{children:z?"Opening":"Connect ChatGPT"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:z,onClick:()=>{x("device")},children:[z?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(F,{size:14}),e.jsx("span",{children:"Device code"})]}),e.jsx("button",{type:"button",className:"settings-icon-button ghost","aria-label":`Delete ${u.displayName} credential`,disabled:z||!u.credential.connected,onClick:()=>{l(a)},children:e.jsx(te,{size:15})})]})]}):ge?e.jsx("div",{className:"provider-subscription-panel",id:H,role:"tabpanel","aria-labelledby":`${i}-subscription`,children:e.jsxs("div",{className:"provider-dialog-note xai-provider-note",children:[e.jsx(F,{size:15}),e.jsx("span",{children:"SuperGrok includes Grok app and Grok Build access. xAI API calls here still use an xAI Console API key with API credits or invoiced billing, so there is no separate Connect SuperGrok step yet."})]})}):W?e.jsxs("div",{className:"provider-subscription-panel",id:H,role:"tabpanel","aria-labelledby":`${i}-subscription`,children:[e.jsxs("div",{className:"provider-dialog-note subscription-provider-note",children:[e.jsx(F,{size:15}),e.jsx("span",{children:"GLM Coding Plan uses a plan API key with the dedicated Coding endpoint. General Z.ai API keys and balances are separate."})]}),ne({panel:!1})]}):null}return e.jsxs("div",{className:"provider-dialog-body",children:[X?null:e.jsxs("form",{className:"provider-card-form",onSubmit:C=>{je(C)},children:[e.jsxs("div",{className:"provider-card-grid",children:[e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Base URL"}),e.jsx("input",{value:j,disabled:m,placeholder:"https://api.example.com/v1",onChange:C=>{A(U=>({...U,baseUrl:!0})),D(C.currentTarget.value)}})]}),e.jsxs("label",{className:"settings-select-field",children:[e.jsx("span",{children:"Default model"}),e.jsx("input",{list:k,value:t,disabled:m,placeholder:"Model id",onChange:C=>{A(U=>({...U,defaultModel:!0})),p(C.currentTarget.value)}}),e.jsx("datalist",{id:k,children:Q.map(C=>e.jsx("option",{value:C.value,children:C.label},C.value))}),I>0?e.jsxs("small",{children:[I," more cached models hidden from suggestions"]}):null]})]}),e.jsxs("div",{className:"settings-button-row",children:[e.jsxs("button",{className:"settings-secondary",disabled:m,children:[m?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(De,{size:14}),e.jsx("span",{children:m?"Saving":"Save config"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:$,onClick:()=>{N(a)},children:[$?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(de,{size:14}),e.jsx("span",{children:$?"Refreshing":"Refresh models"})]}),e.jsxs("button",{type:"button",className:"settings-secondary",disabled:h||!t.trim(),onClick:()=>{_(a,{baseUrl:j.trim()||void 0,modelId:t.trim()||void 0})},children:[h?e.jsx(G,{size:14,className:"settings-spin"}):e.jsx(oe,{size:14}),e.jsx("span",{children:h?"Testing":"Test"})]})]})]}),e.jsx("div",{className:"provider-card-form credential-form",children:X?Ce():ne()})]})}function sn({connection:n,onError:i,onPreferences:f,onProviders:a,preferences:s,providers:b}){const u=d.useRef(n);u.current=n;const[l,N]=d.useState(s.defaultChatProvider),[O,E]=d.useState(s.defaultChatModel),[x,_]=d.useState(!1),[v,P]=d.useState(null),[k,M]=d.useState(null);d.useEffect(()=>{N(s.defaultChatProvider),E(s.defaultChatModel)},[s.defaultChatProvider,s.defaultChatModel]);async function j(o){if(o.preventDefault(),!!n){_(!0),i(null);try{f(await B.savePreferences(n,{defaultChatProvider:l,defaultChatModel:se(l,O,b)}))}catch(r){i(r instanceof Error?r.message:String(r))}finally{_(!1)}}}function D(o){N(o),E(r=>se(o,r,b))}async function t(o,r,m){if(!n)return null;P(`${o}:${r}`),M(null),i(null);try{return await m()}catch(c){return i(c instanceof Error?c.message:String(c)),null}finally{P(null)}}async function p(o,r){await t(o,"config",async()=>{const m=await B.saveProviderSettings(n,{providers:{[o]:r}});return a(m),m})}async function y(o,r){await t(o,"credential",async()=>{const m=await B.saveProviderCredential(n,o,r);return a(m),m})}async function R(o){await t(o,"credential",async()=>{const r=await B.deleteProviderCredential(n,o,{});return a(r),r})}async function S(o){return t("openai","credential",async()=>{const r=await B.startOpenAiSubscriptionAuth(n,{method:o});return r.method==="browser"?(window.open(r.url,"_blank","noopener,noreferrer"),M("OpenAI ChatGPT login opened in your browser. Return here after authorization.")):(window.open(r.url,"_blank","noopener,noreferrer"),M(`OpenAI device login started. Enter code ${r.userCode}.`)),A(r.expiresAt),r})}async function A(o){if(n)for(;Date.now()<o;){await new Promise(r=>setTimeout(r,2500));try{const r=await B.providerSettings(n);a(r);const m=r.statuses.openai?.credential;if(m?.connected&&m.source==="chatgpt_subscription"){M("OpenAI ChatGPT subscription connected.");return}}catch{}}}async function g(o){await t(o,"models",async()=>{const r=await B.refreshProviderModels(n,o,{force:!0});return a(r.providers),r})}async function w(o){await t(o,"models",async()=>{const r=await B.loadProviderModels(n,o,{limit:500});return a(r.providers),r})}async function L(o,r={}){await t(o,"validate",async()=>{const m=await B.validateProviderCredential(n,o,r);return M(m.ok?`${o} validated${m.modelId?` with ${m.modelId}`:""}.`:m.errors.join(`
|
|
5
|
+
`)||`${o} validation failed.`),a(m.providers),m})}return{checkNativeProvider:async(o,r,m)=>{if(!n)throw new Error("Connect to the local OpenPond server first.");r.throwIfAborted(),m&&await B.saveProviderSettings(n,{providers:{[o]:m}}),r.throwIfAborted();const c=await ue(n,`/v1/providers/${o}/native-setup`,{method:"POST",body:JSON.stringify({action:"check"}),signal:r});if(r.throwIfAborted(),u.current?.serverUrl!==n.serverUrl||u.current?.token!==n.token)throw new DOMException("Connection changed","AbortError");return a(c.settings),c},defaultModel:O,defaultProvider:l,providerBusy:v,saving:x,validationMessage:k,changeDefaultProvider:D,deleteProviderCredential:R,loadProviderModels:w,refreshProviderModels:g,saveProviderConfig:p,saveProviderCredential:y,saveProviders:j,setDefaultModel:E,startOpenAiSubscriptionAuth:S,validateProvider:L}}export{F as K,nn as P,$e as a,Ze as b,sn as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as f}from"./index-
|
|
1
|
+
import{r as f}from"./index-BxWTVKtn.js";import{G as C}from"./App-CuhaCsfb.js";function S(n,e,t){return new Set(n.filter(i=>{if(e.has(i.id))return!1;if(t===void 0)return!0;if(typeof i.timestamp!="string")return!1;const a=Date.parse(i.timestamp);return Number.isFinite(a)&&a>=t}).map(i=>i.id))}function v(n){let e=null;for(const t of n){if(typeof t.timestamp!="string")continue;const i=Date.parse(t.timestamp);Number.isFinite(i)&&(e=e===null?i:Math.max(e,i))}return e}function E(n,e){const t=f.useRef({scopeKey:e,ids:new Set(n.map(r=>r.id)),initialized:!1,liveCutoff:null}),i=t.current.scopeKey===e,d=i&&t.current.initialized?S(n,t.current.ids,t.current.liveCutoff??void 0):new Set;return f.useLayoutEffect(()=>{const r=t.current,s=r.scopeKey!==e,u=Date.now();t.current={scopeKey:e,ids:new Set(n.map(l=>l.id)),initialized:!s,liveCutoff:s?Math.max(u,v(n)??0):r.liveCutoff??Math.max(u,v(n)??0)}},[n,i,e]),d}const w=new Map,M=[200,600,1500];function x({connection:n,latestTurnId:e,sessionId:t,turnRunning:i}){const[a,d]=f.useState(()=>({sessionId:null,summaries:w}));return f.useEffect(()=>{if(!n||!t)return;let r=!1,s=null;const u=i?null:e,l=o=>{const c=M[o];c===void 0||r||(s=setTimeout(()=>{m(o+1)},c))},m=async o=>{try{const c=await C.usageTurnCache(n,t);if(r)return;const p=new Map(c.turns.map(h=>[h.turnId,h]));d({sessionId:t,summaries:p}),u&&!p.has(u)&&l(o)}catch{l(o)}};return m(0),()=>{r=!0,s!==null&&clearTimeout(s)}},[n,e,t,i]),a.sessionId===t?a.summaries:w}export{x as a,E as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as a}from"./App-
|
|
1
|
+
import{c as a}from"./App-CuhaCsfb.js";const e=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],y=a("bell",e);const t=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],c=a("bell-off",t);const o=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],k=a("scroll-text",o);const h=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],p=a("wifi-off",h);export{c as B,k as S,p as W,y as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j7 as c}from"./WorkspaceMonacoEditor-
|
|
1
|
+
import{j7 as c}from"./WorkspaceMonacoEditor-BR4qxMgU.js";import"./toggleHighContrast-Cto-fOXm.js";function a(e,o){const r=globalThis.MonacoEnvironment;if(r?.createTrustedTypesPolicy)try{return r.createTrustedTypesPolicy(e,o)}catch(t){console.error(t);return}try{return globalThis.trustedTypes?.createPolicy(e,o)}catch(t){console.error(t);return}}let n;typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope"&&globalThis.workerttPolicy!==void 0?n=globalThis.workerttPolicy:n=a("defaultWorkerFactory",{createScriptURL:e=>e});function l(e){const o=e.label,r=globalThis.MonacoEnvironment;if(r){if(typeof r.getWorker=="function")return r.getWorker("workerMain.js",o);if(typeof r.getWorkerUrl=="function"){const t=r.getWorkerUrl("workerMain.js",o);return new Worker(n?n.createScriptURL(t):t,{name:o,type:"module"})}}if(e.createWorker)return e.createWorker();throw new Error("You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker")}function u(e){const o=Promise.resolve(l({label:e.label??"monaco-editor-worker",moduleId:e.moduleId,createWorker:e.createWorker})).then(r=>(r.postMessage("ignore"),r.postMessage(e.createData),r));return c.createWebWorker({worker:o,host:e.host,keepIdleModels:e.keepIdleModels})}export{u as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as e}from"./WorkspaceMonacoEditor-
|
|
1
|
+
import{l as e}from"./WorkspaceMonacoEditor-BR4qxMgU.js";import"./toggleHighContrast-Cto-fOXm.js";import"./index-BxWTVKtn.js";const r={comments:{lineComment:"#"},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{offSide:!0},onEnterRules:[{beforeText:/:\s*$/,action:{indentAction:e.IndentAction.Indent}}]},l={tokenPostfix:".yaml",brackets:[{token:"delimiter.bracket",open:"{",close:"}"},{token:"delimiter.square",open:"[",close:"]"}],keywords:["true","True","TRUE","false","False","FALSE","null","Null","Null","~"],numberInteger:/(?:0|[+-]?[0-9]+)/,numberFloat:/(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,numberOctal:/0o[0-7]+/,numberHex:/0x[0-9a-fA-F]+/,numberInfinity:/[+-]?\.(?:inf|Inf|INF)/,numberNaN:/\.(?:nan|Nan|NAN)/,numberDate:/\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,tokenizer:{root:[{include:"@whitespace"},{include:"@comment"},[/%[^ ]+.*$/,"meta.directive"],[/---/,"operators.directivesEnd"],[/\.{3}/,"operators.documentEnd"],[/[-?:](?= )/,"operators"],{include:"@anchor"},{include:"@tagHandle"},{include:"@flowCollections"},{include:"@blockStyle"},[/@numberInteger(?![ \t]*\S+)/,"number"],[/@numberFloat(?![ \t]*\S+)/,"number.float"],[/@numberOctal(?![ \t]*\S+)/,"number.octal"],[/@numberHex(?![ \t]*\S+)/,"number.hex"],[/@numberInfinity(?![ \t]*\S+)/,"number.infinity"],[/@numberNaN(?![ \t]*\S+)/,"number.nan"],[/@numberDate(?![ \t]*\S+)/,"number.date"],[/(".*?"|'.*?'|[^#'"]*?)([ \t]*)(:)( |$)/,["type","white","operators","white"]],{include:"@flowScalars"},[/.+?(?=(\s+#|$))/,{cases:{"@keywords":"keyword","@default":"string"}}]],object:[{include:"@whitespace"},{include:"@comment"},[/\}/,"@brackets","@pop"],[/,/,"delimiter.comma"],[/:(?= )/,"operators"],[/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/,"type"],{include:"@flowCollections"},{include:"@flowScalars"},{include:"@tagHandle"},{include:"@anchor"},{include:"@flowNumber"},[/[^\},]+/,{cases:{"@keywords":"keyword","@default":"string"}}]],array:[{include:"@whitespace"},{include:"@comment"},[/\]/,"@brackets","@pop"],[/,/,"delimiter.comma"],{include:"@flowCollections"},{include:"@flowScalars"},{include:"@tagHandle"},{include:"@anchor"},{include:"@flowNumber"},[/[^\],]+/,{cases:{"@keywords":"keyword","@default":"string"}}]],multiString:[[/^( +).+$/,"string","@multiStringContinued.$1"]],multiStringContinued:[[/^( *).+$/,{cases:{"$1==$S2":"string","@default":{token:"@rematch",next:"@popall"}}}]],whitespace:[[/[ \t\r\n]+/,"white"]],comment:[[/#.*$/,"comment"]],flowCollections:[[/\[/,"@brackets","@array"],[/\{/,"@brackets","@object"]],flowScalars:[[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/'[^']*'/,"string"],[/"/,"string","@doubleQuotedString"]],doubleQuotedString:[[/[^\\"]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,"string","@pop"]],blockStyle:[[/[>|][0-9]*[+-]?$/,"operators","@multiString"]],flowNumber:[[/@numberInteger(?=[ \t]*[,\]\}])/,"number"],[/@numberFloat(?=[ \t]*[,\]\}])/,"number.float"],[/@numberOctal(?=[ \t]*[,\]\}])/,"number.octal"],[/@numberHex(?=[ \t]*[,\]\}])/,"number.hex"],[/@numberInfinity(?=[ \t]*[,\]\}])/,"number.infinity"],[/@numberNaN(?=[ \t]*[,\]\}])/,"number.nan"],[/@numberDate(?=[ \t]*[,\]\}])/,"number.date"]],tagHandle:[[/\![^ ]*/,"tag"]],anchor:[[/[&*][^ ]+/,"namespace"]]}};export{r as conf,l as language};
|
package/dist/web/index.html
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
|
|
8
8
|
<link rel="apple-touch-icon" href="/openpond-icon.png" />
|
|
9
9
|
<title>OpenPond App</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-BxWTVKtn.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-dSmk3FLJ.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as e}from"./chunk-ES2ISFJC.js";import{a as o}from"./chunk-FTQLQJQV.js";import{createHash as je}from"node:crypto";function $(i){if(i===null||typeof i=="boolean"||typeof i=="string")return i;if(typeof i=="number"){if(!Number.isFinite(i))throw new Error("Canonical JSON cannot encode a non-finite number.");return i}if(Array.isArray(i))return i.map($);if(typeof i=="object"){let t={};for(let r of Object.keys(i).sort()){let n=i[r];n!==void 0&&(t[r]=$(n))}return t}throw new Error(`Canonical JSON cannot encode ${typeof i}.`)}o($,"canonicalJson");function E(i){return je("sha256").update(JSON.stringify($(i)),"utf8").digest("hex")}o(E,"canonicalHash");function Ye(i){if(!i.maxContextTokens||!i.usableContextTokens)return{shouldCompact:!1,projectedTokens:i.projectedTokens,thresholdTokens:Number.MAX_SAFE_INTEGER,usableContextTokens:0,maxContextTokens:0,tokenSource:"heuristic"};let t=Math.max(.01,Math.min(1,(i.triggerPercent??85)/100)),r=Math.max(1,Math.floor(i.usableContextTokens*t));return{shouldCompact:i.projectedTokens>=r,projectedTokens:i.projectedTokens,thresholdTokens:r,usableContextTokens:i.usableContextTokens,maxContextTokens:i.maxContextTokens,tokenSource:"heuristic"}}o(Ye,"agentCompactionDecision");async function Ze(i){await i.started();try{return await i.compact()}catch(t){throw await i.failed(t),t}}o(Ze,"runAgentCompaction");async function et(i){let t=i.host.projectEvents(i.events),r=i.host.selectEvents(t,i.maxContextTokens),{summaryEvents:n,preservedEvents:s,preservedEventIds:c}=r;if(n.length===0)throw new Error("There is not enough prior context to compact.");let l=i.host.normalizeRecords(n),d=i.host.normalizeRecords(s),h=i.host.buildFileLedger(i.host.normalizeRecords(t)),m=i.host.serializeRecords(l,i.host.inputCharBudget(i.maxContextTokens));if(!m.text.trim())throw new Error("There is not enough prior context to compact.");let g=i.host.buildSummaryMessages({serializedHistory:m.text,fileLedger:h}),v=Date.now(),k=(await i.host.streamSummary({model:i.model,messages:g,signal:i.signal})).trim(),w=Date.now()-v;if(!k)throw new Error("Compaction summary was empty.");let f=i.host.estimateProjection({events:t,preservedEvents:s,summary:k}),x=i.host.createMetrics({sourceEvents:t.length,summarizedEvents:n.length,preservedEvents:s.length,sourceRecords:m.sourceRecordCount,includedRecords:m.includedRecordCount,omittedRecords:m.omittedRecordCount,preservedRecords:d.length,truncatedRecords:m.truncatedRecordCount,summaryInputTruncated:m.inputTruncated,sourceSelectionStrategy:m.selectionStrategy,summaryInputChars:m.inputChars,retainedTailTokens:r.retainedTailTokens,retainedTailBudgetTokens:r.retainedTailBudgetTokens,finalProviderContextTokens:f.inputTokensAfter,durationMs:w,fileLedgerEntries:h.length,splitTurnId:r.splitTurnId});return{summary:k,model:i.model,compactedThroughEventId:t[t.length-1]?.id??null,compactedThroughTurnId:i.host.lastTurnId(t),preservedFromEventId:s[0]?.id??null,preservedEventIds:c,preservedResourceRefs:i.host.durableResourceRefs(i.events),sourceEventCount:n.length,preservedEventCount:s.length,fileLedger:h,inputTokensBefore:f.inputTokensBefore,inputTokensAfter:f.inputTokensAfter,maxContextTokens:i.maxContextTokens,tokenSource:"heuristic",metrics:x}}o(et,"runAgentCompactionProgram");var Se=e.enum(["thread.started","thread.resumed","turn.started","turn.steered","turn.interrupted","turn.completed","turn.failed","item.started","item.delta","item.completed","assistant.reasoning.delta","assistant.delta","tool.started","tool.completed","approval.requested","approval.resolved","user_input.requested","user_input.resolved","compaction.started","compaction.completed","harness.admitted","harness.refiner.queued","harness.refiner.started","harness.refiner.completed","harness.refiner.failed","diagnostic"]),Ee=e.object({sequence:e.number().int().nonnegative(),name:Se,source:e.enum(["runtime","provider","tool","host","refiner"]),status:e.string().trim().min(1).nullable().default(null),threadId:e.string().trim().min(1),turnId:e.string().trim().min(1).nullable().default(null),callId:e.string().trim().min(1).nullable().default(null),output:e.string().nullable().default(null),error:e.string().nullable().default(null),data:e.record(e.string(),e.unknown()).default({})}).strict();function st(i){return E(Ee.parse(i))}o(st,"canonicalEventHash");var q="2026-09-20",lt=["initialize","initialized","runtime/capabilities","thread/start","thread/resume","thread/read","turn/start","turn/steer","task/inbox","task/queue","task/inputUpdate","turn/interrupt","approval/resolve","userInput/resolve","profile/workflows","profile/evaluations","profile/trainingSource","profile/evaluations/prepare","profile/evaluations/run","profile/evaluations/runSuite","profile/evaluations/executeCase","profile/evaluations/executeRun","profile/evaluations/compare","profile/evaluations/report","experiments/executeCase","experiments/cancelCase","harness/inspect","harness/proposalReview","harness/review","harness/acceptEvaluationReview","harness/materializeEvaluationTaskset","harness/runEvaluationBaseline","harness/validate","harness/backgroundReview","harness/diff","harness/rollback","refiner/inspect","refiner/update","refiner/activate","refiner/rollback"],W=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),Q=e.object({jsonrpc:e.literal("2.0"),method:e.string().trim().min(1),params:e.unknown().optional()}).strict(),L=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number()]),result:e.unknown()}).strict(),U=e.object({jsonrpc:e.literal("2.0"),id:e.union([e.string(),e.number(),e.null()]),error:e.object({code:e.number().int(),message:e.string(),data:e.unknown().optional()}).strict()}).strict(),ut=e.union([W,Q,L,U]),_e=e.object({protocolVersion:e.string().trim().min(1),client:e.object({name:e.string().trim().min(1),version:e.string().trim().min(1)}).strict(),capabilities:e.record(e.string(),e.unknown()).default({})}).strict(),V=class{static{o(this,"AgentJsonRpcDispatcher")}#e;#t=null;#r=!1;constructor(t){this.#e=t}get initialized(){return this.#r}async handle(t){let r=Q.safeParse(t);if(r.success&&!("id"in t)){if(r.data.method==="initialized"){if(!this.#t)throw new _(-32002,"initialize must be called first");this.#r=!0}return null}let n=W.safeParse(t);if(!n.success)return K(null,-32600,"Invalid Request",n.error.flatten());let s=n.data;try{let c=await this.#n(s.method,s.params);return{jsonrpc:"2.0",id:s.id,result:c}}catch(c){let l=c instanceof _?c:new _(-32603,c instanceof Error?c.message:String(c));return K(s.id,l.code,l.message,l.data)}}async#n(t,r){if(t==="initialize"){let n=_e.parse(r);if(n.protocolVersion!==q)throw new _(-32001,"Incompatible agent protocol version",{requested:n.protocolVersion,supported:q});return this.#t=n,{protocolVersion:q,server:{name:"openpond-app-server",version:"1"},capabilities:await this.#e.capabilities()}}if(!this.#r)throw new _(-32002,"initialized notification is required");switch(t){case"runtime/capabilities":return this.#e.capabilities(r);case"thread/start":return this.#e.threadStart(r);case"thread/resume":return this.#e.threadResume(r);case"thread/read":return this.#e.threadRead(r);case"turn/start":return this.#e.turnStart(r);case"turn/steer":return this.#e.turnSteer(r);case"task/inbox":return this.#e.taskInbox(r);case"task/queue":return this.#e.taskQueue(r);case"task/inputUpdate":return this.#e.taskInputUpdate(r);case"turn/interrupt":return this.#e.turnInterrupt(r);case"approval/resolve":return this.#e.approvalResolve(r);case"userInput/resolve":return this.#e.userInputResolve(r);case"profile/workflows":return this.#e.profileWorkflows(r);case"profile/evaluations":return this.#e.profileEvaluations(r);case"profile/trainingSource":return this.#e.profileTrainingSource(r);case"profile/evaluations/prepare":return this.#e.profileEvaluationPrepare(r);case"profile/evaluations/run":return this.#e.profileEvaluationRun(r);case"experiments/executeCase":{if(!this.#e.experimentExecuteCase)throw new Error("Experiment execution is unavailable in this runtime.");return this.#e.experimentExecuteCase(r)}case"experiments/cancelCase":{if(!this.#e.experimentCancelCase)throw new Error("Experiment cancellation is unavailable in this runtime.");return this.#e.experimentCancelCase(r)}case"profile/evaluations/runSuite":return this.#e.profileEvaluationRunSuite(r);case"profile/evaluations/executeCase":return this.#e.profileEvaluationExecuteCase(r);case"profile/evaluations/executeRun":return this.#e.profileEvaluationExecuteRun(r);case"profile/evaluations/compare":return this.#e.profileEvaluationCompare(r);case"profile/evaluations/report":return this.#e.profileEvaluationReport(r);case"harness/inspect":return this.#e.harnessInspect(r);case"harness/proposalReview":return this.#e.harnessProposalReview(r);case"harness/review":return this.#e.harnessReview(r);case"harness/acceptEvaluationReview":return this.#e.harnessAcceptEvaluationReview(r);case"harness/materializeEvaluationTaskset":return this.#e.harnessMaterializeEvaluationTaskset(r);case"harness/runEvaluationBaseline":return this.#e.harnessRunEvaluationBaseline(r);case"harness/validate":return this.#e.harnessValidate(r);case"harness/backgroundReview":return this.#e.harnessBackgroundReview(r);case"harness/diff":return this.#e.harnessDiff(r);case"harness/rollback":return this.#e.harnessRollback(r);case"refiner/inspect":return this.#e.refinerInspect(r);case"refiner/update":return this.#e.refinerUpdate(r);case"refiner/activate":return this.#e.refinerActivate(r);case"refiner/rollback":return this.#e.refinerRollback(r);default:throw new _(-32601,`Method not found: ${t}`)}}},_=class extends Error{static{o(this,"JsonRpcDispatchError")}code;data;constructor(t,r,n){super(r),this.code=t,this.data=n}};function K(i,t,r,n){return{jsonrpc:"2.0",id:i,error:{code:t,message:r,...n===void 0?{}:{data:n}}}}o(K,"jsonRpcError");var X=class{static{o(this,"AgentRpcClient")}#e;#t;constructor(t){this.#e=t.request.bind(t),this.#t=t.notify.bind(t)}async initialize(t,r={}){let n=await this.#e("initialize",{protocolVersion:q,client:t,capabilities:r});return await this.#t("initialized"),n}capabilities=o((t={})=>this.#e("runtime/capabilities",t),"capabilities");threadStart=o(t=>this.#e("thread/start",t),"threadStart");threadResume=o(t=>this.#e("thread/resume",t),"threadResume");threadRead=o(t=>this.#e("thread/read",t),"threadRead");turnStart=o(t=>this.#e("turn/start",t),"turnStart");turnSteer=o(t=>this.#e("turn/steer",t),"turnSteer");taskInbox=o(t=>this.#e("task/inbox",t),"taskInbox");taskQueue=o(t=>this.#e("task/queue",t),"taskQueue");taskInputUpdate=o(t=>this.#e("task/inputUpdate",t),"taskInputUpdate");turnInterrupt=o(t=>this.#e("turn/interrupt",t),"turnInterrupt");approvalResolve=o(t=>this.#e("approval/resolve",t),"approvalResolve");userInputResolve=o(t=>this.#e("userInput/resolve",t),"userInputResolve");profileWorkflows=o(t=>this.#e("profile/workflows",t),"profileWorkflows");profileEvaluations=o(t=>this.#e("profile/evaluations",t),"profileEvaluations");profileEvaluationPrepare=o(t=>this.#e("profile/evaluations/prepare",t),"profileEvaluationPrepare");profileEvaluationRun=o(t=>this.#e("profile/evaluations/run",t),"profileEvaluationRun");profileEvaluationRunSuite=o(t=>this.#e("profile/evaluations/runSuite",t),"profileEvaluationRunSuite");profileEvaluationExecuteCase=o(t=>this.#e("profile/evaluations/executeCase",t),"profileEvaluationExecuteCase");profileEvaluationExecuteRun=o(t=>this.#e("profile/evaluations/executeRun",t),"profileEvaluationExecuteRun");profileEvaluationCompare=o(t=>this.#e("profile/evaluations/compare",t),"profileEvaluationCompare");experimentExecuteCase=o(t=>this.#e("experiments/executeCase",t),"experimentExecuteCase");experimentCancelCase=o(t=>this.#e("experiments/cancelCase",t),"experimentCancelCase");harnessInspect=o((t={})=>this.#e("harness/inspect",t),"harnessInspect");harnessProposalReview=o((t={})=>this.#e("harness/proposalReview",t),"harnessProposalReview");harnessReview=o((t={})=>this.#e("harness/review",t),"harnessReview");harnessAcceptEvaluationReview=o((t={})=>this.#e("harness/acceptEvaluationReview",t),"harnessAcceptEvaluationReview");harnessMaterializeEvaluationTaskset=o((t={})=>this.#e("harness/materializeEvaluationTaskset",t),"harnessMaterializeEvaluationTaskset");harnessRunEvaluationBaseline=o((t={})=>this.#e("harness/runEvaluationBaseline",t),"harnessRunEvaluationBaseline");harnessValidate=o((t={})=>this.#e("harness/validate",t),"harnessValidate");harnessBackgroundReview=o((t={})=>this.#e("harness/backgroundReview",t),"harnessBackgroundReview");harnessDiff=o((t={})=>this.#e("harness/diff",t),"harnessDiff");harnessRollback=o((t={})=>this.#e("harness/rollback",t),"harnessRollback");refinerInspect=o(t=>this.#e("refiner/inspect",t),"refinerInspect");refinerUpdate=o(t=>this.#e("refiner/update",t),"refinerUpdate");refinerActivate=o(t=>this.#e("refiner/activate",t),"refinerActivate");refinerRollback=o(t=>this.#e("refiner/rollback",t),"refinerRollback")};var D=e.object({caseId:e.string().trim().min(1).max(191),admissionHash:e.string().regex(/^[a-f0-9]{64}$/),definitionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),operation:e.enum(["create","reset","step","collect","destroy"]),value:e.record(e.string(),e.unknown()),timeoutMs:e.number().int().min(1).max(3e4)}).strict();var u=e.string().trim().min(1).max(200),O=e.string().trim().min(1).max(32e3),P=e.number().int().nonnegative(),Y=e.object({id:u,sessionId:u,senderSessionId:u.nullable(),senderKind:e.enum(["user","task","runtime"]),kind:e.enum(["steer","message","followup","queued","result"]),body:O,payload:e.record(e.string(),e.unknown()),idempotencyKey:u,replyTo:u.nullable(),expectedTurnId:u.nullable()}).strict(),Re=e.discriminatedUnion("action",[e.object({action:e.literal("resume"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("cancel"),expectedRevision:e.number().int().positive()}).strict(),e.object({action:e.literal("edit"),expectedRevision:e.number().int().positive(),body:O}).strict(),e.object({action:e.literal("steer"),expectedRevision:e.number().int().positive(),expectedTurnId:u}).strict()]),Z=e.object({id:u,sessionId:u,turnId:u,targetSessionId:u.nullable(),targetTurnId:u.nullable(),targetInputId:u.nullable(),afterSequence:P,deadline:e.string(),state:e.enum(["waiting","message","completed","failed","interrupted","unavailable","timeout","cancelled"]),createdAt:e.string(),updatedAt:e.string()}).strict(),ee=e.record(e.string(),e.unknown()),Te=e.enum(["queued","running","completed","failed","cancelled","needs_resume"]),Ce=e.object({parentSessionId:u.nullable().optional(),childSessionId:u.nullable().optional(),status:e.array(Te).nullable().optional(),afterId:e.string().max(200),limit:e.number().int().min(1).max(10)}).strict(),te=e.discriminatedUnion("action",[e.object({action:e.literal("recoverTaskInboxOwners"),ownerId:u}).strict(),e.object({action:e.literal("hasTaskCompletion"),turnId:u}).strict(),e.object({action:e.literal("taskInboxSnapshot"),sessionId:u}).strict(),e.object({action:e.literal("taskInboxSnapshotInputs"),sessionId:u,afterSequence:P}).strict(),e.object({action:e.literal("declareTaskWork"),sessionId:u,turnId:u,ownerId:u,areas:e.array(O).max(100)}).strict(),e.object({action:e.literal("taskWorkAreas"),sessionId:u}).strict(),e.object({action:e.literal("admitTaskInput"),input:Y}).strict(),e.object({action:e.literal("admitTaskInputs"),inputs:e.array(Y).max(50)}).strict(),e.object({action:e.literal("rejectTaskInput"),id:u,error:O}).strict(),e.object({action:e.literal("getTaskInput"),id:u}).strict(),e.object({action:e.literal("taskInputsForSession"),sessionId:u,query:e.object({afterSequence:P.optional(),pendingOnly:e.boolean().optional(),limit:e.number().int().min(1).max(500).optional()}).strict()}).strict(),e.object({action:e.literal("mutateTaskInput"),sessionId:u,inputId:u,change:Re}).strict(),e.object({action:e.literal("openTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("renewTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("pendingTaskInputs"),sessionId:u,turnId:u,afterSequence:P}).strict(),e.object({action:e.literal("taskAssignmentInputs"),turnId:u,afterSequence:P}).strict(),e.object({action:e.literal("pauseTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("includeTaskInputs"),sessionId:u,turnId:u,ownerId:u,requestId:u}).strict(),e.object({action:e.literal("settleTaskInputRequest"),requestId:u,outcome:e.enum(["resolved","failed","replaced"])}).strict(),e.object({action:e.literal("sealTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("sealNativeTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("closeTaskInboxTurn"),sessionId:u,turnId:u,ownerId:u,outcome:e.enum(["completed","failed","interrupted"])}).strict(),e.object({action:e.literal("taskInboxPaused"),sessionId:u}).strict(),e.object({action:e.literal("reserveTaskFollowup"),sessionId:u,turnId:u,ownerId:u}).strict(),e.object({action:e.literal("taskInboxWakeTargets"),afterSessionId:e.string().max(200)}).strict(),e.object({action:e.literal("createTaskWait"),value:Z}).strict(),e.object({action:e.literal("settleTaskWait"),id:u,state:Z.shape.state}).strict(),e.object({action:e.literal("taskWaitsForSession"),sessionId:u,afterId:e.string().max(200)}).strict(),e.object({action:e.literal("commitSubagentCompletion"),value:ee,turnId:u}).strict(),e.object({action:e.literal("pendingTaskCompletions"),afterTurnId:e.string().max(200)}).strict(),e.object({action:e.literal("settleTaskCompletion"),turnId:u,inputId:u}).strict(),e.object({action:e.literal("upsertSubagentRun"),value:ee}).strict(),e.object({action:e.literal("getSubagentRun"),id:u}).strict(),e.object({action:e.literal("listSubagentRuns"),query:Ce}).strict()]);var A=e.string().trim().min(1).max(191),re=e.object({createdAt:e.string().min(1),id:A}).strict(),ne=e.enum(["trigger_decision","route_decision","refiner_outcome","proposal","targeted_validation","apply_receipt"]),ie=e.discriminatedUnion("action",[e.object({action:e.literal("active_release"),workspaceId:A}).strict(),e.object({action:e.literal("put_artifact"),workspaceId:A,kind:ne,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:A,kind:ne,before:re.nullable(),limit:e.number().int().min(1).max(200)}).strict(),e.object({action:e.literal("pending_trigger_page"),workspaceId:A,before:re.nullable(),limit:e.number().int().min(1).max(200)}).strict()]);var b=e.string().trim().min(1).max(240),se=e.string().regex(/^[a-f0-9]{64}$/),oe=e.enum(["run_overlay","observation","trigger_decision","route_decision","proposal","targeted_validation","apply_receipt","refiner_outcome"]),ae=e.object({createdAt:e.string().datetime(),id:b}).strict(),ce=e.discriminatedUnion("action",[e.object({action:e.literal("artifact_put"),workspaceId:b,kind:oe,artifact:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("artifact_page"),workspaceId:b,kind:oe,before:ae.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("pending_page"),workspaceId:b,before:ae.nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("workspace_get"),workspaceId:b}).strict(),e.object({action:e.literal("background_get"),workspaceId:b}).strict(),e.object({action:e.literal("overlay_get"),runId:b}).strict(),e.object({action:e.literal("overlay_freeze"),runId:b,expectedRevision:e.number().int().nonnegative(),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("memory_get"),workspaceId:b,sessionId:b,key:b}).strict(),e.object({action:e.literal("memory_page"),workspaceId:b,sessionId:b,before:e.object({updatedAt:e.string().datetime(),key:b}).strict().nullable(),limit:e.number().int().min(1).max(20),includeDeleted:e.boolean()}).strict(),e.object({action:e.literal("memory_write"),sessionId:b,input:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("release_get"),contentHash:se}).strict(),e.object({action:e.literal("release_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("session_get"),sessionId:b}).strict(),e.object({action:e.literal("turn_get"),turnId:b}).strict(),e.object({action:e.literal("turn_page"),sessionId:b,before:e.number().int().positive().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_page"),turnId:b,afterSequence:e.number().int().nonnegative(),names:e.array(b).max(40),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("event_append"),event:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("usage_put"),record:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("snapshot_restore"),turnId:b,expectedHash:se,snapshot:e.record(e.string(),e.unknown())}).strict()]);var j=e.string().trim().min(1).max(200),le=e.string().regex(/^[a-f0-9]{64}$/),qe=e.object({kind:e.enum(["structural","visual","test","user_review"]),status:e.enum(["passed","failed","not_run"]),label:e.string().trim().min(1).max(240),detail:e.string().trim().max(4e3).nullable().optional(),ref:e.string().trim().max(4096).nullable().optional()}),ue=e.object({id:j,title:e.string().trim().min(1).max(240),sourceTaskId:j,sourceTurnId:j,revision:e.number().int().positive(),createdAt:e.string().datetime(),contentType:e.string().trim().min(1).max(200),sizeBytes:e.number().int().min(1).max(1e7),sha256:le,validation:e.array(qe).max(32)}).strict(),de=e.object({sessionId:j,turnId:j,output:ue}).strict(),pe=e.object({uploadId:j,index:e.number().int().min(0).max(1024),offset:e.number().int().min(0).max(1e7),sha256:le,contentsBase64:e.string().min(1).max(131072)}).strict(),me=e.object({uploadId:j}).strict(),Pe=ue.pick({id:!0,title:!0,sourceTaskId:!0,sourceTurnId:!0,revision:!0,createdAt:!0,validation:!0}),he=e.object({sessionId:j,turnId:j,output:Pe,sandboxPath:e.string().trim().min(1).max(4096)}).strict();var z=e.string().trim().min(1).max(200),Ae=e.object({type:e.enum(["create","get","start","stop","exec","open_port","list_files","download_file","upload_file","search_files","delete_file","stat_file","mkdir","move_file","process_start","process_get","git_status","git_diff","git_export_patch","git_branch","git_commit","git_pull","git_push"]),sandboxId:z.optional(),payload:e.unknown().optional(),processId:z.optional(),failOnUnpreservedChanges:e.boolean().optional()}).strict().superRefine((i,t)=>{i.type!=="create"&&!i.sandboxId&&t.addIssue({code:"custom",message:"Sandbox identity is required."}),i.type==="create"&&i.sandboxId&&t.addIssue({code:"custom",message:"Create cannot target a sandbox identity."}),i.type==="process_get"&&!i.processId&&t.addIssue({code:"custom",message:"Process identity is required."})}),fe=e.object({action:Ae}).strict(),be=e.object({sessionId:z,turnId:z,name:z}).strict();var p=1,a=e.string().trim().min(1).max(191),R=e.number().int().min(1).max(200),Ht=e.object({teamId:a,ownerUserId:a,workspaceId:a,conversationId:a,turnId:a,attempt:e.number().int().min(1),leaseGeneration:e.number().int().min(1)}).strict(),ge=e.discriminatedUnion("operation",[e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/grade"),params:e.object({action:e.enum(["upload","execute"]),callId:a,sessionId:a,turnId:a,sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().positive().max(2e7),timeoutMs:e.number().int().positive().max(3e5),offset:e.number().int().nonnegative().max(2e7).optional(),contentsBase64:e.string().max(131072).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/sandbox"),params:e.object({sessionId:a,turnId:a,action:e.enum(["upload","exec","read","stop"]),area:e.enum(["policy","runtime"]).optional(),path:e.string().min(1).max(4096).optional(),sha256:e.string().regex(/^[a-f0-9]{64}$/).optional(),sizeBytes:e.number().int().min(0).max(1e7).optional(),offset:e.number().int().min(0).max(1e7).optional(),contentsBase64:e.string().max(131072).optional(),command:e.string().min(1).max(2e4).optional(),stdin:e.string().max(12e4).optional(),cwd:e.string().max(4096).optional(),timeoutMs:e.number().int().min(1).max(18e4).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/list"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/read"),params:e.object({fileId:a,revision:e.number().int().min(1),offset:e.number().int().min(0).max(1e7).optional(),maxChars:e.number().int().min(1).max(1e5).optional(),firstPage:e.number().int().min(1).max(1e3).optional(),pageCount:e.number().int().min(1).max(10).optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/readBytes"),params:e.object({sessionId:a,turnId:a,fileId:a,revision:e.number().int().positive(),sha256:e.string().regex(/^[a-f0-9]{64}$/),sizeBytes:e.number().int().min(1).max(1e7),offset:e.number().int().min(0).max(1e7)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile.externalDataset.authorize"),params:e.object({bindingHash:e.string().regex(/^[a-f0-9]{64}$/),manifestHash:e.string().regex(/^[a-f0-9]{64}$/).optional(),taskId:a.optional(),seed:e.string().min(1).max(500).optional()}).strict().refine(i=>!!i.taskId==!!i.seed,"Case authority requires both task and seed.")}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/environment"),params:D}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("experiment/policy"),params:e.object({caseId:a,admissionHash:e.string().regex(/^[a-f0-9]{64}$/),ordinal:e.number().int().nonnegative(),messages:e.array(e.record(e.string(),e.unknown())).max(2e3),tools:e.array(e.record(e.string(),e.unknown())).max(200)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("sandbox/request"),params:fe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("embedding/authorize"),params:be}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/begin"),params:de}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/chunk"),params:pe}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/complete"),params:me}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("output/saveSandboxFile"),params:he}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("settings/get"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/get"),params:e.object({reference:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/get"),params:e.object({runId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/put"),params:e.object({runId:a,expectedRevision:e.number().int().min(0).nullable(),overlay:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/overlay/freezeProposal"),params:e.object({runId:a,expectedRevision:e.number().int().min(0),overlay:e.record(e.string(),e.unknown()),proposal:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/get"),params:e.object({workspaceId:a,key:e.string().min(1).max(120)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/list"),params:e.object({workspaceId:a,includeDeleted:e.boolean(),before:e.object({updatedAt:e.string(),key:e.string()}).strict().nullable(),limit:R}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/search"),params:e.object({workspaceId:a,query:e.string().trim().min(1).max(500),limit:e.number().int().min(1).max(20)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/memory/write"),params:e.object({input:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/state/read"),params:e.object({workspaceId:a,kind:e.enum(["selection","workspace_settings","evaluation_review_settings","candidates","cross_run_requests"]),afterId:a.nullable(),limit:e.number().int().min(1).max(100)}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("profile-evaluations/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),kind:e.enum(["grade","receipt","run","comparison","suite"]),id:a}).strict(),e.object({action:e.literal("page"),kind:e.enum(["grade","receipt","run","comparison","suite"]),profileKey:e.string().regex(/^[a-f0-9]{64}$/),before:e.object({createdAt:e.string(),id:a}).strict().nullable(),limit:e.number().int().min(1).max(100)}).strict(),e.object({action:e.literal("put"),kind:e.enum(["grade","receipt","run","comparison","suite"]),payload:e.record(e.string(),e.unknown()),profileKey:e.string().regex(/^[a-f0-9]{64}$/).nullable(),createdAt:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/workspace/transition"),params:e.discriminatedUnion("action",[e.object({action:e.literal("advance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),now:e.string()}).strict(),e.object({action:e.literal("reviewedAdvance"),receiptId:a,workspaceId:a,proposal:e.record(e.string(),e.unknown()),validations:e.array(e.record(e.string(),e.unknown())).max(100),nextRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),nextSourceRevision:e.string().min(1),reviewer:a,now:e.string()}).strict(),e.object({action:e.literal("rollback"),receiptId:a,workspaceId:a,expectedWorkspaceRevision:e.number().int().nonnegative(),expectedChannelRevision:e.number().int().nonnegative(),targetRelease:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),targetSourceRevision:e.string().min(1),rollbackOf:e.object({id:a,contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),now:e.string()}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("task-inbox/execute"),params:te}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("harness/review/execute"),params:ce}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("refiner/execute"),params:e.object({action:ie}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("create-improve/execute"),params:e.discriminatedUnion("action",[e.object({action:e.literal("get"),runId:a}).strict(),e.object({action:e.literal("page"),query:e.object({profileId:a.nullable(),targetKind:a.nullable(),targetId:a.nullable(),state:e.array(a).max(20)}).strict(),before:e.object({updatedAt:e.string(),id:a}).strict().nullable(),limit:R}).strict(),e.object({action:e.literal("put"),run:e.record(e.string(),e.unknown())}).strict(),e.object({action:e.literal("mutate"),mutation:e.record(e.string(),e.unknown()),next:e.record(e.string(),e.unknown())}).strict()])}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/get"),params:e.object({approvalId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("approval/upsert"),params:e.object({approval:e.record(e.string(),e.unknown()),expectedRevision:e.number().int().min(1).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/getByRequestId"),params:e.object({requestId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/upsert"),params:e.object({record:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("usage/page"),params:e.object({query:e.object({sessionId:a.optional(),turnId:a.optional(),provider:a.optional(),model:a.optional(),startedAtFrom:e.string().optional(),startedAtTo:e.string().optional(),visibility:e.enum(["user_facing","background","system"]).optional(),status:e.enum(["started","completed","failed","interrupted","missing"]).optional()}).strict(),before:e.object({startedAt:e.string(),requestOrdinal:e.number().int().min(0),id:a}).strict().nullable(),limit:R}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("capabilities"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/count"),params:e.object({}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/get"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/page"),params:e.object({afterId:a.nullable(),limit:R}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("session/put"),params:e.object({sessionId:a,expectedRevision:e.number().int().min(1).nullable(),session:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/count"),params:e.object({sessionId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/wakeCount"),params:e.object({sessionId:a,key:e.enum(["messageId","fromRunId"]),value:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/get"),params:e.object({turnId:a}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/put"),params:e.object({sessionId:a,turnId:a,expectedRevision:e.number().int().min(1).nullable(),turn:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/latest"),params:e.object({sessionId:a,status:e.enum(["in_progress","completed","failed","interrupted"]).nullable()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("turn/page"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:R}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("thread/turnPage"),params:e.object({sessionId:a,beforeSortIndex:e.number().int().min(0).nullable().optional(),limit:R}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("event/append"),params:e.object({event:e.record(e.string(),e.unknown())}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/page"),params:e.object({sessionId:a.nullable(),afterSequence:e.number().int().min(0),beforeSequence:e.number().int().min(1).nullable().optional(),limit:R,excludeReasoningDeltas:e.boolean().optional()}).strict()}).strict(),e.object({contractVersion:e.literal(p),requestId:a,operation:e.literal("events/latestAssistantText"),params:e.object({sessionId:a}).strict()}).strict()]),Vt=e.object({contractVersion:e.literal(p),operations:e.array(e.enum(["experiment/policy","experiment/environment","sandbox/request","embedding/authorize","output/begin","output/chunk","output/complete","output/saveSandboxFile","output/list","output/read","output/readBytes","settings/get","harness/get","harness/overlay/get","harness/overlay/put","harness/overlay/freezeProposal","harness/memory/get","harness/memory/list","harness/memory/search","harness/memory/write","harness/state/read","profile-evaluations/execute","profile-evaluations/sandbox","profile-evaluations/grade","harness/review/execute","harness/workspace/transition","task-inbox/execute","refiner/execute","create-improve/execute","approval/get","approval/upsert","usage/getByRequestId","usage/upsert","usage/page","session/count","session/get","session/page","session/put","turn/count","turn/wakeCount","turn/get","turn/put","turn/latest","turn/page","thread/turnPage","event/append","events/page","events/latestAssistantText"])).max(50),allowedTools:e.array(a).max(128),maxPageSize:R,maxRequestBytes:e.number().int().min(1).max(8388608),maxInFlight:e.number().int().min(1).max(64)}).strict();var we=class{static{o(this,"AgentHostStorageClient")}#e=new Map;#t=null;#r=1;bind(t){if(this.#t)throw new Error("Host storage client is already bound.");this.#t=t}async request(t,r=15e3){let n=ge.parse(t);if(!this.#t)throw new Error("Host storage transport is unavailable.");if(this.#e.size>=32)throw new Error("Host storage request limit exceeded.");let s=`host-storage:${this.#r++}`,c={jsonrpc:"2.0",id:s,method:"host/storage",params:n},l=n.operation==="experiment/policy"||n.operation==="experiment/environment";if(Buffer.byteLength(JSON.stringify(c))>(l?8388608:256e3))throw new Error("Host storage request is too large.");let d=new Promise((h,m)=>{let g=n.operation==="sandbox/request"||l?3e5:6e4,v=setTimeout(()=>{this.#e.delete(s),m(new Error("Host storage request timed out."))},Math.max(1,Math.min(g,r)));this.#e.set(s,{resolve:h,reject:m,timer:v,maxResponseBytes:n.operation==="experiment/environment"?16e5:1e6})});try{await this.#t(c)}catch(h){let m=this.#e.get(s);m&&(clearTimeout(m.timer),this.#e.delete(s),m.reject(h instanceof Error?h:new Error(String(h))))}return d}accept(t){let r=L.safeParse(t),n=r.success?null:U.safeParse(t),s=r.success?r.data:n?.success?n.data:null;if(!s||typeof s.id!="string"||!s.id.startsWith("host-storage:"))return!1;let c=this.#e.get(s.id);return c?(clearTimeout(c.timer),this.#e.delete(s.id),Buffer.byteLength(JSON.stringify(s))>c.maxResponseBytes?(c.reject(new Error("Host storage response is too large.")),!0):("error"in s?c.reject(new Error(`Host storage request failed: ${s.error.message}`)):c.resolve(s.result),!0)):!0}close(){this.#t=null;for(let t of this.#e.values())clearTimeout(t.timer),t.reject(new Error("Host storage transport closed."));this.#e.clear()}};import{once as ze}from"node:events";import{createInterface as He}from"node:readline";async function Ft(i){let t=null,r=Promise.resolve(),n=[],s=o(f=>(r=r.then(async()=>{i.writable.write(`${JSON.stringify(f)}
|
|
3
|
-
`)||await ze(i.writable,"drain")}),r),"write");i.hostStorageClient?.bind(f=>s(f));let c=o(()=>{if(!(!t?.initialized||n.length===0))for(let f of n.splice(0))s(f)},"flushPendingNotifications"),l,d=new Set,h=He({input:i.readable,crlfDelay:1/0}),m=[],g=!1,v=null,k=o(async f=>{let x=t;if(!x)throw new Error("Agent runtime dispatcher is unavailable.");let S=(async()=>{let G=await x.handle(f);G&&await s(G),c()})(),F=f&&typeof f=="object"&&"method"in f?f.method:null;if(F==="initialize"||F==="initialized"){await S;return}d.add(S),S.finally(()=>d.delete(S))},"dispatch"),w=(async()=>{let f=typeof i.host=="function"?await i.host():i.host;for(t=new V(f),l=f.subscribe?.(x=>{if(!t?.initialized){n.push(x);return}s(x)});m.length>0;)await k(m.shift());g=!0})().catch(f=>{v=f,h.close()});try{for await(let f of h){if(!f.trim())continue;if(Buffer.byteLength(f,"utf8")>1e6){await s({jsonrpc:"2.0",id:null,error:{code:-32600,message:"Request exceeds the JSONL size limit"}});continue}let x;try{x=JSON.parse(f)}catch{await s({jsonrpc:"2.0",id:null,error:{code:-32700,message:"Parse error"}});continue}if(!i.hostStorageClient?.accept(x))if(g)await k(x);else if(m.length>=64){let S=x&&typeof x=="object"&&"id"in x?x.id:null;(typeof S=="string"||typeof S=="number")&&await s({jsonrpc:"2.0",id:S,error:{code:-32e3,message:"Runtime startup request limit exceeded"}})}else m.push(x)}if(await w,v)throw v;await Promise.all(d),await r}finally{i.hostStorageClient?.close(),l?.()}}o(Ft,"runAgentJsonlServer");var M=e.object({threadId:e.string().trim().min(1)}).passthrough(),Ve=M.extend({includeHistory:e.boolean().optional()}),Oe=e.object({session:e.unknown()}).strict(),H=M.extend({input:e.unknown()}),Me=H.extend({idempotencyKey:e.string().trim().min(1).max(200)}),Be=H.extend({inputId:e.string().trim().min(1)}),Ne=M.extend({reason:e.string().trim().min(1).optional()}),$e=e.object({approvalId:e.string().trim().min(1),input:e.unknown()}).strict();function tr(i){let t=o(async(n,s,c)=>{let l=performance.now();i.telemetry?.({method:n,phase:"started",threadId:s,durationMs:null,errorClass:null});try{let d=await c();return i.telemetry?.({method:n,phase:"completed",threadId:s,durationMs:performance.now()-l,errorClass:null}),d}catch(d){throw i.telemetry?.({method:n,phase:"failed",threadId:s,durationMs:performance.now()-l,errorClass:d instanceof Error?d.name:"UnknownError"}),d}},"run"),r=o(async(n,s="thread/read")=>{let{threadId:c,includeHistory:l}=Ve.parse(n);return t(s,c,async()=>{if(l===!1)return{thread:await i.readThread(c),turns:[],events:[]};let[d,h,m]=await Promise.all([i.readThread(c),i.listTurns(c),i.listEvents(c)]);return{thread:d,turns:h,events:m}})},"threadRead");return{capabilities:o(n=>t("runtime/capabilities",null,()=>i.capabilities(n)),"capabilities"),threadStart:o(async n=>t("thread/start",null,async()=>({thread:await i.createThread(Oe.parse(n).session)})),"threadStart"),threadResume:o(n=>r(n,"thread/resume"),"threadResume"),threadRead:r,turnStart:o(async n=>{let s=H.parse(n);return t("turn/start",s.threadId,async()=>({turn:await i.startTurn(s.threadId,s.input)}))},"turnStart"),turnSteer:o(async n=>{let s=H.parse(n);return t("turn/steer",s.threadId,async()=>({receipt:await i.steerTurn(s.threadId,s.input)}))},"turnSteer"),taskInbox:o(async n=>{let{threadId:s}=M.parse(n);return t("task/inbox",s,()=>i.readTaskInbox(s))},"taskInbox"),taskQueue:o(async n=>{let s=Me.parse(n);return t("task/queue",s.threadId,()=>i.queueTaskInput(s.threadId,s.input,s.idempotencyKey))},"taskQueue"),taskInputUpdate:o(async n=>{let s=Be.parse(n);return t("task/inputUpdate",s.threadId,()=>i.updateTaskInput(s.threadId,s.inputId,s.input))},"taskInputUpdate"),turnInterrupt:o(async n=>{let s=Ne.parse(n);return t("turn/interrupt",s.threadId,async()=>({turn:await i.interruptTurn(s.threadId,s.reason)}))},"turnInterrupt"),approvalResolve:o(async n=>{let s=$e.parse(n);return t("approval/resolve",null,async()=>({approval:await i.resolveApproval(s.approvalId,s.input)}))},"approvalResolve"),userInputResolve:o(async n=>{let s=H.parse(n);return t("userInput/resolve",s.threadId,async()=>(i.isTurnActive(s.threadId)&&await i.waitForTurnSettlement(s.threadId),{turn:await i.startTurn(s.threadId,s.input)}))},"userInputResolve"),profileWorkflows:o(()=>t("profile/workflows",null,()=>i.listProfileWorkflows()),"profileWorkflows"),profileEvaluations:o(n=>t("profile/evaluations",null,()=>i.listProfileEvaluations(n)),"profileEvaluations"),profileTrainingSource:o(()=>t("profile/trainingSource",null,()=>i.loadProfileTrainingSource()),"profileTrainingSource"),profileEvaluationPrepare:o(n=>t("profile/evaluations/prepare",null,()=>i.prepareProfileEvaluationRun(n)),"profileEvaluationPrepare"),profileEvaluationRun:o(n=>t("profile/evaluations/run",null,()=>i.runPreparedProfileEvaluation(n)),"profileEvaluationRun"),...i.executeExperimentCase?{experimentExecuteCase:o(n=>t("experiments/executeCase",null,()=>i.executeExperimentCase(n)),"experimentExecuteCase")}:{},...i.cancelExperimentCase?{experimentCancelCase:o(n=>t("experiments/cancelCase",null,()=>i.cancelExperimentCase(n)),"experimentCancelCase")}:{},profileEvaluationRunSuite:o(n=>t("profile/evaluations/runSuite",null,()=>i.runProfileEvaluationSuite(n)),"profileEvaluationRunSuite"),profileEvaluationExecuteCase:o(n=>t("profile/evaluations/executeCase",null,()=>i.executeProfileEvaluationCase(n)),"profileEvaluationExecuteCase"),profileEvaluationExecuteRun:o(n=>t("profile/evaluations/executeRun",null,()=>i.executeProfileEvaluationRun(n)),"profileEvaluationExecuteRun"),profileEvaluationCompare:o(n=>t("profile/evaluations/compare",null,()=>i.compareProfileEvaluationRuns(n)),"profileEvaluationCompare"),profileEvaluationReport:o(n=>t("profile/evaluations/report",null,()=>i.buildProfileEvaluationReport(n)),"profileEvaluationReport"),harnessInspect:o(()=>t("harness/inspect",null,()=>i.inspectHarness()),"harnessInspect"),harnessProposalReview:o(n=>t("harness/proposalReview",null,()=>i.reviewHarnessProposal(n)),"harnessProposalReview"),harnessReview:o(n=>t("harness/review",null,()=>i.reviewHarness(n)),"harnessReview"),harnessAcceptEvaluationReview:o(n=>t("harness/acceptEvaluationReview",null,()=>i.acceptHarnessEvaluationReview(n)),"harnessAcceptEvaluationReview"),harnessMaterializeEvaluationTaskset:o(n=>t("harness/materializeEvaluationTaskset",null,()=>i.materializeHarnessEvaluationTaskset(n)),"harnessMaterializeEvaluationTaskset"),harnessRunEvaluationBaseline:o(n=>t("harness/runEvaluationBaseline",null,()=>i.runHarnessEvaluationBaseline(n)),"harnessRunEvaluationBaseline"),harnessValidate:o(()=>t("harness/validate",null,()=>i.validateHarness()),"harnessValidate"),harnessBackgroundReview:o(n=>t("harness/backgroundReview",null,()=>i.updateHarnessBackgroundReview(n)),"harnessBackgroundReview"),harnessDiff:o(n=>t("harness/diff",null,()=>i.diffHarness(n)),"harnessDiff"),harnessRollback:o(n=>t("harness/rollback",null,()=>i.rollbackHarness(n)),"harnessRollback"),refinerInspect:o(()=>t("refiner/inspect",null,()=>i.inspectRefiner()),"refinerInspect"),refinerUpdate:o(n=>t("refiner/update",null,()=>i.updateRefiner(n)),"refinerUpdate"),refinerActivate:o(n=>t("refiner/activate",null,()=>i.activateRefiner(n)),"refinerActivate"),refinerRollback:o(n=>t("refiner/rollback",null,()=>i.rollbackRefiner(n)),"refinerRollback"),subscribe:i.subscribeEvents&&i.eventNotification?n=>i.subscribeEvents(s=>n(i.eventNotification(s))):void 0}}o(tr,"createAgentRuntimeService");var T=e.string().regex(/^[a-f0-9]{64}$/),Le=e.object({harnessReleaseHash:T,instructionsHash:T,skillHashes:e.record(e.string(),T),agentAssetHashes:e.record(e.string(),T),toolCatalogHash:T,memoryRevision:e.number().int().nonnegative().nullable()}).strict(),Ue=e.object({protocolVersion:e.string().trim().min(1),threadId:e.string().trim().min(1),turnId:e.string().trim().min(1),harnessReleaseHash:T,toolCatalogHash:T,context:e.record(e.string(),e.unknown()),pendingInteraction:e.record(e.string(),e.unknown()).nullable(),usage:e.record(e.string(),e.unknown())}).strict();function or(i){return E(Le.parse(i))}o(or,"effectiveSurfaceHash");function ar(i){return E(Ue.parse(i))}o(ar,"checkpointHash");function cr(i){return[i.system,...i.harnessInstructions,...i.skillInstructions,...i.hostInstructions??[]].map(t=>t.trim()).filter(Boolean).join(`
|
|
4
|
-
|
|
5
|
-
`)}o(cr,"materializeAgentPrompt");function mr(i){let t=new Map;for(let l of i){let d=l.name.trim();if(!d)throw new Error("Agent tool names cannot be empty.");if(t.has(d))throw new Error(`Duplicate agent tool: ${d}.`);if(!l.unavailableReason&&!l.execute)throw new Error(`Agent tool ${d} is declared as available without an executor.`);t.set(d,{...l,name:d})}let r=[...t.values()].sort((l,d)=>l.name.localeCompare(d.name)),n=r.filter(l=>!l.unavailableReason).map(l=>({name:l.name,description:l.description,inputSchema:e.toJSONSchema(l.inputSchema,{target:"draft-7",unrepresentable:"any"})})),s=r.map(l=>({name:l.name,displayLabel:l.displayLabel??l.name,placement:l.placement,available:!l.unavailableReason,unavailableReason:l.unavailableReason??null})),c=E({modelTools:n,capabilities:s});return{byName:t,tools:r,modelTools:n,capabilities:s,hash:c}}o(mr,"createAgentToolCatalog");async function hr(i,t){let r=i.byName.get(t.name);if(!r)throw new Error(`Unknown agent tool: ${t.name}.`);if(r.unavailableReason)throw new Error(`Agent tool ${t.name} is unavailable: ${r.unavailableReason}`);if(!r.execute)throw new Error(`Agent tool ${t.name} has no executor.`);return r.execute(r.inputSchema.parse(t.arguments),t.context)}o(hr,"executeAgentTool");function fr(i){let t=new Set,r=[...i].map(c=>{let l=c.name.trim();if(!l)throw new Error("Agent tool names cannot be empty.");if(t.has(l))throw new Error(`Duplicate agent tool: ${l}.`);if(t.add(l),!c.unavailableReason&&!c.executorAvailable)throw new Error(`Agent tool ${l} is declared as available without an executor.`);return{...c,name:l}}).sort((c,l)=>c.name.localeCompare(l.name)),n=r.filter(c=>!c.unavailableReason).map(c=>({name:c.name,description:c.description,inputSchema:c.inputSchema})),s=r.map(c=>({name:c.name,displayLabel:c.displayLabel??c.name,placement:c.placement,available:!c.unavailableReason,unavailableReason:c.unavailableReason??null}));return{byName:new Map(r.map(c=>[c.name,c])),tools:r,modelTools:n,capabilities:s,hash:E({modelTools:n,capabilities:s})}}o(fr,"createAgentToolCatalogProjection");async function br(i,t){let r=i.byName.get(t.name);if(!r)throw new Error(`Unknown agent tool: ${t.name}.`);if(r.unavailableReason)throw new Error(`Agent tool ${t.name} is unavailable: ${r.unavailableReason}`);if(!r.execute)throw new Error(`Agent tool ${t.name} has no executor.`);let n=r.validateArguments?r.validateArguments(t.arguments):t.arguments;return r.execute(n,t.context)}o(br,"executeProjectedAgentTool");var ve=class{static{o(this,"TaskSignals")}#e=new Map;notify(t){for(let r of[...this.#e.get(t)??[]])r()}subscribe(t,r){let n=this.#e.get(t);return n||this.#e.set(t,n=new Set),n.add(r),()=>{n.delete(r),n.size===0&&this.#e.delete(t)}}async wait(t){let r=o(()=>{},"wake"),n=0,s=o(()=>{n+=1,r()},"changed"),c=[...new Set(t.taskIds)].map(d=>this.subscribe(d,s)),l=setTimeout(s,Math.max(0,t.deadline-Date.now()));t.signal.addEventListener("abort",s);try{for(;;){t.signal.throwIfAborted();let d=n,h=await t.read();if(h!==null)return h;if(Date.now()>=t.deadline)return null;n===d&&await new Promise(m=>{r=m,(n!==d||t.signal.aborted)&&m()})}}finally{clearTimeout(l),t.signal.removeEventListener("abort",s);for(let d of c)d()}}},xe=class{static{o(this,"TaskSerialExecutor")}#e=new Map;async run(t,r){let s=(this.#e.get(t)??Promise.resolve()).then(r),c=s.then(()=>{},()=>{});this.#e.set(t,c);try{return await s}finally{this.#e.get(t)===c&&this.#e.delete(t)}}};var B=class extends Error{static{o(this,"AcpRpcError")}code;data;constructor(t,r,n){super(r),this.code=t,this.data=n,this.name="AcpRpcError"}};import{execFile as De}from"node:child_process";function y(i,t){if(i.pid){if(process.platform==="win32"){De("taskkill",["/PID",String(i.pid),"/T",...t==="SIGKILL"?["/F"]:[]],{windowsHide:!0},()=>{});return}try{process.kill(-i.pid,t)}catch(r){if(r.code!=="ESRCH")throw r}}}o(y,"signalNativeProcess");import{spawn as Je}from"node:child_process";import{StringDecoder as Fe}from"node:string_decoder";var J=8*1024*1024,N={outcome:{outcome:"cancelled"}};function C(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}o(C,"object");var Ie=class{static{o(this,"AcpClient")}options;child=null;pending=new Map;sessions=new Set;activePrompts=new Set;permissions=new Map;nextId=1;buffer="";decoder=new Fe("utf8");initialized=null;updateQueue=Promise.resolve();stopped=!1;constructor(t){this.options=t}initialize(){return this.initialized?this.initialized:(this.initialized=this.connect(),this.initialized)}async connect(){if(this.stopped)throw new Error("ACP client is closed; reconnect with a new client.");let t=Je(this.options.command,this.options.args,{cwd:this.options.cwd,env:this.options.env??process.env,stdio:["pipe","pipe","pipe"],shell:!1,detached:process.platform!=="win32"});this.child=t,t.stdout.on("data",r=>this.consume(this.decoder.write(r))),t.stderr.resume(),t.stdin.on("error",r=>this.fail(r)),t.on("error",r=>this.fail(r)),t.on("exit",(r,n)=>this.fail(new Error(`ACP agent exited (${n??r??"unknown"}).`)));try{let r=await this.request("initialize",{protocolVersion:1,clientInfo:{name:"openpond",title:"OpenPond",version:"1"},clientCapabilities:{fs:{readTextFile:!1,writeTextFile:!1},terminal:!1,auth:{terminal:!1}}});if(r.protocolVersion!==1)throw new Error(`Unsupported ACP protocol version: ${r.protocolVersion}`);return r}catch(r){throw await this.stop(),r}}async authenticate(t){let n=(await this.initialize()).authMethods?.find(s=>s.id===t);if(!n)throw new Error("The agent did not advertise this authentication method.");if(n.type==="terminal")throw new Error("Run the agent's terminal login, then reconnect.");await this.request("authenticate",{methodId:t})}async createSession(t,r=[]){await this.initialize();let n=await this.request("session/new",{cwd:t,mcpServers:r});if(typeof n.sessionId!="string"||!n.sessionId)throw new Error("Agent returned no native session identity.");return this.sessions.add(n.sessionId),n}async loadSession(t,r,n=[]){if(!(await this.initialize()).agentCapabilities?.loadSession)throw new Error("This agent does not support native session loading.");this.sessions.add(t);try{let c=await this.request("session/load",{sessionId:t,cwd:r,mcpServers:n});return await this.updateQueue,{...c,sessionId:t}}catch(c){throw this.sessions.delete(t),c}}async setModel(t,r){this.assertSession(t),await this.request("session/set_model",{sessionId:t,modelId:r})}async setMode(t,r){this.assertSession(t),await this.request("session/set_mode",{sessionId:t,modeId:r})}async setConfigOption(t,r,n){return this.assertSession(t),await this.request("session/set_config_option",{sessionId:t,configId:r,value:n})}async prompt(t,r,n){if(this.assertSession(t),n?.aborted)throw new Error("ACP prompt cancelled.");if(this.activePrompts.has(t))throw new Error("A prompt is already active for this native session.");this.activePrompts.add(t);let s,c=o(()=>{this.cancel(t),s=setTimeout(()=>{this.stop()},5e3),s.unref()},"abort");n?.addEventListener("abort",c,{once:!0});try{let l=await this.request("session/prompt",{sessionId:t,prompt:r},0);return await this.updateQueue,n?.aborted?{...l,stopReason:"cancelled"}:l}catch(l){if(n?.aborted)return{stopReason:"cancelled"};throw l}finally{s&&clearTimeout(s),n?.removeEventListener("abort",c),this.activePrompts.delete(t),this.cancelPermissions(t)}}cancel(t){this.cancelPermissions(t),this.sessions.has(t)&&this.child&&this.write({jsonrpc:"2.0",method:"session/cancel",params:{sessionId:t}})}async stop(){if(this.stopped)return;this.stopped=!0;let t=this.child;this.fail(new Error("ACP connection closed.")),!(!t||t.exitCode!==null||t.signalCode!==null)&&await new Promise(r=>{let n=setTimeout(()=>y(t,"SIGKILL"),2e3);n.unref(),t.once("exit",()=>{clearTimeout(n),r()}),y(t,"SIGTERM")})}assertSession(t){if(!this.sessions.has(t))throw new Error("Session does not belong to this ACP connection.")}request(t,r,n=this.options.requestTimeoutMs??3e4){let s=this.nextId++;return new Promise((c,l)=>{let d=n>0?setTimeout(()=>{this.pending.delete(s),l(new Error(`ACP request timed out: ${t}`))},n):void 0;d?.unref(),this.pending.set(s,{resolve:c,reject:l,timer:d});try{this.write({jsonrpc:"2.0",id:s,method:t,params:r})}catch(h){d&&clearTimeout(d),this.pending.delete(s),l(h)}})}write(t){if(!this.child||this.child.stdin.destroyed)throw new Error("ACP connection is not running.");let r=JSON.stringify(t);if(Buffer.byteLength(r)>J)throw new Error("ACP frame exceeds the size limit.");this.child.stdin.write(`${r}
|
|
6
|
-
`)}consume(t){this.buffer+=t;let r;for(;(r=this.buffer.indexOf(`
|
|
7
|
-
`))!==-1;){let n=this.buffer.slice(0,r);if(this.buffer=this.buffer.slice(r+1),!!n.trim())try{if(Buffer.byteLength(n)>J)throw new Error("ACP frame exceeds the size limit.");this.receive(JSON.parse(n))}catch{this.fail(new Error("Invalid ACP protocol frame.")),this.stop();return}}Buffer.byteLength(this.buffer)>J&&(this.fail(new Error("ACP frame exceeds the size limit.")),this.stop())}receive(t){if(!C(t)||t.jsonrpc!=="2.0")throw new Error("Invalid JSON-RPC envelope.");if(typeof t.method=="string"){if("id"in t){this.handleRequest(t);return}if(t.method==="session/update"&&C(t.params)){let{sessionId:n,update:s}=t.params;if(typeof n!="string"||!this.sessions.has(n)||!C(s))return;this.updateQueue=this.updateQueue.then(async()=>{await this.options.onUpdate?.(n,s)}),this.updateQueue.catch(c=>{this.fail(c),this.stop()})}return}if(typeof t.id!="number")return;let r=this.pending.get(t.id);r&&(this.pending.delete(t.id),r.timer&&clearTimeout(r.timer),C(t.error)?r.reject(new B(Number(t.error.code),String(t.error.message),t.error.data)):r.resolve(t.result))}async handleRequest(t){let r=t.id;if(!(typeof r!="number"&&typeof r!="string"))try{if(t.method!=="session/request_permission"){this.write({jsonrpc:"2.0",id:r,error:{code:-32601,message:"Client method not supported."}});return}let n=t.params;if(!C(n)||typeof n.sessionId!="string"||!Array.isArray(n.options)||!C(n.toolCall))throw new Error("Invalid permission request.");if(this.assertSession(n.sessionId),!this.activePrompts.has(n.sessionId)){this.write({jsonrpc:"2.0",id:r,result:N});return}let s=new AbortController,c=this.permissions.get(n.sessionId)??new Set;c.add(s),this.permissions.set(n.sessionId,c);let l=N;try{if(this.options.onPermission&&(l=await Promise.race([this.options.onPermission(n,s.signal),new Promise(d=>s.signal.addEventListener("abort",()=>d(N),{once:!0}))])),s.signal.aborted&&(l=N),l.outcome.outcome==="selected"){let d=l.outcome.optionId;if(!n.options.some(h=>C(h)&&h.optionId===d))throw new Error("Permission option was not advertised by the agent.")}}finally{c.delete(s),c.size||this.permissions.delete(n.sessionId)}this.child&&this.write({jsonrpc:"2.0",id:r,result:l})}catch{this.child&&this.write({jsonrpc:"2.0",id:r,error:{code:-32602,message:"Invalid or expired client request."}})}}cancelPermissions(t){for(let r of this.permissions.get(t)??[])r.abort();this.permissions.delete(t)}fail(t){let r=this.child,n=!!r;this.child=null,r&&(y(r,"SIGTERM"),setTimeout(()=>y(r,"SIGKILL"),2e3).unref());for(let s of this.pending.values())s.timer&&clearTimeout(s.timer),s.reject(t);this.pending.clear();for(let s of this.sessions)this.cancelPermissions(s);this.sessions.clear(),n&&this.options.onExit?.(t)}};import{spawn as Ge}from"node:child_process";import{randomUUID as ye}from"node:crypto";import{StringDecoder as Ke}from"node:string_decoder";var I=o(i=>i&&typeof i=="object"&&!Array.isArray(i)?i:{},"record"),ke=class{static{o(this,"ClaudeCliClient")}options;child=null;sessionId=null;pending=new Map;turn=null;permissions=new Set;updates=Promise.resolve();closed=!1;model="default";constructor(t){this.options=t}async initialize(){return{protocolVersion:1,agentCapabilities:{loadSession:!0,mcpCapabilities:{http:!0},promptCapabilities:{image:!0,embeddedContext:!0}},authMethods:[],agentInfo:{name:"Claude Code CLI",version:"native"}}}async authenticate(t){throw new Error("Use Claude Code's native login, then reconnect.")}async createSession(t,r=[]){return this.start(ye(),t,!1,r)}async loadSession(t,r,n=[]){return this.start(t,r,!0,n)}async start(t,r,n,s){if(this.child||this.closed)throw new Error("Claude connection already owns a session or is closed.");if(!/^[a-f0-9-]{36}$/i.test(t))throw new Error("Invalid native Claude session identity.");this.sessionId=t;let c=Object.fromEntries(s.map(m=>[String(m.name),{type:"http",url:m.url,headers:Object.fromEntries((Array.isArray(m.headers)?m.headers:[]).map(g=>{let v=I(g);return[String(v.name),String(v.value)]}))}])),l=Ge(this.options.command,["--print","--verbose","--input-format","stream-json","--output-format","stream-json","--include-partial-messages","--permission-prompt-tool","stdio",...s.length?["--mcp-config",JSON.stringify({mcpServers:c})]:[],n?"--resume":"--session-id",t],{cwd:r,env:this.options.env??process.env,stdio:["pipe","pipe","pipe"],shell:!1,detached:process.platform!=="win32"});this.child=l;let d=new Ke("utf8"),h="";l.stderr.resume(),l.stdout.on("data",m=>{h+=d.write(m);let g;for(;(g=h.indexOf(`
|
|
8
|
-
`))>=0;){let v=h.slice(0,g);if(h=h.slice(g+1),!!v.trim())try{if(Buffer.byteLength(v)>8*1024*1024)throw new Error("Oversized frame");this.receive(I(JSON.parse(v)))}catch{this.fail(new Error("Invalid Claude CLI protocol frame.")),this.stop();return}}Buffer.byteLength(h)>8*1024*1024&&(this.fail(new Error("Claude CLI frame exceeds limit.")),this.stop())}),l.on("error",m=>this.fail(m)),l.stdin.on("error",m=>this.fail(m)),l.on("exit",m=>{this.fail(new Error(`Claude CLI exited (${m??"signal"}).`)),y(l,"SIGTERM"),setTimeout(()=>y(l,"SIGKILL"),2e3).unref(),this.child=null});try{let m=await this.control({subtype:"initialize",hooks:null}),g=Array.isArray(m.models)?m.models.map(I).filter(w=>typeof w.value=="string"):[],v=g.find(w=>w.value==="default")?.description,k=typeof v=="string"?g.find(w=>w.value!=="default"&&typeof w.displayName=="string"&&(v===w.displayName||v.startsWith(`${w.displayName} \xB7`))):void 0;return{sessionId:t,models:{currentModelId:this.model,availableModels:g.map(w=>({modelId:String(w.value),name:w.value==="default"&&k?`${k.displayName} (default)`:String(w.displayName??w.value),...typeof w.description=="string"?{description:w.description}:{}}))},modes:{currentModeId:String(m.current_permission_mode??"manual"),availableModes:[{id:"manual",name:"Ask for permissions"},{id:"plan",name:"Plan"}]}}}catch(m){throw await this.stop(),m}}async setModel(t,r){this.assertSession(t),await this.control({subtype:"set_model",model:r}),this.model=r}async setMode(t,r){if(this.assertSession(t),!["manual","plan"].includes(r))throw new Error("Unsupported Claude permission mode.");await this.control({subtype:"set_permission_mode",mode:r})}async prompt(t,r,n){if(this.assertSession(t),this.turn)throw new Error("A prompt is already active for this native session.");if(n?.aborted)throw new Error("Claude turn cancelled.");let s=new Promise((d,h)=>{this.turn={resolve:d,reject:h}}),c,l=o(()=>{for(let d of this.permissions)d.abort();this.control({subtype:"interrupt"}).catch(()=>{}),c=setTimeout(()=>{this.stop()},5e3),c.unref()},"abort");n?.addEventListener("abort",l,{once:!0});try{this.write({type:"user",session_id:t,parent_tool_use_id:null,message:{role:"user",content:r.map(h=>h.type==="image"?{type:"image",source:{type:"base64",media_type:h.mimeType,data:h.data}}:h)}});let d=await s;return await this.updates,n?.aborted?{stopReason:"cancelled"}:d}catch(d){if(n?.aborted)return{stopReason:"cancelled"};throw d}finally{n?.removeEventListener("abort",l),c&&clearTimeout(c),this.turn=null;for(let d of this.permissions)d.abort();this.permissions.clear()}}assertSession(t){if(!this.child||this.sessionId!==t||this.closed)throw new Error("Session does not belong to this Claude connection.")}write(t){if(!this.child||this.child.stdin.destroyed)throw new Error("Claude connection is closed.");let r=JSON.stringify(t);if(Buffer.byteLength(r)>8*1024*1024)throw new Error("Claude input exceeds limit.");this.child.stdin.write(`${r}
|
|
9
|
-
`)}control(t){let r=ye();return new Promise((n,s)=>{let c=setTimeout(()=>{this.pending.delete(r),s(new Error(`Claude control request timed out: ${t.subtype}`))},this.options.requestTimeoutMs??3e4);c.unref(),this.pending.set(r,{resolve:n,reject:s,timer:c});try{this.write({type:"control_request",request_id:r,request:t})}catch(l){clearTimeout(c),this.pending.delete(r),s(l)}})}emit(t){if(!this.turn||!this.sessionId)return;let r=this.sessionId;this.updates=this.updates.then(async()=>{await this.options.onUpdate?.(r,t)}),this.updates.catch(n=>{this.fail(n),this.stop()})}receive(t){if(typeof t.session_id=="string"&&t.session_id!==this.sessionId){this.fail(new Error("Claude changed native session identity.")),this.stop();return}if(t.type==="control_response"){let r=I(t.response),n=String(r.request_id),s=this.pending.get(n);if(!s)return;clearTimeout(s.timer),this.pending.delete(n),r.subtype==="error"?s.reject(new Error(String(r.error??"Claude control failed."))):s.resolve(I(r.response))}else if(t.type==="control_request")this.permission(t);else if(t.type==="stream_event"){let r=I(t.event),n=I(r.delta),s=I(r.content_block);r.type==="content_block_delta"&&(n.type==="text_delta"||n.type==="thinking_delta")&&this.emit({sessionUpdate:n.type==="text_delta"?"agent_message_chunk":"agent_thought_chunk",content:{type:"text",text:n.text??n.thinking??""}}),r.type==="content_block_start"&&s.type==="tool_use"&&this.emit({sessionUpdate:"tool_call",toolCallId:s.id,title:s.name,kind:"other",status:"in_progress",rawInput:s.input})}else if(t.type==="assistant"){let r=I(t.message).content;for(let n of Array.isArray(r)?r.map(I):[])n.type==="tool_use"&&this.emit({sessionUpdate:"tool_call_update",toolCallId:n.id,title:n.name,status:"in_progress",rawInput:n.input})}else if(t.type==="user"){let r=I(t.message).content;for(let n of Array.isArray(r)?r.map(I):[])n.type==="tool_result"&&this.emit({sessionUpdate:"tool_call_update",toolCallId:n.tool_use_id,status:n.is_error?"failed":"completed",content:n.content})}else if(t.type==="result"){if(t.session_id&&t.session_id!==this.sessionId){this.fail(new Error("Claude changed native session identity."));return}this.emit({sessionUpdate:"usage_update",usage:t.usage,totalCostUsd:t.total_cost_usd}),t.is_error?this.turn?.reject(new Error(Array.isArray(t.errors)?t.errors.map(String).join("; "):"Claude turn failed.")):this.turn?.resolve({stopReason:"end_turn"})}}async permission(t){let r=I(t.request),n=String(t.request_id);if(r.subtype!=="can_use_tool"||!this.turn||!this.sessionId){this.write({type:"control_response",response:{subtype:"error",request_id:n,error:"Unsupported or inactive control request."}});return}let s=new AbortController;this.permissions.add(s);try{let c=I(r.input),l=r.tool_name==="AskUserQuestion"&&Array.isArray(c.questions)?c.questions:void 0,d=new Promise(g=>s.signal.addEventListener("abort",()=>g({outcome:{outcome:"cancelled"}}),{once:!0})),h=await Promise.race([d,this.options.onPermission?.({sessionId:this.sessionId,toolCall:{toolCallId:r.tool_use_id,title:r.title??r.tool_name,rawInput:r.input},questions:l,options:[{optionId:"allow",name:"Allow once",kind:"allow_once"},{optionId:"deny",name:"Deny",kind:"reject_once"}]},s.signal)]),m=!s.signal.aborted&&h?.outcome.outcome==="selected"&&h.outcome.optionId==="allow";this.child&&this.write({type:"control_response",response:{subtype:"success",request_id:n,response:m?{behavior:"allow",updatedInput:l?{...c,answers:h?.answers}:r.input}:{behavior:"deny",message:"Permission declined or turn cancelled."}}})}catch{this.child&&this.write({type:"control_response",response:{subtype:"success",request_id:n,response:{behavior:"deny",message:"Permission could not be resolved."}}})}finally{this.permissions.delete(s)}}fail(t){for(let r of this.pending.values())clearTimeout(r.timer),r.reject(t);this.pending.clear(),this.turn?.reject(t),this.turn=null;for(let r of this.permissions)r.abort();this.permissions.clear(),this.options.onExit?.(t)}async stop(){if(this.closed)return;this.closed=!0,this.fail(new Error("Claude connection closed."));let t=this.child;!t||t.exitCode!==null||t.signalCode!==null||(await new Promise(r=>{let n=setTimeout(()=>y(t,"SIGKILL"),2e3);n.unref(),t.once("exit",()=>{clearTimeout(n),r()}),y(t,"SIGTERM")}),this.child=null)}};export{$ as a,E as b,Ye as c,Ze as d,et as e,Se as f,Ee as g,st as h,q as i,lt as j,W as k,Q as l,L as m,U as n,ut as o,_e as p,V as q,X as r,D as s,te as t,ie as u,ce as v,ue as w,de as x,pe as y,me as z,Pe as A,he as B,Ae as C,fe as D,be as E,p as F,Ht as G,ge as H,Vt as I,we as J,Ft as K,tr as L,Le as M,Ue as N,or as O,ar as P,cr as Q,mr as R,hr as S,fr as T,br as U,ve as V,xe as W,B as X,Ie as Y,ke as Z};
|