openpond 0.2.36 → 0.2.38
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 +189 -3
- package/dist/app-server.js +1 -1
- package/dist/chunks/actions-command-MHWHPQ66.js +2 -0
- package/dist/chunks/{app-layer-KPPQSL67.js → app-layer-JZTMHORT.js} +1 -1
- package/dist/chunks/app-server-runtime-PDT6BJD2.js +2 -0
- package/dist/chunks/apps-U5GIOD6W.js +2 -0
- package/dist/chunks/{chunk-SHWLRMDG.js → chunk-25OT6IYM.js} +2 -2
- package/dist/chunks/chunk-3HQEEZPO.js +2 -0
- package/dist/chunks/{chunk-K6EGNB2A.js → chunk-562Q5UVS.js} +2 -2
- package/dist/chunks/chunk-7BGT6Q2D.js +8 -0
- package/dist/chunks/{chunk-QPZNN5Q3.js → chunk-AOBTILU5.js} +1 -1
- package/dist/chunks/{chunk-DR3XPQRZ.js → chunk-DDHUSA3I.js} +1 -1
- package/dist/chunks/{chunk-FIFGH6W3.js → chunk-FKVP26MC.js} +1 -1
- package/dist/chunks/{chunk-MXLB6MEW.js → chunk-FUFIZ37W.js} +2 -2
- package/dist/chunks/chunk-GIPSOLAY.js +2 -0
- package/dist/chunks/chunk-GKRTXVNT.js +12 -0
- package/dist/chunks/{chunk-5WFHGIQB.js → chunk-GOHJHZVA.js} +206 -206
- package/dist/chunks/chunk-HZP5U2AA.js +3 -0
- package/dist/chunks/{chunk-Q2Z27DCK.js → chunk-IKM6ICPY.js} +1 -1
- package/dist/chunks/{chunk-EFTLCT7C.js → chunk-J4S7AVGF.js} +1 -1
- package/dist/chunks/chunk-JUX77H6K.js +13 -0
- package/dist/chunks/chunk-KNEMKYHY.js +2 -0
- package/dist/chunks/chunk-MRGA6BKG.js +19 -0
- package/dist/chunks/{chunk-VRY5TEEF.js → chunk-OCWH4BV7.js} +135 -141
- package/dist/chunks/chunk-P5CFBE6Z.js +3 -0
- package/dist/chunks/chunk-PKBU37CH.js +5 -0
- package/dist/chunks/chunk-Q3X5WOVH.js +4 -0
- package/dist/chunks/chunk-QK2GLRCY.js +53 -0
- package/dist/chunks/chunk-QUNRWDVO.js +155 -0
- package/dist/chunks/chunk-RELOOVWW.js +2 -0
- package/dist/chunks/chunk-SBBXUZWL.js +5 -0
- package/dist/chunks/{chunk-Z6F6PYF4.js → chunk-SHCKK3SU.js} +1 -1
- package/dist/chunks/chunk-SHCRE7B2.js +2 -0
- package/dist/chunks/{chunk-4QX2I2DX.js → chunk-T7Y5OYO2.js} +1 -1
- package/dist/chunks/chunk-TZNKOKQJ.js +5 -0
- package/dist/chunks/{chunk-YZ262JZT.js → chunk-V5BC6QT2.js} +1 -1
- package/dist/chunks/{chunk-ZF6OAPTQ.js → chunk-WCZRDULE.js} +7 -7
- package/dist/chunks/chunk-XHJUP7M4.js +23 -0
- package/dist/chunks/chunk-ZCDOE3EO.js +42 -0
- package/dist/chunks/{chunk-34URWDE7.js → chunk-ZCFX6HQO.js} +1 -1
- package/dist/chunks/{chunk-LL3ZAZEU.js → chunk-ZPGTGQJT.js} +1 -1
- package/dist/chunks/cli-OP4EDGZN.js +2 -0
- package/dist/chunks/configuration-command-RPNYWBKK.js +2 -0
- package/dist/chunks/{continual-6EW2SLGL.js → continual-MHMPLLUZ.js} +3 -3
- package/dist/chunks/core-commands-WFTASSGL.js +2 -0
- package/dist/chunks/datasets-V7E4I5N3.js +13 -0
- package/dist/chunks/desktop-test-NZAZVXLK.js +3 -0
- package/dist/chunks/dist-4OUZANXR.js +2 -0
- package/dist/chunks/dist-GKCGK44T.js +2 -0
- package/dist/chunks/experiments-7UBJCQAQ.js +2 -0
- package/dist/chunks/{extension-LG3JL5QD.js → extension-OQ7CFD4Q.js} +1 -1
- package/dist/chunks/{help-XP73IYAV.js → help-4BB2A5JC.js} +1 -1
- package/dist/chunks/hosted-harness-runtime-6TE37GBH.js +2 -0
- package/dist/chunks/hosted-profile-compiler-7ZWCIHPA.js +3 -0
- package/dist/chunks/opchat-QVB4UIZR.js +3 -0
- package/dist/chunks/organizations-MUKXB6MX.js +2 -0
- package/dist/chunks/{profile-O7NIC76F.js → profile-LZYR4CMX.js} +1 -1
- package/dist/chunks/project-agent-FHNWIH2D.js +2 -0
- package/dist/chunks/sandbox-command-GJN3HSJQ.js +2 -0
- package/dist/chunks/{sandbox-template-H5M4NV2F.js → sandbox-template-6RLQYNTY.js} +1 -1
- package/dist/chunks/{src-BITVDQDA.js → src-2NVS6PNZ.js} +112 -112
- package/dist/chunks/{src-WN3RDFPF.js → src-PASASTIA.js} +5 -5
- package/dist/chunks/{taskset-YPKY3HUM.js → taskset-BZYQT65N.js} +1 -1
- package/dist/chunks/{teams-bot-RPZVD4UD.js → teams-bot-UQB636V3.js} +1 -1
- package/dist/chunks/training-7PST5HZU.js +1 -1
- package/dist/chunks/{workspaces-XMU4772P.js → workspaces-2KYAFRX4.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/web/assets/{App-BRZg56AC.js → App-BL1D_PLh.js} +9 -9
- package/dist/web/assets/{AppDialog-BR9UjEFe.js → AppDialog-CmPsGOzE.js} +1 -1
- package/dist/web/assets/{AppTerminalPanel-DNXVV6S_.js → AppTerminalPanel-0_Ewf4wJ.js} +2 -2
- package/dist/web/assets/{AppsView-DhaB7uT7.js → AppsView-Ddn9R2I-.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-zecj1P2T.js → BrowserSidebar-j2Yyiaz-.js} +1 -1
- package/dist/web/assets/{CartesianChart-DRhWC0XA.js → CartesianChart-BWAkc0mY.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-BzNNwOcD.js → CollaborationTabs-SVc7oX8N.js} +1 -1
- package/dist/web/assets/{CommandMenu-C7HuXmgN.js → CommandMenu-CcX5ypdX.js} +1 -1
- package/dist/web/assets/{CommunityView-C4HfU5ky.js → CommunityView-B7W1C8KG.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-CG8YZxWB.js → ComposerCreateImproveStrip-BBKdrbNP.js} +1 -1
- package/dist/web/assets/{GetStartedView-ZxtcgU5X.js → GetStartedView-BXuTBT4U.js} +1 -1
- package/dist/web/assets/HostedModelLearningReview-C3oAdyoF.js +1 -0
- package/dist/web/assets/{HostedModelLearningSettings-BKM_1-LZ.js → HostedModelLearningSettings-9e5z5eRf.js} +1 -1
- package/dist/web/assets/{LabModelVersionDetailPage-CklKwV_e.js → LabModelVersionDetailPage-CctGBUae.js} +1 -1
- package/dist/web/assets/{LabSkillSidebar-Cq_axOXr.js → LabSkillSidebar-Cl8Sdiqc.js} +1 -1
- package/dist/web/assets/{LabsRoute-BPGkQnKq.js → LabsRoute-di9O0XV1.js} +4 -4
- package/dist/web/assets/{MainChatThread-DvllW6Ej.js → MainChatThread-BaEeNsrh.js} +2 -2
- package/dist/web/assets/{MainPane-BaUIvio6.js → MainPane-Dw90VsN-.js} +4 -4
- package/dist/web/assets/{MarkdownText-DP7Hjp4L.js → MarkdownText-CGGUFrZe.js} +1 -1
- package/dist/web/assets/{NativeSkillSidebar-BSSKKH-y.js → NativeSkillSidebar-2mgh6WV4.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-cWw4m_pU.js → NewExperienceSwitcher-DMTe3jS9.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-BMzXEHsC.js → NewProjectDialog-D6pvuCoo.js} +1 -1
- package/dist/web/assets/{OutputsPage-CGWtgJ_j.js → OutputsPage-DMeIKxzN.js} +1 -1
- package/dist/web/assets/{ProjectsPage-C00Wt3oR.js → ProjectsPage-V5oXwB-5.js} +1 -1
- package/dist/web/assets/{RightChatPanelStack-0D_jpeAm.js → RightChatPanelStack-B0y2XNdm.js} +1 -1
- package/dist/web/assets/{RightSidebarHomePanel-BgHpI97K.js → RightSidebarHomePanel-BksZR71F.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-C-P_Jv04.js → ScheduledWorkPage-BRcVebWV.js} +1 -1
- package/dist/web/assets/{SettingsView-BJDvzvtZ.js → SettingsView-CtI170q1.js} +3 -3
- package/dist/web/assets/{TeamChatView-BdUQNXvx.js → TeamChatView-DWGM8eXj.js} +1 -1
- package/dist/web/assets/{TerminalOverlay-85H1eqcg.js → TerminalOverlay-DLSmAkbQ.js} +1 -1
- package/dist/web/assets/{TrainingCreationPanel-Bdx2BJzb.js → TrainingCreationPanel-C6e6zhC8.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-TcvqZfYS.js → TrainingDraftPanel-Q1GXOAlQ.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-Dm8bsNIT.js → UsageSettingsSection-UET2vS1c.js} +1 -1
- package/dist/web/assets/{WorkSidebarPanel-C9bKi4NH.js → WorkSidebarPanel-DMsXId2s.js} +1 -1
- package/dist/web/assets/{WorkspaceDiffPanel-CFzHklbv.js → WorkspaceDiffPanel-B_eZE-bq.js} +3 -3
- package/dist/web/assets/{WorkspaceEnvironmentMenu-_e6IkhGw.js → WorkspaceEnvironmentMenu-C848cDBP.js} +1 -1
- package/dist/web/assets/{WorkspaceGitDialogs-BglcR8S9.js → WorkspaceGitDialogs-CSnIC26s.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-BuipCT-i.js → WorkspaceMonacoEditor-C5dvv9s_.js} +3 -3
- package/dist/web/assets/{arrow-up-right-jN0p0koy.js → arrow-up-right-CsvQameJ.js} +1 -1
- package/dist/web/assets/{clipboard-Bat4as9H.js → clipboard-fZsv7_ot.js} +1 -1
- package/dist/web/assets/{cloud-upload-CFs0F_2n.js → cloud-upload-CUXNsLn2.js} +1 -1
- package/dist/web/assets/{cssMode-Cg4Jey3B.js → cssMode-1tbsSShK.js} +1 -1
- package/dist/web/assets/{folder-open-BqInWH_9.js → folder-open-Da8t5AtB.js} +1 -1
- package/dist/web/assets/{folder-plus-BSA6I7ld.js → folder-plus-X7B8dzc3.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-CLDqrpDQ.js → git-commit-horizontal-CajQIfK5.js} +1 -1
- package/dist/web/assets/{htmlMode-DHHN3vwk.js → htmlMode-qapgENKW.js} +1 -1
- package/dist/web/assets/{index-VtbQYCWA.js → index-DUQK09vA.js} +2 -2
- package/dist/web/assets/{info-BSebzpyp.js → info-BYfs9_PT.js} +1 -1
- package/dist/web/assets/{jsonMode-mvqMGlEK.js → jsonMode-DYPkWxLK.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-Bw_QMGcP.js → lspLanguageFeatures-Cbcp__rz.js} +1 -1
- package/dist/web/assets/{minimize-2-CaHjbHpF.js → minimize-2-Dp7tWjno.js} +1 -1
- package/dist/web/assets/{monaco.contribution-DubQum0F.js → monaco.contribution-COP3_DCK.js} +2 -2
- package/dist/web/assets/{monaco.contribution-KrPDFXc4.js → monaco.contribution-CcL6YtdZ.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CBkwYqsg.js → monaco.contribution-DApKEq_e.js} +2 -2
- package/dist/web/assets/{monaco.contribution-CiXEi4Ka.js → monaco.contribution-cIq6c5M4.js} +2 -2
- package/dist/web/assets/{monitor-DwOfVMY6.js → monitor-nP1D5S_1.js} +1 -1
- package/dist/web/assets/{python-BPnA89YS.js → python-DXYfRGSs.js} +1 -1
- package/dist/web/assets/{refresh-cw-DO-hUyTn.js → refresh-cw-D_9Q01ox.js} +1 -1
- package/dist/web/assets/{save-C7WFI7Mn.js → save-BxG7d5Nm.js} +1 -1
- package/dist/web/assets/{square-DiLQ59tw.js → square--Ua9DQPL.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-BWFPIQBM.js → toggleHighContrast-CqAtkn5E.js} +1 -1
- package/dist/web/assets/{tsMode-CWxqU0x6.js → tsMode-BCdfa4wT.js} +1 -1
- package/dist/web/assets/{upload-vUnuWYGk.js → upload-BkYSJcbc.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BFbGmflA.js → useLocalAgentSchedules-CGlPbPZr.js} +1 -1
- package/dist/web/assets/{useSessionTurnCache-C0zgYrCB.js → useSessionTurnCache-DtNQyWXl.js} +1 -1
- package/dist/web/assets/{wifi-off-DbNO6u3Z.js → wifi-off-DF8YmlRa.js} +1 -1
- package/dist/web/assets/{workers-4I09fePv.js → workers-BUHY0ojx.js} +1 -1
- package/dist/web/assets/{yaml-DpHYonDY.js → yaml-CtBzXx8s.js} +1 -1
- package/dist/web/index.html +1 -1
- package/docs/command-reference.md +35 -0
- package/package.json +3 -1
- package/dist/chunks/actions-command-U2DMVGDS.js +0 -2
- package/dist/chunks/app-server-runtime-ELR3VCKR.js +0 -2
- package/dist/chunks/apps-NBV45ZGW.js +0 -2
- package/dist/chunks/chunk-BFHAJTU4.js +0 -19
- package/dist/chunks/chunk-CL6YPTWP.js +0 -5
- package/dist/chunks/chunk-DJHJIXMW.js +0 -26
- package/dist/chunks/chunk-IFP6W4OW.js +0 -54
- package/dist/chunks/chunk-JB6FTAMW.js +0 -2
- package/dist/chunks/chunk-L67V63N3.js +0 -2
- package/dist/chunks/chunk-MPNHNWN6.js +0 -15
- package/dist/chunks/chunk-P3DI3ZMK.js +0 -3
- package/dist/chunks/chunk-PBRD43CI.js +0 -42
- package/dist/chunks/chunk-RC3JXLP7.js +0 -4
- package/dist/chunks/chunk-VVKE6EYN.js +0 -166
- package/dist/chunks/chunk-XCTFXXVY.js +0 -2
- package/dist/chunks/cli-EG7K37TB.js +0 -2
- package/dist/chunks/configuration-command-MSDFCKOT.js +0 -2
- package/dist/chunks/core-commands-WDHXJPCY.js +0 -2
- package/dist/chunks/desktop-test-SN4BHDV3.js +0 -3
- package/dist/chunks/dist-XCT2G25K.js +0 -2
- package/dist/chunks/hosted-profile-compiler-HQ6T6NDP.js +0 -3
- package/dist/chunks/opchat-5NQ22CPO.js +0 -3
- package/dist/chunks/organizations-AY52SHI4.js +0 -2
- package/dist/chunks/project-agent-UKGWIFFI.js +0 -2
- package/dist/chunks/sandbox-command-WL6DAJTO.js +0 -2
- package/dist/web/assets/HostedModelLearningReview-BhGIhvoc.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as v,b as I}from"./chunk-GLUWATL5.js";import{Pa as L,Qa as E}from"./chunk-IFP6W4OW.js";import{f as w}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";var T=class extends Error{constructor(t,e){super(`API request timed out after ${t}ms: ${e}`);this.timeoutMs=t;this.requestUrl=e;this.name="ApiTimeoutError"}timeoutMs;requestUrl;static{a(this,"ApiTimeoutError")}code="OPENPOND_API_TIMEOUT"},S=class extends Error{constructor(t,e){super(`API response exceeded ${t} bytes: ${e}`);this.maximumBytes=t;this.requestUrl=e;this.name="ApiResponseTooLargeError"}maximumBytes;requestUrl;static{a(this,"ApiResponseTooLargeError")}code="OPENPOND_API_RESPONSE_TOO_LARGE"},O=class extends Error{constructor(t,e,s,r=null){let c=r||e;super(`${s} failed: ${t}${c?` ${c}`:""}`);this.status=t;this.apiMessage=r;this.name="OpenPondApiError",this.code=e||"OPENPOND_API_ERROR"}status;apiMessage;static{a(this,"OpenPondApiError")}code};async function i(o,n,t,e={}){let{timeoutMs:s=3e4,maxResponseBytes:r=8388608,explicitBearerAuth:c=!1,...p}=e,d=`${o}${t}`,m=new Headers(p.headers);m.set("Content-Type","application/json");let g=c?void 0:process.env.OPENPOND_API_KEY,h=n?.trim()||"",u=!c&&h.startsWith("opk_"),x=g||(u?h:null);x&&!m.has("openpond-api-key")&&m.set("openpond-api-key",x),n?m.set("Authorization",u?`ApiKey ${h}`:`Bearer ${n}`):g&&!m.has("Authorization")&&m.set("Authorization",`ApiKey ${g}`);let y=new AbortController,f=new T(s,d),R=s>0?setTimeout(()=>y.abort(f),s):null;R?.unref?.();let P=U(p.signal,y.signal,s),k=a(()=>{R&&clearTimeout(R)},"cleanup");try{let A=await fetch(d,{...p,headers:m,signal:P});return C(A,{cleanup:k,maximumBytes:r,requestUrl:d,timeoutController:y,timeoutError:f})}catch(A){throw k(),y.signal.aborted?f:A}}a(i,"apiFetch");async function l(o,n){let t;try{let e=await o.text();t=e?JSON.parse(e):{}}catch(e){if(e instanceof T||e instanceof S)throw e;t={}}if(!o.ok){let e=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new O(o.status,e,n,s)}return t}a(l,"readApiJson");function C(o,n){if(!o.body)return n.cleanup(),o;let t=Number(o.headers.get("content-length"));if(n.maximumBytes>0&&Number.isFinite(t)&&t>n.maximumBytes)throw n.cleanup(),o.body.cancel(),new S(n.maximumBytes,n.requestUrl);let e=o.body.getReader(),s=0,r=new ReadableStream({async pull(c){try{let p=await e.read();if(p.done){n.cleanup(),c.close();return}if(s+=p.value.byteLength,n.maximumBytes>0&&s>n.maximumBytes){n.cleanup(),await e.cancel(),c.error(new S(n.maximumBytes,n.requestUrl));return}c.enqueue(p.value)}catch(p){n.cleanup(),c.error(n.timeoutController.signal.aborted?n.timeoutError:p)}},async cancel(c){n.cleanup(),await e.cancel(c)}});return new Response(r,{headers:o.headers,status:o.status,statusText:o.statusText})}a(C,"boundedResponse");function U(o,n,t){return t<=0?o??void 0:o?AbortSignal.any([o,n]):n}a(U,"composedSignal");async function _(o,n,t,e,s){let r=await i(o,n,`/v4/apps/${t}/commits`,{method:"POST",body:JSON.stringify({files:e,message:s})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Commit failed: ${r.status} ${c}`)}return await r.json()}a(_,"commitFiles");async function j(o,n,t,e){let s=e?.environment??"production",r=await i(o,n,`/v4/apps/${t}/deployments`,{method:"POST",body:JSON.stringify({environment:s,...e?.commitSha?{commitSha:e.commitSha}:{},...e?.branch?{branch:e.branch}:{}})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Deploy failed: ${r.status} ${c}`)}return await r.json()}a(j,"deployApp");async function B(o,n,t,e){let s=await i(o,n,`/v4/apps/${encodeURIComponent(t)}/deployments/promote-preview`,{method:"POST",body:JSON.stringify(e)});return l(s,"Preview promotion")}a(B,"promotePreviewToProduction");async function G(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/lifecycle/start`,{method:"POST",body:JSON.stringify(e)});return l(s,"App lifecycle start")}a(G,"startAppLifecycle");async function J(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/logs`,{method:"GET"});if(!e.ok){let c=await e.text().catch(()=>"");throw new Error(`Deployment logs failed: ${e.status} ${c}`)}let s=await e.json().catch(()=>({}));return(Array.isArray(s.logs)?s.logs:[]).map(c=>{let p=typeof c.createdAt=="string"?c.createdAt:c.createdAt instanceof Date?c.createdAt.toISOString():new Date().toISOString();return{id:typeof c.id=="string"?c.id:`${Math.random()}`,type:typeof c.type=="string"?c.type:void 0,message:typeof c.message=="string"?c.message:"",createdAt:p}})}a(J,"getDeploymentLogs");async function M(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/status`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment status failed: ${e.status} ${r}`)}return{status:(await e.json().catch(()=>({}))).deployment?.status}}a(M,"getDeploymentStatus");async function F(o,n,t,e){let s=new URLSearchParams;e?.status&&e.status.length>0&&s.set("status",e.status.join(",")),e?.createdAfter&&s.set("createdAfter",e.createdAfter),e?.branch&&s.set("branch",e.branch);let r=s.toString(),c=await i(o,n,`/apps/${t}/deployments/latest${r?`?${r}`:""}`,{method:"GET"});if(!c.ok){let d=await c.text().catch(()=>"");throw new Error(`Latest deployment lookup failed: ${c.status} ${d}`)}let p=await c.json().catch(()=>({}));return p.deployment?{id:p.deployment.id,status:p.deployment.status}:null}a(F,"getLatestDeploymentForApp");async function H(o,n,t){let e=await i(o,n,`/apps/deployments/${t}`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment fetch failed: ${e.status} ${r}`)}return(await e.json().catch(()=>({}))).deployment??null}a(H,"getDeploymentDetail");var V=new URL(I).hostname,D=new URL(v).hostname;async function ae(o,n,t){let e=new URLSearchParams;t?.handle&&e.set("handle",t.handle),typeof t?.limit=="number"&&Number.isFinite(t.limit)&&e.set("limit",String(Math.max(1,Math.floor(t.limit)))),typeof t?.offset=="number"&&Number.isFinite(t.offset)&&e.set("offset",String(Math.max(0,Math.floor(t.offset)))),typeof t?.includeScheduled=="boolean"&&e.set("includeScheduled",t.includeScheduled?"true":"false");let s=e.toString(),r=await i(o,n,`/apps/list${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let p=await r.text().catch(()=>"");throw new Error(`Apps list failed: ${r.status} ${p}`)}let c=await r.json().catch(()=>({}));return Array.isArray(c.apps)?c.apps:[]}a(ae,"listApps");async function ie(o,n,t){let e=await i(o,n,"/api/projects/local",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Create project failed: ${e.status} ${s}`)}return await e.json()}a(ie,"createLocalProject");async function ce(o,n,t){let e=await i(o,n,"/apps/repo/create",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Repo create failed: ${e.status} ${s}`)}return await e.json()}a(ce,"createRepo");async function pe(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/code-visibility`,{method:"PATCH",body:JSON.stringify({codeVisibility:e})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Code visibility update failed: ${s.status} ${r}`)}return await s.json()}a(pe,"updateAppCodeVisibility");async function ue(o,n,t,e){let s=await i(o,n,"/v4/apps/headless",{method:"POST",body:JSON.stringify({items:t,...e?{teamId:e}:{}})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Headless create failed: ${s.status} ${r}`)}return await s.json()}a(ue,"createHeadlessApps");async function le(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/status`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template status failed: ${e.status} ${s}`)}return await e.json()}a(le,"getTemplateStatus");async function de(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/branches`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template branches failed: ${e.status} ${s}`)}return await e.json()}a(de,"listTemplateBranches");async function me(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/template/deploy-latest`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Template deploy failed: ${s.status} ${r}`)}return await s.json()}a(me,"deployLatestTemplate");async function ge(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/environment`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Environment update failed: ${s.status} ${r}`)}return await s.json()}a(ge,"updateAppEnvironment");async function he(o,n,t){let e=await i(o,n,`/v4/apps/${t}/environment`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Environment get failed: ${e.status} ${s}`)}return await e.json()}a(he,"getAppEnvironment");async function ye(o,n){let t=await i(o,n,"/api/tools/manifest",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Manifest fetch failed: ${t.status} ${e}`)}return await t.json()}a(ye,"fetchToolManifest");async function fe(o,n){let t=await i(o,n,"/apps/tools",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Tools lookup failed: ${t.status} ${e}`)}return await t.json()}a(fe,"listUserTools");async function Re(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Schedules lookup failed: ${e.status} ${r}`)}let s=await e.json().catch(()=>({}));return{schedules:Array.isArray(s.schedules)?s.schedules:[]}}a(Re,"listAppSchedules");async function we(o,n,t={}){let e=new URLSearchParams;t.domain&&e.set("domain",t.domain),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion),typeof t.limit=="number"&&e.set("limit",String(t.limit));for(let c of t.tags??[])e.append("tag",c);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe list")}a(we,"listOpenToolRecipes");async function Se(o,n,t){let e=await i(o,n,"/v1/opentool/recipes/search",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool recipe search")}a(Se,"searchOpenToolRecipes");async function xe(o,n,t){let e=new URLSearchParams;typeof t.includeExamples=="boolean"&&e.set("includeExamples",String(t.includeExamples)),typeof t.includeTests=="boolean"&&e.set("includeTests",String(t.includeTests)),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes/${encodeURIComponent(t.id)}${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe get")}a(xe,"getOpenToolRecipe");async function Te(o,n,t){let e=await i(o,n,"/v1/opentool/rules",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool rules get")}a(Te,"getOpenToolRules");function b(o){let n=new URLSearchParams;typeof o=="number"&&Number.isFinite(o)&&n.set("limit",String(Math.max(1,Math.floor(o))));let t=n.toString();return t?`?${t}`:""}a(b,"buildLimitQuery");function N(o){if(Array.isArray(o))return o;if(!o||typeof o!="object")return[];let n=o;return Array.isArray(n.logs)?n.logs:Array.isArray(n.runs)?n.runs:Array.isArray(n.scheduleRuns)?n.scheduleRuns:Array.isArray(n.items)?n.items:[]}a(N,"normalizeScheduleExecutionLogs");async function Pe(o,n,t,e){let s={...e?.preferredScheduleId?{preferredScheduleId:e.preferredScheduleId}:{},...e?.scheduleId?{scheduleId:e.scheduleId}:{},...e?.startAt?{startAt:e.startAt}:{},...e&&"endAt"in e?{endAt:e.endAt??null}:{}},r=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/start`,{method:"POST",body:JSON.stringify(s)});return l(r,"Schedule start")}a(Pe,"startAppSchedules");async function Ae(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/stop`,{method:"POST",body:JSON.stringify({})});return l(e,"Schedule stop")}a(Ae,"stopAppSchedules");async function Ee(o,n){let t=await i(o,n,"/apps/schedules/current/stop",{method:"POST",body:JSON.stringify({})});return l(t,"Current schedule stop")}a(Ee,"stopCurrentAppSchedules");async function Oe(o,n,t){let e=await i(o,n,"/v1/schedules/run",{method:"POST",body:JSON.stringify({scheduleId:t.scheduleId})});return l(e,"Schedule run")}a(Oe,"runScheduleNow");async function be(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/${encodeURIComponent(e)}`,{method:"DELETE"});return l(s,"Schedule delete")}a(be,"deleteOrArchiveSchedule");async function $e(o,n,t,e){let s=await i(o,n,`/v1/schedules/${encodeURIComponent(t)}/execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Schedule execution logs");return{logs:N(r)}}a($e,"listScheduleExecutionLogs");async function ke(o,n,t,e){let s=await i(o,n,`/v1/deployments/${encodeURIComponent(t)}/schedule-execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Deployment schedule execution logs");return{logs:N(r)}}a(ke,"listDeploymentScheduleExecutionLogs");async function Le(o,n,t){let e=await i(o,n,`/v1/schedule-execution-logs/${encodeURIComponent(t)}`,{method:"GET"});return l(e,"Schedule execution log")}a(Le,"getScheduleExecutionLog");async function ve(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/execution-timeline${b(e?.limit)}`,{method:"GET"});return l(s,"App execution timeline")}a(ve,"getAppExecutionTimeline");async function Ie(o,n,t){return i(o,n,"/apps/agent/create",{method:"POST",body:JSON.stringify(t)})}a(Ie,"createAgentFromPrompt");async function De(o,n,t){let e=new URLSearchParams;t?.appId&&e.set("appId",t.appId);let s=e.toString(),r=await i(o,n,`/apps/performance${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Performance lookup failed: ${r.status} ${c}`)}return await r.json()}a(De,"getUserPerformance");async function Ne(o,n,t){let e=new URLSearchParams({appId:t}),s=await i(o,n,`/apps/summary?${e.toString()}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Summary lookup failed: ${s.status} ${r}`)}return await s.json()}a(Ne,"getAppRuntimeSummary");async function z(o,n){let t=await i(o,n,"/v1/account",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Account lookup failed: ${t.status} ${e}`)}return await t.json()}a(z,"getOpenPondAccount");async function qe(o,n){let t=new Date().toISOString(),e=Date.now(),s=o.replace(/\/$/,"");try{let r=await i(s,null,"/health",{method:"GET",headers:{Accept:"application/json"}}),c=Date.now()-e,p=await r.json().catch(()=>({})),d=null,m=null;if(n?.trim())try{let g=await z(s,n);d=!0,m=g.account}catch{d=!1}return{reachable:r.ok,authenticated:d,apiBase:s,latencyMs:c,status:r.status,service:typeof p.service=="string"?p.service:null,checkedAt:t,account:m,...r.ok?{}:{error:r.statusText||`HTTP ${r.status}`}}}catch(r){return{reachable:!1,authenticated:n?.trim()?!1:null,apiBase:s,latencyMs:Date.now()-e,status:null,service:null,checkedAt:t,error:r instanceof Error?r.message:String(r)}}}a(qe,"checkOpenPondApiHealth");async function Ce(o,n,t){let e=await i(o,n,"/apps/assistant/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Assistant run failed: ${e.status} ${s}`)}return await e.json()}a(Ce,"runAssistantMode");async function Ue(o,n,t){let e=await i(o,n,"/apps/agent/digest",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Agent digest failed: ${e.status} ${s}`)}return await e.json()}a(Ue,"postAgentDigest");async function _e(o,n,t){let e=await i(o,n,"/apps/tools/execute",{method:"POST",body:JSON.stringify(t)}),s=await e.text().catch(()=>""),r=null;try{r=s?JSON.parse(s):null}catch{r=s}return e.ok?{ok:!0,status:e.status,data:r}:{ok:!1,status:e.status,error:r&&typeof r=="object"&&"error"in r?String(r.error):s||e.statusText}}a(_e,"executeUserTool");async function je(o,n,t){let e=await i(o,n,"/apps/backtests/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Backtest run failed: ${e.status} ${s}`)}return await e.json()}a(je,"submitBacktestRun");async function Be(o,n,t){let e=t.query&&Object.keys(t.query).length>0?`?${new URLSearchParams(t.query).toString()}`:"",s=await i(o,n,`/apps/backtests/tx${e}`,{method:t.method,body:t.method==="POST"&&t.body!==void 0?JSON.stringify(t.body):void 0});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtests request failed: ${s.status} ${r}`)}return await s.json()}a(Be,"submitBacktestTx");async function Ge(o,n,t){let e=new URLSearchParams(t).toString(),s=await i(o,n,`/apps/backtests/detail?${e}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtest detail failed: ${s.status} ${r}`)}return await s.json()}a(Ge,"submitBacktestDetail");function K(o){let n=o.trim().replace(/^\/+/,"");return encodeURIComponent(n||"tool")}a(K,"normalizeToolPathSegment");function W(o){let n=o.replace(/\/$/,""),t=process.env.OPENPOND_TOOL_URL;if(t)return t.replace(/\/$/,"");try{let e=new URL(n),s=e.hostname.toLowerCase(),r=s==="apps.openpond.live"?null:s===V||s===D||s===`www.${D}`||s==="openpond.live"||s==="www.openpond.live"?"https://apps.openpond.live":null;if(r)return r;let c=s==="localhost"||s==="127.0.0.1",p=e.port||(e.protocol==="https:"?"443":"80");if(c&&p==="3000")return n}catch{}return n}a(W,"resolveWorkerBaseUrl");async function Je(o,n,t){let e=W(o),s=K(t.toolName),c=`${t.deploymentId?`/${t.appId}/deployments/${t.deploymentId}`:`/${t.appId}`}/${s}`,p=new Headers(t.headers||{}),d=t.method??"POST",m=t.body===void 0||d==="GET"?void 0:JSON.stringify(t.body),g=await i(e,n,c,{method:d,body:m,headers:p}),h=await g.text().catch(()=>""),u=null;try{u=h?JSON.parse(h):null}catch{u=h}let x=u&&typeof u=="object"&&"ok"in u?!!u.ok:!0,y=g.ok&&x,f=u&&typeof u=="object"&&"status"in u&&Number(u.status)||g.status,R=u&&typeof u=="object"&&"error"in u?String(u.error):g.ok?void 0:h||g.statusText,P=u&&typeof u=="object"&&"data"in u?u.data:u;return{ok:y,status:f,data:P,error:R}}a(Je,"executeHostedTool");import{createHash as Y}from"node:crypto";var X=3600*1e3;function $(o){return Y("sha256").update(JSON.stringify([o.apiBase.replace(/\/$/,""),o.apiKey.trim()])).digest("hex")}a($,"buildCacheKey");async function q(o,n){let t=await L(w(),o,$(n),{allowStale:!0});return!t||Date.now()-Date.parse(t.updatedAt)>=(n.ttlMs??X)?null:t.payload}a(q,"cached");async function ot(o){return q("cloud.apps",o)}a(ot,"getCachedApps");async function st(o){await E(w(),"cloud.apps",$(o),o.apps)}a(st,"setCachedApps");async function rt(o){return q("cloud.tools",o)}a(rt,"getCachedTools");async function at(o){await E(w(),"cloud.tools",$(o),o.tools)}a(at,"setCachedTools");var pt=["openpond-generic-v1","openpond-work-v1","openpond-coding-core-v1","openpond-agent-harness-v1"];export{i as a,_ as b,j as c,B as d,G as e,J as f,M as g,F as h,H as i,ae as j,ie as k,ce as l,pe as m,ue as n,le as o,de as p,me as q,ge as r,he as s,ye as t,fe as u,Re as v,we as w,Se as x,xe as y,Te as z,Pe as A,Ae as B,Ee as C,Oe as D,be as E,$e as F,ke as G,Le as H,ve as I,Ie as J,De as K,Ne as L,z as M,qe as N,Ce as O,Ue as P,_e as Q,je as R,Be as S,Ge as T,W as U,Je as V,X as W,ot as X,st as Y,rt as Z,at as _,pt as $};
|
|
2
|
+
import{a as v,b as I}from"./chunk-GLUWATL5.js";import{ya as L,za as E}from"./chunk-QK2GLRCY.js";import{f as w}from"./chunk-H7IWJN7L.js";import{a}from"./chunk-FTQLQJQV.js";var T=class extends Error{constructor(t,e){super(`API request timed out after ${t}ms: ${e}`);this.timeoutMs=t;this.requestUrl=e;this.name="ApiTimeoutError"}timeoutMs;requestUrl;static{a(this,"ApiTimeoutError")}code="OPENPOND_API_TIMEOUT"},S=class extends Error{constructor(t,e){super(`API response exceeded ${t} bytes: ${e}`);this.maximumBytes=t;this.requestUrl=e;this.name="ApiResponseTooLargeError"}maximumBytes;requestUrl;static{a(this,"ApiResponseTooLargeError")}code="OPENPOND_API_RESPONSE_TOO_LARGE"},O=class extends Error{constructor(t,e,s,r=null){let c=r||e;super(`${s} failed: ${t}${c?` ${c}`:""}`);this.status=t;this.apiMessage=r;this.name="OpenPondApiError",this.code=e||"OPENPOND_API_ERROR"}status;apiMessage;static{a(this,"OpenPondApiError")}code};async function i(o,n,t,e={}){let{timeoutMs:s=3e4,maxResponseBytes:r=8388608,explicitBearerAuth:c=!1,...p}=e,d=`${o}${t}`,m=new Headers(p.headers);m.set("Content-Type","application/json");let g=c?void 0:process.env.OPENPOND_API_KEY,h=n?.trim()||"",u=!c&&h.startsWith("opk_"),x=g||(u?h:null);x&&!m.has("openpond-api-key")&&m.set("openpond-api-key",x),n?m.set("Authorization",u?`ApiKey ${h}`:`Bearer ${n}`):g&&!m.has("Authorization")&&m.set("Authorization",`ApiKey ${g}`);let y=new AbortController,f=new T(s,d),R=s>0?setTimeout(()=>y.abort(f),s):null;R?.unref?.();let P=U(p.signal,y.signal,s),k=a(()=>{R&&clearTimeout(R)},"cleanup");try{let A=await fetch(d,{...p,headers:m,signal:P});return C(A,{cleanup:k,maximumBytes:r,requestUrl:d,timeoutController:y,timeoutError:f})}catch(A){throw k(),y.signal.aborted?f:A}}a(i,"apiFetch");async function l(o,n){let t;try{let e=await o.text();t=e?JSON.parse(e):{}}catch(e){if(e instanceof T||e instanceof S)throw e;t={}}if(!o.ok){let e=typeof t.error=="string"?t.error:null,s=typeof t.message=="string"?t.message:null;throw new O(o.status,e,n,s)}return t}a(l,"readApiJson");function C(o,n){if(!o.body)return n.cleanup(),o;let t=Number(o.headers.get("content-length"));if(n.maximumBytes>0&&Number.isFinite(t)&&t>n.maximumBytes)throw n.cleanup(),o.body.cancel(),new S(n.maximumBytes,n.requestUrl);let e=o.body.getReader(),s=0,r=new ReadableStream({async pull(c){try{let p=await e.read();if(p.done){n.cleanup(),c.close();return}if(s+=p.value.byteLength,n.maximumBytes>0&&s>n.maximumBytes){n.cleanup(),await e.cancel(),c.error(new S(n.maximumBytes,n.requestUrl));return}c.enqueue(p.value)}catch(p){n.cleanup(),c.error(n.timeoutController.signal.aborted?n.timeoutError:p)}},async cancel(c){n.cleanup(),await e.cancel(c)}});return new Response(r,{headers:o.headers,status:o.status,statusText:o.statusText})}a(C,"boundedResponse");function U(o,n,t){return t<=0?o??void 0:o?AbortSignal.any([o,n]):n}a(U,"composedSignal");async function _(o,n,t,e,s){let r=await i(o,n,`/v4/apps/${t}/commits`,{method:"POST",body:JSON.stringify({files:e,message:s})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Commit failed: ${r.status} ${c}`)}return await r.json()}a(_,"commitFiles");async function j(o,n,t,e){let s=e?.environment??"production",r=await i(o,n,`/v4/apps/${t}/deployments`,{method:"POST",body:JSON.stringify({environment:s,...e?.commitSha?{commitSha:e.commitSha}:{},...e?.branch?{branch:e.branch}:{}})});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Deploy failed: ${r.status} ${c}`)}return await r.json()}a(j,"deployApp");async function B(o,n,t,e){let s=await i(o,n,`/v4/apps/${encodeURIComponent(t)}/deployments/promote-preview`,{method:"POST",body:JSON.stringify(e)});return l(s,"Preview promotion")}a(B,"promotePreviewToProduction");async function G(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/lifecycle/start`,{method:"POST",body:JSON.stringify(e)});return l(s,"App lifecycle start")}a(G,"startAppLifecycle");async function J(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/logs`,{method:"GET"});if(!e.ok){let c=await e.text().catch(()=>"");throw new Error(`Deployment logs failed: ${e.status} ${c}`)}let s=await e.json().catch(()=>({}));return(Array.isArray(s.logs)?s.logs:[]).map(c=>{let p=typeof c.createdAt=="string"?c.createdAt:c.createdAt instanceof Date?c.createdAt.toISOString():new Date().toISOString();return{id:typeof c.id=="string"?c.id:`${Math.random()}`,type:typeof c.type=="string"?c.type:void 0,message:typeof c.message=="string"?c.message:"",createdAt:p}})}a(J,"getDeploymentLogs");async function M(o,n,t){let e=await i(o,n,`/apps/deployments/${t}/status`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment status failed: ${e.status} ${r}`)}return{status:(await e.json().catch(()=>({}))).deployment?.status}}a(M,"getDeploymentStatus");async function F(o,n,t,e){let s=new URLSearchParams;e?.status&&e.status.length>0&&s.set("status",e.status.join(",")),e?.createdAfter&&s.set("createdAfter",e.createdAfter),e?.branch&&s.set("branch",e.branch);let r=s.toString(),c=await i(o,n,`/apps/${t}/deployments/latest${r?`?${r}`:""}`,{method:"GET"});if(!c.ok){let d=await c.text().catch(()=>"");throw new Error(`Latest deployment lookup failed: ${c.status} ${d}`)}let p=await c.json().catch(()=>({}));return p.deployment?{id:p.deployment.id,status:p.deployment.status}:null}a(F,"getLatestDeploymentForApp");async function H(o,n,t){let e=await i(o,n,`/apps/deployments/${t}`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Deployment fetch failed: ${e.status} ${r}`)}return(await e.json().catch(()=>({}))).deployment??null}a(H,"getDeploymentDetail");var V=new URL(I).hostname,D=new URL(v).hostname;async function ae(o,n,t){let e=new URLSearchParams;t?.handle&&e.set("handle",t.handle),typeof t?.limit=="number"&&Number.isFinite(t.limit)&&e.set("limit",String(Math.max(1,Math.floor(t.limit)))),typeof t?.offset=="number"&&Number.isFinite(t.offset)&&e.set("offset",String(Math.max(0,Math.floor(t.offset)))),typeof t?.includeScheduled=="boolean"&&e.set("includeScheduled",t.includeScheduled?"true":"false");let s=e.toString(),r=await i(o,n,`/apps/list${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let p=await r.text().catch(()=>"");throw new Error(`Apps list failed: ${r.status} ${p}`)}let c=await r.json().catch(()=>({}));return Array.isArray(c.apps)?c.apps:[]}a(ae,"listApps");async function ie(o,n,t){let e=await i(o,n,"/api/projects/local",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Create project failed: ${e.status} ${s}`)}return await e.json()}a(ie,"createLocalProject");async function ce(o,n,t){let e=await i(o,n,"/apps/repo/create",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Repo create failed: ${e.status} ${s}`)}return await e.json()}a(ce,"createRepo");async function pe(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/code-visibility`,{method:"PATCH",body:JSON.stringify({codeVisibility:e})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Code visibility update failed: ${s.status} ${r}`)}return await s.json()}a(pe,"updateAppCodeVisibility");async function ue(o,n,t,e){let s=await i(o,n,"/v4/apps/headless",{method:"POST",body:JSON.stringify({items:t,...e?{teamId:e}:{}})});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Headless create failed: ${s.status} ${r}`)}return await s.json()}a(ue,"createHeadlessApps");async function le(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/status`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template status failed: ${e.status} ${s}`)}return await e.json()}a(le,"getTemplateStatus");async function de(o,n,t){let e=await i(o,n,`/v4/apps/${t}/template/branches`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Template branches failed: ${e.status} ${s}`)}return await e.json()}a(de,"listTemplateBranches");async function me(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/template/deploy-latest`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Template deploy failed: ${s.status} ${r}`)}return await s.json()}a(me,"deployLatestTemplate");async function ge(o,n,t,e){let s=await i(o,n,`/v4/apps/${t}/environment`,{method:"POST",body:JSON.stringify(e)});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Environment update failed: ${s.status} ${r}`)}return await s.json()}a(ge,"updateAppEnvironment");async function he(o,n,t){let e=await i(o,n,`/v4/apps/${t}/environment`,{method:"GET"});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Environment get failed: ${e.status} ${s}`)}return await e.json()}a(he,"getAppEnvironment");async function ye(o,n){let t=await i(o,n,"/api/tools/manifest",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Manifest fetch failed: ${t.status} ${e}`)}return await t.json()}a(ye,"fetchToolManifest");async function fe(o,n){let t=await i(o,n,"/apps/tools",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Tools lookup failed: ${t.status} ${e}`)}return await t.json()}a(fe,"listUserTools");async function Re(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules`,{method:"GET"});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`Schedules lookup failed: ${e.status} ${r}`)}let s=await e.json().catch(()=>({}));return{schedules:Array.isArray(s.schedules)?s.schedules:[]}}a(Re,"listAppSchedules");async function we(o,n,t={}){let e=new URLSearchParams;t.domain&&e.set("domain",t.domain),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion),typeof t.limit=="number"&&e.set("limit",String(t.limit));for(let c of t.tags??[])e.append("tag",c);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe list")}a(we,"listOpenToolRecipes");async function Se(o,n,t){let e=await i(o,n,"/v1/opentool/recipes/search",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool recipe search")}a(Se,"searchOpenToolRecipes");async function xe(o,n,t){let e=new URLSearchParams;typeof t.includeExamples=="boolean"&&e.set("includeExamples",String(t.includeExamples)),typeof t.includeTests=="boolean"&&e.set("includeTests",String(t.includeTests)),t.opentoolVersion&&e.set("opentoolVersion",t.opentoolVersion);let s=e.toString(),r=await i(o,n,`/v1/opentool/recipes/${encodeURIComponent(t.id)}${s?`?${s}`:""}`,{method:"GET"});return l(r,"OpenTool recipe get")}a(xe,"getOpenToolRecipe");async function Te(o,n,t){let e=await i(o,n,"/v1/opentool/rules",{method:"POST",body:JSON.stringify(t)});return l(e,"OpenTool rules get")}a(Te,"getOpenToolRules");function b(o){let n=new URLSearchParams;typeof o=="number"&&Number.isFinite(o)&&n.set("limit",String(Math.max(1,Math.floor(o))));let t=n.toString();return t?`?${t}`:""}a(b,"buildLimitQuery");function N(o){if(Array.isArray(o))return o;if(!o||typeof o!="object")return[];let n=o;return Array.isArray(n.logs)?n.logs:Array.isArray(n.runs)?n.runs:Array.isArray(n.scheduleRuns)?n.scheduleRuns:Array.isArray(n.items)?n.items:[]}a(N,"normalizeScheduleExecutionLogs");async function Pe(o,n,t,e){let s={...e?.preferredScheduleId?{preferredScheduleId:e.preferredScheduleId}:{},...e?.scheduleId?{scheduleId:e.scheduleId}:{},...e?.startAt?{startAt:e.startAt}:{},...e&&"endAt"in e?{endAt:e.endAt??null}:{}},r=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/start`,{method:"POST",body:JSON.stringify(s)});return l(r,"Schedule start")}a(Pe,"startAppSchedules");async function Ae(o,n,t){let e=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/stop`,{method:"POST",body:JSON.stringify({})});return l(e,"Schedule stop")}a(Ae,"stopAppSchedules");async function Ee(o,n){let t=await i(o,n,"/apps/schedules/current/stop",{method:"POST",body:JSON.stringify({})});return l(t,"Current schedule stop")}a(Ee,"stopCurrentAppSchedules");async function Oe(o,n,t){let e=await i(o,n,"/v1/schedules/run",{method:"POST",body:JSON.stringify({scheduleId:t.scheduleId})});return l(e,"Schedule run")}a(Oe,"runScheduleNow");async function be(o,n,t,e){let s=await i(o,n,`/apps/${encodeURIComponent(t)}/schedules/${encodeURIComponent(e)}`,{method:"DELETE"});return l(s,"Schedule delete")}a(be,"deleteOrArchiveSchedule");async function $e(o,n,t,e){let s=await i(o,n,`/v1/schedules/${encodeURIComponent(t)}/execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Schedule execution logs");return{logs:N(r)}}a($e,"listScheduleExecutionLogs");async function ke(o,n,t,e){let s=await i(o,n,`/v1/deployments/${encodeURIComponent(t)}/schedule-execution-logs${b(e?.limit)}`,{method:"GET"}),r=await l(s,"Deployment schedule execution logs");return{logs:N(r)}}a(ke,"listDeploymentScheduleExecutionLogs");async function Le(o,n,t){let e=await i(o,n,`/v1/schedule-execution-logs/${encodeURIComponent(t)}`,{method:"GET"});return l(e,"Schedule execution log")}a(Le,"getScheduleExecutionLog");async function ve(o,n,t,e){let s=await i(o,n,`/v1/apps/${encodeURIComponent(t)}/execution-timeline${b(e?.limit)}`,{method:"GET"});return l(s,"App execution timeline")}a(ve,"getAppExecutionTimeline");async function Ie(o,n,t){return i(o,n,"/apps/agent/create",{method:"POST",body:JSON.stringify(t)})}a(Ie,"createAgentFromPrompt");async function De(o,n,t){let e=new URLSearchParams;t?.appId&&e.set("appId",t.appId);let s=e.toString(),r=await i(o,n,`/apps/performance${s?`?${s}`:""}`,{method:"GET"});if(!r.ok){let c=await r.text().catch(()=>"");throw new Error(`Performance lookup failed: ${r.status} ${c}`)}return await r.json()}a(De,"getUserPerformance");async function Ne(o,n,t){let e=new URLSearchParams({appId:t}),s=await i(o,n,`/apps/summary?${e.toString()}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Summary lookup failed: ${s.status} ${r}`)}return await s.json()}a(Ne,"getAppRuntimeSummary");async function z(o,n){let t=await i(o,n,"/v1/account",{method:"GET"});if(!t.ok){let e=await t.text().catch(()=>"");throw new Error(`Account lookup failed: ${t.status} ${e}`)}return await t.json()}a(z,"getOpenPondAccount");async function qe(o,n){let t=new Date().toISOString(),e=Date.now(),s=o.replace(/\/$/,"");try{let r=await i(s,null,"/health",{method:"GET",headers:{Accept:"application/json"}}),c=Date.now()-e,p=await r.json().catch(()=>({})),d=null,m=null;if(n?.trim())try{let g=await z(s,n);d=!0,m=g.account}catch{d=!1}return{reachable:r.ok,authenticated:d,apiBase:s,latencyMs:c,status:r.status,service:typeof p.service=="string"?p.service:null,checkedAt:t,account:m,...r.ok?{}:{error:r.statusText||`HTTP ${r.status}`}}}catch(r){return{reachable:!1,authenticated:n?.trim()?!1:null,apiBase:s,latencyMs:Date.now()-e,status:null,service:null,checkedAt:t,error:r instanceof Error?r.message:String(r)}}}a(qe,"checkOpenPondApiHealth");async function Ce(o,n,t){let e=await i(o,n,"/apps/assistant/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Assistant run failed: ${e.status} ${s}`)}return await e.json()}a(Ce,"runAssistantMode");async function Ue(o,n,t){let e=await i(o,n,"/apps/agent/digest",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Agent digest failed: ${e.status} ${s}`)}return await e.json()}a(Ue,"postAgentDigest");async function _e(o,n,t){let e=await i(o,n,"/apps/tools/execute",{method:"POST",body:JSON.stringify(t)}),s=await e.text().catch(()=>""),r=null;try{r=s?JSON.parse(s):null}catch{r=s}return e.ok?{ok:!0,status:e.status,data:r}:{ok:!1,status:e.status,error:r&&typeof r=="object"&&"error"in r?String(r.error):s||e.statusText}}a(_e,"executeUserTool");async function je(o,n,t){let e=await i(o,n,"/apps/backtests/run",{method:"POST",body:JSON.stringify(t)});if(!e.ok){let s=await e.text().catch(()=>"");throw new Error(`Backtest run failed: ${e.status} ${s}`)}return await e.json()}a(je,"submitBacktestRun");async function Be(o,n,t){let e=t.query&&Object.keys(t.query).length>0?`?${new URLSearchParams(t.query).toString()}`:"",s=await i(o,n,`/apps/backtests/tx${e}`,{method:t.method,body:t.method==="POST"&&t.body!==void 0?JSON.stringify(t.body):void 0});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtests request failed: ${s.status} ${r}`)}return await s.json()}a(Be,"submitBacktestTx");async function Ge(o,n,t){let e=new URLSearchParams(t).toString(),s=await i(o,n,`/apps/backtests/detail?${e}`,{method:"GET"});if(!s.ok){let r=await s.text().catch(()=>"");throw new Error(`Backtest detail failed: ${s.status} ${r}`)}return await s.json()}a(Ge,"submitBacktestDetail");function K(o){let n=o.trim().replace(/^\/+/,"");return encodeURIComponent(n||"tool")}a(K,"normalizeToolPathSegment");function W(o){let n=o.replace(/\/$/,""),t=process.env.OPENPOND_TOOL_URL;if(t)return t.replace(/\/$/,"");try{let e=new URL(n),s=e.hostname.toLowerCase(),r=s==="apps.openpond.live"?null:s===V||s===D||s===`www.${D}`||s==="openpond.live"||s==="www.openpond.live"?"https://apps.openpond.live":null;if(r)return r;let c=s==="localhost"||s==="127.0.0.1",p=e.port||(e.protocol==="https:"?"443":"80");if(c&&p==="3000")return n}catch{}return n}a(W,"resolveWorkerBaseUrl");async function Je(o,n,t){let e=W(o),s=K(t.toolName),c=`${t.deploymentId?`/${t.appId}/deployments/${t.deploymentId}`:`/${t.appId}`}/${s}`,p=new Headers(t.headers||{}),d=t.method??"POST",m=t.body===void 0||d==="GET"?void 0:JSON.stringify(t.body),g=await i(e,n,c,{method:d,body:m,headers:p}),h=await g.text().catch(()=>""),u=null;try{u=h?JSON.parse(h):null}catch{u=h}let x=u&&typeof u=="object"&&"ok"in u?!!u.ok:!0,y=g.ok&&x,f=u&&typeof u=="object"&&"status"in u&&Number(u.status)||g.status,R=u&&typeof u=="object"&&"error"in u?String(u.error):g.ok?void 0:h||g.statusText,P=u&&typeof u=="object"&&"data"in u?u.data:u;return{ok:y,status:f,data:P,error:R}}a(Je,"executeHostedTool");import{createHash as Y}from"node:crypto";var X=3600*1e3;function $(o){return Y("sha256").update(JSON.stringify([o.apiBase.replace(/\/$/,""),o.apiKey.trim()])).digest("hex")}a($,"buildCacheKey");async function q(o,n){let t=await L(w(),o,$(n),{allowStale:!0});return!t||Date.now()-Date.parse(t.updatedAt)>=(n.ttlMs??X)?null:t.payload}a(q,"cached");async function ot(o){return q("cloud.apps",o)}a(ot,"getCachedApps");async function st(o){await E(w(),"cloud.apps",$(o),o.apps)}a(st,"setCachedApps");async function rt(o){return q("cloud.tools",o)}a(rt,"getCachedTools");async function at(o){await E(w(),"cloud.tools",$(o),o.tools)}a(at,"setCachedTools");var pt=["openpond-generic-v1","openpond-work-v1","openpond-coding-core-v1","openpond-agent-harness-v1"];export{i as a,_ as b,j as c,B as d,G as e,J as f,M as g,F as h,H as i,ae as j,ie as k,ce as l,pe as m,ue as n,le as o,de as p,me as q,ge as r,he as s,ye as t,fe as u,Re as v,we as w,Se as x,xe as y,Te as z,Pe as A,Ae as B,Ee as C,Oe as D,be as E,$e as F,ke as G,Le as H,ve as I,Ie as J,De as K,Ne as L,z as M,qe as N,Ce as O,Ue as P,_e as Q,je as R,Be as S,Ge as T,W as U,Je as V,X as W,ot as X,st as Y,rt as Z,at as _,pt as $};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{Ca as Ve,Db as We,Ea as qe,G as we,J as N,Ja as $e,K as p,La as Le,Lb as V,Ma as ne,Ob as U,Pa as Re,Qa as W,Qb as ie,Ra as K,Sa as oe,Ta as Oe,Tb as ce,Ua as ze,V as Ce,Wa as Y,X as Fe,Xa as A,Ya as Q,_b as Ke,c as ke,e as ge,f as G,g as re,rc as Je,sc as Te,tc as Xe,va as je,vc as be,wb as Ge,wc as Se,yc as xe,zb as Ne}from"./chunk-WCZRDULE.js";import{n as he,o as ve,p as Ae}from"./chunk-GIPSOLAY.js";import{B as Ie,E as He,F as Ee,G as Me,H as De,O,P as J,R as $,T as ee,W as X,Y as te,_ as _e,a as B,fa as v,ga as j,ha as H,ia as Be,ka as se,ma as ae,s as Z,xa as z}from"./chunk-JUX77H6K.js";import{b as g}from"./chunk-ES2ISFJC.js";import{a as S}from"./chunk-FTQLQJQV.js";var de=J.shape.id,Ye=g.object({schemaVersion:g.literal("openpond.modelBatchReviewInspection.v1"),packageHash:g.string().regex(/^[a-f0-9]{64}$/),definition:$,binding:Ie,evidence:g.array(X).min(1).max(1e4),decisions:g.array(_e).min(1).max(1e4)}).strict(),Pe=g.object({schemaVersion:g.literal("openpond.modelBatchReviewRequest.v1"),operationId:de,modelId:de,expectedModelRevision:g.number().int().positive(),tasksetRef:J,rewardBindingRef:J.nullable(),definition:g.object({name:g.string().trim().min(1).max(500).optional(),instructions:g.string().trim().min(1).max(2e4).optional(),inputSchema:O.optional(),outputSchema:O.optional(),requiredOutputs:$.shape.requiredOutputs}).strict(),examples:g.array(g.object({evidence:J,input:O.optional(),expected:O.nullable().optional(),evaluatorContext:O.nullable().optional(),proposedTarget:O.nullable().optional()}).strict()).max(1e4)}).strict(),Qe=g.object({schemaVersion:g.literal("openpond.modelBatchReviewReceipt.v1"),operationId:de,modelId:de,source:ee,evidence:g.array(X).min(1).max(1e4),proposals:g.array(te).max(1e4)}).strict();function rt(s){let e=A(s.source),t=A(s.edited),a=s.preparation;if(a.authoringGraph!=="bound"||!e.modelResources||e.learningResources||t.modelResources||t.learningResources)throw new Error("Bound task editing requires its source Reward and an ordinary edited workspace.");if(e.contentHash!==a.sourcePackageHash||!j(v(e.taskset),a.sourceTasksetRef))throw new Error("Bound draft differs from its retained source package.");let i=S(b=>b.taskset.graders.map(F=>F.kind==="custom_verifier"?{...F,exportName:F.exportName??"verify"}:F),"normalizedGraders");if(p(i(e))!==p(i(t)))throw new Error("Edit the saved Reward in Rewards before changing this Taskset's graders.");let m=e.modelResources,u=new Map(m.assets.map(b=>[b.id,b])),k=K(t),x=K(e),R=S(b=>{let{id:F,revision:pe,contentHash:fe,metadata:ue,...st}=b,{javascriptEnvironment:vt,...ye}=ue;return{...st,metadata:{...ye,resources:ye.resources??[]}}},"environmentContent"),n=S(b=>{if(!b)return null;let{id:F,revision:pe,contentHash:fe,...ue}=b.execution.javascript;return ue},"javascriptContent"),w=p(R(e.environment))===p(R(t.environment))&&p(n(x))===p(n(k)),c=w?e.environment:t.environment,l=w?x:k,d=new Set([...m.assets.map(b=>b.id),...t.taskset.tasks.flatMap(b=>b.privilegedContextRef?[b.privilegedContextRef]:[]),...[t.environment.actionSchemaRef,t.environment.observationSchemaRef,t.environment.stateSchemaRef].flatMap(b=>b?[b.id]:[]),...k?.assets.map(b=>b.id)??[]]);for(let b of d){let F=t.files.find(fe=>fe.asset.id===b);if(!F)throw new Error(`Bound Taskset asset is missing: ${b}.`);let pe=new TextDecoder("utf-8",{fatal:!0}).decode(W(F));u.set(b,se.parse(H({schemaVersion:"openpond.learningTextAsset.v1",id:b,revision:1,asset:F.asset,text:pe})))}let I=Y(t),{contentHash:E,...M}=m.taskDefinition,{policy:h,environment:P,environmentRelease:C,tools:q,capabilities:r,verifierSetRelease:f}=t.taskset,T=$.parse(H({...M,instructions:I,execution:{policy:h,environment:P,environmentRelease:C,tools:q,capabilities:r,verifierSetRelease:f}})),{contentHash:D,...o}=t.taskset,y=Z.parse(H({...o,tasks:t.taskset.tasks.map(b=>m.instructionMode==="per_task"?b:{...b,policyVisibleContext:{...b.policyVisibleContext,instructions:I}})})),_=ne({owner:a.lineage.owner,source:{...m,taskset:e.taskset,executionResources:{environment:e.environment,verifierSet:e.verifierSet}},rewardBinding:m.rewardBinding,rewards:m.rewards,assets:[...u.values()],edits:{taskset:y,taskDefinition:T,executionResources:{environment:c,verifierSet:t.verifierSet},...l?{execution:l.execution}:{}}}),L=$e.parse(_.taskset.metadata.modelTasksetDerivation);if(_.taskset.id!==a.tasksetId||_.taskset.revision!==a.tasksetRevision||p({...L,schemaVersion:a.lineage.schemaVersion})!==p(a.lineage))throw new Error("Bound draft differs from its retained ownership lineage.");let{taskset:le,executionResources:et,...tt}=_;return Q({schemaVersion:"openpond.tasksetPackage.v1",taskset:le,...et,modelResources:tt,files:t.files})}S(rt,"publishBoundModelTasksetDraftPackage");function nt(s){let e=ge.parse(s.request),t=ke.parse(s.owner),a=A(s.source);if(a.learningResources)throw new Error("Reviewed Tasksets require their reviewed authoring workflow.");if(a.contentHash!==e.sourcePackageHash)throw new Error("Taskset draft source package changed.");if(a.modelResources){let x=Le({owner:t,source:{...a.modelResources,taskset:a.taskset,executionResources:{environment:a.environment,verifierSet:a.verifierSet}},rewardBinding:a.modelResources.rewardBinding,rewards:a.modelResources.rewards,assets:a.modelResources.assets}),R=x.taskset.metadata.modelTasksetDerivation;return G.parse({schemaVersion:"openpond.modelTasksetDraftPreparation.v1",draftId:`model-taskset-draft-${p({owner:t,operationId:e.operationId})}`,requestHash:p(e),sourcePackageHash:a.contentHash,sourceTasksetRef:v(a.taskset),tasksetId:x.taskset.id,tasksetRevision:x.taskset.revision,lineage:{...R,schemaVersion:"openpond.modelTasksetAuthoring.v1"},authoringGraph:"bound"})}let i=ze(a.taskset),m=i&&p(i.owner)===p(t),u=m?i.root:v(a.taskset),k={schemaVersion:"openpond.modelTasksetAuthoring.v1",owner:t,root:u,parent:v(a.taskset)};return G.parse({schemaVersion:"openpond.modelTasksetDraftPreparation.v1",draftId:`model-taskset-draft-${p({owner:t,operationId:e.operationId})}`,requestHash:p(e),sourcePackageHash:a.contentHash,sourceTasksetRef:v(a.taskset),tasksetId:Oe(k),tasksetRevision:m?a.taskset.revision+1:1,lineage:k})}S(nt,"prepareModelTasksetDraft");function ot(s){let e=G.parse(s.preparation);if(!j(e.sourceTasksetRef,e.lineage.parent))throw new Error("Taskset draft preparation differs from its source lineage.");if(e.authoringGraph==="bound"){if(!s.source)throw new Error("Bound Taskset authoring requires its retained source package.");return rt({preparation:e,source:s.source,edited:s.edited})}let t=it(s.edited),{contentHash:a,...i}=t.verifierSet,m=Fe({...i,id:`${e.tasksetId}-verifiers`,revision:e.tasksetRevision,calibrationReceiptRefs:[],metadata:{sourceVerifierSet:v(t.verifierSet)}}),{contentHash:u,...k}=t.taskset,x=Z.parse(H({...k,id:e.tasksetId,revision:e.tasksetRevision,verifierSetRelease:{id:m.id,contentHash:m.contentHash},metadata:{modelTasksetAuthoring:e.lineage,...t.taskset.metadata.environmentResources===void 0?{}:{environmentResources:t.taskset.metadata.environmentResources},...t.taskset.metadata.ordinaryAuthoring===void 0?{}:{ordinaryAuthoring:t.taskset.metadata.ordinaryAuthoring}}})),R=K(t),n=R?[...t.files.filter(w=>w.asset.id!==qe(t.taskset)),oe({...R.execution,verifierSet:m})]:t.files;return Q({schemaVersion:"openpond.tasksetPackage.v1",taskset:x,environment:t.environment,verifierSet:m,files:n})}S(ot,"publishModelTasksetDraftPackage");function it(s){let e=A(s);if(e.modelResources||e.learningResources)throw new Error("This Taskset requires its bound or reviewed authoring workflow.");return e}S(it,"requireOrdinaryPackage");function ct(s,e,t,a){if(s.environment.entrypoint!=="openpond.javascript-environment.v1")return{taskset:s,inventory:t,generatedFiles:[]};let i="environment/execution.json",m=e.get(i);if(!m||m.length>524288)throw new Error("Authored tool environment requires its bounded private execution declaration.");let u=Ve.parse(JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(m))),k=S(M=>{if(!M)return null;let h=t.find(P=>P.asset.id===M.id&&P.asset.path===M.path);if(!h)throw new Error(`Authored environment dependency is missing: ${M.id}.`);return h.asset},"repin"),{contentHash:x,...R}=u.javascript,n=je.parse(H({...R,id:`javascript-${s.id}`,revision:s.revision,module:k(u.javascript.module)}));if(p(n.tools)!==p(s.environment.metadata.portableTools)||p(n.tools.map(M=>M.name))!==p(s.environment.toolNames))throw new Error("Authored environment tools differ from the Taskset's declared tools.");let w=Ce({schemaVersion:"openpond.environmentRelease.v1",id:`environment-${s.id}`,revision:s.revision,contract:Se(s),actionSchemaRef:k(u.environment.actionSchemaRef),observationSchemaRef:k(u.environment.observationSchemaRef),stateSchemaRef:k(u.environment.stateSchemaRef),artifactCollection:u.environment.artifactCollection,adapterConformanceHashes:{},metadata:{javascriptEnvironment:v(n),resources:s.environment.resources??[]}}),c=V.parse({...s,environment:{...s.environment,metadata:{...s.environment.metadata,portableExecutionResources:{environment:w}}}}),l=be({taskset:c,adapterId:a}),d=oe({javascript:n,environment:w,verifierSet:l.verifierSetRelease}),I=[...t.filter(M=>M.sourcePath!==i),{asset:d.asset,sourcePath:i}],E=V.parse({...c,metadata:{...c.metadata,portableFileInventory:I}});return{taskset:V.parse({...E,contentHash:U(E)}),inventory:I,generatedFiles:[{path:i,role:"environment",content:new TextDecoder().decode(W(d))}]}}S(ct,"prepareAuthoredToolEnvironment");var me=g.array(g.object({asset:we,sourcePath:g.string().min(1)}).strict()).max(1e4),dt=new Set(["taskset.json","capabilities.json","data/tasks.jsonl","graders/graders.json","fixtures/grader-fixtures.json","environment/taskset.ts"]);function mt(s){return dt.has(s)}S(mt,"isGeneratedTasksetPublicationFilePath");function lt(s,e,t){let a=V.parse(s);if(a.metadata.taskDefinition!==void 0||a.metadata.rewardBinding!==void 0)return{taskset:a,generatedFiles:[]};let i=new Map,m=0;for(let[r,f]of e){if(re.parse(r),m+=f.byteLength,i.size>=1e4||m>Re*3/4)throw new Error("Taskset source exceeds the package byte limit.");i.set(r,f.slice())}let u=a.metrics?.customAggregator,k=u?i.get(u.module):void 0;if(u&&!k)throw new Error("Declared Taskset metric module is missing.");let x=u&&k?{...a.metrics,customAggregator:{...u,contentHash:N(k)}}:a.metrics,R=new Map,n=new Set,w=[],c=S((r,f,T,D)=>{let o=i.get(f);if(!o)throw new Error(`Declared Taskset file is missing: ${f}.`);return{id:r,path:f,contentHash:N(o),sizeBytes:o.byteLength,mediaType:T,visibility:D}},"ref"),l=S((r,f=r.path)=>{let T=R.get(r.id);if(T&&p(T)!==p({asset:r,sourcePath:f}))throw new Error(`Conflicting Taskset file identity: ${r.id}.`);let D=i.get(f);if(!D||D.length!==r.sizeBytes||N(D)!==r.contentHash)throw new Error(`Taskset file differs from its declared bytes: ${r.id}.`);R.set(r.id,{asset:r,sourcePath:f}),n.add(f)},"add");for(let r of a.tasks){let f=xe(r);for(let T of f.artifactRefs)l(T,r.assets?.find(D=>D.id===T.id)?.artifactRef??T.path);for(let T of f.requiredOutputs??[])T.schemaRef&&l(T.schemaRef)}for(let r of a.environment.resources??[])l(c(r.id,r.path,r.mediaType??"application/octet-stream",r.visibility==="policy_visible"?"policy":"host_private"));let d=a.graders.map(r=>{if(r.kind==="custom_verifier"){let f=c(`verifier-${r.id}`,r.module,"application/javascript","host_private"),T=we.safeParse(r.metadata.portableVerifierRef);return T.success&&T.data.contentHash===f.contentHash&&T.data.sizeBytes===f.sizeBytes&&(f=T.data),l(f,r.module),{...r,metadata:{...r.metadata,portableVerifierRef:f}}}if(r.kind==="human"||r.kind==="model_judge"){let f=new TextEncoder().encode(r.rubric),T=`graders/rubric-${N(f)}.md`;i.set(T,f);let D=c(`rubric-${r.id}`,T,"text/markdown","verifier");return l(D),w.push({path:T,role:"verifier",content:r.rubric}),{...r,metadata:{...r.metadata,portableRubricRef:D}}}return r});u&&![...R.values()].some(r=>r.asset.path===u.module&&r.sourcePath===u.module&&r.asset.visibility!=="policy")&&l(c(`metric-${p(u.module)}`,u.module,"application/javascript","host_private"));let I=me.parse(a.metadata.portableFileInventory??[]);for(let r of[...i.keys()].sort())if(!n.has(r)){let f=I.find(T=>T.sourcePath===r&&!R.has(T.asset.id));l(f?{...c(f.asset.id,r,f.asset.mediaType,f.asset.visibility),path:f.asset.path}:c(`taskset-file-${p(r)}`,r,"application/octet-stream","host_private"),r)}let{importedPackageHash:E,derivedPortableMetadata:M,...h}=a.metadata,P={...a.environment.metadata};if(P.portableExecutionResources!==void 0){let r=g.object({environment:g.unknown(),verifierSet:g.unknown().optional()}).parse(P.portableExecutionResources);P.portableExecutionResources={environment:r.environment}}let C=V.parse({...a,graders:d,metrics:x,environment:{...a.environment,metadata:P},metadata:{...h,...E===void 0?{}:{sourceImportedPackageHash:E},portableFileInventory:me.parse([...R.values()].sort((r,f)=>r.asset.id.localeCompare(f.asset.id)))}}),q=ct(C,i,[...R.values()],t);return{taskset:V.parse({...q.taskset,contentHash:U(q.taskset)}),generatedFiles:[...w,...q.generatedFiles]}}S(lt,"prepareAuthoredTasksetSource");function Is(s){let e=A(s.source);if(e.modelResources||e.learningResources)throw new Error("Binding an ordinary Reward requires an ordinary source package.");let t=Y(e);if(!t.trim())throw new Error("Add collection instructions before selecting a saved Reward.");let a=new Map,i=K(e);for(let h of i?.assets??[])a.set(h.id,h);let m=new Set([...e.taskset.tasks.flatMap(h=>h.privilegedContextRef?[h.privilegedContextRef]:[]),...[e.environment.actionSchemaRef,e.environment.observationSchemaRef,e.environment.stateSchemaRef].flatMap(h=>h?[h.id]:[])]);for(let h of m){if(a.has(h))continue;let P=e.files.find(q=>q.asset.id===h);if(!P)throw new Error(`Source Taskset context is missing: ${h}.`);let C=new TextDecoder("utf-8",{fatal:!0}).decode(W(P));a.set(h,se.parse(H({schemaVersion:"openpond.learningTextAsset.v1",id:h,revision:1,asset:P.asset,text:C})))}for(let h of s.assets){let P=e.files.find(C=>C.asset.id===h.id);if(P&&H({asset:P.asset}).contentHash!==H({asset:h.asset}).contentHash)throw new Error(`Selected Reward conflicts with a source asset: ${h.id}.`);a.set(h.id,h)}let{policy:u,environment:k,environmentRelease:x,tools:R,capabilities:n,verifierSetRelease:w}=e.taskset,c=$.parse(H({schemaVersion:"openpond.taskDefinition.v1",id:`${e.taskset.id}-definition`,revision:1,name:e.taskset.id,description:"",instructions:t,category:"custom",familyNamespace:e.taskset.id,inputSchema:{type:"object"},outputSchema:{type:"object"},rewardBinding:v(s.rewardBinding),harness:null,execution:{policy:u,environment:k,environmentRelease:x,tools:R,capabilities:n,verifierSetRelease:w}})),l=ne({...s,assets:[...a.values()],source:{taskset:e.taskset,taskDefinition:c,instructionMode:"per_task",executionResources:{environment:e.environment,verifierSet:e.verifierSet},...i?{execution:i.execution}:{}}}),d=new Map(e.files.map(h=>[h.asset.id,h]));for(let h of l.assets){let P="";for(let C of new TextEncoder().encode(h.text))P+=String.fromCharCode(C);d.set(h.id,{asset:h.asset,base64:btoa(P)})}let{taskset:I,executionResources:E,...M}=l;return Q({schemaVersion:"openpond.tasksetPackage.v1",taskset:I,...E,modelResources:M,files:[...d.values()]})}S(Is,"bindOrdinaryModelTasksetReward");function pt(s){let{request:e,package:t}=s,a=t.learningResources;if(!a)throw new B("model_review_batch_required",422);let i=z(t.taskset),m=`model-review-${p([s.scope,e.modelId,e.operationId])}`,u=new Map(e.examples.map(o=>[p(o.evidence),o])),k=new Set(a.evidence.map(o=>p(v(o)))),x=new Map(a.decisions.map(o=>[p(o.evidence),o]));if(u.size!==e.examples.length||e.examples.some(o=>!k.has(p(o.evidence))))throw new B("model_review_evidence_mismatch",409);for(let o of[s.binding,...s.rewards,...s.assets])Be(o);Me(s.binding,s.rewards);let R=new Map;for(let o of s.binding.sources){let y=s.rewards.find(le=>j(v(le),o.reward)),{contentHash:_,...L}=y;R.set(y.contentHash,He({...L,id:`${m}-reward-${y.contentHash}`,revision:1}))}let n=[...R.values()],{contentHash:w,recipeRef:c,...l}=s.binding,d=Ee({...l,id:`${m}-binding`,revision:1,sources:s.binding.sources.map(o=>({...o,reward:v(R.get(o.reward.contentHash))}))},n),I=n.flatMap(o=>[...o.assets,..."verifierRef"in o.implementation?[o.implementation.verifierRef]:[],..."rubricRef"in o.implementation?[o.implementation.rubricRef]:[],..."inputContract"in o.implementation?[o.implementation.inputContract]:[]]),E=[...new Map(I.map(o=>{let y=s.assets.find(_=>_.id===o.id);if(!y)throw new B("model_review_reward_asset_missing",422);if(ae(y,o),o.visibility==="policy")throw new B("reward_asset_visibility_invalid",422);return[y.id,y]})).values()],{environmentRelease:M,verifierSetRelease:h,...P}=i.definition.execution,{contentHash:C,...q}=i.definition,r=$.parse(H({...q,...e.definition,id:`${m}-definition`,revision:1,rewardBinding:v(d),execution:{...P,policy:{...P.policy,hiddenGraderRefs:De(d,n).filter(o=>o.privileged).map(o=>o.id)}}})),f=ee.parse(H({schemaVersion:"openpond.learningSource.v1",id:m,revision:1,name:`${r.name} review`,kind:"direct",taskDefinition:v(r),enabled:!0,allowedSplits:[...new Set(a.evidence.map(o=>o.submission.split))],mapping:null,adapterVersion:null,reviewOrigin:{modelId:e.modelId,packageHash:t.contentHash,taskset:v(t.taskset),batch:v(a.batch),rewardBinding:v(s.binding)}})),T=a.evidence.map(o=>{let y=u.get(p(v(o))),_=`review-${o.contentHash}`,L=p({instructions:r.instructions,inputSchema:r.inputSchema,outputSchema:r.outputSchema,requiredOutputs:r.requiredOutputs??[],input:y?.input??o.submission.input})!==p({instructions:i.definition.instructions,inputSchema:i.definition.inputSchema,outputSchema:i.definition.outputSchema,requiredOutputs:i.definition.requiredOutputs??[],input:o.submission.input});return X.parse(H({schemaVersion:"openpond.taskEvidence.v1",id:Ae(f.id,o.submission.exampleId,_),revision:1,source:v(f),submission:{...o.submission,sourceId:f.id,taskDefinition:v(r),attemptId:_,observedOutput:L?null:o.submission.observedOutput,idempotencyKey:`${m}-${o.contentHash}`,...y?.input===void 0?{}:{input:y.input},...y?.expected===void 0?{}:{expected:y.expected},...y?.evaluatorContext===void 0?{}:{evaluatorContext:y.evaluatorContext}},supersedes:v(o),correctionFeedbackId:null,receivedAt:s.now}))}),D=T.flatMap(o=>{let y=u.get(p(o.supersedes)),_=x.get(p(o.supersedes)),L=y?.proposedTarget===void 0?_.approvedTarget:y.proposedTarget;return L===null?[]:[te.parse({schemaVersion:"openpond.taskFeedbackRecord.v1",id:`feedback-${p([m,o.id])}`,revision:1,submission:{schemaVersion:"openpond.taskFeedback.v1",sourceId:f.id,idempotencyKey:`${m}-${o.id}`,exampleId:o.submission.exampleId,attemptId:o.submission.attemptId,expectedEvidenceHash:o.contentHash,occurredAt:s.now,kind:"target_correction",value:L,note:"Proposed target for the revised task. Grade and review before admission."},status:"pending_review",evidence:v(o),createdAt:s.now,review:null})]});return{source:f,definition:r,binding:d,rewards:n,assets:E,evidence:T,proposals:D}}S(pt,"prepareModelBatchReview");var Ue=S(s=>`model-batch-review-${p([s.modelId,s.operationId])}`,"operation");function _s(s){let e=A(s);if(!e.learningResources)throw new B("model_review_batch_required",422);let t=z(e.taskset);return Ye.parse({schemaVersion:"openpond.modelBatchReviewInspection.v1",packageHash:e.contentHash,definition:t.definition,binding:t.binding,evidence:e.learningResources.evidence,decisions:e.learningResources.decisions})}S(_s,"inspectModelBatchPackage");async function ft(s,e){let t=Pe.parse(e),a=await s.operation(Ue(t));if(!a)return null;if(a.requestHash!==p(t))throw new B("learning_idempotency_conflict",409);return Ze(s,t,a.resources)}S(ft,"findModelBatchReview");async function Bs(s,e){let t=Pe.parse(e.request),a=await ft(s,t);if(a)return a;let i=A(e.package);if(!i.learningResources)throw new B("model_review_batch_required",422);let m=z(i.taskset),u=t.rewardBindingRef,k=!u||j(u,v(m.binding)),x=k?m.binding:await ve(s,"binding",u),R=k?m.rewards:await Promise.all(x.sources.map(d=>ve(s,"reward",d.reward))),n=new Set(R.flatMap(d=>[...d.assets,..."verifierRef"in d.implementation?[d.implementation.verifierRef]:[],..."rubricRef"in d.implementation?[d.implementation.rubricRef]:[],..."inputContract"in d.implementation?[d.implementation.inputContract]:[]]).map(d=>d.id)),w=k?i.learningResources.assets:await Promise.all([...n].map(d=>he(s,"asset",d,1))),c=pt({...e,request:t,package:i,binding:x,rewards:R,assets:w}),l=[];for(let d of c.assets){let I=await s.get("asset",d.id,1);if(I&&I.contentHash!==d.contentHash)throw new B("model_review_asset_conflict",409);I||await s.put("asset",d,0)}for(let d of c.rewards)await s.put("reward",d,0);await s.put("binding",c.binding,0),await s.put("definition",c.definition,0),await s.put("source",c.source,0,{parentId:t.modelId}),l.push({kind:"source",id:c.source.id,revision:1});for(let d of c.evidence)await s.put("evidence",d,0,{parentId:c.source.id}),l.push({kind:"evidence",id:d.id,revision:1});for(let d of c.proposals)await s.put("feedback",d,0,{parentId:d.evidence.id,status:d.status}),l.push({kind:"feedback",id:d.id,revision:1});return await s.saveOperation(Ue(t),{requestHash:p(t),resources:l}),Ze(s,t,l)}S(Bs,"beginModelBatchReview");async function Ze(s,e,t){let a=await Promise.all(t.map(i=>he(s,i.kind,i.id,i.revision)));return Qe.parse({schemaVersion:"openpond.modelBatchReviewReceipt.v1",operationId:e.operationId,modelId:e.modelId,source:a.find(i=>i.schemaVersion==="openpond.learningSource.v1"),evidence:a.filter(i=>i.schemaVersion==="openpond.taskEvidence.v1"),proposals:a.filter(i=>i.schemaVersion==="openpond.taskFeedbackRecord.v1")})}S(Ze,"readReceipt");function Cs(s){let e=A(s.package),t=e.taskset,a=e.modelResources,i=e.learningResources?z(t):void 0,m=Ge.parse({schemaVersion:"openpond.uploadedFileDatasetSource.v1",kind:"uploaded_file",id:`package-source-${p({profileId:s.profileId,packageHash:e.contentHash})}`,profileId:s.profileId,title:s.name,sourceHash:e.contentHash,occurredAt:s.createdAt,licensingStatus:"pending",secretScanStatus:"pending",piiScanStatus:"pending",originalFileNames:["taskset-package.json"],mediaTypes:["application/json"],sourceFileHashes:[e.contentHash],totalBytes:new TextEncoder().encode(JSON.stringify(e)).byteLength,parserVersion:"openpond.tasksetPackage.v1",metadata:{}}),u=Ke({profileId:s.profileId,id:`${t.id}-import`,name:s.name,now:s.createdAt}),k=[];for(let c of t.graders)if(c.kind==="custom_verifier"){let l=a?.assets.find(E=>E.id===c.verifierRef.id),d=e.files.find(E=>E.asset.id===c.verifierRef.id);if(!d)throw new Error(`Imported verifier source is missing: ${c.id}.`);let I=Xe(c.verifierRef.contentHash);k.some(E=>E.path===I)||k.push({path:I,role:"verifier",content:l?ae(l,c.verifierRef):new TextDecoder("utf-8",{fatal:!0}).decode(W(d))})}let x=t.metadata.ordinaryAuthoring??t.metadata.starterAuthoring,R=We.array().max(1e5).parse(x?.graderFixtures??[]),n=t.environment.kind==="text"?"chat":t.environment.kind==="custom_program"?"program":t.environment.kind,w=V.parse({schemaVersion:"openpond.taskset.v1",id:t.id,revision:t.revision,profileId:s.profileId,profileRelease:null,createImproveRunId:null,name:s.name,objective:Y(e),status:"needs_review",sourceRefs:[m],datasetArtifact:null,policy:t.policy,environment:{...u.environment,kind:n,entrypoint:t.environment.entrypoint,resources:Ne.array().max(1e4).parse(t.metadata.environmentResources??[]),stateful:t.environment.stateful,deterministicSeeds:t.environment.deterministicSeeds,toolNames:t.tools.map(c=>c.name),defaultTimeoutMs:t.environment.defaultTimeoutMs,networkPolicy:t.environment.networkPolicy,metadata:{runtimeSourceTasksetId:ut(s.profileId,e.contentHash),portableEnvironment:t.environment,portableTools:t.tools,portableExecutionResources:{environment:e.environment,verifierSet:e.verifierSet}}},capabilities:{...u.capabilities,taskKind:n==="chat"?"chat":n==="program"?"custom_program":"single_agent",compatibleMethods:["none"],requiresTools:t.tools.length>0,requiresState:t.environment.stateful,rewardKinds:[...new Set(t.graders.map(c=>c.kind==="human"?"human":c.kind==="model_judge"?"model_judge":"deterministic"))]},tasks:t.tasks.map(c=>({...c,schemaVersion:"openpond.taskData.v1",sourceRefs:[m.id],assets:c.artifactRefs.map(l=>({id:l.id,sourceRefId:m.id,artifactRef:l.path,fileName:l.path.split("/").at(-1),mediaType:l.mediaType,sha256:l.contentHash,sizeBytes:l.sizeBytes,split:c.split,metadata:{portableAsset:l}})),...c.requiredOutputs?{requiredOutputs:c.requiredOutputs.map(l=>({...l,schemaRef:l.schemaRef?.id??null,maxBytes:l.maxBytes??void 0}))}:{},metadata:{portableTaskRecord:c,exampleOrigin:"imported"}})),graders:a?Te(a.rewardBinding,a.rewards,a.assets):i?Te(i.binding,i.rewards,e.learningResources.assets):Je(e),graderFixtures:R,learningSignals:u.learningSignals,...t.metrics?{metrics:t.metrics}:{},authoringProvenance:{schemaVersion:"openpond.taskAuthoringProvenance.v1",model:null,modelConfig:{},skillHash:p("openpond-package-import-v1"),promptTemplateVersion:"package-import-v1",buildIntent:"discovery",buildSpecification:null,evidenceHashes:[e.contentHash],tasksetSdkVersion:"package-import-v1",sourceCommit:null,repairHistory:[],createdAt:s.createdAt},readiness:null,contentHash:"00000000",createdAt:s.createdAt,updatedAt:s.createdAt,metadata:{importedPackageHash:e.contentHash,...i?{learning:i}:{},portableFileInventory:e.files.map(c=>({asset:c.asset,sourcePath:c.asset.path})),...a?{taskDefinition:v(a.taskDefinition),rewardBinding:v(a.rewardBinding),rewardExecution:{binding:a.rewardBinding,rewards:a.rewards}}:{},portableCapabilities:t.capabilities,derivedPortableMetadata:t.metadata,...t.metadata.modelTasksetDerivation?{modelTasksetDerivation:t.metadata.modelTasksetDerivation}:{}}});return{package:e,taskset:V.parse({...w,contentHash:U(w)}),generatedFiles:k}}S(Cs,"prepareImportedTasksetPackage");function ut(s,e){return`package-${p({profileId:s,packageHash:e})}`}S(ut,"tasksetPackageSourceId");var ht=g.object({draft:ie,filePaths:g.array(g.object({assetId:g.string().min(1),paths:g.array(re).min(1).max(1e4)}).strict()).max(1e4)}).strict();function Vs(s){let e=A(s.source),t=ie.parse(s.sourceDraft),a=G.parse(s.preparation);if(e.contentHash!==a.sourcePackageHash||!j(v(e.taskset),a.sourceTasksetRef))throw new Error("Taskset draft preparation differs from its source package.");if(e.learningResources)throw new Error("Reviewed Tasksets require their reviewed authoring workflow.");if(!!e.modelResources!=(a.authoringGraph==="bound"))throw new Error("Taskset draft authoring graph differs from its source.");let i=me.parse(t.metadata.portableFileInventory??[]),m=S(n=>ce(n)?`source-artifacts/${e.contentHash}/${p(n)}/${n.split("/").at(-1)}`:n,"sourcePath");if([...t.tasks.flatMap(n=>(n.assets??[]).map(w=>w.artifactRef)),...(t.environment.resources??[]).map(n=>n.path),...e.taskset.tasks.flatMap(n=>(n.requiredOutputs??[]).flatMap(w=>w.schemaRef?[w.schemaRef.path]:[])),...t.metrics.customAggregator?[t.metrics.customAggregator.module]:[],...t.graders.flatMap(n=>n.kind==="custom_verifier"?[n.module]:[])].some(ce))throw new Error("A referenced source asset occupies a reserved Taskset authoring path.");let k=e.files.map(n=>{let w=new Set([n.asset.path]);for(let c of i)c.asset.id===n.asset.id&&w.add(c.sourcePath);for(let c of t.tasks)for(let l of c.assets??[])l.id===n.asset.id&&w.add(l.artifactRef);for(let c of e.taskset.graders)if(c.kind==="custom_verifier"&&c.verifierRef.id===n.asset.id){let l=t.graders.find(d=>d.id===c.id);l?.kind==="custom_verifier"&&w.add(l.module)}return{assetId:n.asset.id,paths:[...w].map(m)}}),x={...t.metadata};if(e.modelResources)for(let n of["taskDefinition","rewardBinding","rewardExecution","derivedPortableMetadata","modelTasksetDerivation","importedPackageHash"])delete x[n];let R=ie.parse({...t,id:a.draftId,revision:1,status:"draft",graders:t.graders.map(n=>({...n,metadata:{...n.metadata,portableGrader:e.taskset.graders.find(w=>w.id===n.id)}})),environment:{...t.environment,metadata:{...t.environment.metadata,portableExecutionResources:{environment:e.environment}}},modelScope:{modelId:a.lineage.owner.modelId,expectedModelRevision:s.expectedModelRevision,source:a},publishedTasksetRef:a.tasksetRevision>1?a.sourceTasksetRef:null,metadata:{...x,modelTasksetAuthoring:a.lineage,portableFileInventory:i.map(n=>({...n,sourcePath:m(n.sourcePath),asset:{...n.asset,id:ce(n.sourcePath)?`source-artifact-${p({packageHash:e.contentHash,assetId:n.asset.id})}`:n.asset.id,path:m(n.asset.path)}}))}});return ht.parse({draft:R,filePaths:k})}S(Vs,"prepareTasksetDraftSource");export{Pe as a,nt as b,ot as c,me as d,mt as e,lt as f,Is as g,_s as h,ft as i,Bs as j,Cs as k,ut as l,ht as m,Vs as n};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{b as de}from"./chunk-22UARBPW.js";import{a as fe,c as ge,d as ye,f as Re,g as Ae,i as Ce,j as Oe}from"./chunk-JEVA7YQL.js";import{A as z,B as J,C as $,D as V,E as Y,F as Q,G as X,H as Z,I as ee,J as te,K as ne,L as oe,M as se,N as re,O as ae,Q as le,V as pe,W as ie,X as ce,Y as ue,Z as me,_ as he,c as E,d as b,e as x,f as L,g as B,h as D,i as I,j as v,l as U,o as M,p as _,q as H,r as N,s as q,u as k,v as K,w as F,x as G,y as j,z as W}from"./chunk-Z6F6PYF4.js";import{a as P,b as w}from"./chunk-GLUWATL5.js";import{a as s}from"./chunk-FTQLQJQV.js";function xe(t,e=14){if(t.length<e+1)return null;let r=0,o=0;for(let l=1;l<=e;l+=1){let m=t[l]-t[l-1];m>=0?r+=m:o-=m}let a=r/e,i=o/e;for(let l=e+1;l<t.length;l+=1){let m=t[l]-t[l-1],d=m>0?m:0,n=m<0?-m:0;a=(a*(e-1)+d)/e,i=(i*(e-1)+n)/e}return i===0?100:100-100/(1+a/i)}s(xe,"computeRsi");function T(t,e){if(t.length<e)return[];let r=[],o=0;for(let a=0;a<t.length;a+=1)o+=t[a],a>=e&&(o-=t[a-e]),a>=e-1&&r.push(o/e);return r}s(T,"computeSmaSeries");function Le(t,e){let r=T(t,e);return r.length>0?r[r.length-1]:null}s(Le,"computeSma");function A(t,e){if(t.length<e)return[];let r=2/(e+1),a=t.slice(0,e).reduce((p,l)=>p+l,0)/e,i=[a];for(let p=e;p<t.length;p+=1)a=t[p]*r+a*(1-r),i.push(a);return i}s(A,"computeEmaSeries");function Be(t,e){let r=A(t,e);return r.length>0?r[r.length-1]:null}s(Be,"computeEma");function De(t){let e=A(t,12),r=A(t,26);if(e.length===0||r.length===0)return null;let o=e.length-r.length,a=r.map((m,d)=>e[d+o]-m),i=A(a,9);if(i.length===0)return null;let p=a[a.length-1],l=i[i.length-1];return{macd:p,signalLine:l,histogram:p-l}}s(De,"computeMacd");function Ie(t,e,r,o){if(t.length<o)return null;let a=e==="ema"?A(t,r):T(t,r),i=e==="ema"?A(t,o):T(t,o);if(a.length===0||i.length===0)return null;let p=a.length-i.length;if(p<0)return null;let l=i.length-1,m=a[l+p],d=i[l],n=l-1,c=n>=0?a[n+p]:null,u=n>=0?i[n]:null,h="neutral";return c!=null&&u!=null?c<=u&&m>d?h="bullish-cross":c>=u&&m<d?h="bearish-cross":m>d?h="bullish":m<d&&(h="bearish"):m>d?h="bullish":m<d&&(h="bearish"),{fast:m,slow:d,signal:h}}s(Ie,"computeMaCross");function ve(t,e=20,r=2){if(t.length<e)return null;let o=t.slice(-e),a=o.reduce((l,m)=>l+m,0)/e,i=o.reduce((l,m)=>l+Math.pow(m-a,2),0)/e,p=Math.sqrt(i);return{middle:a,upper:a+r*p,lower:a-r*p}}s(ve,"computeBollinger");function Ue(t,e=24){if(t.length<2)return null;let r=t[t.length-1],o=Math.max(0,t.length-1-e),a=t[o];if(a===0)return null;let i=(r-a)/a*100;return{previous:a,percent:i}}s(Ue,"computePriceChange");function Me(t,e=14){if(t.length<e+1)return null;let r=[];for(let i=1;i<t.length;i+=1){let p=t[i],l=t[i-1],m=p.high-p.low,d=Math.abs(p.high-l.close),n=Math.abs(p.low-l.close);r.push(Math.max(m,d,n))}return r.length<e?null:r.slice(-e).reduce((i,p)=>i+p,0)/e}s(Me,"computeAtr");function Te(t){return t.replace(/\/$/,"")}s(Te,"resolveUrl");function _e(t){let e=process.env.OPENPOND_BASE_URL,r=t.baseUrl||e||P;return Te(r.trim())}s(_e,"resolveBaseUrl");function He(t){let e=process.env.OPENPOND_API_URL,r=t.apiUrl||e||w;return Te(r.trim())}s(He,"resolveApiUrl");function Ne(t,e){return fe({apiBaseUrl:e,opChatApiBaseUrl:t.opChatApiUrl,chatApiBaseUrl:t.chatApiUrl})}s(Ne,"resolveChatApiUrl");function qe(t,e){let r=process.env.OPENPOND_TOOL_URL,o=t.toolUrl||r||e;return Te(o.trim())}s(qe,"resolveToolUrl");function ke(t){let e=t.apiKey?.trim();if(e)return e;let r=process.env.OPENPOND_API_KEY?.trim();if(r)return r;throw new Error("OPENPOND_API_KEY is required")}s(ke,"resolveApiKey");function Ke(t){let e=t.split("/").filter(Boolean);if(e.length!==2)throw new Error("expected <handle>/<repo>");return{handle:e[0],repo:e[1]}}s(Ke,"parseHandleRepo");function Pe(t){return(t||"").trim().toLowerCase()}s(Pe,"normalizeRepoName");function Fe(t){if(!t||typeof t!="object")return{name:"unknown",raw:t};let e=t,r=e.profile||e.function,o=typeof e.name=="string"?e.name:typeof r?.name=="string"?r.name:"unknown",a=typeof e.description=="string"?e.description:typeof r?.description=="string"?r.description:void 0;return{name:o,description:a,raw:t}}s(Fe,"normalizeToolSummary");function Ge(t){if(!t)return[];if(Array.isArray(t.toolsJson))return t.toolsJson;if(t.metadataJson&&typeof t.metadataJson=="object"){let e=t.metadataJson.tools;if(Array.isArray(e))return e}return[]}s(Ge,"extractDeploymentTools");async function O(t){let{handle:e,repo:r}=Ke(t.target),o=await Se({apiBase:t.apiBase,apiKey:t.apiKey,useCache:t.useCache,cacheTtlMs:t.cacheTtlMs,forceRefresh:t.forceRefresh}),a=Pe(r),i=o.find(p=>p.handle&&p.handle!==e?!1:[p.repo,p.gitRepo,p.id].map(Pe).includes(a));if(!i)throw new Error(`app not found for ${e}/${r}`);return{app:i,handle:e,repo:r}}s(O,"resolveAppTarget");async function Se(t){if(t.useCache&&!t.forceRefresh){let r=await ce({apiBase:t.apiBase,apiKey:t.apiKey,ttlMs:t.cacheTtlMs});if(r)return r}let e=await v(t.apiBase,t.apiKey);return t.useCache&&await ue({apiBase:t.apiBase,apiKey:t.apiKey,apps:e}),e}s(Se,"fetchAppsWithCache");async function we(t){if(t.useCache&&!t.forceRefresh){let o=await me({apiBase:t.apiBase,apiKey:t.apiKey,ttlMs:t.cacheTtlMs});if(o)return o}let e=await k(t.apiBase,t.apiKey),r=Array.isArray(e.tools)?e.tools:[];return t.useCache&&await he({apiBase:t.apiBase,apiKey:t.apiKey,tools:r}),r}s(we,"fetchToolsWithCache");function je(t){if(!t)return"POST";let e=t.toUpperCase();switch(e){case"GET":case"POST":case"PUT":case"DELETE":return e;default:throw new Error("method must be GET, POST, PUT, or DELETE")}}s(je,"normalizeMethod");async function We(t,e){let r,o,a;return await de(t,{...e,onConversationId:s(i=>{r=i,e?.onConversationId?.(i)},"onConversationId"),onItems:s(i=>{for(let p of i){let l=p;!o&&typeof l.appId=="string"&&(o=l.appId,e?.onAppId?.(l.appId)),!a&&typeof l.deploymentId=="string"&&(a=l.deploymentId,e?.onDeploymentId?.(l.deploymentId))}e?.onItems?.(i)},"onItems")}),{conversationId:r,appId:o,deploymentId:a}}s(We,"consumeAgentCreateStream");function Pt(t){let e=ke(t),r=_e(t),o=He(t),a=Ne(t,o),i=qe(t,r),p=t.cacheTtlMs??ie,l=t.useCache!==!1,m=s(async()=>{l&&await Promise.all([Se({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:!0}),we({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:!0})])},"refreshCache"),d=s(async(n,c)=>(await D(o,e,n,{branch:c}))?.id??null,"resolveLatestDeploymentId");return{baseUrl:r,apiUrl:o,chatApiUrl:a,toolUrl:i,apiKey:e,account:{get:s(async()=>se(o,e),"get"),health:s(async()=>re(o,e),"health")},chat:{providers:s(async()=>Re({apiBaseUrl:a,token:e}),"providers"),provider:s(async n=>Ae({apiBaseUrl:a,token:e,provider:n}),"provider"),models:s(async()=>ge({apiBaseUrl:a,token:e}),"models"),model:s(async n=>ye({apiBaseUrl:a,token:e,model:n}),"model"),send:s(async n=>Ce({...n,apiBaseUrl:a,token:e}),"send"),stream:s(n=>Oe({...n,apiBaseUrl:a,token:e}),"stream")},tool:{list:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.deploymentId||await d(u.id,c?.branch);if(!h)return{app:u,deploymentId:null,tools:[]};let g=await I(o,e,h),y=Ge(g).map(Fe);return{app:u,deploymentId:h,tools:y}},"list"),run:s(async(n,c,u)=>{let{app:h}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:u?.forceRefresh}),g=u?.deploymentId||await d(h.id,u?.branch);if(!g)throw new Error("no deployments found");let f=je(u?.method);return pe(i,e,{appId:h.id,deploymentId:g,toolName:c,method:f,body:u?.body,headers:u?.headers})},"run")},deploy:{watch:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.deploymentId||await d(u.id,c?.branch);if(!h)throw new Error("no deployments found");let g=c?.intervalMs??5e3,f=c?.timeoutMs??240*1e3,y=[],S=new Set,Ee=Date.now(),R=null;for(;Date.now()-Ee<f;){let be=await L(o,e,h);for(let C of be)S.has(C.id)||(S.add(C.id),y.push(C),c?.onLog?.(C));if(R=(await B(o,e,h)).status??null,c?.onStatus?.(R),R==="failed")return{deploymentId:h,status:R,logs:y};if(R==="running"||R==="deployed")return{deploymentId:h,status:R,logs:y};await new Promise(C=>setTimeout(C,g))}return{deploymentId:h,status:"timeout",logs:y}},"watch")},template:{status:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh});return M(o,e,u.id)},"status"),branches:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh});return _(o,e,u.id)},"branches"),update:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.environment==="preview"?"preview":"production";return H(o,e,u.id,{environment:h})},"update")},opentool:{recipesList:s(async(n={})=>F(o,e,n),"recipesList"),recipesSearch:s(async n=>G(o,e,n),"recipesSearch"),recipeGet:s(async n=>j(o,e,n),"recipeGet"),rulesGet:s(async n=>W(o,e,n),"rulesGet")},apps:{list:s(async n=>{let c=await Se({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:n?.forceRefresh});return n?.handle?c.filter(u=>u.handle===n.handle):c},"list"),tools:s(async n=>we({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:n?.forceRefresh}),"tools"),performance:s(async n=>ne(o,e,{appId:n?.appId}),"performance"),summary:s(async n=>oe(o,e,n.appId),"summary"),schedules:s(async n=>K(o,e,n.appId),"schedules"),schedulesStart:s(async n=>{let{appId:c,...u}=n;return z(o,e,c,u)},"schedulesStart"),schedulesStop:s(async n=>J(o,e,n.appId),"schedulesStop"),schedulesStopCurrent:s(async()=>$(o,e),"schedulesStopCurrent"),scheduleRunNow:s(async n=>V(o,e,n),"scheduleRunNow"),scheduleDelete:s(async n=>Y(o,e,n.appId,n.scheduleId),"scheduleDelete"),scheduleExecutionLogs:s(async n=>Q(o,e,n.scheduleId,{limit:n.limit}),"scheduleExecutionLogs"),scheduleExecutionLog:s(async n=>Z(o,e,n.runId),"scheduleExecutionLog"),deploymentScheduleExecutionLogs:s(async n=>X(o,e,n.deploymentId,{limit:n.limit}),"deploymentScheduleExecutionLogs"),executionTimeline:s(async n=>ee(o,e,n.appId,{limit:n.limit}),"executionTimeline"),assistantRun:s(async n=>ae(o,e,n),"assistantRun"),agentCreate:s(async(n,c)=>{let{refreshCache:u,...h}=n,g={...h,streamDeployLogs:h.streamDeployLogs??!0},f=await te(o,e,g);if(!f.ok){let S=await f.text().catch(()=>"");throw new Error(`agent create failed: ${f.status} ${S}`)}let y=await We(f,c);if(l&&u!==!1)try{await m()}catch{}return y},"agentCreate"),toolsExecute:s(async n=>le(o,e,n),"toolsExecute"),deploy:s(async n=>E(o,e,n.appId,{environment:n.environment,commitSha:n.commitSha,branch:n.branch}),"deploy"),startApp:s(async n=>{let{appId:c,...u}=n;return x(o,e,c,u)},"startApp"),promotePreview:s(async n=>{let{appId:c,...u}=n;return b(o,e,c,u)},"promotePreview"),envGet:s(async n=>q(o,e,n.appId),"envGet"),envSet:s(async n=>N(o,e,n.appId,{envVars:n.envVars}),"envSet")},repo:{create:s(async n=>{let{refreshCache:c,...u}=n,h=await U(o,e,u);if(l&&c!==!1)try{await m()}catch{}return h},"create")},cache:{refresh:m}}}s(Pt,"createClient");export{xe as a,T as b,Le as c,A as d,Be as e,De as f,Ie as g,ve as h,Ue as i,Me as j,We as k,Pt as l};
|
|
2
|
+
import{a as fe,c as ge,d as ye,f as Re,g as Ae,i as Ce,j as Oe}from"./chunk-JEVA7YQL.js";import{b as de}from"./chunk-22UARBPW.js";import{A as z,B as J,C as $,D as V,E as Y,F as Q,G as X,H as Z,I as ee,J as te,K as ne,L as oe,M as se,N as re,O as ae,Q as le,V as pe,W as ie,X as ce,Y as ue,Z as me,_ as he,c as E,d as b,e as x,f as L,g as B,h as D,i as I,j as v,l as U,o as M,p as _,q as H,r as N,s as q,u as k,v as K,w as F,x as G,y as j,z as W}from"./chunk-SHCKK3SU.js";import{a as P,b as w}from"./chunk-GLUWATL5.js";import{a as s}from"./chunk-FTQLQJQV.js";function xe(t,e=14){if(t.length<e+1)return null;let r=0,o=0;for(let l=1;l<=e;l+=1){let m=t[l]-t[l-1];m>=0?r+=m:o-=m}let a=r/e,i=o/e;for(let l=e+1;l<t.length;l+=1){let m=t[l]-t[l-1],d=m>0?m:0,n=m<0?-m:0;a=(a*(e-1)+d)/e,i=(i*(e-1)+n)/e}return i===0?100:100-100/(1+a/i)}s(xe,"computeRsi");function T(t,e){if(t.length<e)return[];let r=[],o=0;for(let a=0;a<t.length;a+=1)o+=t[a],a>=e&&(o-=t[a-e]),a>=e-1&&r.push(o/e);return r}s(T,"computeSmaSeries");function Le(t,e){let r=T(t,e);return r.length>0?r[r.length-1]:null}s(Le,"computeSma");function A(t,e){if(t.length<e)return[];let r=2/(e+1),a=t.slice(0,e).reduce((p,l)=>p+l,0)/e,i=[a];for(let p=e;p<t.length;p+=1)a=t[p]*r+a*(1-r),i.push(a);return i}s(A,"computeEmaSeries");function Be(t,e){let r=A(t,e);return r.length>0?r[r.length-1]:null}s(Be,"computeEma");function De(t){let e=A(t,12),r=A(t,26);if(e.length===0||r.length===0)return null;let o=e.length-r.length,a=r.map((m,d)=>e[d+o]-m),i=A(a,9);if(i.length===0)return null;let p=a[a.length-1],l=i[i.length-1];return{macd:p,signalLine:l,histogram:p-l}}s(De,"computeMacd");function Ie(t,e,r,o){if(t.length<o)return null;let a=e==="ema"?A(t,r):T(t,r),i=e==="ema"?A(t,o):T(t,o);if(a.length===0||i.length===0)return null;let p=a.length-i.length;if(p<0)return null;let l=i.length-1,m=a[l+p],d=i[l],n=l-1,c=n>=0?a[n+p]:null,u=n>=0?i[n]:null,h="neutral";return c!=null&&u!=null?c<=u&&m>d?h="bullish-cross":c>=u&&m<d?h="bearish-cross":m>d?h="bullish":m<d&&(h="bearish"):m>d?h="bullish":m<d&&(h="bearish"),{fast:m,slow:d,signal:h}}s(Ie,"computeMaCross");function ve(t,e=20,r=2){if(t.length<e)return null;let o=t.slice(-e),a=o.reduce((l,m)=>l+m,0)/e,i=o.reduce((l,m)=>l+Math.pow(m-a,2),0)/e,p=Math.sqrt(i);return{middle:a,upper:a+r*p,lower:a-r*p}}s(ve,"computeBollinger");function Ue(t,e=24){if(t.length<2)return null;let r=t[t.length-1],o=Math.max(0,t.length-1-e),a=t[o];if(a===0)return null;let i=(r-a)/a*100;return{previous:a,percent:i}}s(Ue,"computePriceChange");function Me(t,e=14){if(t.length<e+1)return null;let r=[];for(let i=1;i<t.length;i+=1){let p=t[i],l=t[i-1],m=p.high-p.low,d=Math.abs(p.high-l.close),n=Math.abs(p.low-l.close);r.push(Math.max(m,d,n))}return r.length<e?null:r.slice(-e).reduce((i,p)=>i+p,0)/e}s(Me,"computeAtr");function Te(t){return t.replace(/\/$/,"")}s(Te,"resolveUrl");function _e(t){let e=process.env.OPENPOND_BASE_URL,r=t.baseUrl||e||P;return Te(r.trim())}s(_e,"resolveBaseUrl");function He(t){let e=process.env.OPENPOND_API_URL,r=t.apiUrl||e||w;return Te(r.trim())}s(He,"resolveApiUrl");function Ne(t,e){return fe({apiBaseUrl:e,opChatApiBaseUrl:t.opChatApiUrl,chatApiBaseUrl:t.chatApiUrl})}s(Ne,"resolveChatApiUrl");function qe(t,e){let r=process.env.OPENPOND_TOOL_URL,o=t.toolUrl||r||e;return Te(o.trim())}s(qe,"resolveToolUrl");function ke(t){let e=t.apiKey?.trim();if(e)return e;let r=process.env.OPENPOND_API_KEY?.trim();if(r)return r;throw new Error("OPENPOND_API_KEY is required")}s(ke,"resolveApiKey");function Ke(t){let e=t.split("/").filter(Boolean);if(e.length!==2)throw new Error("expected <handle>/<repo>");return{handle:e[0],repo:e[1]}}s(Ke,"parseHandleRepo");function Pe(t){return(t||"").trim().toLowerCase()}s(Pe,"normalizeRepoName");function Fe(t){if(!t||typeof t!="object")return{name:"unknown",raw:t};let e=t,r=e.profile||e.function,o=typeof e.name=="string"?e.name:typeof r?.name=="string"?r.name:"unknown",a=typeof e.description=="string"?e.description:typeof r?.description=="string"?r.description:void 0;return{name:o,description:a,raw:t}}s(Fe,"normalizeToolSummary");function Ge(t){if(!t)return[];if(Array.isArray(t.toolsJson))return t.toolsJson;if(t.metadataJson&&typeof t.metadataJson=="object"){let e=t.metadataJson.tools;if(Array.isArray(e))return e}return[]}s(Ge,"extractDeploymentTools");async function O(t){let{handle:e,repo:r}=Ke(t.target),o=await Se({apiBase:t.apiBase,apiKey:t.apiKey,useCache:t.useCache,cacheTtlMs:t.cacheTtlMs,forceRefresh:t.forceRefresh}),a=Pe(r),i=o.find(p=>p.handle&&p.handle!==e?!1:[p.repo,p.gitRepo,p.id].map(Pe).includes(a));if(!i)throw new Error(`app not found for ${e}/${r}`);return{app:i,handle:e,repo:r}}s(O,"resolveAppTarget");async function Se(t){if(t.useCache&&!t.forceRefresh){let r=await ce({apiBase:t.apiBase,apiKey:t.apiKey,ttlMs:t.cacheTtlMs});if(r)return r}let e=await v(t.apiBase,t.apiKey);return t.useCache&&await ue({apiBase:t.apiBase,apiKey:t.apiKey,apps:e}),e}s(Se,"fetchAppsWithCache");async function we(t){if(t.useCache&&!t.forceRefresh){let o=await me({apiBase:t.apiBase,apiKey:t.apiKey,ttlMs:t.cacheTtlMs});if(o)return o}let e=await k(t.apiBase,t.apiKey),r=Array.isArray(e.tools)?e.tools:[];return t.useCache&&await he({apiBase:t.apiBase,apiKey:t.apiKey,tools:r}),r}s(we,"fetchToolsWithCache");function je(t){if(!t)return"POST";let e=t.toUpperCase();switch(e){case"GET":case"POST":case"PUT":case"DELETE":return e;default:throw new Error("method must be GET, POST, PUT, or DELETE")}}s(je,"normalizeMethod");async function We(t,e){let r,o,a;return await de(t,{...e,onConversationId:s(i=>{r=i,e?.onConversationId?.(i)},"onConversationId"),onItems:s(i=>{for(let p of i){let l=p;!o&&typeof l.appId=="string"&&(o=l.appId,e?.onAppId?.(l.appId)),!a&&typeof l.deploymentId=="string"&&(a=l.deploymentId,e?.onDeploymentId?.(l.deploymentId))}e?.onItems?.(i)},"onItems")}),{conversationId:r,appId:o,deploymentId:a}}s(We,"consumeAgentCreateStream");function Pt(t){let e=ke(t),r=_e(t),o=He(t),a=Ne(t,o),i=qe(t,r),p=t.cacheTtlMs??ie,l=t.useCache!==!1,m=s(async()=>{l&&await Promise.all([Se({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:!0}),we({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:!0})])},"refreshCache"),d=s(async(n,c)=>(await D(o,e,n,{branch:c}))?.id??null,"resolveLatestDeploymentId");return{baseUrl:r,apiUrl:o,chatApiUrl:a,toolUrl:i,apiKey:e,account:{get:s(async()=>se(o,e),"get"),health:s(async()=>re(o,e),"health")},chat:{providers:s(async()=>Re({apiBaseUrl:a,token:e}),"providers"),provider:s(async n=>Ae({apiBaseUrl:a,token:e,provider:n}),"provider"),models:s(async()=>ge({apiBaseUrl:a,token:e}),"models"),model:s(async n=>ye({apiBaseUrl:a,token:e,model:n}),"model"),send:s(async n=>Ce({...n,apiBaseUrl:a,token:e}),"send"),stream:s(n=>Oe({...n,apiBaseUrl:a,token:e}),"stream")},tool:{list:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.deploymentId||await d(u.id,c?.branch);if(!h)return{app:u,deploymentId:null,tools:[]};let g=await I(o,e,h),y=Ge(g).map(Fe);return{app:u,deploymentId:h,tools:y}},"list"),run:s(async(n,c,u)=>{let{app:h}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:u?.forceRefresh}),g=u?.deploymentId||await d(h.id,u?.branch);if(!g)throw new Error("no deployments found");let f=je(u?.method);return pe(i,e,{appId:h.id,deploymentId:g,toolName:c,method:f,body:u?.body,headers:u?.headers})},"run")},deploy:{watch:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.deploymentId||await d(u.id,c?.branch);if(!h)throw new Error("no deployments found");let g=c?.intervalMs??5e3,f=c?.timeoutMs??240*1e3,y=[],S=new Set,Ee=Date.now(),R=null;for(;Date.now()-Ee<f;){let be=await L(o,e,h);for(let C of be)S.has(C.id)||(S.add(C.id),y.push(C),c?.onLog?.(C));if(R=(await B(o,e,h)).status??null,c?.onStatus?.(R),R==="failed")return{deploymentId:h,status:R,logs:y};if(R==="running"||R==="deployed")return{deploymentId:h,status:R,logs:y};await new Promise(C=>setTimeout(C,g))}return{deploymentId:h,status:"timeout",logs:y}},"watch")},template:{status:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh});return M(o,e,u.id)},"status"),branches:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh});return _(o,e,u.id)},"branches"),update:s(async(n,c)=>{let{app:u}=await O({apiBase:o,apiKey:e,target:n,useCache:l,cacheTtlMs:p,forceRefresh:c?.forceRefresh}),h=c?.environment==="preview"?"preview":"production";return H(o,e,u.id,{environment:h})},"update")},opentool:{recipesList:s(async(n={})=>F(o,e,n),"recipesList"),recipesSearch:s(async n=>G(o,e,n),"recipesSearch"),recipeGet:s(async n=>j(o,e,n),"recipeGet"),rulesGet:s(async n=>W(o,e,n),"rulesGet")},apps:{list:s(async n=>{let c=await Se({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:n?.forceRefresh});return n?.handle?c.filter(u=>u.handle===n.handle):c},"list"),tools:s(async n=>we({apiBase:o,apiKey:e,useCache:l,cacheTtlMs:p,forceRefresh:n?.forceRefresh}),"tools"),performance:s(async n=>ne(o,e,{appId:n?.appId}),"performance"),summary:s(async n=>oe(o,e,n.appId),"summary"),schedules:s(async n=>K(o,e,n.appId),"schedules"),schedulesStart:s(async n=>{let{appId:c,...u}=n;return z(o,e,c,u)},"schedulesStart"),schedulesStop:s(async n=>J(o,e,n.appId),"schedulesStop"),schedulesStopCurrent:s(async()=>$(o,e),"schedulesStopCurrent"),scheduleRunNow:s(async n=>V(o,e,n),"scheduleRunNow"),scheduleDelete:s(async n=>Y(o,e,n.appId,n.scheduleId),"scheduleDelete"),scheduleExecutionLogs:s(async n=>Q(o,e,n.scheduleId,{limit:n.limit}),"scheduleExecutionLogs"),scheduleExecutionLog:s(async n=>Z(o,e,n.runId),"scheduleExecutionLog"),deploymentScheduleExecutionLogs:s(async n=>X(o,e,n.deploymentId,{limit:n.limit}),"deploymentScheduleExecutionLogs"),executionTimeline:s(async n=>ee(o,e,n.appId,{limit:n.limit}),"executionTimeline"),assistantRun:s(async n=>ae(o,e,n),"assistantRun"),agentCreate:s(async(n,c)=>{let{refreshCache:u,...h}=n,g={...h,streamDeployLogs:h.streamDeployLogs??!0},f=await te(o,e,g);if(!f.ok){let S=await f.text().catch(()=>"");throw new Error(`agent create failed: ${f.status} ${S}`)}let y=await We(f,c);if(l&&u!==!1)try{await m()}catch{}return y},"agentCreate"),toolsExecute:s(async n=>le(o,e,n),"toolsExecute"),deploy:s(async n=>E(o,e,n.appId,{environment:n.environment,commitSha:n.commitSha,branch:n.branch}),"deploy"),startApp:s(async n=>{let{appId:c,...u}=n;return x(o,e,c,u)},"startApp"),promotePreview:s(async n=>{let{appId:c,...u}=n;return b(o,e,c,u)},"promotePreview"),envGet:s(async n=>q(o,e,n.appId),"envGet"),envSet:s(async n=>N(o,e,n.appId,{envVars:n.envVars}),"envSet")},repo:{create:s(async n=>{let{refreshCache:c,...u}=n,h=await U(o,e,u);if(l&&c!==!1)try{await m()}catch{}return h},"create")},cache:{refresh:m}}}s(Pt,"createClient");export{xe as a,T as b,Le as c,A as d,Be as e,De as f,Ie as g,ve as h,Ue as i,Me as j,We as k,Pt as l};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
+
import{a as ge,b as Ge}from"./chunk-RELOOVWW.js";import{B as De,D as ze,E as Ne,F as A,G as Ke,H as Fe,l as ue,z as Be}from"./chunk-GIPSOLAY.js";import{a as Q,b as I,c as O,h as Xe,i as fe,j as he}from"./chunk-MJC26GOX.js";import{$a as Ye,D as He,M as $e,Ma as Je,P as pe,_a as Ve,b as le,ga as me,h as X,k as qe,m as Le,v as We,z as Ue}from"./chunk-JUX77H6K.js";import{a as f,e as Ae,i as Te,l as p,m as Me}from"./chunk-HZP5U2AA.js";import{b as t}from"./chunk-ES2ISFJC.js";import{a as c}from"./chunk-FTQLQJQV.js";var j=t.object({id:t.string().trim().min(1).max(240),revision:t.number().int().positive(),contentHash:t.string().regex(/^[a-f0-9]{64}$/),targetId:t.string().trim().min(1).max(240).nullable()}).strict(),ye=t.array(t.object({role:t.enum(["system","user","assistant"]),content:t.string().max(1e5)}).strict()).max(100).superRefine((o,e)=>{o.reduce((n,r)=>n+r.content.length,0)>1e5&&e.addIssue({code:"custom",message:"Evaluation prompt exceeds 100,000 characters."})});var xe=$e.extend({mode:t.enum(["nightly","approved_count"]),minimumTasks:t.number().int().min(1).max(1e4),maximumSpendUsd:t.number().positive().max(1e5),maximumDailySpendUsd:t.number().positive().max(1e6)}).strict().superRefine((o,e)=>{o.maximumDailySpendUsd<o.maximumSpendUsd&&e.addIssue({code:"custom",path:["maximumDailySpendUsd"],message:"The daily budget must cover one update."})});var E=class extends Error{static{c(this,"OpenPondProtocolError")}code;constructor(e,n){super(n),this.name="OpenPondProtocolError",this.code=e}};function P(o){return JSON.stringify(be(o))}c(P,"canonicalJson");async function Z(o){let e=new TextEncoder().encode(P(o)),n=await globalThis.crypto.subtle.digest("SHA-256",e);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")}c(Z,"canonicalSha256");function be(o){if(o===null||typeof o=="string"||typeof o=="boolean")return o;if(typeof o=="number"){if(!Number.isFinite(o))throw new E("non_json_value","Canonical JSON cannot contain a non-finite number.");return Object.is(o,-0)?0:o}if(Array.isArray(o))return o.map(e=>be(e));if(typeof o=="object"){let e=Object.getPrototypeOf(o);if(e!==Object.prototype&&e!==null)throw new E("non_json_value","Canonical JSON accepts only plain objects.");let n={};for(let r of Object.keys(o).sort()){let s=o[r];if(s===void 0||typeof s=="function"||typeof s=="symbol")throw new E("non_json_value",`Canonical JSON cannot contain ${typeof s} at ${r}.`);n[r]=be(s)}return n}throw new E("non_json_value",`Canonical JSON cannot contain ${typeof o}.`)}c(be,"normalizeCanonicalJson");var l=t.string().trim().min(1).max(500),v=t.string().regex(/^[a-f0-9]{64}$/),S=t.string().datetime({offset:!0}),_=t.object({id:l,contentHash:v}).strict(),k=_.extend({revision:t.number().int().positive()}).strict(),L=t.object({schemaVersion:t.literal("openpond.baseModelPreference.v1"),modelId:l,revision:t.string().trim().min(1).max(256).nullable(),tokenizerRevision:t.string().trim().min(1).max(256).nullable(),chatTemplateHash:t.string().trim().min(8).max(256).nullable(),modelAssetId:l.nullable(),source:t.enum(["managed","local","builtin"])}).strict(),Qe=t.enum(["sft","dpo","grpo","ppo","sdft","opd","opsd","sdpo"]),At=t.object({schemaVersion:t.string().regex(/^openpond\.[A-Za-z0-9]+Recipe\.v\d+$/),method:Qe,parameterization:t.enum(["lora","full"])}).catchall(t.unknown()),Tt=t.object({profileProjectId:l,sourceRevision:t.string().regex(/^[a-f0-9]{40,64}$/),harnessRelease:_}).strict(),Mt=t.object({profileProjectId:l,sourceRevision:t.string().regex(/^[a-f0-9]{40,64}$/),catalogHash:v,definitionId:l,harnessRelease:_,tasksetRelease:_}).strict(),Ze=t.object({tasksetRef:k.nullable().default(null),evaluationTasksetRef:k.nullable().optional(),profileSource:Tt.nullable().optional(),profileEvaluation:Mt.nullable().optional(),rewardBindingRef:k.nullable().optional(),tasksetRelease:_.nullable().default(null),harnessRelease:_.nullable().default(null),baseModel:L.nullable().default(null),method:Qe.nullable().default(null),destinationId:l.nullable().default(null),managedRolloutPlacement:t.enum(["local","remote"]).default("remote"),managedGpuPlacementObjective:t.enum(["fast","balanced","economical"]).default("balanced"),managedGpuRequirement:t.enum(["any","h100_hbm3"]).default("any"),runPreset:t.enum(["small","standard","custom","small_experiment"]).nullable().default(null),recipe:At.nullable().default(null),preferredMaximumSpendUsd:t.number().nonnegative().nullable().default(null),preferredRetentionDays:t.number().int().nonnegative().nullable().default(null)}).strict(),et=Ze.omit({managedGpuRequirement:!0}),qt=t.object({schemaVersion:t.literal("openpond.hostedModelProjectLink.v1"),apiOrigin:t.string().url().refine(o=>new URL(o).origin===o,"Use a canonical API origin.").nullable().default(null),teamId:l,projectId:l,portableProjectId:l,revision:t.number().int().positive(),etag:v,syncedSourceRevision:t.number().int().positive(),syncedAt:S,tasksets:t.array(t.object({localTasksetId:l,localTasksetHash:v.nullable().default(null),releaseId:l,releaseRevision:t.number().int().positive(),releaseHash:v,packageHash:v.nullable().default(null),hostedTasksetId:l,syncedAt:S}).strict()).max(1e4).default([])}).strict(),Lt=t.object({localTasksetId:l,releaseId:l,releaseRevision:t.number().int().positive(),releaseHash:v,state:t.enum(["syncing","synced","sync_failed"]),hostedTasksetId:l.nullable().default(null),lastAttemptAt:S,syncedAt:S.nullable().default(null),lastError:t.string().trim().min(1).max(5e3).nullable().default(null)}).strict(),Wt=t.object({schemaVersion:t.literal("openpond.modelProject.v2"),id:l,profileId:l,revision:t.number().int().positive().default(1),name:t.string().trim().min(1).max(200),objective:t.string().trim().max(5e3).nullable(),defaultBaseModel:L.nullable(),defaultDestinationId:l.nullable(),trainingSetup:Ze,hosted:qt.nullable().default(null),tasksetSyncs:t.array(Lt).max(1e4).default([]),createdAt:S,updatedAt:S}).strict(),Ut=Wt.pick({id:!0,profileId:!0,name:!0,objective:!0,defaultBaseModel:!0,defaultDestinationId:!0,trainingSetup:!0}),Cn=t.object({schemaVersion:t.literal("openpond.modelProjectSave.v1"),operationId:l,expectedRevision:t.number().int().nonnegative(),project:Ut,learning:xe.optional()}).strict().superRefine((o,e)=>{o.learning&&o.expectedRevision!==0&&e.addIssue({code:"custom",path:["learning"],message:"Use learning settings to edit an existing Model's policy."})}),jn=t.object({schemaVersion:t.literal("openpond.modelProjectConfigurationCheck.v1"),configurationHash:v,projectId:l,expectedRevision:t.number().int().nonnegative(),checkedAt:S,canSave:t.boolean(),deferred:t.array(t.enum(["base_model","taskset"])).max(2),findings:t.array(t.object({code:l,severity:t.enum(["error","warning"]),message:t.string().min(1).max(5e3),field:t.string().min(1).max(500).nullable()}).strict()).max(100)}).strict(),En=t.object({id:l,name:t.string().min(1).max(500),available:t.boolean(),preference:L}).strict();var _n=t.object({schemaVersion:t.literal("openpond.hostedModelProjectSync.v2"),portableProjectId:l,name:t.string().trim().min(1).max(200),objective:t.string().trim().max(5e3).nullable(),defaultBaseModel:L.nullable(),defaultDestinationId:l.nullable(),trainingSetup:et,sourceRevision:t.number().int().positive(),sourceUpdatedAt:S,expectedEtag:v.nullable().default(null)}).strict(),Ht=t.object({id:l,teamId:l,portableProjectId:l,name:t.string().trim().min(1).max(200),objective:t.string().trim().max(5e3).nullable(),defaultBaseModel:L.nullable(),defaultDestinationId:l.nullable(),trainingSetup:et,sourceRevision:t.number().int().positive(),sourceUpdatedAt:S,revision:t.number().int().positive(),etag:v,createdAt:S,updatedAt:S}).strict(),$t=t.object({kind:t.enum(["taskset_release","harness_release","dataset_release","evidence_set","model_version","reward_model_version","evaluation_receipt"]),ref:_,role:t.string().trim().min(1).max(200).nullable().default(null),updatedAt:S}).strict(),An=t.object({project:Ht,resources:t.array($t).max(1e4),jobCount:t.number().int().nonnegative(),latestJobIds:t.array(l).max(100)}).strict(),Tn=t.object({schemaVersion:t.literal("openpond.modelProjectApiError.v2"),code:t.string().trim().min(1).max(200),message:t.string().trim().min(1).max(5e3),retryable:t.boolean().default(!1),requestId:t.string().trim().min(1).max(500).nullable().default(null),details:t.record(t.string(),t.unknown()).default({})}).strict();var tt=t.object({schemaVersion:t.literal("openpond.experimentAttemptGrade.v1"),selectionHash:t.string().regex(/^[a-f0-9]{64}$/),grades:t.array(X).min(1).max(100),score:t.number().min(0).max(1).nullable(),passed:t.boolean(),rewardEligible:t.boolean(),gradingStatus:t.enum(["scored","unscorable","not_configured"]),failureClass:Te.nullable(),contentHash:t.string().regex(/^[a-f0-9]{64}$/)}).strict().superRefine((o,e)=>{let{contentHash:n,...r}=o;p(r)!==n&&e.addIssue({code:"custom",message:"Experiment grading integrity failed."});let s=o.grades.flatMap(i=>i.components);(s.length!==o.grades.length||new Set(s.map(i=>i.graderId)).size!==s.length)&&e.addIssue({code:"custom",message:"Each selected criterion requires exactly one distinct grader result."});for(let i of o.grades){let{contentHash:a,...d}=i;p(d)!==a&&e.addIssue({code:"custom",message:"A retained criterion changed."});for(let y of i.components){let{contentHash:x,...g}=y;p(g)!==x&&e.addIssue({code:"custom",message:"A retained grader result changed."})}}});var m=t.string().trim().min(1).max(200),W=t.string().regex(/^[a-f0-9]{64}$/),we=t.discriminatedUnion("kind",[t.object({kind:t.literal("hosted_chat"),modelId:m,messages:ye.optional(),maxOutputTokens:t.number().int().min(1).max(4096).default(1024),temperature:t.number().min(0).max(2).default(0),topP:t.number().gt(0).max(1).default(1)}).strict(),t.object({kind:t.literal("fixture"),fixtureId:m}).strict()]),Bt=t.object({schemaVersion:t.literal("openpond.modelStarterAttemptRequest.v1"),operationId:m,teamId:m,modelProjectId:m.nullable(),project:j.optional(),taskset:k,taskId:m,environmentSeed:t.number().int().min(0).max(2147483647).default(0),policy:we}).strict(),Vn=t.object({modelProjectId:m.nullable(),taskset:k,afterTaskId:m.optional(),limit:t.number().int().min(1).max(100).default(25)}).strict(),Yn=t.object({modelProjectId:m.nullable(),taskset:k,available:t.boolean(),unavailableReason:t.string().max(1e3).nullable(),models:t.array(t.object({id:m,name:t.string().max(500)}).strict()).max(200),tasks:t.array(t.object({id:m,split:t.enum(["train","validation","frozen_eval"]),inputPreview:t.string().max(500),fixtures:t.array(t.object({id:m,label:t.string().max(200)}).strict()).max(1e3)}).strict()).max(100),nextCursor:m.nullable()}).strict(),ee=t.object({schemaVersion:t.literal("openpond.modelStarterAttemptSummary.v1"),id:m,revision:t.number().int().positive(),request:Bt,status:t.enum(["queued","running","cancelling","completed","failed","cancelled"]),policySnapshot:t.object({modelId:m,provider:m,upstreamModelId:t.string().min(1).max(500),configurationHash:W}).strict().nullable(),createdAt:t.iso.datetime(),startedAt:t.iso.datetime().nullable(),completedAt:t.iso.datetime().nullable(),cleanupComplete:t.boolean(),resultAvailable:t.boolean(),score:t.number().min(0).max(1).nullable(),gradingStatus:t.enum(["not_started","scored","unscorable","not_configured"]).default("not_started"),passed:t.boolean().nullable(),outputPreview:t.string().max(500).nullable(),error:t.object({code:m,message:t.string().max(2e3)}).strict().nullable()}).strict().superRefine((o,e)=>{o.request.policy.kind==="fixture"!=(o.policySnapshot===null)&&e.addIssue({code:"custom",path:["policySnapshot"],message:"Fixture execution must not claim a model identity."}),o.status==="completed"&&(!o.cleanupComplete||!o.resultAvailable||!o.completedAt)&&e.addIssue({code:"custom",message:"Completed attempts require retained results and confirmed cleanup."})}),Xn=t.object({modelProjectId:m,afterId:m.optional(),limit:t.number().int().min(1).max(100).default(25)}).strict(),Qn=t.object({items:t.array(ee).max(100),nextCursor:m.nullable()}).strict(),Zn=t.object({schemaVersion:t.literal("openpond.modelStarterAttemptResult.v1"),attempt:ee,output:t.string().max(1048576).nullable(),messages:t.array(t.record(t.string(),t.unknown())).max(4002),composition:He.nullable(),grade:X.nullable().optional(),experimentGrade:tt.nullable().optional(),environment:t.object({status:t.enum(["completed","budget_exhausted","cancelled","timed_out","policy_failure","environment_failure"]),collected:t.boolean(),definition:k,initialStateHash:W.nullable(),finalStateHash:W.nullable(),attemptHash:W}).strict(),providerRequestIds:t.array(m).max(1001),contentHash:W}).strict().superRefine((o,e)=>{o.experimentGrade&&((o.grade||o.composition)&&e.addIssue({code:"custom",message:"Selected Experiment grading cannot claim another grade population."}),(!["completed","failed"].includes(o.attempt.status)||!o.attempt.resultAvailable||o.attempt.score!==o.experimentGrade.score||o.attempt.gradingStatus!==o.experimentGrade.gradingStatus||o.attempt.passed!==(o.experimentGrade.score===null?null:o.experimentGrade.passed))&&e.addIssue({code:"custom",message:"Experiment grading differs from its retained attempt summary."})),o.grade&&(o.composition&&e.addIssue({code:"custom",path:["grade"],message:"An ordinary grade cannot also claim a Reward composition."}),(!["completed","failed"].includes(o.attempt.status)||!o.attempt.resultAvailable||o.attempt.score!==o.grade.score||o.attempt.gradingStatus!==o.grade.gradingStatus||o.attempt.passed!==(o.grade.score===null?null:o.grade.passed))&&e.addIssue({code:"custom",path:["grade"],message:"Ordinary grade differs from its terminal attempt summary."}))});var R=t.string().trim().min(1).max(200),nt=t.string().regex(/^[a-f0-9]{64}$/),Dt=t.discriminatedUnion("kind",[we.options[0],t.object({kind:t.literal("fixture")}).strict()]),te=t.object({schemaVersion:t.literal("openpond.modelTasksetRunRequest.v1"),operationId:R,teamId:R,modelProjectId:R.nullable(),name:t.string().trim().min(1).max(200).optional(),project:j.optional(),taskset:k,policy:Dt,population:t.array(Ve).min(1).max(1e4)}).strict().superRefine((o,e)=>{new Set(o.population.map(n=>n.receiptId)).size!==o.population.length&&e.addIssue({code:"custom",path:["population"],message:"Run receipt identities must be unique."}),o.population.some(n=>n.fixtureId!==null!=(o.policy.kind==="fixture"))&&e.addIssue({code:"custom",path:["population"],message:"Only fixture runs require a fixture identity for every member."}),o.population.some(n=>!/^(0|[1-9][0-9]*)$/.test(n.seed)||Number(n.seed)>2147483647)&&e.addIssue({code:"custom",path:["population"],message:"Hosted environment seeds must be integers from 0 to 2147483647."})}),rt=t.object({schemaVersion:t.literal("openpond.modelTasksetRunSummary.v1"),id:R,revision:t.number().int().positive(),teamId:R,modelProjectId:R.nullable(),name:t.string().trim().min(1).max(200).optional(),project:j.optional(),operationId:R,taskset:k,policyKind:t.enum(["hosted_chat","fixture"]),manifestHash:nt,status:t.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:t.number().int().min(1).max(1e4),counts:t.object({pending:t.number().int().nonnegative(),running:t.number().int().nonnegative(),completed:t.number().int().nonnegative(),failed:t.number().int().nonnegative(),cancelled:t.number().int().nonnegative()}).strict(),createdAt:t.iso.datetime(),startedAt:t.iso.datetime().nullable(),completedAt:t.iso.datetime().nullable(),cleanupComplete:t.boolean(),resultAvailable:t.boolean(),score:t.number().min(0).max(1).nullable(),metricName:t.string().min(1).max(240),error:t.object({code:R,message:t.string().max(2e3)}).strict().nullable()}).strict().superRefine((o,e)=>{Object.values(o.counts).reduce((n,r)=>n+r,0)!==o.totalCount&&e.addIssue({code:"custom",path:["counts"],message:"Run counts must account for the complete population."}),o.status!=="completed"&&o.score!==null&&e.addIssue({code:"custom",path:["score"],message:"Only completed evaluations publish a metric value."}),["completed","failed","cancelled"].includes(o.status)&&(!o.completedAt||o.counts.pending||o.counts.running)&&e.addIssue({code:"custom",message:"Terminal runs require complete population accounting."}),o.status==="cancelled"&&!o.cleanupComplete&&e.addIssue({code:"custom",message:"Cancelled runs require confirmed cleanup."}),o.resultAvailable&&!["completed","failed","cancelled"].includes(o.status)&&e.addIssue({code:"custom",message:"Run results require terminal population accounting."}),o.status==="completed"&&(!o.cleanupComplete||!o.resultAvailable)&&e.addIssue({code:"custom",message:"Completed evaluations require retained results and confirmed cleanup."})}),ot=t.object({summary:rt,request:te,manifest:Ye,policySnapshot:ee.shape.policySnapshot}).strict(),ur=t.object({modelProjectId:R.optional(),projectId:j.shape.id.optional(),afterId:R.optional(),limit:t.number().int().min(1).max(100).default(25)}).strict(),gr=t.object({items:t.array(rt).max(100),nextCursor:R.nullable()}).strict(),fr=t.object({schemaVersion:t.literal("openpond.modelTasksetRunResult.v1"),run:ot,receipts:t.array(Je).min(1).max(1e4),metric:qe.nullable(),contentHash:nt}).strict();async function ne(o){let e=ot.parse(o),{summary:n,request:r,manifest:s,policySnapshot:i}=e;if(Me(s,"Taskset run manifest"),s.contentHash!==n.manifestHash||s.id!==n.id||s.createdAt!==n.createdAt||n.teamId!==r.teamId||n.modelProjectId!==r.modelProjectId||P(n.project??null)!==P(r.project??null)||P(s.metadata.project??null)!==P(r.project??null)||(n.name??null)!==(r.name??null)||n.operationId!==r.operationId||n.policyKind!==r.policy.kind||n.totalCount!==r.population.length||n.metricName!==s.metricPolicy.primaryMetric||P(n.taskset)!==P(r.taskset)||s.tasksetRelease.id!==r.taskset.id||s.tasksetRelease.contentHash!==r.taskset.contentHash||P(s.population)!==P(r.population))throw new Error("Evaluation run differs from its admitted request or manifest.");if(r.policy.kind==="fixture"){if(s.policy.kind!=="fixture"||i!==null)throw new Error("Fixture checks cannot claim a model identity.")}else if(s.policy.kind!=="model"||!i||i.modelId!==r.policy.modelId||s.policy.model.provider!==i.provider||s.policy.model.model!==i.upstreamModelId||s.policy.model.revision!==null||s.policy.model.artifactHash!==null||s.policy.model.tokenizerRevision!==null||s.policy.model.chatTemplateHash!==null||s.policy.configurationHash!==await Z({policy:r.policy,snapshot:i}))throw new Error("Evaluation model differs from its admitted policy.");return e}c(ne,"verifyModelTasksetRunDetails");var at=t.string().min(1).max(200).refine(o=>!["__proto__","prototype","constructor"].includes(o),"Use an ordinary field name."),zt=t.array(at).min(1).max(20),st=t.enum(["input","output","expectedOutput","evaluatorContext"]),Nt=t.object({destination:st,path:zt,source:st,sourcePath:t.array(at).max(20)}).strict(),U=t.array(Nt).max(100).superRefine((o,e)=>{for(let[n,r]of o.entries())o.slice(0,n).some(s=>s.destination===r.destination&&(it(s.path,r.path)||it(r.path,s.path)))&&e.addIssue({code:"custom",path:[n,"path"],message:"Mapped destination paths must not overlap."})});function it(o,e){return o.length<=e.length&&o.every((n,r)=>n===e[r])}c(it,"prefix");var C=t.string().trim().min(1).max(200),H=t.string().regex(/^[a-f0-9]{64}$/),T=t.object({id:C,revision:t.number().int().positive(),contentHash:H}).strict(),re=t.object({id:C,version:t.string().min(1).max(200),contentHash:H,feedbackKey:We,release:T.nullable(),mappings:U.optional()}).strict(),Kt=t.object({id:C,version:t.string().min(1).max(200),contentHash:H,mappings:U}).strict(),ct=t.object({operationId:C,id:C.optional(),expectedRevision:t.number().int().nonnegative(),request:te,maximumCostUsd:t.number().finite().positive().max(1e4),graders:t.array(Kt).min(1).max(100).optional()}).strict().superRefine((o,e)=>{o.request.name||e.addIssue({code:"custom",path:["request","name"],message:"Name this Experiment before saving it."}),!!o.id!=o.expectedRevision>0&&e.addIssue({code:"custom",path:["expectedRevision"],message:"An update requires its saved definition revision."}),Math.round(o.maximumCostUsd*1e6)<1&&e.addIssue({code:"custom",path:["maximumCostUsd"],message:"The budget must be at least $0.000001."}),o.graders&&new Set(o.graders.map(n=>n.id)).size!==o.graders.length&&e.addIssue({code:"custom",path:["graders"],message:"Select each grader once."})}),Ft=t.object({schemaVersion:t.literal("openpond.experimentDefinition.v1"),id:C,teamId:C,revision:t.number().int().positive(),request:te,maximumCostUsd:t.number().finite().positive().max(1e4),graders:t.array(re).min(1).max(100),createdAt:t.iso.datetime(),updatedAt:t.iso.datetime()}).strict(),Jt=Ft.extend({contentHash:H}),dt=t.object({operationId:C,definition:T}).strict(),lt=t.object({projectId:C.optional(),datasetHash:H.optional(),search:t.string().trim().max(200).optional(),afterId:C.optional(),limit:t.number().int().min(1).max(100).default(30)}).strict(),Or=t.object({definition:T,maximumCostUsd:t.number().finite().positive().max(1e4),graders:t.array(re).min(1).max(100)}).strict();function pt(o){let e=Jt.parse(o),{contentHash:n,...r}=e;if(n!==p(r)||e.request.teamId!==e.teamId||!e.request.name)throw new Error("Experiment definition differs from its immutable content.");if(new Set(e.graders.map(s=>s.feedbackKey)).size!==e.graders.length)throw new Error("Experiment feedback keys must be distinct.");return e}c(pt,"verifyExperimentDefinition");var Se=c(o=>({id:o.id,revision:o.revision,contentHash:o.contentHash}),"experimentDefinitionRef");var $=t.string().trim().min(1).max(200),Pe=t.object({operationId:$,execution:Ae,graders:t.array(Ue).min(1).max(100),maximumCostUsd:t.number().finite().min(1e-6).max(1e4),mappings:t.array(t.object({graderId:$,fields:U}).strict()).max(100).optional()}).strict().superRefine((o,e)=>{new Set(o.graders.map(n=>n.id)).size!==o.graders.length&&e.addIssue({code:"custom",path:["graders"],message:"Select each grader once."}),o.mappings&&(new Set(o.mappings.map(n=>n.graderId)).size!==o.mappings.length||o.mappings.some(n=>!o.graders.some(r=>r.id===n.graderId)))&&e.addIssue({code:"custom",path:["mappings"],message:"Map each selected grader at most once."})}),Gt=t.object({schemaVersion:t.literal("openpond.experimentScoringPass.v1"),id:$,teamId:$,revision:t.number().int().positive(),request:Pe,graders:t.array(re).min(1).max(100),status:t.enum(["queued","running","cancelling","completed","failed","cancelled"]),totalCount:t.number().int().min(1).max(1e4),counts:t.object({pending:t.number().int().nonnegative(),running:t.number().int().nonnegative(),scored:t.number().int().nonnegative(),unavailable:t.number().int().nonnegative(),failed:t.number().int().nonnegative(),cancelled:t.number().int().nonnegative()}).strict(),resultAvailable:t.boolean(),createdAt:t.iso.datetime(),startedAt:t.iso.datetime().nullable(),completedAt:t.iso.datetime().nullable(),error:t.object({code:$,message:t.string().max(2e3)}).strict().nullable()}).strict(),Vt=Gt.extend({contentHash:t.string().regex(/^[a-f0-9]{64}$/)});function mt(o){let e=Vt.parse(o),{contentHash:n,...r}=e;if(p(r)!==n||Object.values(e.counts).reduce((i,a)=>i+a,0)!==e.totalCount)throw new Error("Scoring pass integrity or population accounting failed.");let s=["completed","failed","cancelled"].includes(e.status);if(s&&(!e.completedAt||e.counts.pending||e.counts.running)||!s&&(e.completedAt!==null||e.resultAvailable)||e.status==="completed"&&!e.resultAvailable)throw new Error("Scoring pass lifecycle differs from its retained result.");if(e.graders.length!==e.request.graders.length||new Set(e.graders.map(i=>i.feedbackKey)).size!==e.graders.length||e.graders.some((i,a)=>p(i.release)!==p(e.request.graders[a])||p(i.mappings??[])!==p(e.request.mappings?.find(d=>d.graderId===i.release?.id)?.fields??[])))throw new Error("Scoring pass graders differ from their exact admission.");return e}c(mt,"verifyExperimentScoringPass");var u=t.string().trim().min(1).max(200),ke=class extends Error{constructor(n,r,s){super(s);this.status=n;this.code=r;this.name="OpenPondExperimentError"}status;code;static{c(this,"OpenPondExperimentError")}},oe=class{constructor(e){this.options=e;let n=new URL(e.baseUrl);if(!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash||!e.apiKey.trim()||!e.teamId.trim())throw new Error("A clean API origin and workspace credentials are required.");this.baseUrl=n.toString().replace(/\/+$/,"")}options;static{c(this,"OpenPondExperimentsClient")}baseUrl;async save(e,n){let r=ct.parse(e);if(r.request.teamId!==this.options.teamId)throw new Error("Experiment workspace mismatch.");let s=this.definition(await this.request("","POST",r,n),r.id);if(s.revision!==r.expectedRevision+1||p(s.request)!==p(r.request)||s.maximumCostUsd!==r.maximumCostUsd)throw new Error("Experiment save receipt differs from its submitted configuration.");if(r.graders&&p(r.graders)!==p(s.graders.map(i=>({id:i.id,version:i.version,contentHash:i.contentHash,mappings:i.mappings??[]}))))throw new Error("Experiment save receipt differs from its selected graders or mappings.");return s}async get(e,n={}){let r=n.reference?T.parse(n.reference):void 0;if(r&&r.id!==e)throw new Error("Experiment reference identity mismatch.");let s=r?`?${new URLSearchParams({revision:String(r.revision),contentHash:r.contentHash})}`:"",i=this.definition(await this.request(`/${encodeURIComponent(u.parse(e))}${s}`,"GET",void 0,n.signal),e);if(n.reference&&p(Se(i))!==p(n.reference))throw new Error("Experiment revision mismatch.");return i}async list(e={},n){let r=lt.parse(e),s=new URLSearchParams(Object.entries(r).map(([d,y])=>[d,String(y)])),i=t.object({items:t.array(t.unknown()).max(100),nextCursor:u.nullable()}).strict().parse(await this.request(`?${s}`,"GET",void 0,n)),a=i.items.map(d=>this.definition(d));if(a.length>r.limit||new Set(a.map(d=>d.id)).size!==a.length||a.some(d=>r.projectId&&d.request.project?.id!==r.projectId||r.datasetHash&&d.request.taskset.contentHash!==r.datasetHash))throw new Error("Experiment page differs from its selected scope.");return{items:a,nextCursor:i.nextCursor}}async start(e,n){let r=dt.parse(e),s=t.object({definition:t.unknown(),run:t.unknown()}).strict().parse(await this.request(`/${encodeURIComponent(r.definition.id)}/start`,"POST",r,n)),i=this.definition(s.definition,r.definition.id);if(p(Se(i))!==p(r.definition))throw new Error("Experiment Start revision mismatch.");let a=await ne(s.run);if(a.summary.teamId!==this.options.teamId||a.request.operationId!==r.operationId||p(a.request)!==p({...i.request,operationId:r.operationId})||p(a.manifest.metadata.experimentDefinition)!==p(r.definition)||a.manifest.metadata.experimentConfigurationHash!==p({definition:r.definition,maximumCostUsd:i.maximumCostUsd,graders:i.graders}))throw new Error("Experiment execution differs from its saved configuration.");return a}async result(e,n){let r=t.object({executionId:u,passId:u.nullable(),manifest:t.unknown(),result:t.unknown()}).strict().parse(await this.request(`/executions/${encodeURIComponent(u.parse(e))}/result`,"GET",void 0,n)),s=ge(r);if(r.executionId!==e||s.manifest.teamId!==this.options.teamId||s.manifest.lineage?.execution.id!==e||s.manifest.lineage.scoringPassId!==r.passId)throw new Error("Experiment result identity mismatch.");return{...s,executionId:e,passId:r.passId}}async executions(e,n={}){let r=new URLSearchParams(n.afterId?{afterId:u.parse(n.afterId)}:{}),s=t.object({items:t.array(t.unknown()).max(30),nextCursor:u.nullable()}).strict().parse(await this.request(`/${encodeURIComponent(u.parse(e))}/executions?${r}`,"GET",void 0,n.signal)),i=await Promise.all(s.items.map(a=>ne(a)));if(i.some(a=>a.summary.teamId!==this.options.teamId||T.parse(a.manifest.metadata.experimentDefinition).id!==e)||new Set(i.map(a=>a.summary.id)).size!==i.length)throw new Error("Experiment execution page has invalid ownership or repeated identities.");return{items:i,nextCursor:s.nextCursor}}async execution(e,n){return this.executionDetails(await this.request(`/executions/${encodeURIComponent(u.parse(e))}`,"GET",void 0,n),e)}async cancel(e,n){return this.executionDetails(await this.request(`/executions/${encodeURIComponent(u.parse(e))}/cancel`,"POST",{},n),e)}async retry(e,n,r){let s=await this.executionDetails(await this.request(`/executions/${encodeURIComponent(u.parse(e))}/retry`,"POST",{operationId:u.parse(n)},r));if(s.request.operationId!==n)throw new Error("Experiment retry operation mismatch.");return s}async score(e,n){let r=Pe.parse(e),s=this.pass(await this.request(`/executions/${encodeURIComponent(r.execution.id)}/scoring-passes`,"POST",r,n));if(p(s.request)!==p(r))throw new Error("Scoring admission differs from its submitted inputs.");return s}async scoringPass(e,n){return this.pass(await this.request(`/scoring-passes/${encodeURIComponent(u.parse(e))}`,"GET",void 0,n),e)}async scoringPasses(e,n={}){let r=new URLSearchParams(n.afterId?{afterId:u.parse(n.afterId)}:{}),s=t.object({items:t.array(t.unknown()).max(30),nextCursor:u.nullable()}).strict().parse(await this.request(`/executions/${encodeURIComponent(u.parse(e))}/scoring-passes?${r}`,"GET",void 0,n.signal)),i=s.items.map(a=>this.pass(a));if(i.some(a=>a.request.execution.id!==e)||new Set(i.map(a=>a.id)).size!==i.length)throw new Error("Scoring pass page differs from its execution ownership.");return{items:i,nextCursor:s.nextCursor}}async cancelScoringPass(e,n){return this.pass(await this.request(`/scoring-passes/${encodeURIComponent(u.parse(e))}/cancel`,"POST",{},n),e)}async scoringResult(e,n){let r=t.object({executionId:u,passId:u,manifest:t.unknown(),result:t.unknown()}).strict().parse(await this.request(`/scoring-passes/${encodeURIComponent(u.parse(e))}/result`,"GET",void 0,n)),s=ge(r);if(r.passId!==e||s.manifest.teamId!==this.options.teamId||s.manifest.id!==e||s.manifest.lineage?.execution.id!==r.executionId||s.manifest.lineage.scoringPassId!==e)throw new Error("Scoring result identity mismatch.");return{...s,executionId:r.executionId,passId:e}}async compare(e,n,r){let s=c(d=>d.startsWith("score_")?this.scoringResult(d,r):this.result(d,r),"read"),[i,a]=await Promise.all([s(e),s(n)]);return{baseline:i,candidate:a,comparison:Ge(i,a)}}definition(e,n){let r=pt(e);if(r.teamId!==this.options.teamId||n&&r.id!==n)throw new Error("Experiment identity mismatch.");return r}async executionDetails(e,n){let r=await ne(e);if(r.summary.teamId!==this.options.teamId||n&&r.summary.id!==n)throw new Error("Experiment execution identity mismatch.");return r}pass(e,n){let r=mt(e);if(r.teamId!==this.options.teamId||n&&r.id!==n)throw new Error("Scoring pass identity mismatch.");return r}async request(e,n,r,s){let i=await(this.options.fetch??fetch)(`${this.baseUrl}/v1/experiments${e}`,{method:n,signal:s,redirect:"error",headers:{Authorization:`Bearer ${this.options.apiKey}`,"X-OpenPond-Team-Id":this.options.teamId,"Content-Type":"application/json",Accept:"application/json"},...r===void 0?{}:{body:JSON.stringify(r)}}),a=await i.json();if(!i.ok){let d=t.object({code:t.string(),message:t.string()}).safeParse(a);throw new ke(i.status,d.success?d.data.code:"experiment_request_failed",d.success?d.data.message:"Experiment request failed.")}return a}};function ut(o,e){return{supportsResume:!e,get:c((...n)=>o.get(...n),"get"),start:e?async()=>{throw new Error("This runtime does not support resuming a stopped guest; start fresh Work with saved outputs")}:(...n)=>o.start(...n),exec:c((n,r)=>o.exec(n,e?{...r,timeoutSeconds:Math.min(r.timeoutSeconds??30,60)}:r),"exec"),mkdir:c((...n)=>o.mkdir(...n),"mkdir"),uploadFile:c((...n)=>o.uploadFile(...n),"uploadFile"),uploadFileBase64:c((...n)=>o.uploadFileBase64(...n),"uploadFileBase64"),listFiles:c((...n)=>o.listFiles(...n),"listFiles"),downloadFileResponse:c((...n)=>o.downloadFileResponse(...n),"downloadFileResponse"),stop:c((...n)=>o.stop(...n),"stop"),delete:c((...n)=>o.delete(...n),"delete"),createWork:c(({requestId:n,repo:r,budgetUsd:s,metadata:i})=>{if(e){if(r?.trim())throw new Error("This runtime does not support repository provisioning; provide Work inputs instead");if(s!==void 0)throw new Error("Hosted spending budgets are not supported by this runtime");let d={resources:e.resources??{cpu:1,memoryGb:2,diskGb:10},...n?{requestId:n}:{}};return o.create(d)}let a=s?.trim()||"1.00";return o.create({...r?.trim()?{repo:r.trim()}:{},runtimeProfileId:"openpond-work-v1",resources:{cpu:2,memoryGb:4,diskGb:16},budget:{maxUsd:a},quotas:{maxSpendUsd:a,maxDurationSeconds:3600,idleTimeoutSeconds:900,maxCommands:200,maxOpenPorts:4},metadata:{source:"openpond-sdk-work",...i,...n?{workRequestId:n}:{}}},{async:!0})},"createWork")}}c(ut,"workSandbox");function Re(o,e){let n=new URL(o);if(!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash)throw new Error(`${e} must be an HTTP(S) endpoint without embedded credentials, query or fragment`);return n.toString().replace(/\/$/,"")}c(Re,"configuredEndpoint");function se(o,e){if(!o?.trim())throw new Error(`${e} is required`);return o.trim()}c(se,"configuredKey");var Yt=t.object({choices:t.array(t.object({message:t.object({content:t.string().nullable().optional(),tool_calls:t.array(t.object({id:t.string().min(1),type:t.literal("function"),function:t.object({name:t.string().min(1),arguments:t.string()})})).optional()})})).min(1)});async function gt(o,e){if(!e)return he(o);let n=await fetch(`${o.apiBaseUrl}/chat/completions`,{method:"POST",headers:{authorization:`Bearer ${o.token}`,"content-type":"application/json"},body:JSON.stringify({model:o.model,messages:o.messages,tools:o.tools,tool_choice:"auto",stream:!1}),signal:o.signal,redirect:"error"});if(!n.ok)throw new Error(`Configured model request failed (${n.status})`);return Yt.parse(await n.json())}c(gt,"workModelTurn");var Xt="openpond-chat",Qt=24,Zt=4e4,Ie=2e4,Oe="outputs",ve="inputs/previous-outputs",bt="inputs/.openpond-context.json",en=100,ft=100,ht=100*1024*1024,D=class{static{c(this,"OpenPondWorkClient")}#e;#n;#t;#r;#o;#s;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl,this.#t=e.chatApiBaseUrl,this.#r=ut(e.sandboxes,e.sandboxConfig),this.#o=e.defaultModel??Xt,this.#s=e.customModel??!1}async run(e){let n=e.prompt.trim();if(!n)throw new Error("Work prompt is required");e.signal?.throwIfAborted();let r=c(async b=>e.onEvent?.(b),"emit"),s=e.cleanup??"keep",i=rn(s),a=null,d=null,y=!1,x=xt(e.maxSteps,1,100,Qt),g="";try{await r({type:"status",message:"Preparing sandbox"}),a=await this.#g(e),await r({type:"sandbox",sandboxId:a.id,state:a.state}),await this.#m(a.id,e.inputs??[]),d=await this.#u(a.id);let b=[{role:"system",content:nn(a.id,(e.inputs?.length??0)>0)},...(e.history??[]).map(w=>({...w})),{role:"user",content:n}];for(let w=1;w<=x;w+=1){e.signal?.throwIfAborted(),await r({type:"status",message:`Thinking \xB7 step ${w}`});let _e=(await gt({apiBaseUrl:this.#t,token:this.#e,model:e.model?.trim()||this.#o,messages:b,tools:tn,toolChoice:"auto",signal:e.signal,metadata:{source:"openpond-sdk-work",sandboxId:a.id,apiBaseUrl:this.#n,...e.metadata}},this.#s)).choices?.[0],G=_e?.message?.content?.trim()??"",V=_e?.message?.tool_calls??[];if(b.push({role:"assistant",content:G||null,...V.length>0?{tool_calls:V}:{}}),G&&(g=G,await r({type:"assistant",text:G})),V.length===0){let q=await this.#d(a.id,d);for(let de of q)await r({type:"output",output:de});y=!0,await this.#i(a.id,q,e,i,r);let Y={sandboxId:a.id,text:g,steps:w,outputs:q,lifecycle:i};return await r({type:"done",...Y}),Y}for(let[q,Y]of V.entries()){e.signal?.throwIfAborted();let de=await this.#f(a.id,Y,q,e.timeoutSeconds,r);b.push(de)}}throw new Error(`Work did not finish within ${x} steps`)}catch(b){if(a&&d&&!y)try{let w=await this.#d(a.id,d);for(let Ee of w)await r({type:"output",output:Ee});await this.#i(a.id,w,e,i,r)}catch(w){yt(b,i,w)}throw yt(b,i),b}}async deleteSandbox(e){try{if((await this.#r.get(e)).state==="deleted")return;await this.#r.delete(e)}catch(n){if(n instanceof Q&&n.status===404)return;throw n}}async#m(e,n){if(n.length===0)return;if(n.length>ft)throw new Error(`Work inputs exceed the ${ft} file limit`);if(n.reduce((a,d)=>a+Buffer.byteLength(d.contentsBase64,"base64"),0)>ht)throw new Error(`Work inputs exceed the ${ht} byte limit`);await this.#r.mkdir(e,{path:ve,recursive:!0});let s=new Set,i=[];for(let[a,d]of n.entries()){let y=sn(d,a,s),x=`${ve}/${y}`;await this.#r.uploadFileBase64(e,x,d.contentsBase64),i.push({id:d.id,path:x,name:d.name,mimeType:d.mimeType??null,checksumSha256:d.checksumSha256??null,revision:d.revision??null,metadata:d.metadata??{}})}await this.#r.uploadFile(e,bt,JSON.stringify({version:1,files:i},null,2))}async#i(e,n,r,s,i){if(s.persistence.outputCount=n.length,n.length===0)s.persistence.status="not_needed";else if(r.persistOutput){s.persistence.status="running";for(let a of n){await i({type:"persistence",output:a,status:"started"});try{let d=on(this.#r,e,a);await r.persistOutput({output:a,download:d}),s.persistence.persistedCount+=1,await i({type:"persistence",output:a,status:"succeeded"})}catch(d){let y=B(d);throw s.persistence.status="failed",s.persistence.error=y,await i({type:"persistence",output:a,status:"failed",error:y}),(r.cleanup??"keep")!=="keep"&&await this.#a(e,s,i),d}}s.persistence.status="complete"}else{if((r.cleanup??"keep")==="delete"&&!r.discardOutputs)throw s.persistence.status="failed",s.persistence.error="Deleting a Work sandbox with outputs requires persistOutput or discardOutputs: true",await this.#a(e,s,i),new Error(s.persistence.error);s.persistence.status="not_requested"}await this.#c(e,r.cleanup??"keep",s,i)}async#a(e,n,r){if(this.#r.supportsResume){await this.#c(e,"stop",n,r);return}n.cleanup.status="pending",n.cleanup.finalSandboxState="running",n.cleanup.error="Output persistence must be retried before guest deletion",await r({type:"cleanup",policy:n.cleanupPolicy,status:"pending",sandboxState:"running",error:n.cleanup.error})}async#c(e,n,r,s){if(n!=="keep"){r.cleanup.status="running",await s({type:"cleanup",policy:n,status:"started"});try{let i=n==="delete"?await this.#r.delete(e):(await this.#r.stop(e)).sandbox;r.cleanup.finalSandboxState=i.state,r.cleanup.status=n==="delete"&&i.state==="deleted"||n==="stop"&&i.state==="stopped"?"complete":"pending",await s({type:"cleanup",policy:n,status:r.cleanup.status,sandboxState:i.state})}catch(i){let a=B(i);throw r.cleanup.status="failed",r.cleanup.error=a,await s({type:"cleanup",policy:n,status:"failed",error:a}),i}}}downloadOutput(e,n){return this.#r.downloadFileResponse(e,typeof n=="string"?n:n.path)}async#u(e){return await this.#r.mkdir(e,{path:Oe,recursive:!0}),an(await this.#l(e))}async#d(e,n){return(await this.#l(e)).filter(s=>n.get(s.path)!==wt(s)).sort((s,i)=>s.path.localeCompare(i.path)).slice(0,en).map(cn)}async#l(e){return(await this.#r.listFiles(e,{path:Oe,recursive:!0,maxEntries:500})).files.filter(r=>r.type==="file"&&!St(r.path).includes("/.openpond-"))}async#g(e){if(e.sandboxId){let r=await this.#r.get(e.sandboxId);if(r.state==="stopped")await this.#r.start(r.id,{async:!0});else if(r.state==="deleted"||r.state==="error")throw new Error(`Cannot resume sandbox ${r.id} in state ${r.state}`);return await this.#p(r.id,e.signal)}let n=await this.#r.createWork(e);return this.#p(n.id,e.signal)}async#p(e,n){let r=Date.now()+72e4,s=await this.#r.get(e);for(;Date.now()<r;){if(n?.throwIfAborted(),s.state==="running")return s;if(s.state==="error"||s.state==="deleted")throw new Error(`Sandbox ${s.id} entered ${s.state}${s.logs.length?`: ${s.logs.join(`
|
|
3
|
+
`)}`:""}`);await mn(2e3,n),s=await this.#r.get(e)}throw new Error(`Sandbox ${e} did not become ready before timeout`)}async#f(e,n,r,s,i){let a=n.id||`work_tool_${r}`,d=n.function?.name;if(d!=="run_command")return M(a,{error:`Unknown tool: ${d??"missing"}`});let y;try{y=JSON.parse(n.function?.arguments||"{}")}catch(g){return M(a,{error:`Invalid tool arguments: ${B(g)}`})}let x=typeof y.command=="string"?y.command.trim():"";if(!x)return M(a,{error:"command is required"});if(x.length>Ie){let g=`command exceeds the ${Ie} character limit`;return await i({type:"tool",toolCallId:a,command:x,status:"failed",output:g}),M(a,{status:"failed",error:g})}await i({type:"tool",toolCallId:a,command:x,status:"started"});try{let g=await this.#r.exec(e,{command:x,timeoutSeconds:xt(s,1,900,180)}),b=pn(g.command.output,Zt),w=g.command.status==="succeeded"?"succeeded":"failed";return await i({type:"tool",toolCallId:a,command:x,status:w,output:b,exitCode:g.command.exitCode}),M(a,{status:g.command.status,exitCode:g.command.exitCode,output:b})}catch(g){if(g instanceof Q)throw g;let b=B(g);return await i({type:"tool",toolCallId:a,command:x,status:"failed",output:b}),M(a,{status:"failed",error:b})}}},tn=[{type:"function",function:{name:"run_command",description:"Run a shell command inside the persistent OpenPond sandbox. Use standard shell tools to inspect, edit, build, and test files. Commands start in the repository workspace.",parameters:{type:"object",additionalProperties:!1,properties:{command:{type:"string",minLength:1,maxLength:Ie,description:"Shell command to execute."}},required:["command"]}}}];function nn(o,e){return["You are OpenPond Work, a careful coding agent operating in an isolated Linux sandbox.",`The active sandbox is ${o}.`,...e?[`The authoritative saved files for this turn are staged under /workspace/${ve}; their manifest is /workspace/${bt}.`,"Before revising a previous output, read its staged file and manifest. Copy the staged input into the output directory before editing it; previous output paths may not exist in this sandbox.","Preserve the actual file bytes. Never reconstruct a saved file from the conversation or claim to have preserved it without reading the staged input."]:[],"Use run_command to inspect the workspace, edit files, and validate your work.",`Place completed user-facing files in ${Oe}. The runtime collects new and revised files there automatically when the turn completes.`,"Do the requested work completely. Preserve existing user changes and avoid destructive commands.","Keep the user informed with concise prose, but call tools whenever verification or file changes are needed.","Before finishing, run relevant tests and summarize the concrete result."].join(`
|
|
4
|
+
`)}c(nn,"systemPrompt");function rn(o){return{cleanupPolicy:o,persistence:{status:"not_requested",outputCount:0,persistedCount:0},cleanup:{status:"not_requested"}}}c(rn,"initialLifecycle");function on(o,e,n){let r=null;return()=>(r??=o.downloadFileResponse(e,{path:n.path,maxBytes:Math.max(1,n.sizeBytes)}).then(s=>{let i=Buffer.byteLength(s.file.contentsBase64,"base64");if(s.file.truncated||s.file.returnedBytes!==s.file.totalSizeBytes||i!==n.sizeBytes)throw new Error(`Output download was incomplete for ${n.name}`);return s}),r)}c(on,"lazyOutputDownload");function sn(o,e,n){let r=o.id.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,80)||`input-${e+1}`,s=o.name.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(-120)||"file",i=`${r}-${s}`,a=i,d=1;for(;n.has(a);)d+=1,a=`${i}-${d}`;return n.add(a),a}c(sn,"uniqueInputName");function yt(o,e,n){!o||typeof o!="object"||Object.assign(o,{workLifecycle:e,...n?{workFinalizationError:B(n)}:{}})}c(yt,"attachWorkFailure");function an(o){return new Map(o.map(e=>[e.path,wt(e)]))}c(an,"outputSignatures");function wt(o){return`${o.sizeBytes}:${o.updatedAt}`}c(wt,"outputSignature");function cn(o){let e=St(o.path).split("/").at(-1)||o.path,n=dn(e);return{path:o.path,name:e,mimeType:n,sizeBytes:o.sizeBytes,updatedAt:o.updatedAt,isBinary:o.isBinary??null,previewable:o.previewable??(n.startsWith("image/")||n==="application/pdf"||n.startsWith("text/"))}}c(cn,"workOutputFromFile");function St(o){return o.replaceAll("\\","/")}c(St,"normalizedOutputPath");function dn(o){let e=o.toLowerCase().match(/\.[^.]+$/)?.[0]??"";return ln[e]??"application/octet-stream"}c(dn,"workOutputMimeType");var ln=Object.freeze({".avif":"image/avif",".csv":"text/csv",".docx":"application/vnd.openxmlformats-officedocument.wordprocessingml.document",".gif":"image/gif",".html":"text/html",".jpeg":"image/jpeg",".jpg":"image/jpeg",".json":"application/json",".m4a":"audio/mp4",".md":"text/markdown",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".pdf":"application/pdf",".png":"image/png",".pptx":"application/vnd.openxmlformats-officedocument.presentationml.presentation",".svg":"image/svg+xml",".tsv":"text/tab-separated-values",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".webp":"image/webp",".xlsx":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"});function M(o,e){return{role:"tool",tool_call_id:o,content:JSON.stringify(e)}}c(M,"toolMessage");function xt(o,e,n,r){return Number.isFinite(o)?Math.min(n,Math.max(e,Math.floor(o))):r}c(xt,"boundedInteger");function pn(o,e){return o.length<=e?o:`${o.slice(0,e)}
|
|
5
|
+
\u2026 output truncated by openpond-sdk`}c(pn,"truncate");function B(o){return o instanceof Error?o.message:String(o)}c(B,"errorMessage");function mn(o,e){return new Promise((n,r)=>{if(e?.aborted){r(e.reason);return}let s=setTimeout(n,o);s.unref?.(),e?.addEventListener("abort",()=>{clearTimeout(s),r(e.reason)},{once:!0})})}c(mn,"sleep");import{promises as Pt}from"node:fs";var z=class{static{c(this,"OpenPondProjectActionsClient")}#e;#n;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl.replace(/\/+$/,"")}async list(e){let n=await I(this.#n,this.#e,ie(e.projectId,"releases",e.teamId));return(await O(n,"List Project Action releases")).releases}async catalog(e){let n=await I(this.#n,this.#e,ie(e.projectId,"catalog",e.teamId));return(await O(n,"Get Project Action catalog")).catalog}async publish(e){let[n,r]=await Promise.all([Pt.readFile(e.build.bundlePath),Pt.readFile(e.build.runnerPath)]),s=await I(this.#n,this.#e,ie(e.projectId,"releases",e.teamId),{method:"POST",body:JSON.stringify({sourceRef:e.sourceRef,sourceCommitSha:e.sourceCommitSha,bundleBase64:n.toString("base64"),runnerBase64:r.toString("base64"),registry:e.build.registry,manifest:e.build.manifest,metadata:e.metadata})});return(await O(s,"Publish Project Actions")).release}async run(e){let n=await I(this.#n,this.#e,ie(e.projectId,`actions/${encodeURIComponent(e.actionId)}`,e.teamId),{method:"POST",body:JSON.stringify({input:e.value??{},releaseId:e.releaseId,idempotencyKey:e.idempotencyKey,callerType:e.callerType??"sdk",callerId:e.callerId}),signal:e.signal,timeoutMs:9e5});return(await O(n,"Run Project Action")).invocation}};function ie(o,e,n){return`/v1/project-actions/${encodeURIComponent(o)}/${e}?teamId=${encodeURIComponent(n)}`}c(ie,"projectActionPath");var K=class{static{c(this,"OpenPondProfileActionsClient")}#e;#n;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl.replace(/\/+$/,"")}async catalog(e){let n=N(e.teamId,"teamId"),r=new URLSearchParams({teamId:n});e.profileId?.trim()&&r.set("profileId",e.profileId.trim()),e.profileName?.trim()&&r.set("profileName",e.profileName.trim());let s=await I(this.#n,this.#e,`/v1/profile/actions?${r.toString()}`);return(await O(s,"Get Profile Action catalog")).catalog}async run(e){let n=N(e.teamId,"teamId"),r=N(e.actionKey,"actionKey"),s=N(e.idempotencyKey,"idempotencyKey"),i=N(e.catalogVersion,"catalogVersion"),a=await I(this.#n,this.#e,`/v1/profile/actions/run?${new URLSearchParams({teamId:n}).toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e.profileId?.trim()?{profileId:e.profileId.trim()}:{},...e.profileName?.trim()?{profileName:e.profileName.trim()}:{},actionKey:r,value:e.value??{},conversationId:e.conversationId??null,createConversation:e.createConversation,conversationTitle:e.conversationTitle??null,idempotencyKey:s,catalogVersion:i,externalCapabilityLeases:e.externalCapabilityLeases})});return O(a,"Run Profile Action")}};function N(o,e){let n=o.trim();if(!n)throw new Error(`${e} is required`);return n}c(N,"requiredValue");import{randomUUID as kt}from"node:crypto";var F=class{static{c(this,"OpenPondWorkflowsClient")}#e;#n;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl.replace(/\/+$/,"")}async list(e={}){return this.#t("","List Workflows",{signal:e.signal})}async create(e,n={}){return this.#t("","Create Workflow",{method:"POST",body:JSON.stringify({...e,clientRequestId:e.clientRequestId?.trim()||kt()}),signal:n.signal})}async update(e,n,r={}){return this.#t(`/schedules/${encodeURIComponent(Ce(e,"scheduleId"))}`,"Update Workflow",{method:"PATCH",body:JSON.stringify(n),signal:r.signal})}async delete(e,n={}){return this.#t(`/schedules/${encodeURIComponent(Ce(e,"scheduleId"))}`,"Delete Workflow",{method:"DELETE",signal:n.signal})}async runNow(e,n={},r={}){return this.#t(`/schedules/${encodeURIComponent(Ce(e,"scheduleId"))}/run`,"Run Workflow",{method:"POST",body:JSON.stringify({clientRequestId:n.clientRequestId?.trim()||kt()}),signal:r.signal})}async#t(e,n,r={}){let s=await I(this.#n,this.#e,`/v1/saved-work${e}`,r);return O(s,n)}};function Ce(o,e){let n=o.trim();if(!n)throw new Error(`${e} is required`);return n}c(Ce,"requiredId");var ae=t.object({id:f,scope:f,sourceId:f,name:t.string().trim().min(1).max(100),keyPrefix:t.string().min(1).max(100),createdAt:t.iso.datetime(),expiresAt:t.iso.datetime(),revokedAt:t.iso.datetime().nullable()}).strict(),Rt=t.string().regex(/^opk_key_[A-Za-z0-9]{16}_[A-Za-z0-9]{48}$/),ce=t.discriminatedUnion("action",[t.object({action:t.literal("create"),scope:f,sourceId:f,name:t.string().trim().min(1).max(100),expiresAt:t.iso.datetime(),operationId:f,apiKey:Rt}).strict(),t.object({action:t.literal("list"),scope:f,sourceId:f,afterId:f.optional(),limit:t.number().int().min(1).max(100).default(30)}).strict(),t.object({action:t.literal("revoke"),scope:f,sourceId:f,id:f}).strict()]),It=t.object({credential:ae,apiKey:Rt}).strict(),Ot=t.object({items:t.array(ae).max(100),nextCursor:f.nullable()}).strict(),vt=t.object({scope:f,sourceId:f}).strict(),Ct=t.object({scope:f,source:pe,taskDefinition:pe,enabled:t.boolean(),allowedSplits:t.array(Le).min(1).max(4)}).strict();var un=t.object({batchId:t.string().trim().min(1).max(500),modelProjectId:t.string().trim().min(1).max(500)}).strict(),gn=t.object({batchId:t.string().min(1),projectId:t.string().min(1),tasksetId:t.string().min(1),releaseId:t.string().min(1),revision:t.number().int().positive(),contentHash:t.string().regex(/^[a-f0-9]{64}$/)}).strict(),h=class extends Error{constructor(n,r,s,i){super(s);this.status=n;this.code=r;this.details=i;this.name="OpenPondLearningError"}status;code;details;static{c(this,"OpenPondLearningError")}},J=class{static{c(this,"OpenPondLearningClient")}#e;constructor(e){if(!e.apiKey.trim()||!e.scope.trim())throw new Error("Learning API key and scope are required.");let n=new URL(e.baseUrl);if(!["http:","https:"].includes(n.protocol)||n.username||n.password||n.search||n.hash)throw new Error("Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.");this.#e={...e,baseUrl:n.toString().replace(/\/+$/,"")}}async command(e,n={}){ze(e);let r=Ne.parse({scope:this.#e.scope,command:e}),s=Fe.parse(await this.#t("commands",r,n));if(s.operationId!==e.operationId)throw new h(502,"operation_identity_mismatch","Learning response did not match the submitted operation.",null);return s}submitExample(e,n={}){return this.command({action:"submit_example",operationId:e.idempotencyKey,example:e},n)}submitFeedback(e,n={}){return this.command({action:"submit_feedback",operationId:e.idempotencyKey,feedback:e},n)}async get(e,n,r,s={}){let i=A.parse({action:"get",scope:this.#e.scope,kind:e,id:n,...r===void 0?{}:{revision:r}});return ue[e].parse(await this.#t("read",i,s))}async inspectEvidence(e,n={}){let r=A.parse({action:"inspect_evidence",scope:this.#e.scope,evidence:e}),s=Ke.parse(await this.#t("read",r,n));if(!me(s.evidence,e))throw new h(502,"evidence_identity_mismatch","Inspection did not match the requested evidence release.",null);return s}async inspectTaskQueue(e=null,n={}){let r=A.parse({action:"inspect_task_queue",scope:this.#e.scope,modelProjectId:e}),s=De.parse(await this.#t("read",r,n));if(s.modelProjectId!==e)throw new h(502,"model_identity_mismatch","Task queue did not match the requested Model.",null);return s}async inspectPolicy(e,n={}){let r=A.parse({action:"inspect_policy",scope:this.#e.scope,policy:e}),s=Be.parse(await this.#t("read",r,n));if(!me(s.policy,e))throw new h(502,"policy_identity_mismatch","Inspection did not match the requested policy release.",null);return s}async createSourceCredential(e,n={}){let r=ce.parse({...e,action:"create",scope:this.#e.scope}),s=It.parse(await this.#t("credentials",r,n));if(this.#n(s.credential,e.sourceId),s.apiKey!==e.apiKey||!e.apiKey.startsWith(`${s.credential.keyPrefix}_`))throw new h(502,"credential_identity_mismatch","Credential response did not match the prepared credential.",null);return s}async listSourceCredentials(e,n={},r={}){let s=ce.parse({...n,action:"list",scope:this.#e.scope,sourceId:e}),i=Ot.parse(await this.#t("credentials",s,r));if(i.items.length>(n.limit??30))throw new h(502,"credential_page_invalid","Credential response exceeded the requested page size.",null);for(let a of i.items)this.#n(a,e);return i}async revokeSourceCredential(e,n,r={}){let s=ce.parse({action:"revoke",scope:this.#e.scope,sourceId:e,id:n}),i=ae.parse(await this.#t("credentials",s,r));if(this.#n(i,e),i.id!==n||i.revokedAt===null)throw new h(502,"credential_revocation_mismatch","Credential revocation did not match the requested credential.",null);return i}async sourceConfiguration(e,n={}){let r=vt.parse({scope:this.#e.scope,sourceId:e}),s=Ct.parse(await this.#t("source-config",r,n));if(s.scope!==this.#e.scope||s.source.id!==e)throw new h(502,"source_identity_mismatch","Source configuration did not match the requested source.",null);return s}#n(e,n){if(e.scope!==this.#e.scope||e.sourceId!==n)throw new h(502,"credential_scope_mismatch","Credential response did not match the requested source.",null)}async list(e,n={},r={}){let s=A.parse({action:"list",scope:this.#e.scope,kind:e,...n});return t.object({items:t.array(ue[e]).max(100),nextCursor:t.string().nullable()}).strict().parse(await this.#t("read",s,r))}async publishBatch(e,n={}){let r=un.parse(e),s=gn.parse(await this.#t("publish-batch",{...r,scope:this.#e.scope},n));if(s.batchId!==r.batchId)throw new h(502,"batch_identity_mismatch","Published batch response did not match the requested batch.",null);return s}async#t(e,n,r){le(n,16777216);let s=await(this.#e.fetch??globalThis.fetch)(`${this.#e.baseUrl}/v1/learning/${e}`,{method:"POST",headers:{Authorization:`Bearer ${this.#e.apiKey}`,"Content-Type":"application/json",Accept:"application/json","X-OpenPond-Team-Id":this.#e.scope},body:JSON.stringify(n),signal:r.signal,redirect:"error"}),i=await fn(s);if(!s.ok){let a=t.object({code:t.string().optional(),error:t.string().optional()}).passthrough().safeParse(i);throw new h(s.status,a.success?a.data.code??"learning_request_failed":"learning_request_failed",a.success?a.data.error??`Learning request failed (${s.status}).`:`Learning request failed (${s.status}).`,i)}return i}};async function fn(o){let n=o.body?.getReader();if(!n)throw new h(o.status,"empty_response","Learning response was empty.",null);let r=new TextDecoder,s=0,i="";try{for(;;){let d=await n.read();if(d.done)break;if(s+=d.value.byteLength,s>16777216)throw new h(o.status,"response_too_large","Learning response exceeded 16 MiB; request a smaller page.",null);i+=r.decode(d.value,{stream:!0})}i+=r.decode();let a=JSON.parse(i);return le(a,16777216),a}finally{await n.cancel(),n.releaseLock()}}c(fn,"readBoundedLearningResponse");var je=class{static{c(this,"OpenPondClient")}sandboxes;work;workflows;actions;profileActions;learning;experiments;constructor(e){let n=e.apiKey?.trim()??"";if(!n&&(!e.sandbox||!e.model))throw new Error("OpenPond API key is required when using a default sandbox or model");let r=e.sandbox?{...e.sandbox,endpoint:Re(e.sandbox.endpoint,"Sandbox endpoint"),apiKey:se(e.sandbox.apiKey,"Sandbox API key")}:void 0,s=e.model?{endpoint:Re(e.model.endpoint,"Model endpoint"),apiKey:se(e.model.apiKey,"Model API key"),model:se(e.model.model,"Model ID")}:void 0,i=e.baseUrl?.trim()||"https://api.openpond.ai";this.learning=a=>new J({apiKey:n,baseUrl:i,scope:a}),this.experiments=a=>new oe({apiKey:n,baseUrl:i,teamId:a}),this.sandboxes=Xe({apiKey:r?.apiKey??n,baseUrl:i,sandboxApiUrl:r?.endpoint??e.sandboxApiUrl,customEndpoint:!!r}),this.work=new D({apiKey:s?.apiKey??n,apiBaseUrl:i,chatApiBaseUrl:s?.endpoint||e.chatApiUrl?.trim()||fe({apiBaseUrl:i,env:{}}),sandboxes:this.sandboxes,sandboxConfig:r,defaultModel:s?.model,customModel:!!s}),this.workflows=new F({apiKey:n,apiBaseUrl:i}),this.actions=new z({apiKey:n,apiBaseUrl:i}),this.profileActions=new K({apiKey:n,apiBaseUrl:i})}};function Qo(o){return new je(o)}c(Qo,"createOpenPondClient");export{P as a,_ as b,k as c,L as d,At as e,ct as f,dt as g,Se as h,Pe as i,oe as j,Qo as k};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import{a as n}from"./chunk-FTQLQJQV.js";var s="127.0.0.1";var f="0.2.
|
|
2
|
+
import{a as n}from"./chunk-FTQLQJQV.js";var s="127.0.0.1";var f="0.2.38",m="You are OpenPond Chat. Respond in the user's language. If the user's latest message is language-neutral, ambiguous, or only a short test, respond in English. Be concise and directly answer the latest request. Do not use emojis. Use Markdown when it improves scanability. If you emit reasoning or thinking content, keep it sparse and user-readable: at most one short sentence for major progress, decisions, or blockers. Omit reasoning for routine searches, reads, tool calls, and obvious next steps. Do not restate the user request, narrate every action, or include code blocks, code excerpts, diffs, raw tool payloads, or markdown examples in reasoning. Put necessary code or exact snippets only in the final assistant answer. When the user asks to show or preview an image that is available as a workspace path or signed image URL, use Markdown image syntax like  instead of a bare path or raw HTML. For workspace-backed answers, use a Codex-style shape: brief outcome first, then Changed Files if files changed, then Verification if checks ran. End with a concise final answer that summarizes the result and verification when relevant. Do not mention raw tool JSON, internal repo paths, or origin/remote URLs unless the user explicitly asks for them or they are necessary to explain a git/deploy failure.";import{randomUUID as p}from"node:crypto";import i from"node:path";import{fileURLToPath as c}from"node:url";function u(){return new Date().toISOString()}n(u,"now");function l(e){if(typeof e=="string")return e;if(e instanceof Error)return e.message||e.name;if(e==null)return"";try{return JSON.stringify(e)}catch{return String(e)}}n(l,"textFromUnknown");function w(e){if(!e||typeof e!="object")return"";let t=e;for(let r of["delta","text","output","chunk","message"])if(typeof t[r]=="string")return t[r];return t.delta&&typeof t.delta=="object"?l(t.delta):""}n(w,"extractDelta");function x(e){return{id:p(),timestamp:u(),...e}}n(x,"event");function k(e){let t=e.replace(/^https?:\/\//,""),[r,o]=t.split(":");return{host:r||s,port:o?Number.parseInt(o,10):17874}}n(k,"parseListen");function b(e){return(process.argv[1]?i.resolve(process.argv[1]):"")===i.resolve(c(e))}n(b,"isCliEntrypoint");export{s as a,f as b,m as c,u as d,l as e,w as f,x as g,k as h,b as i};
|