openpond 0.2.52 → 0.2.54
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 +2 -1
- 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-NITNSHYS.js → app-server-runtime-7AXV6JZI.js} +1 -1
- package/dist/chunks/{apps-NELJL377.js → apps-TM74FFQB.js} +1 -1
- package/dist/chunks/{chunk-XC7AHL57.js → chunk-37DXASQL.js} +115 -115
- package/dist/chunks/chunk-4EEH7MEC.js +2 -0
- 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-T5T7NCHJ.js → chunk-5TNDPNS3.js} +1 -1
- package/dist/chunks/{chunk-AV3WI7JZ.js → chunk-6JAN4RMN.js} +1 -1
- package/dist/chunks/{chunk-OE2VF6KU.js → chunk-6VF3Q6QJ.js} +1 -1
- package/dist/chunks/{chunk-PVSUQGWK.js → chunk-7ZG3IT7C.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-ZBZBV5TB.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-L3V4QKRV.js → chunk-NHFGEVVH.js} +1 -1
- package/dist/chunks/{chunk-HJEY5LBD.js → chunk-PQHTZ5CP.js} +1 -1
- package/dist/chunks/{chunk-CFLMKFOE.js → chunk-UE3DMPGM.js} +2 -2
- package/dist/chunks/{chunk-QJRXTIOC.js → chunk-USKE34VR.js} +1 -1
- package/dist/chunks/{chunk-FQZFLNLY.js → chunk-YD55Z5H3.js} +1 -1
- package/dist/chunks/{chunk-RLZPX4YP.js → chunk-YJ4PNAST.js} +1 -1
- package/dist/chunks/{cli-ZYFSCHZK.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-5VFPYEIV.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-MGBPXXW2.js → hosted-experiment-improvement-HAB3UE6A.js} +1 -1
- package/dist/chunks/{hosted-harness-runtime-WOLADXXP.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-NBMUCZVS.js → hosted-profile-compiler-SCVJI2CP.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-OC4XNGL2.js} +1 -1
- package/dist/chunks/{hosted-profile-evaluation-preparation-I6H6RFT6.js → hosted-profile-evaluation-preparation-ZD4FM3FD.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-MGP3OYHL.js → src-NE6R4XC6.js} +109 -109
- package/dist/chunks/{teams-bot-Z6RJGHME.js → teams-bot-7I4BAUVO.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/web/assets/App-CO2F717V.css +1 -0
- package/dist/web/assets/{App-Dg6mZIQk.js → App-CuhaCsfb.js} +65 -64
- package/dist/web/assets/{AppDialog-gcj3rrTZ.js → AppDialog-BdusXgU0.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-Be-E4qZF.js → AppTerminalPanel-C4uRpnBz.js} +2 -2
- package/dist/web/assets/{AppsView-BdyPNSpT.js → AppsView-BS1czXUP.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-CcQxU0uO.js → BrowserSidebar-Bl7V6YO2.js} +1 -1
- package/dist/web/assets/{CartesianChart-CN5hB6rV.js → CartesianChart-BstFbsdn.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-BiDPHgXG.js → CollaborationTabs-B8YAf0c1.js} +1 -1
- package/dist/web/assets/{CommandMenu-B2qJCgWH.js → CommandMenu-DZct7zUJ.js} +1 -1
- package/dist/web/assets/{CommunityView-D1aOQKfS.js → CommunityView-CR0-W-uG.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-f1tdD0QS.js → ComposerCreateImproveStrip-DR-Qo7b4.js} +1 -1
- package/dist/web/assets/{GetStartedView-CPYs0fYN.js → GetStartedView-xqQoMMei.js} +1 -1
- package/dist/web/assets/HostedModelLearningReview-CHxxf_Lu.js +1 -0
- package/dist/web/assets/{HostedModelLearningSettings-IEKRXOkG.js → HostedModelLearningSettings-De3i9wF4.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-DkIa0oG_.js → LabModelVersionDetailPage-DAY1MmqP.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-BUlU1Ti-.js → LabSkillSidebar-DLnIgnry.js} +1 -1
- package/dist/web/assets/{LabsRoute-8cKFNq19.js → LabsRoute-CXJRJMhr.js} +4 -4
- package/dist/web/assets/{MainChatThread-C5GwaIl_.js → MainChatThread-BwAla81W.js} +2 -2
- package/dist/web/assets/{MainPane-SMqq5YAM.js → MainPane-CakOBCHw.js} +4 -4
- package/dist/web/assets/{MarkdownText-CLnvdLVg.js → MarkdownText-gJMuefaJ.js} +1 -1
- package/dist/web/assets/{NativeSkillSidebar-B9bVb00x.js → NativeSkillSidebar-Dlxb8iOC.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-CelgG7Ua.js → NewExperienceSwitcher-DM-cqJ-K.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-eEnsg9s2.js → NewProjectDialog-Cu1q75gq.js} +1 -1
- package/dist/web/assets/{OutputsPage-ByvsTUW-.js → OutputsPage-DiXMkasl.js} +1 -1
- package/dist/web/assets/{ProjectsPage-Cl2zFh8X.js → ProjectsPage-DqiBHiCB.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-MnGscF87.js → RightChatPanelStack-VaOOmxwd.js} +1 -1
- package/dist/web/assets/{RightSidebarHomePanel-C6NXMYuy.js → RightSidebarHomePanel-CeSFJM5s.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-DCb6d7Lg.js → ScheduledWorkPage-D1jRQxFs.js} +1 -1
- package/dist/web/assets/{SettingsView-BMFfrxmo.js → SettingsView-RA9OXgcu.js} +3 -3
- package/dist/web/assets/{TeamChatView-DW_v2B9E.js → TeamChatView-DM0adMtj.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-BJ7qsr9F.js → TerminalOverlay-CFlH51DD.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-GSIwP6f1.js → TrainingCreationPanel-CgIBVGha.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-DorY6I29.js → TrainingDraftPanel-Bbo3RRie.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-DmzStI9q.js → UsageSettingsSection-CSRjJUSa.js} +1 -1
- package/dist/web/assets/{WorkSidebarPanel-zsJrGaaL.js → WorkSidebarPanel-DwlEMEoG.js} +1 -1
- package/dist/web/assets/WorkspaceDiffPanel-pGVezNMw.js +14 -0
- package/dist/web/assets/{WorkspaceEnvironmentMenu-vJw9hE0y.js → WorkspaceEnvironmentMenu-Byjngd9V.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-BpL-xtRX.js → WorkspaceGitDialogs-Dgmg-6XG.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-CJ3x0GHH.js → WorkspaceMonacoEditor-BR4qxMgU.js} +3 -3
- package/dist/web/assets/{arrow-up-right-C60QSULo.js → arrow-up-right-H0pvnH2s.js} +1 -1
- package/dist/web/assets/{chunk-UHVJOMWN-BxgPi0yP.js → chunk-UHVJOMWN-BqXRe639.js} +1 -1
- package/dist/web/assets/{clipboard-QIy0Jd_K.js → clipboard-BZzZ82Bk.js} +1 -1
- package/dist/web/assets/{cloud-upload-B9L-_gy0.js → cloud-upload-CJPYPVl8.js} +1 -1
- package/dist/web/assets/{cssMode-ffPyPUW9.js → cssMode-WC4Rg1l-.js} +1 -1
- package/dist/web/assets/{folder-open-BFy7KXWm.js → folder-open-sLZJxLQy.js} +1 -1
- package/dist/web/assets/{folder-plus-C3iGtUOI.js → folder-plus-C84wrpt_.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-DsTniKvi.js → git-commit-horizontal-Cotm7KEC.js} +1 -1
- package/dist/web/assets/{htmlMode-7ytlsiyK.js → htmlMode-C6oZGeaB.js} +1 -1
- package/dist/web/assets/{index-BK8GmZmB.js → index-BxWTVKtn.js} +2 -2
- package/dist/web/assets/index-dSmk3FLJ.css +1 -0
- package/dist/web/assets/{info-C8mwoaIJ.js → info-Dc81lEfw.js} +1 -1
- package/dist/web/assets/{jsonMode-BT35NJi4.js → jsonMode-BET4LQIn.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-BKAwIewO.js → lspLanguageFeatures-BPxA_-Kg.js} +1 -1
- package/dist/web/assets/{minimize-2-34MApatV.js → minimize-2-Bs7MVN3C.js} +1 -1
- package/dist/web/assets/{monaco.contribution-CxtX0z-m.js → monaco.contribution-7AUuf2NS.js} +2 -2
- package/dist/web/assets/{monaco.contribution-9diduNNi.js → monaco.contribution-BH6kkO4b.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DVnPUDsR.js → monaco.contribution-DFzEyaHi.js} +2 -2
- package/dist/web/assets/{monaco.contribution-Dj4R5U8Z.js → monaco.contribution-DXzyQfVi.js} +2 -2
- package/dist/web/assets/{monitor-4JxqJ7wz.js → monitor-DXL019Wf.js} +1 -1
- package/dist/web/assets/{play-C4PtpamL.js → play-CXkxUZeU.js} +1 -1
- package/dist/web/assets/{python-0GVncePC.js → python-PzBkTjWx.js} +1 -1
- package/dist/web/assets/{save-DjB16eou.js → save-DpezrtH2.js} +1 -1
- package/dist/web/assets/{square-Coz7UQqd.js → square-oy7f5Ce6.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-D-3108_3.js → toggleHighContrast-Cto-fOXm.js} +1 -1
- package/dist/web/assets/{tsMode-CV4ktqqR.js → tsMode-BYA4LNc6.js} +1 -1
- package/dist/web/assets/{upload-D007T9Hm.js → upload-C5YFNgtS.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BXjFbAVS.js → useLocalAgentSchedules-CnyTsqlf.js} +1 -1
- package/dist/web/assets/useProviderSettings-B_KeQjE5.js +5 -0
- package/dist/web/assets/{useSessionTurnCache-Bee6zbC_.js → useSessionTurnCache-DICuJSJW.js} +1 -1
- package/dist/web/assets/{wifi-off-BbNZc0za.js → wifi-off-nzHj7JXp.js} +1 -1
- package/dist/web/assets/{workers-DNQ5ne3z.js → workers-Dboaw6f_.js} +1 -1
- package/dist/web/assets/{yaml-BfAho-gB.js → yaml-uuY5JmO8.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunks/chunk-EPY7M5XS.js +0 -2
- package/dist/web/assets/App-DkH8CeoI.css +0 -1
- package/dist/web/assets/HostedModelLearningReview-DVfJyUW_.js +0 -1
- package/dist/web/assets/WorkspaceDiffPanel-CiFsZjMm.js +0 -14
- package/dist/web/assets/index-C0H85uUI.css +0 -1
- package/dist/web/assets/useProviderSettings-SY7mp-5B.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
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{d as N}from"./chunk-7QEE4PBI.js";import"./chunk-XDMUD4FW.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-N3DEA6PG.js";import{c as K}from"./chunk-PA7XP42P.js";import{c as L,f as B}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-RLZPX4YP.js";import"./chunk-Q4H3NUVW.js";import{c as u,f as E}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{a as I,b as S,c as q,g as U,h as $,i as W,j as g,k as A,l as T,m as O,n as j,o as C}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import{d as z}from"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import{Q as x,U as H}from"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import{b as i}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as w}from"./chunk-FTQLQJQV.js";var D=i.enum(["create","save","publish","begin_version"]),V=i.object({operationId:i.string().trim().min(1).max(240),kind:D,requestHash:i.string().regex(/^[a-f0-9]{64}$/),receipt:g,base:g.nullable()}).strict().superRefine((n,a)=>{let{receipt:e,base:t,kind:r}=n;(t&&(t.teamId!==e.teamId||t.datasetId!==e.datasetId||t.revision+1!==e.revision)||!t&&e.revision!==1)&&a.addIssue({code:"custom",message:"Operation recovery history identity/revision mismatch."}),t&&((t.ownerScope??"workspace")!==(e.ownerScope??"workspace")||t.originProjectId!==e.originProjectId||t.workspace.draft.createdAt!==e.workspace.draft.createdAt)&&a.addIssue({code:"custom",message:"Operation recovery cannot change Dataset ownership or origin."});let s=t?e.workspace.draft.status==="published"?"publish":t.workspace.draft.status==="published"?"begin_version":"save":"create";r!==s&&a.addIssue({code:"custom",message:"Operation recovery kind differs from its retained lifecycle."})});var k=class{constructor(a){this.options=a;let e=new URL(a.baseUrl);if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||!a.apiKey.trim()||!a.teamId.trim())throw new Error("A clean API origin and workspace credentials are required.");this.baseUrl=e.toString().replace(/\/+$/,"")}options;static{w(this,"OpenPondDatasetWorkspaceClient")}baseUrl;async list(a={}){let{signal:e,...t}=a,r=$.parse(t),s=new URLSearchParams(Object.entries(r).filter(([,c])=>c!==void 0).map(([c,p])=>[c,String(p)])),o=j.parse(await this.request(`?${s}`,"GET",void 0,e));if(o.teamId!==this.options.teamId||o.datasets.length>r.limit||new Set(o.datasets.map(c=>c.id)).size!==o.datasets.length)throw new Error("Dataset list workspace/page mismatch.");return o}async get(a,e){return this.readback(await this.request(`/${encodeURIComponent(a)}`,"GET",void 0,e),a)}async operationResult(a,e){let t=D.parse(e.kind),r=new URLSearchParams({kind:t,...e.datasetId?{datasetId:e.datasetId}:{}}),s=await this.request(`/operations/${encodeURIComponent(a)}?${r}`,"GET",void 0,e.signal,132*1024*1024);if(s===null)return null;let o=V.parse(s);if(this.readback(o.receipt,o.receipt.datasetId),o.base&&this.readback(o.base,o.receipt.datasetId),o.operationId!==a||o.kind!==t||e.datasetId&&o.receipt.datasetId!==e.datasetId||e.requestHash&&o.requestHash!==e.requestHash)throw new Error("Dataset operation recovery identity/request mismatch.");return o}async beginVersion(a,e,t){let r=T.parse(e),s=this.readback(await this.request(`/${encodeURIComponent(a)}/begin-version`,"POST",r,t),a);if(s.revision!==r.expectedRevision+1||s.workspace.draft.status!=="draft"||!s.publication||!s.workspace.draft.publishedTasksetRef)throw new Error("Editable version receipt mismatch.");return s}async versions(a,e={}){let t=new URLSearchParams(e.beforeRevision===void 0?{}:{beforeRevision:String(e.beforeRevision)}),r=O.parse(await this.request(`/${encodeURIComponent(a)}/versions?${t}`,"GET",void 0,e.signal));if(r.teamId!==this.options.teamId||r.datasetId!==a||r.items.some((s,o)=>o>0&&s.workspaceRevision>=r.items[o-1].workspaceRevision||e.beforeRevision!==void 0&&s.workspaceRevision>=e.beforeRevision))throw new Error("Dataset version history scope/order mismatch.");return r}async version(a,e,t){let r=this.readback(await this.request(`/${encodeURIComponent(a)}/versions/${e}`,"GET",void 0,t),a);if(r.revision!==e||r.workspace.draft.status!=="published")throw new Error("Dataset immutable version mismatch.");return r}async save(a,e){let t=W.parse(a),r=I(t.workspace);if(r.draft.profileId!==this.options.teamId||r.draft.revision!==t.expectedRevision+1)throw new Error("Dataset write scope or revision mismatch.");let s=this.readback(await this.request(`/${encodeURIComponent(r.draft.id)}`,"PUT",t,e),r.draft.id);if(t.originProjectId&&s.originProjectId!==t.originProjectId)throw new Error("Dataset origin Project mismatch.");if(t.ownerScope&&s.ownerScope!==t.ownerScope)throw new Error("Dataset owner scope mismatch.");if(s.workspace.contentHash!==r.contentHash)throw new Error("Dataset write receipt differs from the saved bytes.");return s}async validate(a,e,t){let r=C.parse(await this.request(`/${encodeURIComponent(a)}/validate`,"POST",{expectedRevision:e},t));if(r.teamId!==this.options.teamId||r.datasetId!==a||r.revision!==e)throw new Error("Dataset validation receipt mismatch.");return r}async publish(a,e,t){let r=A.parse(e),s=this.readback(await this.request(`/${encodeURIComponent(a)}/publish`,"POST",r,t),a);if(s.revision!==r.expectedRevision+1||s.workspace.draft.status!=="published"||s.publication?.packageHash!==r.packageHash)throw new Error("Dataset publication receipt mismatch.");return s}readback(a,e){let t=g.parse(a);if(I(t.workspace),t.datasetId!==e||t.teamId!==this.options.teamId)throw new Error("Dataset identity mismatch.");return t}async request(a,e,t,r,s){let o=await(this.options.fetch??fetch)(`${this.baseUrl}/v1/dataset-workspaces${a}`,{method:e,signal:r,redirect:"error",headers:{Authorization:`Bearer ${this.options.apiKey}`,"X-OpenPond-Team-Id":this.options.teamId,"Content-Type":"application/json"},...t===void 0?{}:{body:JSON.stringify(t)}});if(!o.ok)throw new Error(`Dataset request failed (${o.status}).`);if(s!==void 0){if(!o.body)throw new Error("Dataset response is empty.");let c=o.body.getReader(),p=[],h=0;try{for(;;){let d=await c.read();if(d.done)break;if(h+=d.value.byteLength,h>s)throw new Error("Dataset recovery exceeds its bounded response.");p.push(d.value)}}finally{await c.cancel()}let l=new Uint8Array(h),m=0;for(let d of p)l.set(d,m),m+=d.length;return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l))}return o.json()}};var y=i.string().trim().min(1).max(500),_=i.string().regex(/^[a-f0-9]{64}$/),J=i.object({release:S,afterId:y.optional(),limit:i.number().int().min(1).max(1e4).default(100),view:i.enum(["ids","policy"]).default("ids")}).strict().superRefine((n,a)=>{n.view==="policy"&&n.limit>100&&a.addIssue({code:"custom",path:["limit"],message:"Policy previews are bounded to 100 tasks."})}),G=i.object({id:H.shape.id,split:x}).strict(),Q=G.extend({input:i.record(i.string(),i.unknown()),policyVisibleContext:i.record(i.string(),i.unknown()),artifacts:i.array(i.object({id:y,path:i.string(),mediaType:i.string(),sizeBytes:i.number().int().nonnegative()}).strict()).max(1e3)}).strict(),de=i.object({schemaVersion:i.literal("openpond.datasetPopulationPage.v1"),teamId:y,release:S,view:J.shape.view,taskCount:i.number().int().nonnegative(),items:i.array(i.union([G,Q])).max(1e4),graders:i.array(q).max(1e3),nextCursor:y.nullable(),contentHash:_}).strict().superRefine((n,a)=>{n.view==="policy"&&n.items.length>100&&a.addIssue({code:"custom",message:"Policy preview exceeded its task bound."}),n.items.some(e=>"input"in e!=(n.view==="policy"))&&a.addIssue({code:"custom",message:"Dataset task view differs from the requested projection."})});async function ye(n,a){let[e,t]=a,r=u(n,"team"),s=L(n);if(!r||!s||!e||a.length>2||!["upload","read","list","validate","publish"].includes(e))throw new Error("usage: datasets <upload|read|list|validate|publish> [folder|id] --team <id> --api-base-url <origin> [--operation-id <id>] [--expected-revision <n>] [--publish] [--project <id>]");let o=await z(),c=new k({teamId:r,baseUrl:s,apiKey:await K(o,B(o))}),p=u(n,"operationId"),h;if(e==="list"){if(t)throw new Error("List does not accept a dataset id.");h=await c.list({cursor:u(n,"cursor")||void 0})}else{if(!t)throw new Error(`${e} requires a ${e==="upload"?"folder":"dataset id"}.`);if(e==="read")h=await c.get(t);else if(e==="upload"){if(!p||p.length>220)throw new Error("Upload requires a stable --operation-id of at most 220 characters. Reuse it after an uncertain response.");let l=u(n,"expectedRevision"),m=l?Number(l):0;if(!Number.isSafeInteger(m)||m<0)throw new Error("Expected revision must be a nonnegative integer.");let d=await N({directory:t,teamId:r,expectedRevision:m,datasetId:u(n,"datasetId")||void 0}),b=U({workspace:d.workspace,preparation:null,adapterId:"openpond-hosted-taskset-authoring-v1",now:d.workspace.draft.updatedAt}),f=await c.save({operationId:`${p}:save`,expectedRevision:m,workspace:d.workspace,...u(n,"project")?{originProjectId:u(n,"project")}:{}}),R=await c.get(f.datasetId);if(R.workspace.draft.status==="draft"){let P=await c.validate(f.datasetId,f.revision);if(P.workspaceHash!==d.workspace.contentHash||P.packageHash!==b.contentHash)throw new Error("Hosted validation differs from the captured folder bytes.")}else if(R.publication?.packageHash!==b.contentHash)throw new Error("This dataset was changed after the upload receipt. Read the current version before continuing.");let v=E(n.publish)?await c.publish(f.datasetId,{operationId:`${p}:publish`,expectedRevision:f.revision,workspaceHash:f.workspace.contentHash,packageHash:b.contentHash}):f;h={teamId:r,datasetId:v.datasetId,revision:v.revision,status:v.workspace.draft.status,operationId:p,capturedBytes:d.capturedBytes,sourceHash:d.sourceHash,sourceFiles:d.sourceFiles,workspaceHash:f.workspace.contentHash,packageHash:b.contentHash,publication:v.publication}}else{let l=Number(u(n,"expectedRevision"));if(!Number.isSafeInteger(l)||l<=0)throw new Error(`${e} requires --expected-revision with the retained dataset revision.`);if(e==="validate")h=await c.validate(t,l);else{if(!p)throw new Error("Publish requires a stable --operation-id.");let m=u(n,"workspaceHash"),d=u(n,"packageHash");if(!m||!d)throw new Error("Publish requires --workspace-hash and --package-hash from the retained validation receipt. Keep these pins and the operation id unchanged on retry.");h=await c.publish(t,{operationId:p,expectedRevision:l,workspaceHash:m,packageHash:d})}}}console.log(JSON.stringify(h,null,2))}w(ye,"runDatasetsCommand");export{ye as runDatasetsCommand};
|
|
2
|
+
import{d as N}from"./chunk-7QEE4PBI.js";import"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-N3DEA6PG.js";import{c as K}from"./chunk-PA7XP42P.js";import{c as L,f as B}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as u,f as E}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{a as I,b as S,c as q,g as U,h as $,i as W,j as g,k as A,l as T,m as O,n as j,o as C}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import{d as z}from"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import{Q as x,U as H}from"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import{b as i}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as w}from"./chunk-FTQLQJQV.js";var D=i.enum(["create","save","publish","begin_version"]),V=i.object({operationId:i.string().trim().min(1).max(240),kind:D,requestHash:i.string().regex(/^[a-f0-9]{64}$/),receipt:g,base:g.nullable()}).strict().superRefine((n,a)=>{let{receipt:e,base:t,kind:r}=n;(t&&(t.teamId!==e.teamId||t.datasetId!==e.datasetId||t.revision+1!==e.revision)||!t&&e.revision!==1)&&a.addIssue({code:"custom",message:"Operation recovery history identity/revision mismatch."}),t&&((t.ownerScope??"workspace")!==(e.ownerScope??"workspace")||t.originProjectId!==e.originProjectId||t.workspace.draft.createdAt!==e.workspace.draft.createdAt)&&a.addIssue({code:"custom",message:"Operation recovery cannot change Dataset ownership or origin."});let s=t?e.workspace.draft.status==="published"?"publish":t.workspace.draft.status==="published"?"begin_version":"save":"create";r!==s&&a.addIssue({code:"custom",message:"Operation recovery kind differs from its retained lifecycle."})});var k=class{constructor(a){this.options=a;let e=new URL(a.baseUrl);if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||!a.apiKey.trim()||!a.teamId.trim())throw new Error("A clean API origin and workspace credentials are required.");this.baseUrl=e.toString().replace(/\/+$/,"")}options;static{w(this,"OpenPondDatasetWorkspaceClient")}baseUrl;async list(a={}){let{signal:e,...t}=a,r=$.parse(t),s=new URLSearchParams(Object.entries(r).filter(([,c])=>c!==void 0).map(([c,p])=>[c,String(p)])),o=j.parse(await this.request(`?${s}`,"GET",void 0,e));if(o.teamId!==this.options.teamId||o.datasets.length>r.limit||new Set(o.datasets.map(c=>c.id)).size!==o.datasets.length)throw new Error("Dataset list workspace/page mismatch.");return o}async get(a,e){return this.readback(await this.request(`/${encodeURIComponent(a)}`,"GET",void 0,e),a)}async operationResult(a,e){let t=D.parse(e.kind),r=new URLSearchParams({kind:t,...e.datasetId?{datasetId:e.datasetId}:{}}),s=await this.request(`/operations/${encodeURIComponent(a)}?${r}`,"GET",void 0,e.signal,132*1024*1024);if(s===null)return null;let o=V.parse(s);if(this.readback(o.receipt,o.receipt.datasetId),o.base&&this.readback(o.base,o.receipt.datasetId),o.operationId!==a||o.kind!==t||e.datasetId&&o.receipt.datasetId!==e.datasetId||e.requestHash&&o.requestHash!==e.requestHash)throw new Error("Dataset operation recovery identity/request mismatch.");return o}async beginVersion(a,e,t){let r=T.parse(e),s=this.readback(await this.request(`/${encodeURIComponent(a)}/begin-version`,"POST",r,t),a);if(s.revision!==r.expectedRevision+1||s.workspace.draft.status!=="draft"||!s.publication||!s.workspace.draft.publishedTasksetRef)throw new Error("Editable version receipt mismatch.");return s}async versions(a,e={}){let t=new URLSearchParams(e.beforeRevision===void 0?{}:{beforeRevision:String(e.beforeRevision)}),r=O.parse(await this.request(`/${encodeURIComponent(a)}/versions?${t}`,"GET",void 0,e.signal));if(r.teamId!==this.options.teamId||r.datasetId!==a||r.items.some((s,o)=>o>0&&s.workspaceRevision>=r.items[o-1].workspaceRevision||e.beforeRevision!==void 0&&s.workspaceRevision>=e.beforeRevision))throw new Error("Dataset version history scope/order mismatch.");return r}async version(a,e,t){let r=this.readback(await this.request(`/${encodeURIComponent(a)}/versions/${e}`,"GET",void 0,t),a);if(r.revision!==e||r.workspace.draft.status!=="published")throw new Error("Dataset immutable version mismatch.");return r}async save(a,e){let t=W.parse(a),r=I(t.workspace);if(r.draft.profileId!==this.options.teamId||r.draft.revision!==t.expectedRevision+1)throw new Error("Dataset write scope or revision mismatch.");let s=this.readback(await this.request(`/${encodeURIComponent(r.draft.id)}`,"PUT",t,e),r.draft.id);if(t.originProjectId&&s.originProjectId!==t.originProjectId)throw new Error("Dataset origin Project mismatch.");if(t.ownerScope&&s.ownerScope!==t.ownerScope)throw new Error("Dataset owner scope mismatch.");if(s.workspace.contentHash!==r.contentHash)throw new Error("Dataset write receipt differs from the saved bytes.");return s}async validate(a,e,t){let r=C.parse(await this.request(`/${encodeURIComponent(a)}/validate`,"POST",{expectedRevision:e},t));if(r.teamId!==this.options.teamId||r.datasetId!==a||r.revision!==e)throw new Error("Dataset validation receipt mismatch.");return r}async publish(a,e,t){let r=A.parse(e),s=this.readback(await this.request(`/${encodeURIComponent(a)}/publish`,"POST",r,t),a);if(s.revision!==r.expectedRevision+1||s.workspace.draft.status!=="published"||s.publication?.packageHash!==r.packageHash)throw new Error("Dataset publication receipt mismatch.");return s}readback(a,e){let t=g.parse(a);if(I(t.workspace),t.datasetId!==e||t.teamId!==this.options.teamId)throw new Error("Dataset identity mismatch.");return t}async request(a,e,t,r,s){let o=await(this.options.fetch??fetch)(`${this.baseUrl}/v1/dataset-workspaces${a}`,{method:e,signal:r,redirect:"error",headers:{Authorization:`Bearer ${this.options.apiKey}`,"X-OpenPond-Team-Id":this.options.teamId,"Content-Type":"application/json"},...t===void 0?{}:{body:JSON.stringify(t)}});if(!o.ok)throw new Error(`Dataset request failed (${o.status}).`);if(s!==void 0){if(!o.body)throw new Error("Dataset response is empty.");let c=o.body.getReader(),p=[],h=0;try{for(;;){let d=await c.read();if(d.done)break;if(h+=d.value.byteLength,h>s)throw new Error("Dataset recovery exceeds its bounded response.");p.push(d.value)}}finally{await c.cancel()}let l=new Uint8Array(h),m=0;for(let d of p)l.set(d,m),m+=d.length;return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l))}return o.json()}};var y=i.string().trim().min(1).max(500),_=i.string().regex(/^[a-f0-9]{64}$/),J=i.object({release:S,afterId:y.optional(),limit:i.number().int().min(1).max(1e4).default(100),view:i.enum(["ids","policy"]).default("ids")}).strict().superRefine((n,a)=>{n.view==="policy"&&n.limit>100&&a.addIssue({code:"custom",path:["limit"],message:"Policy previews are bounded to 100 tasks."})}),G=i.object({id:H.shape.id,split:x}).strict(),Q=G.extend({input:i.record(i.string(),i.unknown()),policyVisibleContext:i.record(i.string(),i.unknown()),artifacts:i.array(i.object({id:y,path:i.string(),mediaType:i.string(),sizeBytes:i.number().int().nonnegative()}).strict()).max(1e3)}).strict(),de=i.object({schemaVersion:i.literal("openpond.datasetPopulationPage.v1"),teamId:y,release:S,view:J.shape.view,taskCount:i.number().int().nonnegative(),items:i.array(i.union([G,Q])).max(1e4),graders:i.array(q).max(1e3),nextCursor:y.nullable(),contentHash:_}).strict().superRefine((n,a)=>{n.view==="policy"&&n.items.length>100&&a.addIssue({code:"custom",message:"Policy preview exceeded its task bound."}),n.items.some(e=>"input"in e!=(n.view==="policy"))&&a.addIssue({code:"custom",message:"Dataset task view differs from the requested projection."})});async function ye(n,a){let[e,t]=a,r=u(n,"team"),s=L(n);if(!r||!s||!e||a.length>2||!["upload","read","list","validate","publish"].includes(e))throw new Error("usage: datasets <upload|read|list|validate|publish> [folder|id] --team <id> --api-base-url <origin> [--operation-id <id>] [--expected-revision <n>] [--publish] [--project <id>]");let o=await z(),c=new k({teamId:r,baseUrl:s,apiKey:await K(o,B(o))}),p=u(n,"operationId"),h;if(e==="list"){if(t)throw new Error("List does not accept a dataset id.");h=await c.list({cursor:u(n,"cursor")||void 0})}else{if(!t)throw new Error(`${e} requires a ${e==="upload"?"folder":"dataset id"}.`);if(e==="read")h=await c.get(t);else if(e==="upload"){if(!p||p.length>220)throw new Error("Upload requires a stable --operation-id of at most 220 characters. Reuse it after an uncertain response.");let l=u(n,"expectedRevision"),m=l?Number(l):0;if(!Number.isSafeInteger(m)||m<0)throw new Error("Expected revision must be a nonnegative integer.");let d=await N({directory:t,teamId:r,expectedRevision:m,datasetId:u(n,"datasetId")||void 0}),b=U({workspace:d.workspace,preparation:null,adapterId:"openpond-hosted-taskset-authoring-v1",now:d.workspace.draft.updatedAt}),f=await c.save({operationId:`${p}:save`,expectedRevision:m,workspace:d.workspace,...u(n,"project")?{originProjectId:u(n,"project")}:{}}),R=await c.get(f.datasetId);if(R.workspace.draft.status==="draft"){let P=await c.validate(f.datasetId,f.revision);if(P.workspaceHash!==d.workspace.contentHash||P.packageHash!==b.contentHash)throw new Error("Hosted validation differs from the captured folder bytes.")}else if(R.publication?.packageHash!==b.contentHash)throw new Error("This dataset was changed after the upload receipt. Read the current version before continuing.");let v=E(n.publish)?await c.publish(f.datasetId,{operationId:`${p}:publish`,expectedRevision:f.revision,workspaceHash:f.workspace.contentHash,packageHash:b.contentHash}):f;h={teamId:r,datasetId:v.datasetId,revision:v.revision,status:v.workspace.draft.status,operationId:p,capturedBytes:d.capturedBytes,sourceHash:d.sourceHash,sourceFiles:d.sourceFiles,workspaceHash:f.workspace.contentHash,packageHash:b.contentHash,publication:v.publication}}else{let l=Number(u(n,"expectedRevision"));if(!Number.isSafeInteger(l)||l<=0)throw new Error(`${e} requires --expected-revision with the retained dataset revision.`);if(e==="validate")h=await c.validate(t,l);else{if(!p)throw new Error("Publish requires a stable --operation-id.");let m=u(n,"workspaceHash"),d=u(n,"packageHash");if(!m||!d)throw new Error("Publish requires --workspace-hash and --package-hash from the retained validation receipt. Keep these pins and the operation id unchanged on retry.");h=await c.publish(t,{operationId:p,expectedRevision:l,workspaceHash:m,packageHash:d})}}}console.log(JSON.stringify(h,null,2))}w(ye,"runDatasetsCommand");export{ye as runDatasetsCommand};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{u as f}from"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{a as c}from"./chunk-
|
|
2
|
+
import{u as f}from"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import{a as c}from"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as p,f as u}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";import d from"node:path";import{access as v}from"node:fs/promises";import{constants as C}from"node:fs";import{createRequire as P}from"node:module";var l=d.join("scripts","desktop-harness.ts");async function $(n,t){let o=await j({options:n,rest:t}),e=await f(o.command,o.args,{cwd:o.cwd,inherit:!0,timeoutMs:0});if(e.code!==0)throw new m(e.code)}r($,"runDesktopTestCommand");async function j(n){let t=n.options,o=n.rest,e=o[0];if(e!=="run"&&e!=="attach")throw new c(D());let a=o.slice(1);if(a.length===0)throw new c("usage: openpond desktop-test run <scenario...> [options]");let g=p(t,"cwd")||n.cwd||process.cwd(),w=await O(g),k=(n.env??process.env).OPENPOND_NODE_BINARY?.trim()||process.execPath,s=[P(import.meta.url).resolve("tsx/cli"),l,"run",...a],h=x(t,e);return h&&s.push(`--${h}`),i(s,"--app",t,"app"),i(s,"--server",t,"server"),i(s,"--token",t,"token"),i(s,"--token-file",t,"tokenFile"),i(s,"--devtools-port",t,"devtoolsPort"),i(s,"--artifacts-dir",t,"artifactsDir"),H(s,t),i(s,"--grep",t,"grep"),i(s,"--timeout-ms",t,"timeoutMs"),u(t.keepHome)&&s.push("--keep-home"),{command:k,args:s,cwd:w}}r(j,"buildDesktopHarnessInvocation");async function O(n){let t=d.resolve(n);for(;;){let o=d.join(t,l);if(await R(o))return t;let e=d.dirname(t);if(e===t)throw new c(`Could not find ${l}. Run this command from the OpenPond source checkout or pass --cwd <repo>.`);t=e}}r(O,"resolveDesktopHarnessRepoRoot");function x(n,t){let o=t==="attach"?"attach":null;for(let e of["isolated","attach","packaged","none"])if(u(n[e])){if(o&&o!==e)throw new c("Choose only one desktop harness launch mode: --isolated, --attach, --packaged, or --none.");o=e}return o}r(x,"resolveLaunchMode");function i(n,t,o,e){let a=p(o,e);a&&n.push(t,a)}r(i,"appendStringFlag");function H(n,t){let o=p(t,"json"),e=p(t,"jsonPath");if(o&&y(o))throw new c("harness --json requires a report path. Use --json <path> or --json-path <path>.");if(o&&e&&o!==e)throw new c("Use only one JSON report path: --json <path> or --json-path <path>.");let a=o||e;a&&n.push("--json",a)}r(H,"appendJsonFlag");function y(n){return/^(true|false|1|0|yes|no)$/i.test(n)}r(y,"isBooleanLiteral");async function R(n){try{return await v(n,C.R_OK),!0}catch{return!1}}r(R,"fileExists");function D(){return["usage: openpond desktop-test run <scenario...> [options]"," openpond desktop-test attach <scenario...> [options]","","Options include --isolated, --attach, --packaged, --none, --app <path>,","--server <url>, --token <token>, --token-file <path>, --devtools-port <port>, --artifacts-dir <path>,","--json <path>, --json-path <path>, --grep <pattern>, --timeout-ms <ms>,","--keep-home, and --cwd <repo>."].join(`
|
|
3
3
|
`)}r(D,"desktopHarnessCliUsage");var m=class extends Error{static{r(this,"HarnessCommandFailedError")}exitCode;constructor(t){let o=typeof t=="number"&&t>0?t:1;super(`desktop harness failed with exit code ${o}`),this.name="HarnessCommandFailedError",this.exitCode=o}};export{j as buildDesktopHarnessInvocation,O as resolveDesktopHarnessRepoRoot,$ as runDesktopTestCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{A as D,B as E,C as F,D as G,E as H,F as I,G as J,H as K,I as L,J as M,K as N,L as O,M as P,N as Q,O as R,P as S,Q as T,R as U,S as V,T as W,U as X,V as Y,W as Z,X as _,Y as $,Z as aa,a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B,z as C}from"./chunk-
|
|
2
|
+
import{A as D,B as E,C as F,D as G,E as H,F as I,G as J,H as K,I as L,J as M,K as N,L as O,M as P,N as Q,O as R,P as S,Q as T,R as U,S as V,T as W,U as X,V as Y,W as Z,X as _,Y as $,Z as aa,a as d,b as e,c as f,d as g,e as h,f as i,g as j,h as k,i as l,j as m,k as n,l as o,m as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A,y as B,z as C}from"./chunk-7ZG3IT7C.js";import{Aa as c,ya as a,za as b}from"./chunk-SDEDAHV6.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-FTQLQJQV.js";export{l as AGENT_PROTOCOL_VERSION,m as AGENT_RPC_METHODS,$ as AcpClient,_ as AcpRpcError,Q as AgentCheckpointSchema,P as AgentEffectiveSurfaceSchema,i as AgentEventNameSchema,M as AgentHostStorageClient,t as AgentJsonRpcDispatcher,r as AgentProtocolEnvelopeSchema,u as AgentRpcClient,j as CanonicalAgentEventSchema,aa as ClaudeCliClient,v as ExperimentEnvironmentParamsSchema,I as HOST_STORAGE_CONTRACT_VERSION,y as HarnessReviewStorageParamsSchema,L as HostStorageCapabilitySchema,K as HostStorageRequestSchema,J as HostStorageScopeSchema,A as HostedOutputBeginParamsSchema,B as HostedOutputChunkParamsSchema,C as HostedOutputCompleteParamsSchema,z as HostedOutputIdentitySchema,E as HostedOutputSaveSandboxFileParamsSchema,F as HostedSandboxActionSchema,D as HostedSandboxOutputIdentitySchema,G as HostedSandboxRequestParamsSchema,H as HostedToolAuthorizationParamsSchema,s as InitializeParamsSchema,q as JsonRpcErrorSchema,o as JsonRpcNotificationSchema,n as JsonRpcRequestSchema,p as JsonRpcSuccessSchema,x as RefinerStorageActionSchema,w as TaskInboxStorageParamsSchema,Z as TaskSerialExecutor,Y as TaskSignals,f as agentCompactionDecision,k as canonicalEventHash,e as canonicalHash,d as canonicalJson,S as checkpointHash,O as createAgentRuntimeService,U as createAgentToolCatalog,W as createAgentToolCatalogProjection,R as effectiveSurfaceHash,V as executeAgentTool,X as executeProjectedAgentTool,T as materializeAgentPrompt,a as providerRoundSequence,g as runAgentCompaction,h as runAgentCompactionProgram,N as runAgentJsonlServer,c as runProviderRound,b as runProviderRoundLoop};
|
package/dist/chunks/{evaluation-coordination-MOFBXRXN.js → evaluation-coordination-EPHLZXYM.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as p,b as v}from"./chunk-UJ5EFSEC.js";import"./chunk-NPOHW5OU.js";import"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-
|
|
2
|
+
import{a as p,b as v}from"./chunk-UJ5EFSEC.js";import"./chunk-NPOHW5OU.js";import"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as r}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{A as h,B as w,y as d,z as s}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as m}from"./chunk-FTQLQJQV.js";async function b(t,e,n){let[a,o]=n,i=r(e,"actor");if(!i||!a||n.length>2)throw new Error("Select --actor, --team and an evaluation command.");if(e.local!==!0&&e.local!=="true")throw new Error("These evaluation owners currently run through the authenticated native bridge. Select --local --server-url with its loopback origin.");let c={...await v(e),actorId:i,projectId:r(e,"project")||null},l=a==="request"?await p(e):a==="list"?t==="schedule"?{operation:a,...r(e,"cursor")?{cursor:r(e,"cursor")}:{},limit:Number(r(e,"limit")||50)}:{operation:a}:{operation:a,id:o};if((a==="request"||a==="list")&&o)throw new Error("This operation does not accept an additional resource id.");let u=AbortSignal.timeout(6e4),f=t==="schedule"?await new s(c).command(d.parse(l),u):await new w(c).command(h.parse(l),u);console.log(JSON.stringify(f,null,2))}m(b,"runEvaluationCoordinationCommand");export{b as runEvaluationCoordinationCommand};
|
package/dist/chunks/{experiment-improvements-TDHM6NEA.js → experiment-improvements-6JTOPA74.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as s,b as l}from"./chunk-UJ5EFSEC.js";import"./chunk-NPOHW5OU.js";import"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-
|
|
2
|
+
import{a as s,b as l}from"./chunk-UJ5EFSEC.js";import"./chunk-NPOHW5OU.js";import"./chunk-N3DEA6PG.js";import"./chunk-PA7XP42P.js";import"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as e}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{v as m,w as c}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";async function f(t,i){let[r,o]=i,n=e(t,"actor");if(!n||!r||i.length>2)throw new Error("usage: improve <list|read|instructions|request> [id] --team <id> --actor <owner-id> [--input-file <path>] [--local --server-url <loopback-origin>]");let u=m.parse(r==="request"?await s(t):r==="list"?{operation:r,limit:Number(e(t,"limit")||30),...e(t,"cursor")?{cursor:e(t,"cursor")}:{}}:{operation:r,id:o});if(r==="request"&&o||r==="list"&&o)throw new Error("This operation does not accept a candidate id.");let d=new c({...await l(t),actorId:n});console.log(JSON.stringify(await d.command(u,AbortSignal.timeout(6e4)),null,2))}a(f,"runExperimentImprovementsCommand");export{f as runExperimentImprovementsCommand};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as C,c as F}from"./chunk-
|
|
2
|
+
import{b as C,c as F}from"./chunk-GS2NKNKG.js";import{a as A,c as U}from"./chunk-NPOHW5OU.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-N3DEA6PG.js";import{c as _}from"./chunk-PA7XP42P.js";import{c as O,f as k}from"./chunk-BSHAIAXY.js";import"./chunk-XWPC3AN4.js";import"./chunk-YJ4PNAST.js";import"./chunk-AH22RHPS.js";import{c as t}from"./chunk-3M53YXEI.js";import"./chunk-OGPHXXCD.js";import{d as S,e as R,f as x,s as N,t as y,x as H}from"./chunk-2SPZYBDN.js";import"./chunk-QXVIIM4T.js";import{d as v}from"./chunk-R3XFY7VL.js";import{b as P}from"./chunk-GLUWATL5.js";import"./chunk-YL6VFJ4P.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import{Na as q}from"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as m}from"./chunk-FTQLQJQV.js";import{readFile as I,stat as L}from"node:fs/promises";import{readFile as j,stat as B}from"node:fs/promises";async function J(e,f){let[r,i,h]=f,w=t(e,"team");if(e.revision!==void 0)throw new Error("A local Experiment is one immutable run; read it by id rather than a saved configuration revision.");if(r!=="read"&&e.contentHash!==void 0)throw new Error("An exact configuration hash requires the local read action.");if(!w||!r||f.length>(r==="compare"?3:2))throw new Error("Local Experiments require an action and --team; use --server-url for an existing local server.");let g=t(e,"serverUrl")||process.env.OPENPOND_LOCAL_API_URL||A,n=new URL(g);if(n.protocol!=="http:"||!["localhost","127.0.0.1"].includes(n.hostname)||n.username||n.password||n.search||n.hash||n.pathname!=="/")throw new Error("Local Experiments require an HTTP loopback server origin.");let o=await U(n.origin);async function a(l,d){let s=await o(new URL("/v1/local-experiments",n),{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({teamId:w,action:l,payload:d})}),c=await s.json();if(!s.ok)throw new Error(typeof c.error=="string"?c.error:`Local Experiment request failed (${s.status}).`);return c}m(a,"command");async function p(){let l=t(e,"inputFile");if(!l||(await B(l)).size>67108864)throw new Error("Provide a bounded --input-file with exact local configuration and retained package bytes.");return JSON.parse(await j(l,"utf8"))}m(p,"input");let u;if(r==="prepare-harness"){if(i)throw new Error("Local Profile preparation accepts --input-file rather than an id.");u=await a("prepareHarness",await p())}else if(r==="run"){if(i)throw new Error("Local Run accepts reviewed configuration through --input-file rather than an id.");let l=await p();u=await a(l.package?"run":"runFromRelease",l)}else if(r==="list"){if(i)throw new Error("Local List does not accept an id.");let l=t(e,"status"),d=t(e,"limit"),s=t(e,"project"),c=t(e,"afterId"),E=t(e,"datasetHash"),b=t(e,"search");u=await a("list",{...l?{status:l}:{},...s?{projectId:s}:{},...E?{datasetHash:E}:{},...b?{search:b}:{},...c?{afterId:c}:{},...d?{limit:Number(d)}:{}})}else{if(!i)throw new Error(`${r} requires a local Experiment or scoring pass id.`);let l=t(e,"afterId"),d=t(e,"limit");if(r==="duplicate"){let s=t(e,"operationId");if(!s)throw new Error("Duplicate requires --operation-id for safe replay.");let c=C.parse(await a("read",{id:i})),E=x.parse({...c.configuration,operationId:s,request:{...c.configuration.request,operationId:s},sourceExperimentId:c.id});u=await a("runFromRelease",{configuration:E,expectedPackageHash:c.packageHash})}else if(r==="passes")u=await a("passes",{executionId:i,...l?{afterId:l}:{},...d?{limit:Number(d)}:{}});else if(r==="case"){let s=t(e,"receiptId"),c=t(e,"afterSequence");if(!s)throw new Error("Local case inspection requires --receipt-id from the retained execution.");u=await a("case",{id:i,receiptId:s,...c?{afterSequence:Number(c)}:{},...d?{limit:Number(d)}:{}})}else if(r==="score"){let s=await p();if(s.execution?.id!==i)throw new Error("Local scoring input belongs to a different retained execution.");u=await a("score",s)}else if(r==="compare"){if(!h)throw new Error("Local Compare requires baseline and candidate execution ids.");let s=F.parse(await a("compare",{baselineId:i,candidateId:h}));u={...s,comparison:q(s.baseline,s.candidate)}}else if(r==="read"){let s=t(e,"contentHash");u=await a("read",{id:i,...s?{configurationHash:s}:{}})}else if(["status","cancel","result","pass"].includes(r))u=await a(r,{id:i});else if(r==="cancel-pass")u=await a("cancel",{id:i});else if(r==="pass-result")u=await a("result",{id:i});else throw new Error(`Local Experiment action is unavailable: ${r}`)}console.log(JSON.stringify(u,null,2))}m(J,"runLocalExperimentsCommand");async function re(e,f){if(e.local===!0||e.local==="true")return J(e,f);if(e.revision!==void 0||e.contentHash!==void 0)throw new Error("Experiments retain their immutable configuration on the run; definition revisions are not selectable.");let[r,i]=f,h=t(e,"team");if(!h||!r||f.length>(r==="compare"?3:2))throw new Error("usage: experiments <prepare-harness|run|read|list|status|cancel|duplicate|score|passes|pass|cancel-pass|pass-result|result|compare|case> [id] [candidate-id] --team <id> [--input-file <path>] [--operation-id <id>]");let w=await v(),g={teamId:h,apiKey:await _(w,k(w)),baseUrl:O(e)??w.apiBaseUrl??P},n=new y(g),o;if(r==="prepare-harness"){let a=t(e,"inputFile");if(!a||i||(await L(a)).size>1048576)throw new Error("Harness preparation requires a bounded --input-file with its released target, model and ceiling.");o=await n.prepareHarness(R.parse(JSON.parse(await I(a,"utf8"))))}else if(r==="run"){let a=t(e,"inputFile");if(!a||i)throw new Error("Run requires --input-file with the reviewed configuration and stable operationId.");if((await L(a)).size>1048576)throw new Error("Experiment input exceeds one MiB.");o=await n.run(x.parse(JSON.parse(await I(a,"utf8"))))}else if(r==="list"){if(i)throw new Error("List does not accept an Experiment id.");let a=t(e,"limit");o=await n.list(S.parse({projectId:t(e,"project")||void 0,datasetHash:t(e,"datasetHash")||void 0,search:t(e,"search")||void 0,status:t(e,"status")||void 0,afterId:t(e,"afterId")||void 0,...a?{limit:Number(a)}:{}}))}else{if(!i)throw new Error(`${r} requires an id.`);if(r==="read")o=await n.get(i);else if(r==="status")o=await n.get(i);else if(r==="cancel")o=await n.cancel(i);else if(r==="duplicate"){let a=t(e,"operationId");if(!a)throw new Error("Duplicate requires a stable --operation-id for the new Experiment.");o=await n.duplicate(i,a)}else if(r==="score"){let a=t(e,"inputFile");if(!a||(await L(a)).size>1048576)throw new Error("Score requires --input-file containing an exact execution reference, grader releases and explicit ceiling, within one MiB.");let p=N.parse(JSON.parse(await I(a,"utf8")));if(p.execution.id!==i)throw new Error("Scoring input belongs to a different execution.");o=await n.score(p)}else if(r==="passes")o=await n.scoringPasses(i,{afterId:t(e,"afterId")||void 0});else if(r==="pass")o=await n.scoringPass(i);else if(r==="cancel-pass")o=await n.cancelScoringPass(i);else if(r==="pass-result")o=await n.scoringResult(i);else if(r==="result")o=await n.result(i);else if(r==="case"){let a=t(e,"receiptId");if(!a)throw new Error("Case inspection requires --receipt-id from the retained Experiment.");let p=await n.get(i);o=await new H(g).case(i,a,{manifestHash:p.manifest.contentHash,afterId:t(e,"afterId")||void 0})}else if(r==="compare"){if(!f[2])throw new Error("Compare requires a baseline and candidate execution id.");o=await n.compare(i,f[2])}else throw new Error(`Unknown Experiment action: ${r}`)}console.log(JSON.stringify(o,null,2))}m(re,"runExperimentsCommand");export{re as runExperimentsCommand};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import"./chunk-BX4J2VDU.js";import{a as se}from"./chunk-
|
|
2
|
+
import"./chunk-BX4J2VDU.js";import{a as se}from"./chunk-GS2NKNKG.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-YIB3J4RC.js";import"./chunk-JEVA7YQL.js";import"./chunk-22UARBPW.js";import{a as T,x as D}from"./chunk-N5QNXMIS.js";import"./chunk-JDLAHVAJ.js";import"./chunk-EAPFMACH.js";import"./chunk-6FA3GG5B.js";import{f as G}from"./chunk-3M53YXEI.js";import"./chunk-QXVIIM4T.js";import"./chunk-R3XFY7VL.js";import"./chunk-GLUWATL5.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import{f as N}from"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import{f as ne,h as z,p as B,r as oe}from"./chunk-H7IWJN7L.js";import{a as r}from"./chunk-FTQLQJQV.js";var u=class extends Error{static{r(this,"GithubExtensionError")}code;status;constructor(t,o){super(t),this.name="GithubExtensionError",this.code=o.code,this.status=o.status??400}};import{createHash as ce}from"node:crypto";import J from"node:path";var ie="HEAD",ae=64,de=512,le=20*1024*1024,K=5*1024*1024,me=8,Ue=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,pe=/^[A-Za-z0-9_.-]+$/,ue=new Set(["agents","assets","references","scripts"]);function Se(e={}){let t=e.fetch??fetch,o=e.githubToken?.trim()||process.env.GITHUB_TOKEN?.trim()||process.env.GH_TOKEN?.trim()||null;return{async resolve(n){let s=await qe(n,t,o);return{preview:await Te(s,t,o),files:ge(s)}},async download(n,s){await _e({resolution:n,fetchImpl:t,githubToken:o,writeFile:s})}}}r(Se,"createGithubSourceClient");function I(e){let t=e.trim(),o="",n="";if(/^(?:https?:\/\/)?github\.com\//i.test(t)){let d=new URL(t.startsWith("http")?t:`https://${t}`);if(d.hostname.toLowerCase()!=="github.com")throw j(e);let a=d.pathname.replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw j(e);[o="",n=""]=a}else{let a=t.replace(/^github:/i,"").replace(/^\/+|\/+$/g,"").split("/");if(a.length!==2)throw j(e);[o="",n=""]=a}if(n=n.replace(/\.git$/i,""),!pe.test(o)||!pe.test(n))throw j(e);let s=o.toLowerCase(),i=n.toLowerCase();return{id:`github:${s}/${i}`,owner:s,repo:i,repositoryUrl:`https://github.com/${s}/${i}`}}r(I,"parseGithubExtensionSource");async function qe(e,t,o){let n=I(e.source),s=e.ref?.trim()||ie,i=await H(t,o,`/repos/${n.owner}/${n.repo}`),d=s===ie?i.default_branch?.trim()||"main":s,a=await H(t,o,`/repos/${n.owner}/${n.repo}/commits/${encodeURIComponent(d)}`),b=a.sha?.trim(),f=a.commit?.tree?.sha?.trim();if(!b||!f)throw new u("GitHub returned an incomplete commit response.",{code:"github_invalid_commit",status:502});let y=await H(t,o,`/repos/${n.owner}/${n.repo}/git/trees/${f}?recursive=1`);if(y.truncated)throw new u("The GitHub repository tree is too large to install safely.",{code:"github_tree_truncated"});let w=(y.tree??[]).filter(ze),x=Le(w);if(x.length===0)throw new u("No skills found. Add SKILL.md at the repository root or use a standard agent skills directory.",{code:"extension_no_skills"});if(x.length>ae)throw new u(`Extension contains more than ${ae} skills.`,{code:"extension_too_many_skills"});Ge(x);let A=w.find(m=>m.type==="blob"&&/^readme(?:\.[^/]+)?$/i.test(m.path))??null;return{identity:n,requestedRef:s,resolvedCommit:b,tree:w,skillPackages:x,readme:A}}r(qe,"resolveSource");async function Te(e,t,o){let n=await xe(e.skillPackages,me,async a=>{let b=await Fe(e,a.entry,t,o);return je(a,b)}),s=De(n.map(a=>a.name));for(let a of n)s.has(a.name)&&(a.validationStatus="error",a.validationMessages=[...a.validationMessages,`Duplicate skill name: ${a.name}`]);let i=n.flatMap(a=>a.validationMessages.map(b=>`${a.relativePath}: ${b}`)),d=ge(e);return{...e.identity,source:"github",requestedRef:e.requestedRef,resolvedCommit:e.resolvedCommit,sourcePath:null,readmePath:e.readme?.path??null,packageHash:Ne(d),skills:n.sort((a,b)=>a.name.localeCompare(b.name)),validationStatus:i.length===0?"valid":"error",validationMessages:i}}r(Te,"buildPreview");function je(e,t){let o=T(t),n=e.root==="."?null:J.posix.basename(e.root),s=o.name??n??"invalid-skill",i=[...o.messages];Ue.test(s)||i.push("Skill name must be lowercase kebab-case."),n&&s!==n&&i.push(`Skill name must match its directory name (${n}).`);let d=e.files.filter(a=>a.path!==e.entry.path).map(a=>Be(e.root,a.path)).sort();return{name:s,description:o.description??"",relativePath:e.root==="."?"SKILL.md":`${e.root}/SKILL.md`,sourcePath:"",charCount:t.length,sourceHash:ce("sha256").update(t).digest("hex"),resourceFiles:d,validationStatus:i.length===0?"valid":"error",validationMessages:[...new Set(i)]}}r(je,"previewSkill");function Le(e){let t=[],o=e.find(a=>a.type==="blob"&&a.path==="SKILL.md");o&&t.push({root:".",entry:o});let n=e.filter(a=>a.type==="blob"&&a.path.endsWith("/SKILL.md")),s=n.filter(a=>Me(a.path)),i=s.length>0?s:n,d=new Set(i.map(a=>J.posix.dirname(a.path)));for(let a of i){let b=J.posix.dirname(a.path);[...d].some(f=>f!==b&&b.startsWith(`${f}/`))||t.push({root:b,entry:a})}return t.map(({root:a,entry:b})=>{let f=e.filter(x=>{if(x.type!=="blob")return!1;if(a!==".")return x.path.startsWith(`${a}/`);if(x.path==="SKILL.md")return!0;let A=x.path.split("/",1)[0]??"";return ue.has(A)}),y=e.find(x=>x.type!=="blob"&&x.type!=="tree"&&(a==="."?x.path==="SKILL.md"||ue.has(x.path.split("/",1)[0]??""):x.path.startsWith(`${a}/`))),w=f.find(x=>x.mode==="120000");if(y||w)throw new u(`Skill package ${a} contains a symlink or submodule.`,{code:"extension_unsafe_entry"});return{root:a,entry:b,files:f}})}r(Le,"discoverSkillPackages");function Me(e){let t=e.split("/");if(t.at(-1)!=="SKILL.md")return!1;let o=t.slice(0,-1);if(o.length<2)return!1;let n=o.lastIndexOf("skills");if(n<0||n>2)return!1;let s=o.slice(0,n),i=o.slice(n+1);if(i.length<1||i.length>2)return!1;if(n===0)return!0;let d=s[0]??"";return d.startsWith(".")||d==="agent"||d==="data"}r(Me,"isStandardAgentSkillsPath");function ge(e){let t=new Map;e.readme&&t.set(e.readme.path,e.readme);for(let o of e.skillPackages)for(let n of o.files)t.set(n.path,n);return[...t.values()].sort((o,n)=>o.path.localeCompare(n.path))}r(ge,"filesToDownload");async function _e(e){let t=0;await xe(e.resolution.files,me,async o=>{let n=await be({owner:e.resolution.preview.owner,repo:e.resolution.preview.repo,commit:e.resolution.preview.resolvedCommit,file:o,fetchImpl:e.fetchImpl,githubToken:e.githubToken});if(t+=n.byteLength,t>le)throw new u("Extension download exceeds the maximum allowed size.",{code:"extension_too_large"});await e.writeFile(o.path,n,o.mode==="100755")})}r(_e,"downloadFiles");async function Fe(e,t,o,n){let s=await be({owner:e.identity.owner,repo:e.identity.repo,commit:e.resolvedCommit,file:t,fetchImpl:o,githubToken:n});return new TextDecoder("utf-8",{fatal:!0}).decode(s)}r(Fe,"downloadText");async function be(e){let t=e.file.path.split("/").map(encodeURIComponent).join("/"),o=`https://raw.githubusercontent.com/${e.owner}/${e.repo}/${e.commit}/${t}`,n=await e.fetchImpl(o,{headers:he(e.githubToken,"application/vnd.github.raw"),redirect:"follow"});if(!n.ok)throw new u(`GitHub file download failed (${n.status}): ${e.file.path}`,{code:"github_download_failed",status:n.status});let s=Number(n.headers.get("content-length"));if(Number.isFinite(s)&&s>K)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});let i=new Uint8Array(await n.arrayBuffer());if(i.byteLength>K)throw new u(`Extension file is too large: ${e.file.path}`,{code:"extension_file_too_large"});return i}r(be,"downloadBytes");async function H(e,t,o){let n=await e(`https://api.github.com${o}`,{headers:he(t,"application/vnd.github+json")});if(!n.ok){let s=await n.json().catch(()=>null),i=typeof s?.message=="string"?`: ${s.message}`:"";throw new u(`GitHub request failed (${n.status})${i}`,{code:n.status===404?"github_repository_not_found":"github_request_failed",status:n.status})}return await n.json()}r(H,"githubJson");function he(e,t){let o=new Headers({Accept:t,"User-Agent":"openpond-extension-installer","X-GitHub-Api-Version":"2022-11-28"});return e&&o.set("Authorization",`Bearer ${e}`),o}r(he,"githubHeaders");function Ge(e){let t=new Map;for(let n of e)for(let s of n.files)t.set(s.path,s);if(t.size>de)throw new u(`Extension contains more than ${de} skill files.`,{code:"extension_too_many_files"});let o=0;for(let n of t.values()){if((n.size??0)>K)throw new u(`Extension file is too large: ${n.path}`,{code:"extension_file_too_large"});o+=n.size??0}if(o>le)throw new u("Extension exceeds the maximum allowed size.",{code:"extension_too_large"})}r(Ge,"validateDownloadLimits");function ze(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.path=="string"&&!t.path.startsWith("/")&&!t.path.split("/").includes("..")&&typeof t.mode=="string"&&(t.type==="blob"||t.type==="tree"||t.type==="commit")&&typeof t.sha=="string"}r(ze,"validTreeEntry");function Ne(e){let t=ce("sha256");for(let o of e)t.update(`${o.path}\0${o.sha}\0${o.size??""}
|
|
3
3
|
`);return t.digest("hex")}r(Ne,"hashTree");function Be(e,t){return e==="."?t:t.slice(e.length+1)}r(Be,"relativeSkillPath");function De(e){let t=new Set,o=new Set;for(let n of e)t.has(n)&&o.add(n),t.add(n);return o}r(De,"duplicateValues");async function xe(e,t,o){let n=new Array(e.length),s=0;async function i(){for(;s<e.length;){let d=s;s+=1,n[d]=await o(e[d])}}return r(i,"worker"),await Promise.all(Array.from({length:Math.min(t,e.length)},i)),n}r(xe,"mapConcurrent");function j(e){return new u(`Invalid GitHub extension source: ${e}. Use owner/repo or https://github.com/owner/repo.`,{code:"github_invalid_source"})}r(j,"invalidSource");import{createHash as He,randomUUID as we}from"node:crypto";import{existsSync as v}from"node:fs";import{mkdir as W,readFile as Je,rename as k,rm as E,stat as Ke,writeFile as Re}from"node:fs/promises";import g from"node:path";var M=1,We=15e3;function Oe(e={}){let t=g.resolve(e.home??e.rootPath??ne()),o=g.resolve(e.rootPath??g.join(t,"library","extensions")),n=z(t).database,s=Se({fetch:e.fetch,githubToken:e.githubToken}),i=e.now??(()=>new Date);async function d(){try{let m=await O(t),p=await Promise.all(m.extensions.map(S=>V(o,S)));return Ze(p,await C(e.reservedSkillNames)),{rootPath:o,registryPath:n,extensions:p.sort(Q),error:null}}catch(m){return{rootPath:o,registryPath:n,extensions:[],error:m instanceof Error?m.message:String(m)}}}r(d,"list");async function a(m){let p=await s.resolve(m),S=await O(t),c=S.extensions.find(l=>l.id===p.preview.id)??null;return U(p.preview,S.extensions.filter(l=>l.id!==c?.id),await C(e.reservedSkillNames)),p.preview}r(a,"preview");async function b(m){let p=I(m.source);return Y(o,p.id,async()=>{let S=await O(t);if(S.extensions.some(h=>h.id===p.id))throw new u(`${p.owner}/${p.repo} is already installed.`,{code:"extension_already_installed",status:409});let c=await s.resolve(m);Ie(c.preview),U(c.preview,S.extensions,await C(e.reservedSkillNames));let l=i().toISOString(),R=await fe({rootPath:o,resolution:c,installedAt:l,updatedAt:l,github:s});try{let h=await C(e.reservedSkillNames);return await X(t,i,P=>({...P,extensions:Xe(P,R,h)})),await Pe(o,R.id),R}catch(h){throw await ye(o,R.id),h}})}r(b,"add");async function f(m){let p=I(m.source);return Y(o,p.id,async()=>{let S=await O(t),c=L(S,p.id),l=await s.resolve({source:c.repositoryUrl,ref:m.ref?.trim()||c.requestedRef});if(Ie(l.preview),U(l.preview,S.extensions.filter(h=>h.id!==c.id),await C(e.reservedSkillNames)),c.resolvedCommit===l.preview.resolvedCommit&&c.packageHash===l.preview.packageHash&&c.requestedRef===l.preview.requestedRef)return V(o,c);let R=await fe({rootPath:o,resolution:l,installedAt:c.installedAt,updatedAt:i().toISOString(),github:s});try{let h=await C(e.reservedSkillNames);return await X(t,i,P=>({...P,extensions:Ye(P,R,h)})),await Pe(o,R.id),R}catch(h){throw await ye(o,R.id),h}})}r(f,"update");async function y(){let m=await d();if(m.error)throw new u(m.error,{code:"extension_registry_error"});let p={updated:[],unchanged:[],failed:[]};for(let S of m.extensions)try{let c=await f({source:S.repositoryUrl,ref:S.requestedRef});c.resolvedCommit===S.resolvedCommit&&c.packageHash===S.packageHash?p.unchanged.push(c):p.updated.push(c)}catch(c){p.failed.push({id:S.id,error:c instanceof Error?c.message:String(c)})}return p}r(y,"updateAll");async function w(m){let p=I(m),S=await O(t);return V(o,L(S,p.id))}r(w,"inspect");async function x(m){let p=I(m);return Y(o,p.id,async()=>{let S=await O(t),c=L(S,p.id),l=q(o,p.owner,p.repo),R=`${l}.${we()}.remove`;v(l)&&await k(l,R);try{return await X(t,i,h=>({...h,extensions:h.extensions.filter(P=>P.id!==c.id)})),await E(R,{recursive:!0,force:!0}),c}catch(h){throw v(R)&&!v(l)&&await k(R,l),h}})}r(x,"remove");async function A(m){let p=m.trim();if(!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(p))throw new u("Extension skill name must be lowercase kebab-case.",{code:"extension_skill_invalid_name"});let S=await d();if(S.error)throw new u(S.error,{code:"extension_registry_error"});let c=S.extensions.flatMap(te=>te.skills.filter(F=>F.name===p).map(F=>({extension:te,skill:F})));if(c.length===0)throw new u(`Extension skill not found: ${p}`,{code:"extension_skill_not_found",status:404});if(c.length>1)throw new u(`Extension skill name is ambiguous: ${p}`,{code:"extension_skill_conflict",status:409});let l=c[0];if(l.extension.validationStatus!=="valid"||l.skill.validationStatus!=="valid")throw new u(`Extension skill ${p} is not valid.`,{code:"extension_skill_invalid"});let R=$e(l.extension.sourcePath,l.skill.relativePath),h=await Je(R,"utf8"),P=He("sha256").update(h).digest("hex");if(P!==l.skill.sourceHash)throw new u(`Extension skill ${p} changed on disk. Update or reinstall its extension before using it.`,{code:"extension_skill_modified"});let $=T(h);if($.messages.length>0||$.name!==p||!$.description)throw new u(`Extension skill ${p} is not valid. ${$.messages.join(" ")}`.trim(),{code:"extension_skill_invalid"});return{name:p,description:$.description,body:$.body,path:l.skill.relativePath,sourcePath:l.extension.sourcePath,sourceHash:P,charCount:h.length,packagePath:g.dirname(R),resourceFiles:l.skill.resourceFiles}}return r(A,"readSkill"),{rootPath:o,registryPath:n,list:d,preview:a,add:b,update:f,updateAll:y,inspect:w,remove:x,readSkill:A}}r(Oe,"createGithubExtensionManager");async function fe(e){let t=e.resolution.preview,o=q(e.rootPath,t.owner,t.repo),n=`${o}.${we()}.install`,s=Z(e.rootPath,t.id),i=g.join(n,"current");await E(n,{recursive:!0,force:!0}),await E(s,{recursive:!0,force:!0}),await W(i,{recursive:!0,mode:448});try{await e.github.download(e.resolution,async(a,b,f)=>{let y=$e(i,a);await W(g.dirname(y),{recursive:!0,mode:448}),await Re(y,b,{mode:f?448:384})});let d=Ve(t,o,e.installedAt,e.updatedAt);return await Re(g.join(n,"extension.json"),`${JSON.stringify(d,null,2)}
|
|
4
4
|
`,{mode:384}),await W(g.dirname(o),{recursive:!0,mode:448}),v(o)&&await k(o,s),await k(n,o),d}catch(d){throw await E(n,{recursive:!0,force:!0}),v(s)&&!v(o)&&await k(s,o),d}}r(fe,"materializeExtension");function Ve(e,t,o,n){let s=g.join(t,"current");return{...e,sourcePath:s,readmePath:e.readmePath?g.join(s,e.readmePath):null,installedAt:o,updatedAt:n,skills:e.skills.map(i=>({...i,sourcePath:g.join(s,i.relativePath)}))}}r(Ve,"installedExtension");async function Pe(e,t){await E(Z(e,t),{recursive:!0,force:!0})}r(Pe,"finalizeMaterialization");async function ye(e,t){let o=I(t.replace(/^github:/,"")),n=q(e,o.owner,o.repo),s=Z(e,t);await E(n,{recursive:!0,force:!0}),v(s)&&await k(s,n)}r(ye,"rollbackMaterialization");async function V(e,t){let o=q(e,t.owner,t.repo),n=g.join(o,"current"),s=(await Ke(g.join(o,"extension.json")).catch(()=>null))?.isFile()??!1,i=t.validationMessages.filter(d=>d!=="Installed files are missing.");return s||i.push("Installed files are missing."),{...t,sourcePath:n,readmePath:t.readmePath?g.join(n,g.basename(t.readmePath)):null,skills:t.skills.map(d=>({...d,sourcePath:g.join(n,d.relativePath)})),validationStatus:i.length===0?"valid":"error",validationMessages:i}}r(V,"hydrateExtension");function Ie(e){if(e.validationStatus!=="valid")throw new u(`Extension contains invalid skills: ${e.validationMessages.join(" ")}`,{code:"extension_invalid"})}r(Ie,"assertInstallable");function U(e,t,o){let n=new Map;for(let i of o)n.set(i,"a shipped OpenPond skill");for(let i of t)for(let d of i.skills)n.set(d.name,i.id);let s=e.skills.map(i=>({name:i.name,owner:n.get(i.name)})).filter(i=>!!i.owner);if(s.length!==0)throw new u(`Skill name conflict: ${s.map(i=>`${i.name} (${i.owner})`).join(", ")}.`,{code:"extension_skill_conflict",status:409})}r(U,"assertSkillNamesAvailable");function Xe(e,t,o){if(e.extensions.some(n=>n.id===t.id))throw new u(`${t.owner}/${t.repo} is already installed.`,{code:"extension_already_installed",status:409});return U(t,e.extensions,o),[...e.extensions,t].sort(Q)}r(Xe,"appendInstalledExtension");function Ye(e,t,o){return L(e,t.id),U(t,e.extensions.filter(n=>n.id!==t.id),o),e.extensions.map(n=>n.id===t.id?t:n).sort(Q)}r(Ye,"replaceInstalledExtension");function Ze(e,t){let o=new Map;for(let n of t)o.set(n,"built-in");for(let n of e)for(let s of n.skills){let i=o.get(s.name);if(!i){o.set(s.name,n.id);continue}let d=`Skill name conflicts with ${i}: ${s.name}`;s.validationStatus="error",s.validationMessages=[...new Set([...s.validationMessages,d])],n.validationStatus="error",n.validationMessages=[...new Set([...n.validationMessages,d])]}}r(Ze,"markInstalledSkillConflicts");async function C(e){let t=typeof e=="function"?await e():e??[];return[...new Set(t.map(o=>o.trim()).filter(Boolean))]}r(C,"reservedSkillNames");function L(e,t){let o=e.extensions.find(n=>n.id===t);if(o)return o;throw new u(`${t.replace(/^github:/,"")} is not installed.`,{code:"extension_not_installed",status:404})}r(L,"requireInstalled");async function O(e){let t=B(e,"extension_installations","registry")?.value;if(!t)return et();if(t.schemaVersion!==M||!Array.isArray(t.extensions)||!t.extensions.every(ve))throw new Error("Extension registry has an unsupported format.");return Qe(t)}r(O,"readRegistry");async function X(e,t,o){await N(g.join(z(e).runtime,"extension-registry"),async()=>{let n=B(e,"extension_installations","registry"),s=o(await O(e));oe(e,"extension_installations","registry",{...s,schemaVersion:M,updatedAt:t().toISOString()},n?.revision??null)})}r(X,"writeRegistry");function Qe(e){return{schemaVersion:M,updatedAt:typeof e?.updatedAt=="string"?e.updatedAt:null,extensions:Array.isArray(e?.extensions)?e.extensions.filter(ve):[]}}r(Qe,"normalizeRegistry");function et(){return{schemaVersion:M,updatedAt:null,extensions:[]}}r(et,"emptyRegistry");function ve(e){if(!e||typeof e!="object")return!1;let t=e;return t.source==="github"&&typeof t.id=="string"&&typeof t.owner=="string"&&typeof t.repo=="string"&&typeof t.repositoryUrl=="string"&&typeof t.requestedRef=="string"&&typeof t.resolvedCommit=="string"&&Array.isArray(t.skills)}r(ve,"isStoredExtension");function $e(e,t){if(g.isAbsolute(t)||t.split(/[\\/]/).includes(".."))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});let o=g.resolve(e,...t.split("/")),n=`${g.resolve(e)}${g.sep}`;if(!o.startsWith(n))throw new u(`Unsafe extension path: ${t}`,{code:"extension_unsafe_path"});return o}r($e,"safeDestination");function q(e,t,o){return g.join(e,"github",t,o)}r(q,"extensionDirectory");function Z(e,t){let o=I(t.replace(/^github:/,""));return`${q(e,o.owner,o.repo)}.previous`}r(Z,"backupDirectory");async function Y(e,t,o){let n=t.replace(/[^a-z0-9.-]+/gi,"-");return N(g.join(e,".locks",n),o,We)}r(Y,"withExtensionLock");function Q(e,t){return e.id.localeCompare(t.id)}r(Q,"extensionSort");async function Ln(e,t,o=Oe({reservedSkillNames:r(async()=>{let n=await D();return[...se,...n.skills.map(s=>s.name)]},"reservedSkillNames")})){let n=t[0]?.toLowerCase()||"list",s=G(e.json);if(n==="list"){let i=await o.list();if(i.error)throw new Error(i.error);tt(i.extensions,s);return}if(n==="add"||n==="preview"){let d={source:_(t[1],n),ref:Ce(e.ref)},a=n==="preview"?await o.preview(d):await o.add(d);ee(a,s,n==="preview"?"Preview":"Installed");return}if(n==="inspect"){ee(await o.inspect(_(t[1],n)),s,"Installed");return}if(n==="update"){if(G(e.all)){let a=await o.updateAll();if(s)console.log(JSON.stringify(a,null,2));else{console.log(`Updated ${a.updated.length}; unchanged ${a.unchanged.length}; failed ${a.failed.length}.`);for(let b of a.failed)console.log(`- ${b.id}: ${b.error}`)}a.failed.length>0&&(process.exitCode=1);return}let i=_(t[1],n),d=await o.update({source:i,ref:Ce(e.ref)});ee(d,s,"Updated");return}if(n==="remove"){let i=await o.remove(_(t[1],n));console.log(s?JSON.stringify({removed:i},null,2):`Removed ${i.owner}/${i.repo} and ${i.skills.length} skill(s).`);return}throw new Error("usage: openpond extension <add|preview|list|inspect|update|remove> [owner/repo] [--ref <ref>] [--all] [--json]")}r(Ln,"runOpenPondExtensionCommand");function ee(e,t,o){if(t){console.log(JSON.stringify(e,null,2));return}console.log(`${o} ${e.owner}/${e.repo}@${e.resolvedCommit.slice(0,12)} (${e.requestedRef}).`);for(let n of e.skills){let s=n.resourceFiles.length>0?`, ${n.resourceFiles.length} resource(s)`:"";console.log(`- ${n.name}${s}: ${n.description}`)}}r(ee,"printExtension");function tt(e,t){if(t){console.log(JSON.stringify({extensions:e},null,2));return}if(e.length===0){console.log("No third-party extensions installed.");return}console.log(`Third-party extensions (${e.length}):`);for(let o of e)console.log(`- ${o.owner}/${o.repo}@${o.resolvedCommit.slice(0,12)} \xB7 ${o.skills.length} skill(s) \xB7 ${o.validationStatus}`)}r(tt,"printExtensionList");function _(e,t){let o=e?.trim();if(o)return o;throw new Error(`usage: openpond extension ${t} <owner/repo>`)}r(_,"requiredSource");function Ce(e){return typeof e=="string"&&e.trim()?e.trim():void 0}r(Ce,"optionText");export{Ln as runOpenPondExtensionCommand};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{d as r,f as i,k as p}from"./chunk-
|
|
2
|
+
import{d as r,f as i,k as p}from"./chunk-AH22RHPS.js";import"./chunk-3M53YXEI.js";import{a as t}from"./chunk-FTQLQJQV.js";function d(){console.log(m())}t(d,"printHelp");function m(){let n=["OpenPond CLI","","Usage:"," openpond [--no-open] [--hostname HOST] [--port PORT]"," openpond <command> [options] [-- passthrough...]"," openpond --version","","Commands:"];for(let o of i()){let s=o.aliases?.length?` (aliases: ${o.aliases.join(", ")})`:"";n.push(` ${o.usage}${s}`);for(let e of o.usages??[])n.push(` ${e}`)}n.push("","Global options:");for(let[o,s]of Object.entries(r).sort(([e],[a])=>e.localeCompare(a))){let e=o.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`);n.push(s==="boolean"?` --${e}`:` --${e} <${s}>`)}return n.push("","Run `openpond <command> --help` for the selected command schema.","Arguments after `--` are passed through without option parsing."),n.join(`
|
|
3
3
|
`)}t(m,"formatCliHelp");function l(){return["# OpenPond CLI command reference","","<!-- Generated by `pnpm --dir apps/cli docs:commands`; do not edit by hand. -->","","Parsing, aliases, command help, and this reference use the same authoritative registry.","",...i().map(o=>`## ${o.name}
|
|
4
4
|
|
|
5
5
|
\`\`\`text
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as Ie,b as ye,c as Re,d as He,e as Ee,f as Pe,h as B,i as Ae,j as je}from"./chunk-FQZFLNLY.js";import{e as Ce,f as U}from"./chunk-IOQUF34U.js";import{V as be,Va as Se,W as ke,hb as xe,jb as Te,n as we,nb as G,o as ve,ob as De,pb as ze}from"./chunk-L3V4QKRV.js";import"./chunk-EMKZVP7Z.js";import"./chunk-DLZP22WV.js";import{k as ge}from"./chunk-OE2VF6KU.js";import{a as z}from"./chunk-T5LE6R5S.js";import"./chunk-QJRXTIOC.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{h as me,ma as fe,qa as D,ra as he}from"./chunk-7MXZJQS7.js";import"./chunk-7YR6CBNU.js";import"./chunk-USMZT5FZ.js";import"./chunk-5CMKGD43.js";import{M as W}from"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import{Da as de,Ea as ce,M as C,N as $,a as se,lc as pe}from"./chunk-XDMUD4FW.js";import{aa as le,ga as V,ia as ue}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import{Ca as ie,za as ae}from"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import{B as re,C as oe,E as ne}from"./chunk-WV2APYWG.js";import{Ma as M}from"./chunk-PJM2G7SG.js";import{L as Y,P as ee,sa as te}from"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import{l as J,m as R,r as X}from"./chunk-NNF6KCHD.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as $e}from"node:fs";import Ue from"node:path";import Le from"node:http";var Q=e.object({socketPath:e.string().min(1).max(1e3),capability:e.string().regex(/^[a-f0-9]{64}$/),jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ne=e.object({jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/),requestId:e.string().min(1).max(500),model:X,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max","none"]).nullable(),messages:e.array(e.unknown()).min(1).max(1e3),tools:e.array(e.unknown()).max(100),toolChoice:e.unknown(),maxOutputTokens:e.number().int().positive().max(131072),temperature:e.number().finite().optional(),topP:e.number().finite().optional(),seed:e.number().int().optional()}).strict(),Je=e.discriminatedUnion("kind",[e.object({kind:e.literal("chat_completions_reasoning"),reasoningContent:e.string()}).strict(),e.object({kind:e.literal("responses_reasoning_items"),items:e.array(e.record(e.string(),e.unknown()))}).strict()]),Ve=e.object({id:e.string().optional(),type:e.string(),function:e.object({name:e.string().optional(),arguments:e.string().optional()}).passthrough().optional()}).passthrough(),Ge=e.object({text:e.string().optional(),usage:e.unknown().optional(),costUsd:e.number().finite().nonnegative().optional(),continuation:Je.optional(),toolCalls:e.array(Ve).optional()}).strict();function qe(s,r){let t=Q.parse(s);async function n(u,v,I=r){I.throwIfAborted();let x=Buffer.from(JSON.stringify({action:u,jobId:t.jobId,pinHash:t.pinHash,value:v}));if(x.length>8*1024*1024)throw new Error("Hosted advanced request exceeds its private byte limit.");return new Promise((y,h)=>{let l=Le.request({socketPath:t.socketPath,path:"/",method:"POST",headers:{authorization:`Bearer ${t.capability}`,"content-type":"application/json","content-length":x.length},signal:I},H=>{let E=[],P=0;H.on("data",w=>{if(P+=w.length,P>8388608){H.destroy(new Error("Hosted advanced response exceeds its private byte limit."));return}E.push(w)}),H.on("error",h),H.on("end",()=>{try{let w=JSON.parse(Buffer.concat(E).toString("utf8"));if(H.statusCode!==200)throw new Error(typeof w?.error=="string"?w.error:"The actual hosted advanced owner refused this operation.");y(w)}catch(w){h(w)}})});l.on("error",h),l.end(x)})}i(n,"call");let d=i(async function*(u){let v=Ne.parse({jobId:t.jobId,pinHash:t.pinHash,requestId:u.requestId,model:u.model,reasoningEffort:u.reasoningEffort,messages:u.messages,tools:u.tools,toolChoice:u.toolChoice,maxOutputTokens:u.maxOutputTokens??4096,...u.temperature===void 0?{}:{temperature:u.temperature},...u.topP===void 0?{}:{topP:u.topP},...u.seed===void 0?{}:{seed:u.seed}}),I=e.object({deltas:e.array(Ge).max(1e5)}).strict().parse(await n("model",v,AbortSignal.any([r,u.signal])));for(let x of I.deltas)yield x},"stream");return{stream:d,text:i(async u=>{let v="";for await(let I of d({...u,reasoningEffort:u.reasoningEffort??null,tools:[],toolChoice:"none"}))I.text&&(v+=I.text),I.usage!==void 0&&u.onUsage?.(I.usage,I.costUsd);return v},"text"),authorize:i(async()=>{await n("authorize",{})},"authorize"),ceiling:i(async(u,v,I)=>e.object({configurationHash:e.string().regex(/^[a-f0-9]{64}$/),maximumChargeUsd:e.number().finite().positive()}).strict().parse(await n("ceiling",{modelId:u,pricing:v,maximumOutputTokens:I})),"ceiling"),compute:i((u,v=!1)=>n("compute",u,v?AbortSignal.timeout(6e4):r),"compute"),checkpoint:i(u=>n("checkpoint",u),"checkpoint")}}i(qe,"createHostedAdvancedModelBridge");import Qe from"node:path";var Me=e.string().regex(/^[a-f0-9]{64}$/),Ke=e.object({taskId:e.string().min(1),caseHash:Me,session:C,turn:$,events:e.array(se).max(1e4),traceHash:Me,output:e.string().nullable()}).strict(),K=e.object({packageValue:ae,contexts:e.array(Ke).max(1e4)}).strict();async function _e(s){let r=V(s.pin),t=K.parse(s.privateSource),n=ie(t.packageValue),d=M(e.object({manifest:e.unknown(),result:e.unknown()}).parse(s.evidence));async function m(){if(await s.authorize(),r.actorId!==s.actor.actorId||r.teamId!==s.actor.teamId||r.profileRef.source!=="openpond_git"||r.profileRef.repositoryId!==s.source.repositoryId||r.profileRef.profileId!==s.source.profileId||r.sourceRevision!==s.source.sourceRevision)throw new Error("The actual hosted advanced source owner changed.")}if(i(m,"authorize"),await m(),d.manifest.teamId!==r.teamId||d.result.status!=="completed"||d.manifest.id!==r.evidence.id||d.result.contentHash!==r.evidence.contentHash||R(d.manifest.dataset)!==R(r.externalDatasetBinding.dataset))throw new Error("The exact completed hosted advanced evidence changed.");if(n.contentHash!==r.externalDatasetBinding.packageHash||n.contentHash!==r.adaptationDatasetBinding.packageHash||n.environment.contentHash!==r.environmentPolicy.environmentHash||n.environment.contract.networkPolicy!=="none")throw new Error("The hosted advanced environment/package is not the exact reviewed closed-network release.");if(n.taskset.tools.some(l=>l.name==="web_search"||l.name==="web_fetch"))throw new Error("Live external tools require their own qualified frozen-observation and budget owner.");if(n.verifierSet.graders.some(l=>l.kind==="human"||l.kind==="model_judge"&&l.calibrationStatus!=="passed"))throw new Error("Advanced hosted evaluation needs executable, qualified independent graders.");let u=r.adaptationTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),v=r.holdoutTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),I=new Set(u.map(l=>l?.clusterKey));if(u.some(l=>!l||l.split!==r.adaptationSplit)||v.some(l=>!l||l.split!==r.holdoutSplit||I.has(l.clusterKey)))throw new Error("Hosted adaptation/holdout membership or independent families changed.");let x=await s.store.getHarnessReleaseRecord(r.baselineRelease.contentHash);if(!x||x.harnessRelease.id!==r.baselineRelease.id||s.workspace.currentChannel.release?.contentHash!==r.baselineRelease.contentHash)throw new Error("The exact hosted source baseline is unavailable.");let y=await D({workspaceId:typeof x.agentSnapshot.metadata.workspaceId=="string"?x.agentSnapshot.metadata.workspaceId:x.workspaceId,sourceDir:Qe.join(x.bundlePath,"source")});if(z(y).protectedClosureHash!==r.privateClosureHash)throw new Error("The protected hosted Profile closure changed.");let h={packageValue:n,authorize:m};return{read:i(async l=>{if(V(l).contentHash!==r.contentHash)throw new Error("The actual hosted advanced admission changed.");return await m(),h},"read"),evidence:i(async()=>(await m(),d),"evidence"),authorize:i(async()=>m(),"authorize"),reviewContext:i(async(l,H)=>{await m();let E=t.contexts.filter(p=>p.taskId===H),P=d.result.cases.find(p=>p.identity.caseId===H);if(E.length!==1||!P||P.status!=="completed")throw new Error("The actual retained hosted review case is unavailable.");let w=E[0];if(w.caseHash!==R(P)||w.session.cloudTeamId!==r.teamId||w.turn.sessionId!==w.session.id||w.turn.status==="in_progress"||w.events.some(p=>p.sessionId!==w.session.id||p.turnId!==w.turn.id))throw new Error("The actual hosted review session/turn/trace binding changed.");return await m(),{...w,case:{output:w.output}}},"reviewContext")}}i(_e,"createHostedAdvancedRefinerSource");import{randomUUID as Ze}from"node:crypto";function Oe(s){async function r(n){let d=await s.store.getSession(n);if(!d||d.cloudTeamId!==s.teamId||d.metadata?.hostedAdvancedTurnId!==s.hostedTurnId||d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The actual hosted advanced case owner changed.");return d}i(r,"read");async function t(n,d,m){let u=await r(n),v=e.object({action:e.string()}).passthrough().parse(d).action;return ce.parse(await s.bridge.compute({session:u,payload:d,turnId:m??null},v==="sandbox_stop"||v==="sandbox_receipts"))}return i(t,"tool"),{createSession:i(async n=>{await s.bridge.authorize();let d=C.partial().parse(n),m=new Date().toISOString();if(d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The foreground case belongs to another actual advanced Run.");let u=C.parse({...d,id:`hosted-advanced-case-${Ze()}`,provider:"openpond",currentProfile:s.profileRef,cloudTeamId:s.teamId,cwd:null,codexThreadId:null,appId:null,appName:null,createdAt:m,updatedAt:m,status:"active",pinned:!1,archived:!1,order:0,hiddenFromDefaultSidebar:!0,title:d.title??"Advanced hosted evaluation case",metadata:{...d.metadata,source:"hosted-advanced-evaluation",hostedAdvancedTurnId:s.hostedTurnId,actorId:s.actorId,workspaceTarget:"hosted",benchmarkRuntime:"hosted_managed_work"}});return await s.store.insertSessionAtFront(u),await s.bridge.authorize(),u},"createSession"),getSession:r,runtimeEventsForSession:i(n=>s.store.runtimeEventsForSession(n),"runtimeEventsForSession"),executeWorkspaceTool:i((n,d,m)=>t(n,d,m?.turnId),"executeWorkspaceTool"),settleCostEvidence:i((n,d)=>t(n,{action:"sandbox_receipts",args:{}},d?.turnId),"settleCostEvidence")}}i(Oe,"createHostedAdvancedWorkRuntime");var Xe=e.string().regex(/^[a-f0-9]{64}$/),Be=e.object({version:e.string().min(1),source:e.string().min(1),effectiveAt:e.string().min(1),inputUsdPerMillionTokens:e.number().finite().nonnegative(),cachedInputUsdPerMillionTokens:e.number().finite().nonnegative(),outputUsdPerMillionTokens:e.number().finite().nonnegative()}).strict(),Z=e.object({operation:e.enum(["prepare_run","start","read","resume","cancel"]),request:ue,configuration:e.object({id:e.string().min(1),profileId:e.string().min(1),etag:Xe}).strict(),refinerRelease:Y,privateSource:K,upstream:e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict(),judgeModels:e.array(e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict()).max(50),bridge:Q.optional(),hostedTurnId:e.string().min(1).optional()}).strict();async function Fe(s){let r=Z.parse(s.request),t=r.request.pin;if(r.request.model.providerId!=="openpond"||r.request.model.modelId!==r.upstream.modelId||r.configuration.id!==r.request.modelId||r.configuration.profileId!==t.profileRef.profileId||r.request.profileId!==t.profileRef.profileId||r.refinerRelease.id!==t.refinerRelease.id||r.refinerRelease.contentHash!==t.refinerRelease.contentHash)throw new Error("The actual hosted advanced configuration/model/Refiner admission changed.");let n=`advanced-refiner-${R([t.actorId,t.teamId,t.operationId,t.contentHash,r.request.model,[r.request.seed],1]).slice(0,40)}`;if((r.operation==="start"||r.operation==="resume")&&(!r.bridge||!r.hostedTurnId))throw new Error("The actual hosted advanced execution grant is unavailable.");let m=r.bridge?qe(r.bridge,s.signal):null;if(r.bridge&&(r.bridge.jobId!==n||r.bridge.pinHash!==t.contentHash))throw new Error("The hosted model bridge belongs to another actual Run.");let u=i(async()=>{s.signal.throwIfAborted(),await s.authorize(),m&&await m.authorize()},"authorize"),v=await _e({...s,pin:t,privateSource:r.privateSource,authorize:u}),I=we(ve(s.storeDir));await I.persistRelease(r.refinerRelease),await I.writeSource(ee(r.refinerRelease.profile)),I.binding()?.release.contentHash!==t.refinerRelease.contentHash&&await I.transition(r.refinerRelease,{operation:"activate",bindingChanged:!0,actor:s.actor.actorId,reason:"Pin the actual hosted evaluation fork to its admitted immutable Refiner release.",authoringSkillHash:null});let y=ke({storeDir:s.storeDir,authorize:i(async()=>u(),"authorize"),packageForPin:i(async()=>r.privateSource.packageValue,"packageForPin"),prepareModel:i(async(c,f,k)=>{if(!m)throw new Error("The actual hosted model ceiling owner is unavailable.");return m.ceiling(c,k,f)},"prepareModel")}),h=i(async function*(c){let f=be(),k=[r.upstream,...r.judgeModels].find(q=>q.modelId===c.model.modelId);if(!m||!f||!k)throw new Error("The actual hosted model and durable shared budget are unavailable.");let{signal:T,...j}=c,O=c.maxOutputTokens??4096,L=await f.call(c.requestId,j,k.pricing,O,async()=>{let q=[],F=null;for await(let N of m.stream({...c,signal:AbortSignal.any([T,f.signal])}))q.push(N),N.costUsd!==void 0&&(F=(F??0)+N.costUsd);return{value:q,costUsd:F}});for(let q of L)yield q},"stream"),l=i(async c=>{let f="";for await(let k of h({...c,reasoningEffort:c.reasoningEffort??null,tools:[],toolChoice:"none"}))k.text&&(f+=k.text),k.usage!==void 0&&c.onUsage?.(k.usage,k.costUsd);return f},"text"),H=Ie({store:s.store,storeDir:s.storeDir}),E=await H.projectSelected({profileId:t.profileRef.profileId,package:r.privateSource.packageValue,adaptationSplit:t.adaptationSplit,holdoutSplit:t.holdoutSplit}),P=i(async c=>{let f=C.partial().parse(c),k=new Date().toISOString(),T=C.parse({...f,id:`hosted-review-${R([n,f.metadata]).slice(0,40)}`,cloudTeamId:t.teamId,currentProfile:t.profileRef,appId:null,appName:null,cwd:null,codexThreadId:null,title:f.title??"Hosted Refiner review",provider:"openpond",createdAt:k,updatedAt:k,status:"active",pinned:!1,archived:!1,order:0,metadata:{...f.metadata,hostedAdvancedTurnId:r.hostedTurnId??null,actorId:t.actorId,source:"hosted-advanced-evaluation"}});return await s.store.insertSessionAtFront(T),T},"createSession"),w=m&&r.hostedTurnId?Oe({store:s.store,bridge:m,teamId:t.teamId,actorId:t.actorId,hostedTurnId:r.hostedTurnId,modelRunId:n,profileRef:t.profileRef}):void 0,p=Se({store:s.store,storeDir:s.storeDir,modelJudge:ye({store:s.store,modelText:l}),modelText:l,modelStream:h,workRuntime:w,resolveTasksetRelease:i(c=>H.releaseForTaskset(c),"resolveTasksetRelease")}),a={store:s.store,storeDir:s.storeDir,evaluation:p,benchmarkTasksets:H,loadProfileState:i(async()=>s.profile,"loadProfileState"),resolveEvaluationProject:i(async(c,f)=>{if(await u(),c!==r.configuration.id||f!==r.configuration.profileId)throw new Error("The actual hosted evaluation configuration changed.");return{id:c,profileId:f}},"resolveEvaluationProject"),resolveUpstreamModel:i(async()=>({providerId:"openpond",modelId:r.upstream.modelId,revision:r.upstream.revision,pricing:r.upstream.pricing}),"resolveUpstreamModel"),advancedBoundary:y,refinerStream:i(async function*(c){if(!c.requestId)throw new Error("A hosted Refiner call needs its actual retained ID.");yield*h({model:c.model,reasoningEffort:"low",messages:c.messages,tools:[],toolChoice:"none",requestId:c.requestId,maxOutputTokens:4096,signal:c.signal,hostedTokenPricing:c.pricing})},"refinerStream")},o=Re({...a,reviewQuality:He({source:v,boundary:y,benchmark:a,createSession:P})}),g={advancedEvaluation:t,selectedTaskset:{id:E.id,revision:E.revision,contentHash:E.contentHash},modelId:r.request.modelId,profileId:r.request.profileId,model:r.request.model,reasoningEffort:r.request.reasoningEffort,seeds:[r.request.seed],repetitions:1,maximumSpendUsd:t.maximumCostUsd},b,S=i(()=>{o.cancel(n)},"stop");s.signal.addEventListener("abort",S,{once:!0});try{if(r.operation==="prepare_run")return o.prepare(g);let c=await s.store.getModelRun(n);if(!c||c.evaluation?.benchmarkId!=="harness-refiner"||c.evaluation.advancedEvaluation?.contentHash!==t.contentHash)throw new Error("The original hosted advanced Run is unavailable.");if(r.operation==="read")return c;if(r.operation==="cancel")return o.cancel(n);if(m){let T=!1;b=setInterval(()=>{T||(T=!0,s.store.getModelRun(n).then(j=>j?m.checkpoint(j):void 0).catch(()=>S()).finally(()=>{T=!1}))},2e3)}r.operation==="start"?await o.start(g):await o.resume(n);let f=await o.wait(n);if(!f)throw new Error("The actual hosted advanced engine did not retain its Run.");let k=pe.parse(f);return m&&await m.checkpoint(k),k}finally{b&&clearInterval(b),s.signal.removeEventListener("abort",S),await o.close(),await y.close()}}i(Fe,"runHostedAdvancedRefinerOwner");import{promises as _}from"node:fs";import A from"node:path";var Ye=e.object({actor:e.object({actorId:e.string().min(1),teamId:e.string().min(1)}).strict(),storeDir:e.string().min(1),source:e.object({repoPath:e.string().min(1),repositoryId:e.string().min(1),profileId:e.string().min(1),sourceRevision:e.string().regex(/^[a-f0-9]{40,64}$/),filesHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),evidence:e.object({manifest:e.unknown(),result:e.unknown()}).strict(),operation:e.enum(["advanced","describe","command","queue","cancelQueued","bind","finish","beginTesting","cancelTesting","failTesting","comparison","beginAdoption","export","source","tool","toolCatalog"]),advanced:Z.optional(),command:le.optional(),candidateId:e.string().optional(),revision:e.number().int().positive().optional(),actualSession:C.optional(),actualTurn:$.optional(),recipe:e.unknown().optional(),baseline:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),candidate:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),humanProjection:oe.optional(),humanSelections:re.optional(),adoptionReadback:e.unknown().optional(),failure:e.object({message:e.string().max(2e3),cancelled:e.boolean()}).strict().optional(),tool:e.object({name:e.string(),args:e.record(e.string(),e.unknown()),callId:e.string()}).strict().optional(),agentRuntime:e.object({source:e.string(),cliRelativePath:e.string()}).strict().optional(),queued:e.object({sessionId:e.string(),turnId:e.string(),createdAt:e.string().datetime()}).strict().optional()}).strict();async function We(s,r=new AbortController().signal){r.throwIfAborted();let t=Ye.parse(s),{actor:n,source:d}=t;if(!A.isAbsolute(t.storeDir)||!A.isAbsolute(d.repoPath))throw new Error("Hosted candidate owner requires contained absolute private paths.");let m=M(t.evidence),u=[t.baseline,t.candidate].filter(l=>l!==void 0).map(l=>M(l));if(m.manifest.teamId!==n.teamId)throw new Error("Hosted candidate evidence belongs to another team.");if(await B(d.repoPath)!==d.filesHash)throw new Error("The admitted hosted Profile source bytes changed.");let v=`hosted-improve-source-${R([n,d.repositoryId,d.profileId,d.sourceRevision]).slice(0,40)}`,I=A.join(t.storeDir,"library","profile-experiment-origins",v);if(await _.mkdir(A.dirname(I),{recursive:!0,mode:448}),await _.stat(I).catch(()=>null)||await _.cp(d.repoPath,I,{recursive:!0,errorOnExist:!0,force:!1}),await B(I)!==d.filesHash)throw new Error("The private accepted Profile cache changed.");let x=await W(I,d.profileId);if(x.error||!x.sourcePath)throw new Error("The accepted hosted Profile does not compile.");let y=new xe(t.storeDir),h;try{let l=await y.getHarnessWorkspace(v);l||(l=(await fe({store:y,storeDir:t.storeDir,id:v,ownerId:n.actorId,name:d.profileId,profile:x,sourceRevision:d.sourceRevision,repositoryId:d.repositoryId,selectionEligible:!1,originMetadata:{profileExperimentOrigin:{schemaVersion:"openpond.profileExperimentOrigin.v1",...n,sourceRevision:d.sourceRevision,sourcePath:I,sourceFilesHash:d.filesHash},hostedImprovementOwner:!0}})).workspace);let H={source:"openpond_git",repositoryId:d.repositoryId,profileId:d.profileId},E=i(async()=>{if(r.throwIfAborted(),await B(I)!==d.filesHash||await B(d.repoPath)!==d.filesHash)throw new Error("Accepted source changed during private candidate I/O.")},"authorizer");if(t.operation==="advanced"){if(!t.advanced)throw new Error("Missing actual hosted advanced owner command.");return Fe({store:y,storeDir:t.storeDir,actor:n,profile:x,workspace:l,source:d,evidence:m,request:t.advanced,authorize:E,signal:r})}let P=i(()=>{if(!t.adoptionReadback)throw new Error("Actual hosted Git owner has not returned its sealed adoption receipt.");return e.object({receipt:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),activeRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),testedCandidateRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),executableSourceHash:e.string().regex(/^[a-f0-9]{64}$/),protectedClosureHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(t.adoptionReadback)},"readback");h=Ee({store:y,storeDir:t.storeDir,projectHumanComparison:i(async()=>{if(await E(),!t.humanProjection)throw new Error("The current private Human comparison owner is unavailable.");return ne(t.humanProjection)},"projectHumanComparison"),authorizeOwner:i(async(a,o,g,b,S)=>{if(R(a)!==R(n)||R(g)!==R(H)||o.id!==v)throw new Error("Hosted candidate source owner changed.");if(S.requireCurrentBase&&(o.currentChannel.release?.contentHash!==l.currentChannel.release?.contentHash||d.sourceRevision!==o.metadata.profileExperimentOrigin.sourceRevision))throw new Error("Hosted candidate accepted revision changed.");await E()},"authorizeOwner"),loadEvidence:i(async(a,o)=>{if(R(a)!==R(n))throw new Error("Hosted candidate evidence actor changed.");let g=[m,...u].find(b=>b.manifest.id===o.id&&b.result.contentHash===o.contentHash&&b.manifest.teamId===n.teamId);if(!g)throw new Error("Hosted candidate exact retained evidence changed.");return await E(),g},"loadEvidence"),freezeProfile:i(async(a,o,g)=>{let b=await y.getHarnessReleaseRecord(o.baseRelease.contentHash);if(!b)throw new Error("Hosted source baseline is missing.");let S=await D({workspaceId:typeof b.agentSnapshot.metadata.workspaceId=="string"?b.agentSnapshot.metadata.workspaceId:b.workspaceId,sourceDir:A.join(b.bundlePath,"source")}),c=await D({workspaceId:typeof g.release.agentSnapshot.metadata.workspaceId=="string"?g.release.agentSnapshot.metadata.workspaceId:g.release.workspaceId,sourceDir:A.join(g.release.bundlePath,"source")});return Ae({store:y,storeDir:t.storeDir,state:o},async f=>{await Ce({...f,state:o,base:S,candidate:c});let k=await W(f.root,o.profileRef.profileId),T=await U({storeDir:t.storeDir,state:o,profile:k,sourceRevision:g.profileSourceRevision,base:S}),j=z(T);if(j.protectedClosureHash!==z(S).protectedClosureHash)throw new Error("Hosted source candidate changed protected evaluation closure.");let O=A.join(t.storeDir,"library","profile-candidate-archives",o.id,j.contentHash);await _.mkdir(A.dirname(O),{recursive:!0,mode:448}),await _.stat(O).catch(()=>null)||await _.cp(f.root,O,{recursive:!0,errorOnExist:!0,force:!1});let L=await W(O,o.profileRef.profileId);if((await U({storeDir:t.storeDir,state:o,profile:L,sourceRevision:g.profileSourceRevision,base:S})).harnessRelease.contentHash!==T.harnessRelease.contentHash)throw new Error("Hosted frozen Profile archive readback differs.");let F=await he({storeDir:t.storeDir,workspaceId:g.release.workspaceId,compiled:T,createdAt:g.release.createdAt});return await E(),{...g,release:F,executableIdentity:j}})},"freezeProfile"),adopt:i(async()=>P(),"adopt"),readAdoption:i(async()=>t.adoptionReadback?P():null,"readAdoption"),rollback:i(async()=>P(),"rollback")});let w=Pe({store:y,improvements:h,actorId:i(async()=>n.actorId,"actorId"),teamId:i(async()=>n.teamId,"teamId"),loadProfile:i(async a=>{if(R(a)!==R(H))throw new Error("Candidate requested another source owner.");return x},"loadProfile"),agentRuntime:t.agentRuntime,operationSignal:r,loadAgentRuntime:De({storeDir:t.storeDir,loadArchive:ze({storeDir:t.storeDir})})});if(t.operation==="describe"){await E();let a=l.currentChannel.release,o=a?await y.getHarnessReleaseRecord(a.contentHash):null;if(!a||!o||o.workspaceId!==l.id||o.harnessRelease.id!==a.id||o.harnessRelease.contentHash!==a.contentHash||l.ownerScope.kind!=="personal"||l.ownerScope.id!==n.actorId)throw new Error("Hosted source release is unavailable to its admitted owner.");let g=await D({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:v,sourceDir:A.join(o.bundlePath,"source")});if(g.harnessRelease.contentHash!==o.harnessRelease.contentHash)throw new Error("Hosted source compiler readback changed.");let b=await ge({runtime:{release:o},ref:H,sourceRevision:d.sourceRevision,harnessRelease:a}),S=i(c=>{let f=g.sourceFiles.find(k=>k.path===c)?.bytes;return f?JSON.parse(Buffer.from(f).toString("utf8")):null},"readJson");return await E(),{workspaceId:v,ownerRevision:l.revision,profileRef:H,baseRelease:l.currentChannel.release,profileSourceRevision:d.sourceRevision,manifest:g.manifest,executable:z(g),catalogHash:b.catalogHash,workflows:S("workflows/catalog.json"),actions:S("workflows/actions.json")}}if(t.operation==="command"){let a=t.command;if(!a)throw new Error("Missing canonical Improve command.");if(a.operation==="start")return h.start(n,a.request);if(a.operation==="list")return h.list(n,a.limit,a.cursor);if(!("id"in a))throw new Error("Discover exact hosted source choices through the authenticated host.");let o=await h.read(n,a.id);if(a.operation==="read")return o;if(a.operation==="instructions"){let g=await h.partition(n,o.id),b=await me(g.sourceRoot,o.component.path),S=await _.readFile(b);if(S.length>25e4)throw new Error("Instruction editor size limit exceeded.");let c=S.toString("utf8");if(o.component.kind==="workflow"){let f=JSON.parse(c).workflows?.find(k=>k.id===o.component.workflowId);if(f?.invocation?.kind!=="instructions")throw new Error("Use Work to author this executable Workflow.");c=f.invocation.instructions}return{candidateId:o.id,candidateRevision:o.revision,path:o.component.path,text:c,textHash:J(c),contentHash:J(S)}}if(a.operation==="humanComparisonOptions")throw new Error("Read the actual paired sources through their current hosted Experiment owner.");if(!("revision"in a)||o.revision!==a.revision)throw new Error("Candidate revision changed.");if(a.operation==="edit")return h.edit(n,o.id,o.revision,a.expectedFileHash,a.text);if(a.operation==="mode")return h.setMode(n,o.id,o.revision,a.mode);if(a.operation==="freeze")return h.freeze(n,o.id,o.revision);if(a.operation==="useCandidate")return h.useCandidate(n,o.id,o.revision);if(a.operation==="rollback")return h.rollback(n,o.id,o.revision);if(a.operation==="discard")return h.discard(n,o.id,o.revision);throw new Error("Hosted Work/test lifecycle requires the actual host turn/run admission.")}if(!t.candidateId)throw new Error("Missing actual hosted candidate ID.");let p=await h.read(n,t.candidateId);if(t.operation==="beginAdoption")return h.beginAdoption(n,p.id,t.revision);if(t.operation==="export")return je(y,p,"hosted_execution");if(t.operation==="source"){if(!p.frozen||p.status!=="frozen"&&p.status!=="testing"&&p.status!=="ready_for_review"&&p.status!=="adopting")throw new Error("Only the exact frozen source can enter hosted preparation.");let a=await y.getHarnessReleaseRecord(p.frozen.release.contentHash);if(!a||a.harnessRelease.id!==p.frozen.release.id)throw new Error("Frozen hosted source is unavailable.");let o=await D({workspaceId:typeof a.agentSnapshot.metadata.workspaceId=="string"?a.agentSnapshot.metadata.workspaceId:a.workspaceId,sourceDir:A.join(a.bundlePath,"source")}),g=z(o);if(o.harnessRelease.contentHash!==p.frozen.release.contentHash||g.contentHash!==p.frozen.executableSourceHash||g.protectedClosureHash!==p.frozen.protectedClosureHash)throw new Error("Frozen hosted executable changed.");let b=A.join(t.storeDir,"library","profile-candidate-archives",p.id,g.contentHash),S=await W(b,p.profileRef.profileId);if(S.error||!S.sourcePath)throw new Error("Frozen actual Profile archive is unavailable.");let c=await y.getHarnessReleaseRecord(p.baseRelease.contentHash);if(!c)throw new Error("Frozen baseline is unavailable.");let f=await D({workspaceId:typeof c.agentSnapshot.metadata.workspaceId=="string"?c.agentSnapshot.metadata.workspaceId:c.workspaceId,sourceDir:A.join(c.bundlePath,"source")}),k=await U({storeDir:t.storeDir,state:p,profile:S,sourceRevision:p.frozen.profileSourceRevision,base:f});if(k.harnessRelease.contentHash!==p.frozen.release.contentHash||z(k).contentHash!==g.contentHash)throw new Error("Actual frozen Profile archive differs from its compiled release.");return{state:p,profileSource:{repoPath:b,profileId:p.profileRef.profileId,sourceRevision:p.frozen.profileSourceRevision,repositoryId:p.profileRef.repositoryId,filesHash:await B(b)},sourcePackage:te({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,files:new Map(o.sourceFiles.map(T=>[T.path,T.bytes]))})}}if(t.operation==="comparison"){if(!t.baseline||!t.candidate)throw new Error("Missing actual hosted paired evidence.");return h.completeComparison(n,p.id,t.revision,M(t.baseline),M(t.candidate),t.humanSelections)}if(t.operation==="beginTesting")return h.beginTesting(n,p.id,t.revision,t.recipe);if(t.operation==="failTesting"){if(!t.failure)throw new Error("Missing actual hosted test failure.");return h.failTesting(n,p.id,t.revision,t.failure.message,t.failure.cancelled)}if(t.operation==="cancelTesting")return h.cancelTesting(n,p.id,t.revision);if(t.operation==="queue"){if(!t.queued)throw new Error("Missing actual hosted queue admission.");return h.queueAuthoringTurn(n,p.id,t.revision,t.queued.sessionId,t.queued.turnId,t.queued.createdAt)}if(t.operation==="cancelQueued")return h.cancelQueuedAuthoring(n,p.id,t.revision);if(t.operation==="bind"||t.operation==="finish"||t.operation==="tool"||t.operation==="toolCatalog"){if(!t.actualSession||!t.actualTurn||t.actualTurn.sessionId!==t.actualSession.id||t.actualSession.cloudTeamId!==n.teamId||R(t.actualSession.currentProfile)!==R(H))throw new Error("Actual hosted candidate Work binding changed.");let a=t.actualSession,o=t.actualTurn,g=await y.getSession(a.id);if(!g)await y.insertSessionAtFront(a);else if(R({...g,updatedAt:a.updatedAt,status:a.status})!==R(a))throw new Error("Retained hosted candidate session changed.");let b=await y.getTurn(o.id);if(!b)await y.insertTurn(o);else{if(b.sessionId!==o.sessionId||R(b.metadata.refinementCandidate)!==R(o.metadata.refinementCandidate)||b.prompt!==o.prompt)throw new Error("Actual hosted candidate turn identity changed.");await y.updateTurn(o.id,()=>o)}if(t.operation==="bind")return h.bindAuthoringTurn(n,p.id,t.revision,a.id,o.id);if(t.operation==="finish")return h.finishAuthoring(n,p.id,t.revision);if(t.operation==="toolCatalog")return await w.candidateAuthoringForTurn(a.id,o.id),[...G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}),...Te(async()=>{throw new Error("Hosted file tools require a bound private call.")}),{name:"exec_command",description:"Run a bounded command confined to the selected public candidate component.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:2e4},cwd:{type:"string"}},required:["command"]}},{name:"view_image",description:"Inspect an image inside the candidate public source tree.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string"}},required:["path"]}}].map(({name:c,description:f,parameters:k})=>({name:c,description:f,parameters:k}));if(!t.tool)throw new Error("Missing candidate tool call.");await w.authorizeCandidateTool({sessionId:a.id,turnId:o.id,name:t.tool.name});let S={session:a,turnId:o.id,args:t.tool.args,callId:t.tool.callId,signal:r,workspaceDiffBaseline:null,turnPermissions:{approvalPolicy:"never",sandbox:"workspace-write",codexPermissionMode:"default"},provider:a.provider,model:o.modelRef?.modelId??a.modelRef?.modelId??"",mentionedApps:[],userPrompt:o.prompt,turnMetadata:o.metadata};if(t.tool.name==="get_profile"||t.tool.name.startsWith("agent_")||t.tool.name==="ask_user"){let c=G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}).find(f=>f.name===t.tool.name);if(!c)throw new Error("Candidate authoring tool is unavailable.");return c.execute(S)}if(t.tool.name==="view_image")return w.executeCandidateImage(S);if(t.tool.name==="exec_command")return w.executeCandidateCommand(S,{session:a,turnId:o.id,command:e.string().min(1).max(2e4).parse(t.tool.args.command),cwd:typeof t.tool.args.cwd=="string"?t.tool.args.cwd:null,signal:S.signal,source:"model_tool"});if(["list_files","read_files","search_files","workspace_status","write_file","write_files","edit_file","delete_file"].includes(t.tool.name))return w.executeCandidateWorkspaceTool({session:a,turnId:o.id,request:de.parse({action:t.tool.name,args:t.tool.args,source:"chat_action"})});throw new Error("This hosted tool has no confined candidate transport.")}throw new Error("Unknown private hosted Improve operation.")}finally{await h?.close(),await y.close()}}i(We,"runHostedExperimentImprovementOwner");async function wr(s){if(s.length!==1||s[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(s[0]))throw new Error("Hosted Improve IPC argument is invalid.");let r=e.object({directory:e.string(),file:e.string().regex(/^[A-Za-z0-9_-]+\.json$/)}).strict().parse(JSON.parse(Buffer.from(s[0],"base64url").toString("utf8")));if(!Ue.isAbsolute(r.directory))throw new Error("Hosted Improve IPC requires an absolute private directory.");let t=Ue.join(r.directory,r.file),n=await $e.lstat(t);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("Hosted Improve private request exceeds its byte/type limit.");let d=new AbortController,m=i(()=>d.abort(new Error("The actual hosted owner stopped this private operation.")),"stop");process.once("SIGTERM",m),process.once("SIGINT",m);try{let u=await We(JSON.parse(await $e.readFile(t,"utf8")),d.signal),v=Buffer.from(JSON.stringify(u));if(v.length>32*1024*1024)throw new Error("Hosted Improve private response exceeds its byte limit.");process.stdout.write(`${v.toString("utf8")}
|
|
2
|
+
import{a as Ie,b as ye,c as Re,d as He,e as Ee,f as Pe,h as B,i as Ae,j as je}from"./chunk-YD55Z5H3.js";import{e as Ce,f as U}from"./chunk-H2VT22JK.js";import{V as be,Va as Se,W as ke,hb as xe,jb as Te,n as we,nb as G,o as ve,ob as De,pb as ze}from"./chunk-NHFGEVVH.js";import"./chunk-EMKZVP7Z.js";import"./chunk-FPUUZQUP.js";import{k as ge}from"./chunk-6VF3Q6QJ.js";import{a as z}from"./chunk-T5LE6R5S.js";import"./chunk-USKE34VR.js";import"./chunk-SDO4FC4Q.js";import"./chunk-IR3YJWPW.js";import{h as me,ma as fe,qa as D,ra as he}from"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-USMZT5FZ.js";import"./chunk-5CMKGD43.js";import{M as W}from"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import{Da as de,Ea as ce,M as C,N as $,a as se,lc as pe}from"./chunk-2JO2KWT3.js";import{aa as le,ga as V,ia as ue}from"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import{Ca as ie,za as ae}from"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import{B as re,C as oe,E as ne}from"./chunk-WV2APYWG.js";import{Ma as M}from"./chunk-PJM2G7SG.js";import{L as Y,P as ee,sa as te}from"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import{l as J,m as R,r as X}from"./chunk-NNF6KCHD.js";import{b as e}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as i}from"./chunk-FTQLQJQV.js";import{promises as $e}from"node:fs";import Ue from"node:path";import Le from"node:http";var Q=e.object({socketPath:e.string().min(1).max(1e3),capability:e.string().regex(/^[a-f0-9]{64}$/),jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),Ne=e.object({jobId:e.string().min(1),pinHash:e.string().regex(/^[a-f0-9]{64}$/),requestId:e.string().min(1).max(500),model:X,reasoningEffort:e.enum(["off","low","medium","high","xhigh","max","none"]).nullable(),messages:e.array(e.unknown()).min(1).max(1e3),tools:e.array(e.unknown()).max(100),toolChoice:e.unknown(),maxOutputTokens:e.number().int().positive().max(131072),temperature:e.number().finite().optional(),topP:e.number().finite().optional(),seed:e.number().int().optional()}).strict(),Je=e.discriminatedUnion("kind",[e.object({kind:e.literal("chat_completions_reasoning"),reasoningContent:e.string()}).strict(),e.object({kind:e.literal("responses_reasoning_items"),items:e.array(e.record(e.string(),e.unknown()))}).strict()]),Ve=e.object({id:e.string().optional(),type:e.string(),function:e.object({name:e.string().optional(),arguments:e.string().optional()}).passthrough().optional()}).passthrough(),Ge=e.object({text:e.string().optional(),usage:e.unknown().optional(),costUsd:e.number().finite().nonnegative().optional(),continuation:Je.optional(),toolCalls:e.array(Ve).optional()}).strict();function qe(s,r){let t=Q.parse(s);async function n(u,v,I=r){I.throwIfAborted();let x=Buffer.from(JSON.stringify({action:u,jobId:t.jobId,pinHash:t.pinHash,value:v}));if(x.length>8*1024*1024)throw new Error("Hosted advanced request exceeds its private byte limit.");return new Promise((y,h)=>{let l=Le.request({socketPath:t.socketPath,path:"/",method:"POST",headers:{authorization:`Bearer ${t.capability}`,"content-type":"application/json","content-length":x.length},signal:I},H=>{let E=[],P=0;H.on("data",w=>{if(P+=w.length,P>8388608){H.destroy(new Error("Hosted advanced response exceeds its private byte limit."));return}E.push(w)}),H.on("error",h),H.on("end",()=>{try{let w=JSON.parse(Buffer.concat(E).toString("utf8"));if(H.statusCode!==200)throw new Error(typeof w?.error=="string"?w.error:"The actual hosted advanced owner refused this operation.");y(w)}catch(w){h(w)}})});l.on("error",h),l.end(x)})}i(n,"call");let d=i(async function*(u){let v=Ne.parse({jobId:t.jobId,pinHash:t.pinHash,requestId:u.requestId,model:u.model,reasoningEffort:u.reasoningEffort,messages:u.messages,tools:u.tools,toolChoice:u.toolChoice,maxOutputTokens:u.maxOutputTokens??4096,...u.temperature===void 0?{}:{temperature:u.temperature},...u.topP===void 0?{}:{topP:u.topP},...u.seed===void 0?{}:{seed:u.seed}}),I=e.object({deltas:e.array(Ge).max(1e5)}).strict().parse(await n("model",v,AbortSignal.any([r,u.signal])));for(let x of I.deltas)yield x},"stream");return{stream:d,text:i(async u=>{let v="";for await(let I of d({...u,reasoningEffort:u.reasoningEffort??null,tools:[],toolChoice:"none"}))I.text&&(v+=I.text),I.usage!==void 0&&u.onUsage?.(I.usage,I.costUsd);return v},"text"),authorize:i(async()=>{await n("authorize",{})},"authorize"),ceiling:i(async(u,v,I)=>e.object({configurationHash:e.string().regex(/^[a-f0-9]{64}$/),maximumChargeUsd:e.number().finite().positive()}).strict().parse(await n("ceiling",{modelId:u,pricing:v,maximumOutputTokens:I})),"ceiling"),compute:i((u,v=!1)=>n("compute",u,v?AbortSignal.timeout(6e4):r),"compute"),checkpoint:i(u=>n("checkpoint",u),"checkpoint")}}i(qe,"createHostedAdvancedModelBridge");import Qe from"node:path";var Me=e.string().regex(/^[a-f0-9]{64}$/),Ke=e.object({taskId:e.string().min(1),caseHash:Me,session:C,turn:$,events:e.array(se).max(1e4),traceHash:Me,output:e.string().nullable()}).strict(),K=e.object({packageValue:ae,contexts:e.array(Ke).max(1e4)}).strict();async function _e(s){let r=V(s.pin),t=K.parse(s.privateSource),n=ie(t.packageValue),d=M(e.object({manifest:e.unknown(),result:e.unknown()}).parse(s.evidence));async function m(){if(await s.authorize(),r.actorId!==s.actor.actorId||r.teamId!==s.actor.teamId||r.profileRef.source!=="openpond_git"||r.profileRef.repositoryId!==s.source.repositoryId||r.profileRef.profileId!==s.source.profileId||r.sourceRevision!==s.source.sourceRevision)throw new Error("The actual hosted advanced source owner changed.")}if(i(m,"authorize"),await m(),d.manifest.teamId!==r.teamId||d.result.status!=="completed"||d.manifest.id!==r.evidence.id||d.result.contentHash!==r.evidence.contentHash||R(d.manifest.dataset)!==R(r.externalDatasetBinding.dataset))throw new Error("The exact completed hosted advanced evidence changed.");if(n.contentHash!==r.externalDatasetBinding.packageHash||n.contentHash!==r.adaptationDatasetBinding.packageHash||n.environment.contentHash!==r.environmentPolicy.environmentHash||n.environment.contract.networkPolicy!=="none")throw new Error("The hosted advanced environment/package is not the exact reviewed closed-network release.");if(n.taskset.tools.some(l=>l.name==="web_search"||l.name==="web_fetch"))throw new Error("Live external tools require their own qualified frozen-observation and budget owner.");if(n.verifierSet.graders.some(l=>l.kind==="human"||l.kind==="model_judge"&&l.calibrationStatus!=="passed"))throw new Error("Advanced hosted evaluation needs executable, qualified independent graders.");let u=r.adaptationTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),v=r.holdoutTaskIds.map(l=>n.taskset.tasks.find(H=>H.id===l)),I=new Set(u.map(l=>l?.clusterKey));if(u.some(l=>!l||l.split!==r.adaptationSplit)||v.some(l=>!l||l.split!==r.holdoutSplit||I.has(l.clusterKey)))throw new Error("Hosted adaptation/holdout membership or independent families changed.");let x=await s.store.getHarnessReleaseRecord(r.baselineRelease.contentHash);if(!x||x.harnessRelease.id!==r.baselineRelease.id||s.workspace.currentChannel.release?.contentHash!==r.baselineRelease.contentHash)throw new Error("The exact hosted source baseline is unavailable.");let y=await D({workspaceId:typeof x.agentSnapshot.metadata.workspaceId=="string"?x.agentSnapshot.metadata.workspaceId:x.workspaceId,sourceDir:Qe.join(x.bundlePath,"source")});if(z(y).protectedClosureHash!==r.privateClosureHash)throw new Error("The protected hosted Profile closure changed.");let h={packageValue:n,authorize:m};return{read:i(async l=>{if(V(l).contentHash!==r.contentHash)throw new Error("The actual hosted advanced admission changed.");return await m(),h},"read"),evidence:i(async()=>(await m(),d),"evidence"),authorize:i(async()=>m(),"authorize"),reviewContext:i(async(l,H)=>{await m();let E=t.contexts.filter(p=>p.taskId===H),P=d.result.cases.find(p=>p.identity.caseId===H);if(E.length!==1||!P||P.status!=="completed")throw new Error("The actual retained hosted review case is unavailable.");let w=E[0];if(w.caseHash!==R(P)||w.session.cloudTeamId!==r.teamId||w.turn.sessionId!==w.session.id||w.turn.status==="in_progress"||w.events.some(p=>p.sessionId!==w.session.id||p.turnId!==w.turn.id))throw new Error("The actual hosted review session/turn/trace binding changed.");return await m(),{...w,case:{output:w.output}}},"reviewContext")}}i(_e,"createHostedAdvancedRefinerSource");import{randomUUID as Ze}from"node:crypto";function Oe(s){async function r(n){let d=await s.store.getSession(n);if(!d||d.cloudTeamId!==s.teamId||d.metadata?.hostedAdvancedTurnId!==s.hostedTurnId||d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The actual hosted advanced case owner changed.");return d}i(r,"read");async function t(n,d,m){let u=await r(n),v=e.object({action:e.string()}).passthrough().parse(d).action;return ce.parse(await s.bridge.compute({session:u,payload:d,turnId:m??null},v==="sandbox_stop"||v==="sandbox_receipts"))}return i(t,"tool"),{createSession:i(async n=>{await s.bridge.authorize();let d=C.partial().parse(n),m=new Date().toISOString();if(d.metadata?.parentModelRunId!==s.modelRunId)throw new Error("The foreground case belongs to another actual advanced Run.");let u=C.parse({...d,id:`hosted-advanced-case-${Ze()}`,provider:"openpond",currentProfile:s.profileRef,cloudTeamId:s.teamId,cwd:null,codexThreadId:null,appId:null,appName:null,createdAt:m,updatedAt:m,status:"active",pinned:!1,archived:!1,order:0,hiddenFromDefaultSidebar:!0,title:d.title??"Advanced hosted evaluation case",metadata:{...d.metadata,source:"hosted-advanced-evaluation",hostedAdvancedTurnId:s.hostedTurnId,actorId:s.actorId,workspaceTarget:"hosted",benchmarkRuntime:"hosted_managed_work"}});return await s.store.insertSessionAtFront(u),await s.bridge.authorize(),u},"createSession"),getSession:r,runtimeEventsForSession:i(n=>s.store.runtimeEventsForSession(n),"runtimeEventsForSession"),executeWorkspaceTool:i((n,d,m)=>t(n,d,m?.turnId),"executeWorkspaceTool"),settleCostEvidence:i((n,d)=>t(n,{action:"sandbox_receipts",args:{}},d?.turnId),"settleCostEvidence")}}i(Oe,"createHostedAdvancedWorkRuntime");var Xe=e.string().regex(/^[a-f0-9]{64}$/),Be=e.object({version:e.string().min(1),source:e.string().min(1),effectiveAt:e.string().min(1),inputUsdPerMillionTokens:e.number().finite().nonnegative(),cachedInputUsdPerMillionTokens:e.number().finite().nonnegative(),outputUsdPerMillionTokens:e.number().finite().nonnegative()}).strict(),Z=e.object({operation:e.enum(["prepare_run","start","read","resume","cancel"]),request:ue,configuration:e.object({id:e.string().min(1),profileId:e.string().min(1),etag:Xe}).strict(),refinerRelease:Y,privateSource:K,upstream:e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict(),judgeModels:e.array(e.object({modelId:e.string().min(1),revision:e.string().min(1),pricing:Be}).strict()).max(50),bridge:Q.optional(),hostedTurnId:e.string().min(1).optional()}).strict();async function Fe(s){let r=Z.parse(s.request),t=r.request.pin;if(r.request.model.providerId!=="openpond"||r.request.model.modelId!==r.upstream.modelId||r.configuration.id!==r.request.modelId||r.configuration.profileId!==t.profileRef.profileId||r.request.profileId!==t.profileRef.profileId||r.refinerRelease.id!==t.refinerRelease.id||r.refinerRelease.contentHash!==t.refinerRelease.contentHash)throw new Error("The actual hosted advanced configuration/model/Refiner admission changed.");let n=`advanced-refiner-${R([t.actorId,t.teamId,t.operationId,t.contentHash,r.request.model,[r.request.seed],1]).slice(0,40)}`;if((r.operation==="start"||r.operation==="resume")&&(!r.bridge||!r.hostedTurnId))throw new Error("The actual hosted advanced execution grant is unavailable.");let m=r.bridge?qe(r.bridge,s.signal):null;if(r.bridge&&(r.bridge.jobId!==n||r.bridge.pinHash!==t.contentHash))throw new Error("The hosted model bridge belongs to another actual Run.");let u=i(async()=>{s.signal.throwIfAborted(),await s.authorize(),m&&await m.authorize()},"authorize"),v=await _e({...s,pin:t,privateSource:r.privateSource,authorize:u}),I=we(ve(s.storeDir));await I.persistRelease(r.refinerRelease),await I.writeSource(ee(r.refinerRelease.profile)),I.binding()?.release.contentHash!==t.refinerRelease.contentHash&&await I.transition(r.refinerRelease,{operation:"activate",bindingChanged:!0,actor:s.actor.actorId,reason:"Pin the actual hosted evaluation fork to its admitted immutable Refiner release.",authoringSkillHash:null});let y=ke({storeDir:s.storeDir,authorize:i(async()=>u(),"authorize"),packageForPin:i(async()=>r.privateSource.packageValue,"packageForPin"),prepareModel:i(async(c,f,k)=>{if(!m)throw new Error("The actual hosted model ceiling owner is unavailable.");return m.ceiling(c,k,f)},"prepareModel")}),h=i(async function*(c){let f=be(),k=[r.upstream,...r.judgeModels].find(q=>q.modelId===c.model.modelId);if(!m||!f||!k)throw new Error("The actual hosted model and durable shared budget are unavailable.");let{signal:T,...j}=c,O=c.maxOutputTokens??4096,L=await f.call(c.requestId,j,k.pricing,O,async()=>{let q=[],F=null;for await(let N of m.stream({...c,signal:AbortSignal.any([T,f.signal])}))q.push(N),N.costUsd!==void 0&&(F=(F??0)+N.costUsd);return{value:q,costUsd:F}});for(let q of L)yield q},"stream"),l=i(async c=>{let f="";for await(let k of h({...c,reasoningEffort:c.reasoningEffort??null,tools:[],toolChoice:"none"}))k.text&&(f+=k.text),k.usage!==void 0&&c.onUsage?.(k.usage,k.costUsd);return f},"text"),H=Ie({store:s.store,storeDir:s.storeDir}),E=await H.projectSelected({profileId:t.profileRef.profileId,package:r.privateSource.packageValue,adaptationSplit:t.adaptationSplit,holdoutSplit:t.holdoutSplit}),P=i(async c=>{let f=C.partial().parse(c),k=new Date().toISOString(),T=C.parse({...f,id:`hosted-review-${R([n,f.metadata]).slice(0,40)}`,cloudTeamId:t.teamId,currentProfile:t.profileRef,appId:null,appName:null,cwd:null,codexThreadId:null,title:f.title??"Hosted Refiner review",provider:"openpond",createdAt:k,updatedAt:k,status:"active",pinned:!1,archived:!1,order:0,metadata:{...f.metadata,hostedAdvancedTurnId:r.hostedTurnId??null,actorId:t.actorId,source:"hosted-advanced-evaluation"}});return await s.store.insertSessionAtFront(T),T},"createSession"),w=m&&r.hostedTurnId?Oe({store:s.store,bridge:m,teamId:t.teamId,actorId:t.actorId,hostedTurnId:r.hostedTurnId,modelRunId:n,profileRef:t.profileRef}):void 0,p=Se({store:s.store,storeDir:s.storeDir,modelJudge:ye({store:s.store,modelText:l}),modelText:l,modelStream:h,workRuntime:w,resolveTasksetRelease:i(c=>H.releaseForTaskset(c),"resolveTasksetRelease")}),a={store:s.store,storeDir:s.storeDir,evaluation:p,benchmarkTasksets:H,loadProfileState:i(async()=>s.profile,"loadProfileState"),resolveEvaluationProject:i(async(c,f)=>{if(await u(),c!==r.configuration.id||f!==r.configuration.profileId)throw new Error("The actual hosted evaluation configuration changed.");return{id:c,profileId:f}},"resolveEvaluationProject"),resolveUpstreamModel:i(async()=>({providerId:"openpond",modelId:r.upstream.modelId,revision:r.upstream.revision,pricing:r.upstream.pricing}),"resolveUpstreamModel"),advancedBoundary:y,refinerStream:i(async function*(c){if(!c.requestId)throw new Error("A hosted Refiner call needs its actual retained ID.");yield*h({model:c.model,reasoningEffort:"low",messages:c.messages,tools:[],toolChoice:"none",requestId:c.requestId,maxOutputTokens:4096,signal:c.signal,hostedTokenPricing:c.pricing})},"refinerStream")},o=Re({...a,reviewQuality:He({source:v,boundary:y,benchmark:a,createSession:P})}),g={advancedEvaluation:t,selectedTaskset:{id:E.id,revision:E.revision,contentHash:E.contentHash},modelId:r.request.modelId,profileId:r.request.profileId,model:r.request.model,reasoningEffort:r.request.reasoningEffort,seeds:[r.request.seed],repetitions:1,maximumSpendUsd:t.maximumCostUsd},b,S=i(()=>{o.cancel(n)},"stop");s.signal.addEventListener("abort",S,{once:!0});try{if(r.operation==="prepare_run")return o.prepare(g);let c=await s.store.getModelRun(n);if(!c||c.evaluation?.benchmarkId!=="harness-refiner"||c.evaluation.advancedEvaluation?.contentHash!==t.contentHash)throw new Error("The original hosted advanced Run is unavailable.");if(r.operation==="read")return c;if(r.operation==="cancel")return o.cancel(n);if(m){let T=!1;b=setInterval(()=>{T||(T=!0,s.store.getModelRun(n).then(j=>j?m.checkpoint(j):void 0).catch(()=>S()).finally(()=>{T=!1}))},2e3)}r.operation==="start"?await o.start(g):await o.resume(n);let f=await o.wait(n);if(!f)throw new Error("The actual hosted advanced engine did not retain its Run.");let k=pe.parse(f);return m&&await m.checkpoint(k),k}finally{b&&clearInterval(b),s.signal.removeEventListener("abort",S),await o.close(),await y.close()}}i(Fe,"runHostedAdvancedRefinerOwner");import{promises as _}from"node:fs";import A from"node:path";var Ye=e.object({actor:e.object({actorId:e.string().min(1),teamId:e.string().min(1)}).strict(),storeDir:e.string().min(1),source:e.object({repoPath:e.string().min(1),repositoryId:e.string().min(1),profileId:e.string().min(1),sourceRevision:e.string().regex(/^[a-f0-9]{40,64}$/),filesHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),evidence:e.object({manifest:e.unknown(),result:e.unknown()}).strict(),operation:e.enum(["advanced","describe","command","queue","cancelQueued","bind","finish","beginTesting","cancelTesting","failTesting","comparison","beginAdoption","export","source","tool","toolCatalog"]),advanced:Z.optional(),command:le.optional(),candidateId:e.string().optional(),revision:e.number().int().positive().optional(),actualSession:C.optional(),actualTurn:$.optional(),recipe:e.unknown().optional(),baseline:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),candidate:e.object({manifest:e.unknown(),result:e.unknown()}).strict().optional(),humanProjection:oe.optional(),humanSelections:re.optional(),adoptionReadback:e.unknown().optional(),failure:e.object({message:e.string().max(2e3),cancelled:e.boolean()}).strict().optional(),tool:e.object({name:e.string(),args:e.record(e.string(),e.unknown()),callId:e.string()}).strict().optional(),agentRuntime:e.object({source:e.string(),cliRelativePath:e.string()}).strict().optional(),queued:e.object({sessionId:e.string(),turnId:e.string(),createdAt:e.string().datetime()}).strict().optional()}).strict();async function We(s,r=new AbortController().signal){r.throwIfAborted();let t=Ye.parse(s),{actor:n,source:d}=t;if(!A.isAbsolute(t.storeDir)||!A.isAbsolute(d.repoPath))throw new Error("Hosted candidate owner requires contained absolute private paths.");let m=M(t.evidence),u=[t.baseline,t.candidate].filter(l=>l!==void 0).map(l=>M(l));if(m.manifest.teamId!==n.teamId)throw new Error("Hosted candidate evidence belongs to another team.");if(await B(d.repoPath)!==d.filesHash)throw new Error("The admitted hosted Profile source bytes changed.");let v=`hosted-improve-source-${R([n,d.repositoryId,d.profileId,d.sourceRevision]).slice(0,40)}`,I=A.join(t.storeDir,"library","profile-experiment-origins",v);if(await _.mkdir(A.dirname(I),{recursive:!0,mode:448}),await _.stat(I).catch(()=>null)||await _.cp(d.repoPath,I,{recursive:!0,errorOnExist:!0,force:!1}),await B(I)!==d.filesHash)throw new Error("The private accepted Profile cache changed.");let x=await W(I,d.profileId);if(x.error||!x.sourcePath)throw new Error("The accepted hosted Profile does not compile.");let y=new xe(t.storeDir),h;try{let l=await y.getHarnessWorkspace(v);l||(l=(await fe({store:y,storeDir:t.storeDir,id:v,ownerId:n.actorId,name:d.profileId,profile:x,sourceRevision:d.sourceRevision,repositoryId:d.repositoryId,selectionEligible:!1,originMetadata:{profileExperimentOrigin:{schemaVersion:"openpond.profileExperimentOrigin.v1",...n,sourceRevision:d.sourceRevision,sourcePath:I,sourceFilesHash:d.filesHash},hostedImprovementOwner:!0}})).workspace);let H={source:"openpond_git",repositoryId:d.repositoryId,profileId:d.profileId},E=i(async()=>{if(r.throwIfAborted(),await B(I)!==d.filesHash||await B(d.repoPath)!==d.filesHash)throw new Error("Accepted source changed during private candidate I/O.")},"authorizer");if(t.operation==="advanced"){if(!t.advanced)throw new Error("Missing actual hosted advanced owner command.");return Fe({store:y,storeDir:t.storeDir,actor:n,profile:x,workspace:l,source:d,evidence:m,request:t.advanced,authorize:E,signal:r})}let P=i(()=>{if(!t.adoptionReadback)throw new Error("Actual hosted Git owner has not returned its sealed adoption receipt.");return e.object({receipt:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),activeRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),testedCandidateRelease:e.object({id:e.string(),contentHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict(),executableSourceHash:e.string().regex(/^[a-f0-9]{64}$/),protectedClosureHash:e.string().regex(/^[a-f0-9]{64}$/)}).strict().parse(t.adoptionReadback)},"readback");h=Ee({store:y,storeDir:t.storeDir,projectHumanComparison:i(async()=>{if(await E(),!t.humanProjection)throw new Error("The current private Human comparison owner is unavailable.");return ne(t.humanProjection)},"projectHumanComparison"),authorizeOwner:i(async(a,o,g,b,S)=>{if(R(a)!==R(n)||R(g)!==R(H)||o.id!==v)throw new Error("Hosted candidate source owner changed.");if(S.requireCurrentBase&&(o.currentChannel.release?.contentHash!==l.currentChannel.release?.contentHash||d.sourceRevision!==o.metadata.profileExperimentOrigin.sourceRevision))throw new Error("Hosted candidate accepted revision changed.");await E()},"authorizeOwner"),loadEvidence:i(async(a,o)=>{if(R(a)!==R(n))throw new Error("Hosted candidate evidence actor changed.");let g=[m,...u].find(b=>b.manifest.id===o.id&&b.result.contentHash===o.contentHash&&b.manifest.teamId===n.teamId);if(!g)throw new Error("Hosted candidate exact retained evidence changed.");return await E(),g},"loadEvidence"),freezeProfile:i(async(a,o,g)=>{let b=await y.getHarnessReleaseRecord(o.baseRelease.contentHash);if(!b)throw new Error("Hosted source baseline is missing.");let S=await D({workspaceId:typeof b.agentSnapshot.metadata.workspaceId=="string"?b.agentSnapshot.metadata.workspaceId:b.workspaceId,sourceDir:A.join(b.bundlePath,"source")}),c=await D({workspaceId:typeof g.release.agentSnapshot.metadata.workspaceId=="string"?g.release.agentSnapshot.metadata.workspaceId:g.release.workspaceId,sourceDir:A.join(g.release.bundlePath,"source")});return Ae({store:y,storeDir:t.storeDir,state:o},async f=>{await Ce({...f,state:o,base:S,candidate:c});let k=await W(f.root,o.profileRef.profileId),T=await U({storeDir:t.storeDir,state:o,profile:k,sourceRevision:g.profileSourceRevision,base:S}),j=z(T);if(j.protectedClosureHash!==z(S).protectedClosureHash)throw new Error("Hosted source candidate changed protected evaluation closure.");let O=A.join(t.storeDir,"library","profile-candidate-archives",o.id,j.contentHash);await _.mkdir(A.dirname(O),{recursive:!0,mode:448}),await _.stat(O).catch(()=>null)||await _.cp(f.root,O,{recursive:!0,errorOnExist:!0,force:!1});let L=await W(O,o.profileRef.profileId);if((await U({storeDir:t.storeDir,state:o,profile:L,sourceRevision:g.profileSourceRevision,base:S})).harnessRelease.contentHash!==T.harnessRelease.contentHash)throw new Error("Hosted frozen Profile archive readback differs.");let F=await he({storeDir:t.storeDir,workspaceId:g.release.workspaceId,compiled:T,createdAt:g.release.createdAt});return await E(),{...g,release:F,executableIdentity:j}})},"freezeProfile"),adopt:i(async()=>P(),"adopt"),readAdoption:i(async()=>t.adoptionReadback?P():null,"readAdoption"),rollback:i(async()=>P(),"rollback")});let w=Pe({store:y,improvements:h,actorId:i(async()=>n.actorId,"actorId"),teamId:i(async()=>n.teamId,"teamId"),loadProfile:i(async a=>{if(R(a)!==R(H))throw new Error("Candidate requested another source owner.");return x},"loadProfile"),agentRuntime:t.agentRuntime,operationSignal:r,loadAgentRuntime:De({storeDir:t.storeDir,loadArchive:ze({storeDir:t.storeDir})})});if(t.operation==="describe"){await E();let a=l.currentChannel.release,o=a?await y.getHarnessReleaseRecord(a.contentHash):null;if(!a||!o||o.workspaceId!==l.id||o.harnessRelease.id!==a.id||o.harnessRelease.contentHash!==a.contentHash||l.ownerScope.kind!=="personal"||l.ownerScope.id!==n.actorId)throw new Error("Hosted source release is unavailable to its admitted owner.");let g=await D({workspaceId:typeof o.agentSnapshot.metadata.workspaceId=="string"?o.agentSnapshot.metadata.workspaceId:v,sourceDir:A.join(o.bundlePath,"source")});if(g.harnessRelease.contentHash!==o.harnessRelease.contentHash)throw new Error("Hosted source compiler readback changed.");let b=await ge({runtime:{release:o},ref:H,sourceRevision:d.sourceRevision,harnessRelease:a}),S=i(c=>{let f=g.sourceFiles.find(k=>k.path===c)?.bytes;return f?JSON.parse(Buffer.from(f).toString("utf8")):null},"readJson");return await E(),{workspaceId:v,ownerRevision:l.revision,profileRef:H,baseRelease:l.currentChannel.release,profileSourceRevision:d.sourceRevision,manifest:g.manifest,executable:z(g),catalogHash:b.catalogHash,workflows:S("workflows/catalog.json"),actions:S("workflows/actions.json")}}if(t.operation==="command"){let a=t.command;if(!a)throw new Error("Missing canonical Improve command.");if(a.operation==="start")return h.start(n,a.request);if(a.operation==="list")return h.list(n,a.limit,a.cursor);if(!("id"in a))throw new Error("Discover exact hosted source choices through the authenticated host.");let o=await h.read(n,a.id);if(a.operation==="read")return o;if(a.operation==="instructions"){let g=await h.partition(n,o.id),b=await me(g.sourceRoot,o.component.path),S=await _.readFile(b);if(S.length>25e4)throw new Error("Instruction editor size limit exceeded.");let c=S.toString("utf8");if(o.component.kind==="workflow"){let f=JSON.parse(c).workflows?.find(k=>k.id===o.component.workflowId);if(f?.invocation?.kind!=="instructions")throw new Error("Use Work to author this executable Workflow.");c=f.invocation.instructions}return{candidateId:o.id,candidateRevision:o.revision,path:o.component.path,text:c,textHash:J(c),contentHash:J(S)}}if(a.operation==="humanComparisonOptions")throw new Error("Read the actual paired sources through their current hosted Experiment owner.");if(!("revision"in a)||o.revision!==a.revision)throw new Error("Candidate revision changed.");if(a.operation==="edit")return h.edit(n,o.id,o.revision,a.expectedFileHash,a.text);if(a.operation==="mode")return h.setMode(n,o.id,o.revision,a.mode);if(a.operation==="freeze")return h.freeze(n,o.id,o.revision);if(a.operation==="useCandidate")return h.useCandidate(n,o.id,o.revision);if(a.operation==="rollback")return h.rollback(n,o.id,o.revision);if(a.operation==="discard")return h.discard(n,o.id,o.revision);throw new Error("Hosted Work/test lifecycle requires the actual host turn/run admission.")}if(!t.candidateId)throw new Error("Missing actual hosted candidate ID.");let p=await h.read(n,t.candidateId);if(t.operation==="beginAdoption")return h.beginAdoption(n,p.id,t.revision);if(t.operation==="export")return je(y,p,"hosted_execution");if(t.operation==="source"){if(!p.frozen||p.status!=="frozen"&&p.status!=="testing"&&p.status!=="ready_for_review"&&p.status!=="adopting")throw new Error("Only the exact frozen source can enter hosted preparation.");let a=await y.getHarnessReleaseRecord(p.frozen.release.contentHash);if(!a||a.harnessRelease.id!==p.frozen.release.id)throw new Error("Frozen hosted source is unavailable.");let o=await D({workspaceId:typeof a.agentSnapshot.metadata.workspaceId=="string"?a.agentSnapshot.metadata.workspaceId:a.workspaceId,sourceDir:A.join(a.bundlePath,"source")}),g=z(o);if(o.harnessRelease.contentHash!==p.frozen.release.contentHash||g.contentHash!==p.frozen.executableSourceHash||g.protectedClosureHash!==p.frozen.protectedClosureHash)throw new Error("Frozen hosted executable changed.");let b=A.join(t.storeDir,"library","profile-candidate-archives",p.id,g.contentHash),S=await W(b,p.profileRef.profileId);if(S.error||!S.sourcePath)throw new Error("Frozen actual Profile archive is unavailable.");let c=await y.getHarnessReleaseRecord(p.baseRelease.contentHash);if(!c)throw new Error("Frozen baseline is unavailable.");let f=await D({workspaceId:typeof c.agentSnapshot.metadata.workspaceId=="string"?c.agentSnapshot.metadata.workspaceId:c.workspaceId,sourceDir:A.join(c.bundlePath,"source")}),k=await U({storeDir:t.storeDir,state:p,profile:S,sourceRevision:p.frozen.profileSourceRevision,base:f});if(k.harnessRelease.contentHash!==p.frozen.release.contentHash||z(k).contentHash!==g.contentHash)throw new Error("Actual frozen Profile archive differs from its compiled release.");return{state:p,profileSource:{repoPath:b,profileId:p.profileRef.profileId,sourceRevision:p.frozen.profileSourceRevision,repositoryId:p.profileRef.repositoryId,filesHash:await B(b)},sourcePackage:te({agentSnapshot:o.agentSnapshot,harnessRelease:o.harnessRelease,files:new Map(o.sourceFiles.map(T=>[T.path,T.bytes]))})}}if(t.operation==="comparison"){if(!t.baseline||!t.candidate)throw new Error("Missing actual hosted paired evidence.");return h.completeComparison(n,p.id,t.revision,M(t.baseline),M(t.candidate),t.humanSelections)}if(t.operation==="beginTesting")return h.beginTesting(n,p.id,t.revision,t.recipe);if(t.operation==="failTesting"){if(!t.failure)throw new Error("Missing actual hosted test failure.");return h.failTesting(n,p.id,t.revision,t.failure.message,t.failure.cancelled)}if(t.operation==="cancelTesting")return h.cancelTesting(n,p.id,t.revision);if(t.operation==="queue"){if(!t.queued)throw new Error("Missing actual hosted queue admission.");return h.queueAuthoringTurn(n,p.id,t.revision,t.queued.sessionId,t.queued.turnId,t.queued.createdAt)}if(t.operation==="cancelQueued")return h.cancelQueuedAuthoring(n,p.id,t.revision);if(t.operation==="bind"||t.operation==="finish"||t.operation==="tool"||t.operation==="toolCatalog"){if(!t.actualSession||!t.actualTurn||t.actualTurn.sessionId!==t.actualSession.id||t.actualSession.cloudTeamId!==n.teamId||R(t.actualSession.currentProfile)!==R(H))throw new Error("Actual hosted candidate Work binding changed.");let a=t.actualSession,o=t.actualTurn,g=await y.getSession(a.id);if(!g)await y.insertSessionAtFront(a);else if(R({...g,updatedAt:a.updatedAt,status:a.status})!==R(a))throw new Error("Retained hosted candidate session changed.");let b=await y.getTurn(o.id);if(!b)await y.insertTurn(o);else{if(b.sessionId!==o.sessionId||R(b.metadata.refinementCandidate)!==R(o.metadata.refinementCandidate)||b.prompt!==o.prompt)throw new Error("Actual hosted candidate turn identity changed.");await y.updateTurn(o.id,()=>o)}if(t.operation==="bind")return h.bindAuthoringTurn(n,p.id,t.revision,a.id,o.id);if(t.operation==="finish")return h.finishAuthoring(n,p.id,t.revision);if(t.operation==="toolCatalog")return await w.candidateAuthoringForTurn(a.id,o.id),[...G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}),...Te(async()=>{throw new Error("Hosted file tools require a bound private call.")}),{name:"exec_command",description:"Run a bounded command confined to the selected public candidate component.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:2e4},cwd:{type:"string"}},required:["command"]}},{name:"view_image",description:"Inspect an image inside the candidate public source tree.",parameters:{type:"object",additionalProperties:!1,properties:{path:{type:"string"}},required:["path"]}}].map(({name:c,description:f,parameters:k})=>({name:c,description:f,parameters:k}));if(!t.tool)throw new Error("Missing candidate tool call.");await w.authorizeCandidateTool({sessionId:a.id,turnId:o.id,name:t.tool.name});let S={session:a,turnId:o.id,args:t.tool.args,callId:t.tool.callId,signal:r,workspaceDiffBaseline:null,turnPermissions:{approvalPolicy:"never",sandbox:"workspace-write",codexPermissionMode:"default"},provider:a.provider,model:o.modelRef?.modelId??a.modelRef?.modelId??"",mentionedApps:[],userPrompt:o.prompt,turnMetadata:o.metadata};if(t.tool.name==="get_profile"||t.tool.name.startsWith("agent_")||t.tool.name==="ask_user"){let c=G({loadProfileState:i(async()=>x,"loadProfileState"),resolveCandidateProfile:w.resolveCandidateProfile,executeCandidateAgentCommand:w.executeCandidateAgentCommand}).find(f=>f.name===t.tool.name);if(!c)throw new Error("Candidate authoring tool is unavailable.");return c.execute(S)}if(t.tool.name==="view_image")return w.executeCandidateImage(S);if(t.tool.name==="exec_command")return w.executeCandidateCommand(S,{session:a,turnId:o.id,command:e.string().min(1).max(2e4).parse(t.tool.args.command),cwd:typeof t.tool.args.cwd=="string"?t.tool.args.cwd:null,signal:S.signal,source:"model_tool"});if(["list_files","read_files","search_files","workspace_status","write_file","write_files","edit_file","delete_file"].includes(t.tool.name))return w.executeCandidateWorkspaceTool({session:a,turnId:o.id,request:de.parse({action:t.tool.name,args:t.tool.args,source:"chat_action"})});throw new Error("This hosted tool has no confined candidate transport.")}throw new Error("Unknown private hosted Improve operation.")}finally{await h?.close(),await y.close()}}i(We,"runHostedExperimentImprovementOwner");async function wr(s){if(s.length!==1||s[0].length>16e3||!/^[A-Za-z0-9_-]+$/.test(s[0]))throw new Error("Hosted Improve IPC argument is invalid.");let r=e.object({directory:e.string(),file:e.string().regex(/^[A-Za-z0-9_-]+\.json$/)}).strict().parse(JSON.parse(Buffer.from(s[0],"base64url").toString("utf8")));if(!Ue.isAbsolute(r.directory))throw new Error("Hosted Improve IPC requires an absolute private directory.");let t=Ue.join(r.directory,r.file),n=await $e.lstat(t);if(!n.isFile()||n.isSymbolicLink()||n.size>32*1024*1024)throw new Error("Hosted Improve private request exceeds its byte/type limit.");let d=new AbortController,m=i(()=>d.abort(new Error("The actual hosted owner stopped this private operation.")),"stop");process.once("SIGTERM",m),process.once("SIGINT",m);try{let u=await We(JSON.parse(await $e.readFile(t,"utf8")),d.signal),v=Buffer.from(JSON.stringify(u));if(v.length>32*1024*1024)throw new Error("Hosted Improve private response exceeds its byte limit.");process.stdout.write(`${v.toString("utf8")}
|
|
3
3
|
`)}finally{process.removeListener("SIGTERM",m),process.removeListener("SIGINT",m)}}i(wr,"runHostedExperimentImprovementCli");export{wr as runHostedExperimentImprovementCli};
|
package/dist/chunks/{hosted-harness-runtime-WOLADXXP.js → hosted-harness-runtime-YM23QNDK.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as a,c as b}from"./chunk-
|
|
2
|
+
import{b as a,c as b}from"./chunk-GCOUYYHG.js";import"./chunk-USKE34VR.js";import"./chunk-7ZG3IT7C.js";import"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-5CMKGD43.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as loadHostedHarnessRuntime,b as loadHostedHarnessRuntimeForSession};
|
package/dist/chunks/{hosted-profile-candidate-LVNKOTKJ.js → hosted-profile-candidate-EOBGKQAS.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a,e as F}from"./chunk-
|
|
2
|
+
import{a,e as F}from"./chunk-H2VT22JK.js";import{a as O}from"./chunk-EMKZVP7Z.js";import{a as h}from"./chunk-T5LE6R5S.js";import{na as I,qa as D,ra as M}from"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-5CMKGD43.js";import{N as w}from"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import{od as A}from"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import{ua as R}from"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import{k as C,l as v}from"./chunk-NNF6KCHD.js";import{b as c}from"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import{a as f}from"./chunk-FTQLQJQV.js";import{promises as m}from"node:fs";import n from"node:path";var $=c.object({action:c.enum(["stage","readback","rollback"]),repoPath:c.string(),outputDir:c.string(),exportFile:c.string(),commit:c.string().regex(/^[a-f0-9]{40}$/).optional(),expectedExecutableSourceHash:c.string().regex(/^[a-f0-9]{64}$/).optional()}).strict();async function z(l){let e=$.parse(l);if(!n.isAbsolute(e.repoPath)||!n.isAbsolute(e.outputDir)||!/^[a-zA-Z0-9_-]+\.json$/.test(e.exportFile))throw new Error("Hosted candidate private IPC is not contained.");let g=n.join(e.outputDir,e.exportFile),H=await m.lstat(g);if(!H.isFile()||H.isSymbolicLink()||H.size>8*1024*1024)throw new Error("Hosted candidate export exceeds its private IPC bound.");let t=O(JSON.parse(await m.readFile(g,"utf8"))),u=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId});if(u.error||!u.sourcePath)throw new Error("Actual hosted Profile source is unavailable.");if(e.action!=="readback"){let o=!1;try{await a(e.repoPath,["symbolic-ref","-q","HEAD"]),o=!0}catch{}if(o||await a(e.repoPath,["rev-parse","HEAD"])!==(e.action==="rollback"?e.commit:t.expectedCommit)||await a(e.repoPath,["status","--porcelain","--untracked-files=all"]))throw new Error("Candidate staging requires a clean detached exact original source worktree.")}let x=f(async o=>I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),sourceRevision:o,repositoryId:t.compiler.repositoryId}),"compile");if(e.action==="readback"){if(!e.commit||await a(e.repoPath,["rev-parse","HEAD"])!==e.commit)throw new Error("Hosted Profile readback is not the committed source.");let o=await x(e.commit),i=h(o);if(i.profileGitHead!==e.commit||i.contentHash!==(e.expectedExecutableSourceHash??t.executableSourceHash)||i.protectedClosureHash!==t.protectedClosureHash)throw new Error("Hosted active executable differs from the actual tested candidate.");let s=await M({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,compiled:o,createdAt:t.createdAt});return{commit:e.commit,activeRelease:{id:s.harnessRelease.id,contentHash:s.harnessRelease.contentHash},executableSourceHash:i.contentHash,protectedClosureHash:i.protectedClosureHash}}if(e.action==="rollback"){if(!e.commit)throw new Error("Rollback requires the exact accepted commit.");await a(e.repoPath,["-c","core.hooksPath=/dev/null","revert","--no-commit",e.commit])}let p=await x(t.expectedCommit);if(p.harnessRelease.contentHash!==t.baseRelease.contentHash||p.harnessRelease.id!==t.baseRelease.id)throw new Error("Hosted original source differs from the owner-attested baseline release.");if(e.action==="stage"){let o=Buffer.from(t.sourceManifest.base64,"base64");if(o.toString("base64")!==t.sourceManifest.base64||o.length!==t.sourceManifest.sizeBytes||v(o)!==t.sourceManifest.contentHash)throw new Error("Candidate source manifest byte identity differs.");let i=A.parse(JSON.parse(o.toString("utf8"))),s=n.join(e.outputDir,"candidate-source");await m.mkdir(s,{recursive:!0}),await m.writeFile(n.join(s,"harness.json"),C(i));let _=R(t.policySource),j=new Map(p.sourceFiles.filter(r=>r.asset.visibility!=="policy").map(r=>[r.path,r]));for(let r of i.files){let k=r.visibility==="policy"?_.get(r.path):j.get(r.path)?.bytes;if(!k)throw new Error("The hosted source cannot hydrate the exact protected candidate closure.");let y=n.join(s,r.path);if(n.relative(s,y).startsWith(".."))throw new Error("Candidate release path escapes private staging.");await m.mkdir(n.dirname(y),{recursive:!0}),await m.writeFile(y,k)}let P=await D({workspaceId:t.compiler.workspaceId,sourceDir:s}),S=h(P);if(P.harnessRelease.contentHash!==t.policySource.harnessRelease.contentHash||S.contentHash!==t.executableSourceHash||S.protectedClosureHash!==t.protectedClosureHash)throw new Error("Owner-attested candidate differs from independently compiled hosted source.");await F({source:u.sourcePath,state:{component:t.component},base:p,candidate:P,profile:u})}await a(e.repoPath,["add","--all"]),await a(e.repoPath,["-c","core.hooksPath=/dev/null","-c","commit.gpgSign=false","commit","-m",`${e.action==="rollback"?"Roll back":"Adopt"} owner-tested candidate ${t.candidateId}`],{GIT_AUTHOR_NAME:"OpenPond",GIT_AUTHOR_EMAIL:"profile-candidate@openpond.local",GIT_COMMITTER_NAME:"OpenPond",GIT_COMMITTER_EMAIL:"profile-candidate@openpond.local"});let E=await a(e.repoPath,["rev-parse","HEAD"]),T=await w({repoPath:e.repoPath,profileId:t.profileRef.profileId}),b=await I({storeDir:e.outputDir,workspaceId:t.compiler.workspaceId,name:t.compiler.name,profile:T,sourceRevision:E,repositoryId:t.compiler.repositoryId}),d=h(b);if(e.action==="stage"&&(d.contentHash!==t.executableSourceHash||d.protectedClosureHash!==t.protectedClosureHash)||e.action==="rollback"&&(d.contentHash!==h(p).contentHash||d.protectedClosureHash!==h(p).protectedClosureHash))throw new Error("Staged actual source differs from its exact tested executable graph.");return{commit:E,activeRelease:{id:b.harnessRelease.id,contentHash:b.harnessRelease.contentHash},executableSourceHash:d.contentHash,protectedClosureHash:d.protectedClosureHash}}f(z,"hostedProfileCandidate");async function Q(l){if(l.length!==1||l[0].length>16e3||!/^[a-zA-Z0-9_-]+$/.test(l[0]))throw new Error("Hosted candidate IPC argument is invalid.");process.stdout.write(`${JSON.stringify(await z(JSON.parse(Buffer.from(l[0],"base64url").toString("utf8"))))}
|
|
3
3
|
`)}f(Q,"runHostedProfileCandidateCli");export{z as hostedProfileCandidate,Q as runHostedProfileCandidateCli};
|
package/dist/chunks/{hosted-profile-compiler-NBMUCZVS.js → hosted-profile-compiler-SCVJI2CP.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-UE3DMPGM.js";import"./chunk-4TZHH5FC.js";import"./chunk-4SHKI3BH.js";import"./chunk-5CMKGD43.js";import"./chunk-HA7EFTPF.js";import"./chunk-L3KS6MOV.js";import"./chunk-7QEE4PBI.js";import"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import"./chunk-Z3D4C7BG.js";import"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-DALJMSJG.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import"./chunk-ES2ISFJC.js";import"./chunk-H7IWJN7L.js";import"./chunk-FTQLQJQV.js";export{a as compileHostedProfileRelease,b as runHostedProfileCompilerCli,c as runHostedProfileEvaluationCli,d as runHostedProfileInspectionCli};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as m,b as c}from"./chunk-XM26DGML.js";import{a as l}from"./chunk-
|
|
2
|
+
import{a as m,b as c}from"./chunk-XM26DGML.js";import{a as l}from"./chunk-4SHKI3BH.js";import{L as f}from"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import{ja as s,oa as u}from"./chunk-WV2APYWG.js";import"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-TGIB24K4.js";import{n as t}from"./chunk-NNF6KCHD.js";import{b as n}from"./chunk-ES2ISFJC.js";import{a as i}from"./chunk-FTQLQJQV.js";var v=n.object({profileRef:f,sourceRevision:n.string().min(1),action:n.enum(["compare","report"]),request:n.unknown(),runs:n.array(l).max(1e4),comparisons:n.array(s).max(1e4),suiteRuns:n.array(u).max(1e4)}).strict();async function h(p){let o=v.parse(p);for(let e of[...o.runs,...o.comparisons,...o.suiteRuns])t(e,"Hosted evaluation evidence");let a={getProfileEvaluationRun:i(async e=>o.runs.find(r=>r.manifest.id===e)??null,"getProfileEvaluationRun"),getProfileEvaluationComparison:i(async e=>o.comparisons.find(r=>r.id===e)??null,"getProfileEvaluationComparison"),getProfileEvaluationSuiteRun:i(async e=>o.suiteRuns.find(r=>r.id===e)??null,"getProfileEvaluationSuiteRun"),saveProfileEvaluationComparison:i(async(e,r)=>r,"saveProfileEvaluationComparison")};return o.action==="compare"?m({store:a,selectedProfile:i(async()=>({ref:o.profileRef,sourceRevision:o.sourceRevision}),"selectedProfile")})(o.request):c({store:a,profileRef:o.profileRef,request:o.request})}i(h,"controlHostedProfileEvaluation");export{h as controlHostedProfileEvaluation};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{c as R,d as P}from"./chunk-
|
|
2
|
+
import{c as R,d as P}from"./chunk-4EEH7MEC.js";import{a as E}from"./chunk-4SHKI3BH.js";import{L as v,M as S,N as w,Y as y,a as h}from"./chunk-2JO2KWT3.js";import"./chunk-IKWDL3RB.js";import"./chunk-6MI4KKWF.js";import"./chunk-QRWPEW3Z.js";import"./chunk-6FA3GG5B.js";import{k as g}from"./chunk-WV2APYWG.js";import{h as m}from"./chunk-PJM2G7SG.js";import"./chunk-SDEDAHV6.js";import"./chunk-TGIB24K4.js";import"./chunk-NNF6KCHD.js";import{b as s}from"./chunk-ES2ISFJC.js";import{a as n}from"./chunk-FTQLQJQV.js";var I=s.object({profileRef:v,inspection:R,run:E.nullable(),receipts:s.array(g).max(1e4),grades:s.array(m).max(1e4),sessions:s.array(S).max(1e4),turns:s.array(w).max(1e4),events:s.array(h).max(1e4),usage:s.array(y).max(1e4)}).strict();async function x(c){let t=I.parse(c),o=n((e,i)=>{let f=new Map;for(let p of e){let d=i(p);if(f.has(d))throw new Error("Hosted evaluation inspection has duplicate evidence identities.");f.set(d,p)}return f},"map"),r=o(t.receipts,e=>e.id),u=o(t.grades,e=>e.contentHash),l=o(t.sessions,e=>e.id),a=o(t.turns,e=>e.id);return P({profileRef:t.profileRef,...t.inspection,store:{getProfileEvaluationRun:n(async e=>t.run?.manifest.id===e?t.run:null,"getProfileEvaluationRun"),getProfileEvaluationReceipt:n(async e=>r.get(e)??null,"getProfileEvaluationReceipt"),getProfileEvaluationGrade:n(async e=>u.get(e)??null,"getProfileEvaluationGrade"),getSession:n(async e=>l.get(e)??null,"getSession"),getTurn:n(async e=>a.get(e)??null,"getTurn"),runtimeEventsForTurn:n(async e=>t.events.filter(i=>i.turnId===e),"runtimeEventsForTurn"),listModelUsageRecords:n(async e=>t.usage.filter(i=>(!e?.sessionId||i.sessionId===e.sessionId)&&(!e?.turnId||i.turnId===e.turnId)),"listModelUsageRecords")}})}n(x,"inspectHostedProfileEvaluation");async function B(c){if(c.length!==0)throw new Error("Hosted evaluation inspection uses bounded standard input.");let t=[],o=0;for await(let l of process.stdin){let a=Buffer.from(l);if(o+=a.length,o>32*1024*1024)throw new Error("Hosted evaluation inspection input is too large.");t.push(a)}let r=JSON.parse(Buffer.concat(t).toString("utf8")),u=r.action==="compare"||r.action==="report"?await(await import("./hosted-profile-evaluation-control-RJ6XJZCS.js")).controlHostedProfileEvaluation(r):await x(r);process.stdout.write(`${JSON.stringify(u)}
|
|
3
3
|
`)}n(B,"runHostedProfileInspectionCli");export{x as inspectHostedProfileEvaluation,B as runHostedProfileInspectionCli};
|