openpond 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/dist/chunks/{actions-command-F55CBR2K.js → actions-command-R5R3KR5Q.js} +1 -1
  2. package/dist/chunks/{app-layer-GNYLOBCX.js → app-layer-JNSKATX7.js} +1 -1
  3. package/dist/chunks/{app-server-runtime-HUJLAGR5.js → app-server-runtime-FV4KHBTY.js} +1 -1
  4. package/dist/chunks/{apps-HZ5JGBDR.js → apps-3TXUNF65.js} +1 -1
  5. package/dist/chunks/{chunk-KV2IXO2T.js → chunk-2LADHICK.js} +1 -1
  6. package/dist/chunks/{chunk-V5CGBGTX.js → chunk-37V5TT45.js} +1 -1
  7. package/dist/chunks/{chunk-SE4J5XAW.js → chunk-3ZEV5UKA.js} +1 -1
  8. package/dist/chunks/{chunk-GPZYIVFV.js → chunk-4HIHSG5M.js} +11 -11
  9. package/dist/chunks/{chunk-SFCXYOXL.js → chunk-EESJULVS.js} +1 -1
  10. package/dist/chunks/{chunk-WJVRQDHW.js → chunk-FESS4IR4.js} +245 -245
  11. package/dist/chunks/{chunk-EG3XB6M6.js → chunk-K4QLUFGX.js} +1 -1
  12. package/dist/chunks/{chunk-XAYIETBO.js → chunk-LYWUCJTV.js} +12 -12
  13. package/dist/chunks/{chunk-T5XCPX4P.js → chunk-NWI7H753.js} +2 -2
  14. package/dist/chunks/{chunk-GEANXBLX.js → chunk-OD6AGGH6.js} +1 -1
  15. package/dist/chunks/{chunk-AF57BF75.js → chunk-QUW7WK32.js} +1 -1
  16. package/dist/chunks/chunk-U6HOHOOI.js +2 -0
  17. package/dist/chunks/{chunk-I7G35U7K.js → chunk-ZKA3XSM7.js} +1 -1
  18. package/dist/chunks/{cli-OXPCJL6M.js → cli-ZZTJVJRT.js} +1 -1
  19. package/dist/chunks/{configuration-command-HAPIYG25.js → configuration-command-54D6TOEV.js} +1 -1
  20. package/dist/chunks/{core-commands-N37UZEVE.js → core-commands-F35UFIXE.js} +1 -1
  21. package/dist/chunks/{desktop-test-V7FBEG7U.js → desktop-test-U2MMP2NE.js} +1 -1
  22. package/dist/chunks/{extension-NEPOQ44P.js → extension-WY2RL5ZH.js} +1 -1
  23. package/dist/chunks/{help-HC4N5ZQC.js → help-VGDW6SBX.js} +1 -1
  24. package/dist/chunks/{opchat-C7XRN4ZW.js → opchat-QK2KIHN3.js} +1 -1
  25. package/dist/chunks/{organizations-LQGRZJ2V.js → organizations-MUDOF6VM.js} +1 -1
  26. package/dist/chunks/{profile-UWM24A7R.js → profile-FW5COIFH.js} +1 -1
  27. package/dist/chunks/{project-agent-2ME52ZJW.js → project-agent-G6GJOIVI.js} +1 -1
  28. package/dist/chunks/{sandbox-command-53L3ZICT.js → sandbox-command-H7INTQJZ.js} +1 -1
  29. package/dist/chunks/{sandbox-template-55HUM5H7.js → sandbox-template-7MXJQ3X4.js} +1 -1
  30. package/dist/chunks/{src-W6QOW5JR.js → src-4QYE5G3N.js} +3 -3
  31. package/dist/chunks/{src-VGW2UEMV.js → src-E7WA3OPU.js} +1 -1
  32. package/dist/chunks/{teams-bot-FHD2HCHN.js → teams-bot-ZDTMGPCU.js} +1 -1
  33. package/dist/chunks/{workspaces-UQ2GPN5U.js → workspaces-UB2HJGNE.js} +1 -1
  34. package/dist/cli.js +1 -1
  35. package/dist/index.js +1 -1
  36. package/dist/web/assets/{App-BoJQRfeu.js → App-DNZ5VhFd.js} +29 -29
  37. package/dist/web/assets/{AppDialog-rdfmJsGF.js → AppDialog-CtqbY289.js} +1 -1
  38. package/dist/web/assets/{AppTerminalPanel-CLW0kxtg.js → AppTerminalPanel-C1U1RKU6.js} +2 -2
  39. package/dist/web/assets/{AppsView-DxMXadnp.js → AppsView-BeGbrJkU.js} +1 -1
  40. package/dist/web/assets/{BrowserSidebar-BH_jl0JS.js → BrowserSidebar-XgQLeXw1.js} +1 -1
  41. package/dist/web/assets/{CartesianChart-oT_rMYpf.js → CartesianChart-Cp_-LaJY.js} +1 -1
  42. package/dist/web/assets/{CollaborationTabs-CukgFGE0.js → CollaborationTabs-BL6guh-3.js} +1 -1
  43. package/dist/web/assets/{CommandMenu-2btBTgOF.js → CommandMenu-B-DEtpTp.js} +1 -1
  44. package/dist/web/assets/{CommunityView-DMTREmN5.js → CommunityView-DcEhEMm_.js} +1 -1
  45. package/dist/web/assets/{ComposerCreateImproveStrip-3tN55cg9.js → ComposerCreateImproveStrip-C4mCZcKl.js} +1 -1
  46. package/dist/web/assets/{GetStartedView-CMHL24_w.js → GetStartedView-BUlaCO6a.js} +1 -1
  47. package/dist/web/assets/HostedModelLearningReview-CZyb95R_.js +1 -0
  48. package/dist/web/assets/{HostedModelLearningSettings-xqd2lSW3.js → HostedModelLearningSettings-D2o7rh0w.js} +1 -1
  49. package/dist/web/assets/{LabModelVersionDetailPage-Bpnya5DM.js → LabModelVersionDetailPage-Bb1XRvo_.js} +1 -1
  50. package/dist/web/assets/{LabSkillSidebar-BKZjScr8.js → LabSkillSidebar-CPucMztm.js} +1 -1
  51. package/dist/web/assets/LabsRoute-C_HDADl0.js +32 -0
  52. package/dist/web/assets/{MainChatThread-Bosxokt-.js → MainChatThread-CnXHxCy3.js} +2 -2
  53. package/dist/web/assets/{MainPane-Di-Rwe7x.js → MainPane-DjnT-kvm.js} +4 -4
  54. package/dist/web/assets/{MarkdownText-dK4SBPp_.js → MarkdownText-_zVYW4pN.js} +1 -1
  55. package/dist/web/assets/{Messages-ftYRMKYa.js → Messages-DxctstDI.js} +1 -1
  56. package/dist/web/assets/{NativeSkillSidebar-Cwo7JdB2.js → NativeSkillSidebar-DV4AGiCD.js} +1 -1
  57. package/dist/web/assets/{NewExperienceSwitcher-C1_JzTq2.js → NewExperienceSwitcher-CZCLJj99.js} +1 -1
  58. package/dist/web/assets/{NewProjectDialog-CxP6v6YW.js → NewProjectDialog-CQSipZ5d.js} +1 -1
  59. package/dist/web/assets/{OutputsPage-DL21_Alp.js → OutputsPage-aPJP4mTV.js} +1 -1
  60. package/dist/web/assets/{ProjectsPage-BO9VyvMA.js → ProjectsPage-CyThuXQv.js} +1 -1
  61. package/dist/web/assets/{RightChatPanelStack-DaqAnzdR.js → RightChatPanelStack-jsP9CukH.js} +1 -1
  62. package/dist/web/assets/{RightSidebarHomePanel-PbUG12AO.js → RightSidebarHomePanel-CtH0vZ36.js} +1 -1
  63. package/dist/web/assets/{ScheduledWorkPage-BhL-cXML.js → ScheduledWorkPage-BY_4jFm7.js} +1 -1
  64. package/dist/web/assets/{SettingsView-D6-s7G88.js → SettingsView-ZPnupcpg.js} +3 -3
  65. package/dist/web/assets/{TeamChatView-DbS1N-fo.js → TeamChatView-DWjwVxMp.js} +1 -1
  66. package/dist/web/assets/{TerminalOverlay-CphyBXJR.js → TerminalOverlay-DxuUGKYH.js} +1 -1
  67. package/dist/web/assets/{TrainingCreationPanel-Czsdraix.js → TrainingCreationPanel-CjIPEoTX.js} +1 -1
  68. package/dist/web/assets/{TrainingDraftPanel-Bq3B5pUk.js → TrainingDraftPanel-CxevAlkr.js} +1 -1
  69. package/dist/web/assets/{UsageSettingsSection-B74FNwaP.js → UsageSettingsSection-CY1lQB_g.js} +1 -1
  70. package/dist/web/assets/{WorkSidebarPanel-BgaK4XSg.js → WorkSidebarPanel-DMsiwOSi.js} +1 -1
  71. package/dist/web/assets/{WorkspaceDiffPanel-C3seHnVY.js → WorkspaceDiffPanel-HdfItqu2.js} +3 -3
  72. package/dist/web/assets/{WorkspaceEnvironmentMenu-DPghQUdv.js → WorkspaceEnvironmentMenu-7DSF_BpI.js} +1 -1
  73. package/dist/web/assets/{WorkspaceGitDialogs-D8c6Okb_.js → WorkspaceGitDialogs-Ck8BzH11.js} +1 -1
  74. package/dist/web/assets/{WorkspaceMonacoEditor-2kjRFf4l.js → WorkspaceMonacoEditor-gsEP4W37.js} +3 -3
  75. package/dist/web/assets/{arrow-up-right-C5X-29oa.js → arrow-up-right-BK6EpHpC.js} +1 -1
  76. package/dist/web/assets/{chat-file-links-Bmz9kVct.js → chat-file-links-BQe708gU.js} +1 -1
  77. package/dist/web/assets/chevron-up-CHxYR4AX.js +1 -0
  78. package/dist/web/assets/{clipboard-fvHMXPWa.js → clipboard-DOmCP7eR.js} +1 -1
  79. package/dist/web/assets/{cloud-upload-BAycsdHL.js → cloud-upload-DLtawDYW.js} +1 -1
  80. package/dist/web/assets/{cssMode-Yis679a5.js → cssMode-C0Qw8i_8.js} +1 -1
  81. package/dist/web/assets/{folder-open-bii4KUCv.js → folder-open-B_Ayxxo8.js} +1 -1
  82. package/dist/web/assets/{folder-plus-B0B7mUCx.js → folder-plus-CPgtt3pN.js} +1 -1
  83. package/dist/web/assets/{git-commit-horizontal-B6yTdtnB.js → git-commit-horizontal-23xCJjd8.js} +1 -1
  84. package/dist/web/assets/{htmlMode-DHeBSKVF.js → htmlMode-DuQ7zaau.js} +1 -1
  85. package/dist/web/assets/{index-667pXXsu.js → index-BoaTQ0Rb.js} +1 -1
  86. package/dist/web/assets/{info-NCOESX3I.js → info-CQ2kJJ5E.js} +1 -1
  87. package/dist/web/assets/{jsonMode-C4oxy1cU.js → jsonMode-DVQSEPUy.js} +1 -1
  88. package/dist/web/assets/{lspLanguageFeatures-CLj3WGZW.js → lspLanguageFeatures-DWKH3min.js} +1 -1
  89. package/dist/web/assets/{minimize-2-DtI1vgd7.js → minimize-2-1M-fFBeP.js} +1 -1
  90. package/dist/web/assets/{monaco.contribution-DZPgekIQ.js → monaco.contribution-B5Jz7f4W.js} +2 -2
  91. package/dist/web/assets/{monaco.contribution-DhVPJ-oY.js → monaco.contribution-DB7pp5Y-.js} +2 -2
  92. package/dist/web/assets/{monaco.contribution-Ddw-TznO.js → monaco.contribution-jXX7-l5p.js} +2 -2
  93. package/dist/web/assets/{monaco.contribution-DrW6DjWP.js → monaco.contribution-ytVV-s22.js} +2 -2
  94. package/dist/web/assets/{play-DB3XFAnG.js → play-D9jaK5MP.js} +1 -1
  95. package/dist/web/assets/{python-DLyUeEeL.js → python-_yRitN2I.js} +1 -1
  96. package/dist/web/assets/{refresh-cw-0zSLZtfp.js → refresh-cw-DZHqZGos.js} +1 -1
  97. package/dist/web/assets/{save-BCZlshOA.js → save-DOT3oYfU.js} +1 -1
  98. package/dist/web/assets/{square-CRytZWR_.js → square-D_1V6onE.js} +1 -1
  99. package/dist/web/assets/{toggleHighContrast-TXg0rI_R.js → toggleHighContrast-C06C-luq.js} +1 -1
  100. package/dist/web/assets/{tsMode-Bj1019AY.js → tsMode-CTMYvh-R.js} +1 -1
  101. package/dist/web/assets/{upload-CnE9u7GB.js → upload-EAAHd0Nx.js} +1 -1
  102. package/dist/web/assets/{useLocalAgentSchedules-qI87RHVI.js → useLocalAgentSchedules-DBsx4aIY.js} +1 -1
  103. package/dist/web/assets/{wifi-off-CfuwRBx7.js → wifi-off-DYRTrfYa.js} +1 -1
  104. package/dist/web/assets/{workers-CXdUI7wU.js → workers-DAytqxd3.js} +1 -1
  105. package/dist/web/assets/{yaml-AP8aiwLm.js → yaml-iZnWWABr.js} +1 -1
  106. package/dist/web/index.html +1 -1
  107. package/package.json +1 -1
  108. package/dist/chunks/chunk-NVGMZ2IN.js +0 -2
  109. package/dist/web/assets/HostedModelLearningReview-CqkSelkC.js +0 -1
  110. package/dist/web/assets/LabsRoute-BhPFmA_Z.js +0 -32
  111. package/dist/web/assets/chevron-up-NbP9vY4E.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
- import{B as Q,D as ee,E as te,F as P,G as ne,H as oe,l as M,z as G}from"./chunk-NVGMZ2IN.js";import{a as j,b as y,c as w,h as Z,i as E,j as B}from"./chunk-KDXLNQNF.js";import{Ha as Y,db as $,wa as K,wb as F}from"./chunk-XAYIETBO.js";import{a as l}from"./chunk-HZP5U2AA.js";import{b as a}from"./chunk-ES2ISFJC.js";import{a as d}from"./chunk-FTQLQJQV.js";var we="openpond-chat",Pe=24,Oe=4e4,N=2e4,H="outputs",D="inputs/previous-outputs",de="inputs/.openpond-context.json",be=100,re=100,se=100*1024*1024,x=class{static{d(this,"OpenPondWorkClient")}#e;#n;#t;#o;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl,this.#t=e.chatApiBaseUrl,this.#o=e.sandboxes}async run(e){let t=e.prompt.trim();if(!t)throw new Error("Work prompt is required");e.signal?.throwIfAborted();let o=d(async m=>e.onEvent?.(m),"emit"),n=e.cleanup??"keep",s=Re(n),i=null,c=null,f=!1,g=ae(e.maxSteps,1,100,Pe),p="";try{await o({type:"status",message:"Preparing sandbox"}),i=await this.#l(e),await o({type:"sandbox",sandboxId:i.id,state:i.state}),await this.#c(i.id,e.inputs??[]),c=await this.#p(i.id);let m=[{role:"system",content:xe(i.id,(e.inputs?.length??0)>0)},...(e.history??[]).map(h=>({...h})),{role:"user",content:t}];for(let h=1;h<=g;h+=1){e.signal?.throwIfAborted(),await o({type:"status",message:`Thinking \xB7 step ${h}`});let X=(await B({apiBaseUrl:this.#t,token:this.#e,model:e.model?.trim()||we,messages:m,tools:ke,toolChoice:"auto",signal:e.signal,metadata:{source:"openpond-sdk-work",sandboxId:i.id,apiBaseUrl:this.#n,...e.metadata}})).choices?.[0],W=X?.message?.content?.trim()??"",L=X?.message?.tool_calls??[];if(m.push({role:"assistant",content:W||null,...L.length>0?{tool_calls:L}:{}}),W&&(p=W,await o({type:"assistant",text:W})),L.length===0){let b=await this.#i(i.id,c);for(let U of b)await o({type:"output",output:U});f=!0,await this.#s(i.id,b,e,s,o);let A={sandboxId:i.id,text:p,steps:h,outputs:b,lifecycle:s};return await o({type:"done",...A}),A}for(let[b,A]of L.entries()){let U=await this.#u(i.id,A,b,e.timeoutSeconds,o);m.push(U)}}throw new Error(`Work did not finish within ${g} steps`)}catch(m){if(i&&c&&!f)try{let h=await this.#i(i.id,c);for(let V of h)await o({type:"output",output:V});await this.#s(i.id,h,e,s,o)}catch(h){ie(m,s,h)}throw ie(m,s),m}}async deleteSandbox(e){(await this.#o.get(e)).state!=="deleted"&&await this.#o.delete(e)}async#c(e,t){if(t.length===0)return;if(t.length>re)throw new Error(`Work inputs exceed the ${re} file limit`);if(t.reduce((i,c)=>i+Buffer.byteLength(c.contentsBase64,"base64"),0)>se)throw new Error(`Work inputs exceed the ${se} byte limit`);await this.#o.mkdir(e,{path:D,recursive:!0});let n=new Set,s=[];for(let[i,c]of t.entries()){let f=Se(c,i,n),g=`${D}/${f}`;await this.#o.uploadFileBase64(e,g,c.contentsBase64),s.push({id:c.id,path:g,name:c.name,mimeType:c.mimeType??null,checksumSha256:c.checksumSha256??null,revision:c.revision??null,metadata:c.metadata??{}})}await this.#o.uploadFile(e,de,JSON.stringify({version:1,files:s},null,2))}async#s(e,t,o,n,s){if(n.persistence.outputCount=t.length,t.length===0)n.persistence.status="not_needed";else if(o.persistOutput){n.persistence.status="running";for(let i of t){await s({type:"persistence",output:i,status:"started"});try{let c=Ce(this.#o,e,i);await o.persistOutput({output:i,download:c}),n.persistence.persistedCount+=1,await s({type:"persistence",output:i,status:"succeeded"})}catch(c){let f=k(c);throw n.persistence.status="failed",n.persistence.error=f,await s({type:"persistence",output:i,status:"failed",error:f}),(o.cleanup??"keep")!=="keep"&&await this.#r(e,"stop",n,s),c}}n.persistence.status="complete"}else{if((o.cleanup??"keep")==="delete"&&!o.discardOutputs)throw n.persistence.status="failed",n.persistence.error="Deleting a Work sandbox with outputs requires persistOutput or discardOutputs: true",await this.#r(e,"stop",n,s),new Error(n.persistence.error);n.persistence.status="not_requested"}await this.#r(e,o.cleanup??"keep",n,s)}async#r(e,t,o,n){if(t!=="keep"){o.cleanup.status="running",await n({type:"cleanup",policy:t,status:"started"});try{let s=t==="delete"?await this.#o.delete(e):(await this.#o.stop(e)).sandbox;o.cleanup.finalSandboxState=s.state,o.cleanup.status=t==="delete"&&s.state==="deleted"||t==="stop"&&s.state==="stopped"?"complete":"pending",await n({type:"cleanup",policy:t,status:o.cleanup.status,sandboxState:s.state})}catch(s){let i=k(s);throw o.cleanup.status="failed",o.cleanup.error=i,await n({type:"cleanup",policy:t,status:"failed",error:i}),s}}}downloadOutput(e,t){return this.#o.downloadFileResponse(e,typeof t=="string"?t:t.path)}async#p(e){return await this.#o.mkdir(e,{path:H,recursive:!0}),Ie(await this.#a(e))}async#i(e,t){return(await this.#a(e)).filter(n=>t.get(n.path)!==ce(n)).sort((n,s)=>n.path.localeCompare(s.path)).slice(0,be).map(ve)}async#a(e){return(await this.#o.listFiles(e,{path:H,recursive:!0,maxEntries:500})).files.filter(o=>o.type==="file"&&!pe(o.path).includes("/.openpond-"))}async#l(e){if(e.sandboxId){let n=await this.#o.get(e.sandboxId);if(n.state==="stopped")await this.#o.start(n.id,{async:!0});else if(n.state==="deleted"||n.state==="error")throw new Error(`Cannot resume sandbox ${n.id} in state ${n.state}`);return await this.#d(n.id,e.signal)}let t=e.budgetUsd?.trim()||"1.00",o=await this.#o.create({...e.repo?.trim()?{repo:e.repo.trim()}:{},runtimeProfileId:"openpond-work-v1",resources:{cpu:2,memoryGb:4,diskGb:16},budget:{maxUsd:t},quotas:{maxSpendUsd:t,maxDurationSeconds:3600,idleTimeoutSeconds:900,maxCommands:200,maxOpenPorts:4},metadata:{source:"openpond-sdk-work",...e.metadata}},{async:!0});return this.#d(o.id,e.signal)}async#d(e,t){let o=Date.now()+72e4,n=await this.#o.get(e);for(;Date.now()<o;){if(t?.throwIfAborted(),n.state==="running")return n;if(n.state==="error"||n.state==="deleted")throw new Error(`Sandbox ${n.id} entered ${n.state}${n.logs.length?`: ${n.logs.join(`
2
+ import{B as Q,D as ee,E as te,F as P,G as ne,H as oe,l as M,z as G}from"./chunk-U6HOHOOI.js";import{a as j,b as y,c as w,h as Z,i as E,j as B}from"./chunk-KDXLNQNF.js";import{Ha as Y,eb as $,wa as K,xb as F}from"./chunk-LYWUCJTV.js";import{a as l}from"./chunk-HZP5U2AA.js";import{b as a}from"./chunk-ES2ISFJC.js";import{a as d}from"./chunk-FTQLQJQV.js";var we="openpond-chat",Pe=24,Oe=4e4,N=2e4,H="outputs",D="inputs/previous-outputs",de="inputs/.openpond-context.json",be=100,re=100,se=100*1024*1024,x=class{static{d(this,"OpenPondWorkClient")}#e;#n;#t;#o;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl,this.#t=e.chatApiBaseUrl,this.#o=e.sandboxes}async run(e){let t=e.prompt.trim();if(!t)throw new Error("Work prompt is required");e.signal?.throwIfAborted();let o=d(async m=>e.onEvent?.(m),"emit"),n=e.cleanup??"keep",s=Re(n),i=null,c=null,f=!1,g=ae(e.maxSteps,1,100,Pe),p="";try{await o({type:"status",message:"Preparing sandbox"}),i=await this.#l(e),await o({type:"sandbox",sandboxId:i.id,state:i.state}),await this.#c(i.id,e.inputs??[]),c=await this.#p(i.id);let m=[{role:"system",content:xe(i.id,(e.inputs?.length??0)>0)},...(e.history??[]).map(h=>({...h})),{role:"user",content:t}];for(let h=1;h<=g;h+=1){e.signal?.throwIfAborted(),await o({type:"status",message:`Thinking \xB7 step ${h}`});let X=(await B({apiBaseUrl:this.#t,token:this.#e,model:e.model?.trim()||we,messages:m,tools:ke,toolChoice:"auto",signal:e.signal,metadata:{source:"openpond-sdk-work",sandboxId:i.id,apiBaseUrl:this.#n,...e.metadata}})).choices?.[0],W=X?.message?.content?.trim()??"",L=X?.message?.tool_calls??[];if(m.push({role:"assistant",content:W||null,...L.length>0?{tool_calls:L}:{}}),W&&(p=W,await o({type:"assistant",text:W})),L.length===0){let b=await this.#i(i.id,c);for(let U of b)await o({type:"output",output:U});f=!0,await this.#s(i.id,b,e,s,o);let A={sandboxId:i.id,text:p,steps:h,outputs:b,lifecycle:s};return await o({type:"done",...A}),A}for(let[b,A]of L.entries()){let U=await this.#u(i.id,A,b,e.timeoutSeconds,o);m.push(U)}}throw new Error(`Work did not finish within ${g} steps`)}catch(m){if(i&&c&&!f)try{let h=await this.#i(i.id,c);for(let V of h)await o({type:"output",output:V});await this.#s(i.id,h,e,s,o)}catch(h){ie(m,s,h)}throw ie(m,s),m}}async deleteSandbox(e){(await this.#o.get(e)).state!=="deleted"&&await this.#o.delete(e)}async#c(e,t){if(t.length===0)return;if(t.length>re)throw new Error(`Work inputs exceed the ${re} file limit`);if(t.reduce((i,c)=>i+Buffer.byteLength(c.contentsBase64,"base64"),0)>se)throw new Error(`Work inputs exceed the ${se} byte limit`);await this.#o.mkdir(e,{path:D,recursive:!0});let n=new Set,s=[];for(let[i,c]of t.entries()){let f=Se(c,i,n),g=`${D}/${f}`;await this.#o.uploadFileBase64(e,g,c.contentsBase64),s.push({id:c.id,path:g,name:c.name,mimeType:c.mimeType??null,checksumSha256:c.checksumSha256??null,revision:c.revision??null,metadata:c.metadata??{}})}await this.#o.uploadFile(e,de,JSON.stringify({version:1,files:s},null,2))}async#s(e,t,o,n,s){if(n.persistence.outputCount=t.length,t.length===0)n.persistence.status="not_needed";else if(o.persistOutput){n.persistence.status="running";for(let i of t){await s({type:"persistence",output:i,status:"started"});try{let c=Ce(this.#o,e,i);await o.persistOutput({output:i,download:c}),n.persistence.persistedCount+=1,await s({type:"persistence",output:i,status:"succeeded"})}catch(c){let f=k(c);throw n.persistence.status="failed",n.persistence.error=f,await s({type:"persistence",output:i,status:"failed",error:f}),(o.cleanup??"keep")!=="keep"&&await this.#r(e,"stop",n,s),c}}n.persistence.status="complete"}else{if((o.cleanup??"keep")==="delete"&&!o.discardOutputs)throw n.persistence.status="failed",n.persistence.error="Deleting a Work sandbox with outputs requires persistOutput or discardOutputs: true",await this.#r(e,"stop",n,s),new Error(n.persistence.error);n.persistence.status="not_requested"}await this.#r(e,o.cleanup??"keep",n,s)}async#r(e,t,o,n){if(t!=="keep"){o.cleanup.status="running",await n({type:"cleanup",policy:t,status:"started"});try{let s=t==="delete"?await this.#o.delete(e):(await this.#o.stop(e)).sandbox;o.cleanup.finalSandboxState=s.state,o.cleanup.status=t==="delete"&&s.state==="deleted"||t==="stop"&&s.state==="stopped"?"complete":"pending",await n({type:"cleanup",policy:t,status:o.cleanup.status,sandboxState:s.state})}catch(s){let i=k(s);throw o.cleanup.status="failed",o.cleanup.error=i,await n({type:"cleanup",policy:t,status:"failed",error:i}),s}}}downloadOutput(e,t){return this.#o.downloadFileResponse(e,typeof t=="string"?t:t.path)}async#p(e){return await this.#o.mkdir(e,{path:H,recursive:!0}),Ie(await this.#a(e))}async#i(e,t){return(await this.#a(e)).filter(n=>t.get(n.path)!==ce(n)).sort((n,s)=>n.path.localeCompare(s.path)).slice(0,be).map(ve)}async#a(e){return(await this.#o.listFiles(e,{path:H,recursive:!0,maxEntries:500})).files.filter(o=>o.type==="file"&&!pe(o.path).includes("/.openpond-"))}async#l(e){if(e.sandboxId){let n=await this.#o.get(e.sandboxId);if(n.state==="stopped")await this.#o.start(n.id,{async:!0});else if(n.state==="deleted"||n.state==="error")throw new Error(`Cannot resume sandbox ${n.id} in state ${n.state}`);return await this.#d(n.id,e.signal)}let t=e.budgetUsd?.trim()||"1.00",o=await this.#o.create({...e.repo?.trim()?{repo:e.repo.trim()}:{},runtimeProfileId:"openpond-work-v1",resources:{cpu:2,memoryGb:4,diskGb:16},budget:{maxUsd:t},quotas:{maxSpendUsd:t,maxDurationSeconds:3600,idleTimeoutSeconds:900,maxCommands:200,maxOpenPorts:4},metadata:{source:"openpond-sdk-work",...e.metadata}},{async:!0});return this.#d(o.id,e.signal)}async#d(e,t){let o=Date.now()+72e4,n=await this.#o.get(e);for(;Date.now()<o;){if(t?.throwIfAborted(),n.state==="running")return n;if(n.state==="error"||n.state==="deleted")throw new Error(`Sandbox ${n.id} entered ${n.state}${n.logs.length?`: ${n.logs.join(`
3
3
  `)}`:""}`);await _e(2e3,t),n=await this.#o.get(e)}throw new Error(`Sandbox ${e} did not become ready before timeout`)}async#u(e,t,o,n,s){let i=t.id||`work_tool_${o}`,c=t.function?.name;if(c!=="run_command")return O(i,{error:`Unknown tool: ${c??"missing"}`});let f;try{f=JSON.parse(t.function?.arguments||"{}")}catch(p){return O(i,{error:`Invalid tool arguments: ${k(p)}`})}let g=typeof f.command=="string"?f.command.trim():"";if(!g)return O(i,{error:"command is required"});if(g.length>N){let p=`command exceeds the ${N} character limit`;return await s({type:"tool",toolCallId:i,command:g,status:"failed",output:p}),O(i,{status:"failed",error:p})}await s({type:"tool",toolCallId:i,command:g,status:"started"});try{let p=await this.#o.exec(e,{command:g,timeoutSeconds:ae(n,1,900,180)}),m=Ae(p.command.output,Oe),h=p.command.status==="succeeded"?"succeeded":"failed";return await s({type:"tool",toolCallId:i,command:g,status:h,output:m,exitCode:p.command.exitCode}),O(i,{status:p.command.status,exitCode:p.command.exitCode,output:m})}catch(p){if(p instanceof j)throw p;let m=k(p);return await s({type:"tool",toolCallId:i,command:g,status:"failed",output:m}),O(i,{status:"failed",error:m})}}},ke=[{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:N,description:"Shell command to execute."}},required:["command"]}}}];function xe(r,e){return["You are OpenPond Work, a careful coding agent operating in an isolated Linux sandbox.",`The active sandbox is ${r}.`,...e?[`Caller-provided durable files are staged under ${D}; structured metadata is in ${de}.`]:[],"Use run_command to inspect the workspace, edit files, and validate your work.",`Place completed user-facing files in ${H}. 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
4
  `)}d(xe,"systemPrompt");function Re(r){return{cleanupPolicy:r,persistence:{status:"not_requested",outputCount:0,persistedCount:0},cleanup:{status:"not_requested"}}}d(Re,"initialLifecycle");function Ce(r,e,t){let o=null;return()=>(o??=r.downloadFileResponse(e,{path:t.path,maxBytes:Math.max(1,t.sizeBytes)}).then(n=>{let s=Buffer.byteLength(n.file.contentsBase64,"base64");if(n.file.truncated||n.file.returnedBytes!==n.file.totalSizeBytes||s!==t.sizeBytes)throw new Error(`Output download was incomplete for ${t.name}`);return n}),o)}d(Ce,"lazyOutputDownload");function Se(r,e,t){let o=r.id.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,80)||`input-${e+1}`,n=r.name.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(-120)||"file",s=`${o}-${n}`,i=s,c=1;for(;t.has(i);)c+=1,i=`${s}-${c}`;return t.add(i),i}d(Se,"uniqueInputName");function ie(r,e,t){!r||typeof r!="object"||Object.assign(r,{workLifecycle:e,...t?{workFinalizationError:k(t)}:{}})}d(ie,"attachWorkFailure");function Ie(r){return new Map(r.map(e=>[e.path,ce(e)]))}d(Ie,"outputSignatures");function ce(r){return`${r.sizeBytes}:${r.updatedAt}`}d(ce,"outputSignature");function ve(r){let e=pe(r.path).split("/").at(-1)||r.path,t=We(e);return{path:r.path,name:e,mimeType:t,sizeBytes:r.sizeBytes,updatedAt:r.updatedAt,isBinary:r.isBinary??null,previewable:r.previewable??(t.startsWith("image/")||t==="application/pdf"||t.startsWith("text/"))}}d(ve,"workOutputFromFile");function pe(r){return r.replaceAll("\\","/")}d(pe,"normalizedOutputPath");function We(r){let e=r.toLowerCase().match(/\.[^.]+$/)?.[0]??"";return Le[e]??"application/octet-stream"}d(We,"workOutputMimeType");var Le=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 O(r,e){return{role:"tool",tool_call_id:r,content:JSON.stringify(e)}}d(O,"toolMessage");function ae(r,e,t,o){return Number.isFinite(r)?Math.min(t,Math.max(e,Math.floor(r))):o}d(ae,"boundedInteger");function Ae(r,e){return r.length<=e?r:`${r.slice(0,e)}
5
5
  \u2026 output truncated by openpond-sdk`}d(Ae,"truncate");function k(r){return r instanceof Error?r.message:String(r)}d(k,"errorMessage");function _e(r,e){return new Promise((t,o)=>{if(e?.aborted){o(e.reason);return}let n=setTimeout(t,r);n.unref?.(),e?.addEventListener("abort",()=>{clearTimeout(n),o(e.reason)},{once:!0})})}d(_e,"sleep");import{promises as le}from"node:fs";var R=class{static{d(this,"OpenPondProjectActionsClient")}#e;#n;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl.replace(/\/+$/,"")}async list(e){let t=await y(this.#n,this.#e,_(e.projectId,"releases",e.teamId));return(await w(t,"List Project Action releases")).releases}async catalog(e){let t=await y(this.#n,this.#e,_(e.projectId,"catalog",e.teamId));return(await w(t,"Get Project Action catalog")).catalog}async publish(e){let[t,o]=await Promise.all([le.readFile(e.build.bundlePath),le.readFile(e.build.runnerPath)]),n=await y(this.#n,this.#e,_(e.projectId,"releases",e.teamId),{method:"POST",body:JSON.stringify({sourceRef:e.sourceRef,sourceCommitSha:e.sourceCommitSha,bundleBase64:t.toString("base64"),runnerBase64:o.toString("base64"),registry:e.build.registry,manifest:e.build.manifest,metadata:e.metadata})});return(await w(n,"Publish Project Actions")).release}async run(e){let t=await y(this.#n,this.#e,_(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 w(t,"Run Project Action")).invocation}};function _(r,e,t){return`/v1/project-actions/${encodeURIComponent(r)}/${e}?teamId=${encodeURIComponent(t)}`}d(_,"projectActionPath");var S=class{static{d(this,"OpenPondProfileActionsClient")}#e;#n;constructor(e){this.#e=e.apiKey,this.#n=e.apiBaseUrl.replace(/\/+$/,"")}async catalog(e){let t=C(e.teamId,"teamId"),o=new URLSearchParams({teamId:t});e.profileId?.trim()&&o.set("profileId",e.profileId.trim()),e.profileName?.trim()&&o.set("profileName",e.profileName.trim());let n=await y(this.#n,this.#e,`/v1/profile/actions?${o.toString()}`);return(await w(n,"Get Profile Action catalog")).catalog}async run(e){let t=C(e.teamId,"teamId"),o=C(e.actionKey,"actionKey"),n=C(e.idempotencyKey,"idempotencyKey"),s=C(e.catalogVersion,"catalogVersion"),i=await y(this.#n,this.#e,`/v1/profile/actions/run?${new URLSearchParams({teamId:t}).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:o,value:e.value??{},conversationId:e.conversationId??null,createConversation:e.createConversation,conversationTitle:e.conversationTitle??null,idempotencyKey:n,catalogVersion:s,externalCapabilityLeases:e.externalCapabilityLeases})});return w(i,"Run Profile Action")}};function C(r,e){let t=r.trim();if(!t)throw new Error(`${e} is required`);return t}d(C,"requiredValue");import{randomUUID as ue}from"node:crypto";var I=class{static{d(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,t={}){return this.#t("","Create Workflow",{method:"POST",body:JSON.stringify({...e,clientRequestId:e.clientRequestId?.trim()||ue()}),signal:t.signal})}async update(e,t,o={}){return this.#t(`/schedules/${encodeURIComponent(z(e,"scheduleId"))}`,"Update Workflow",{method:"PATCH",body:JSON.stringify(t),signal:o.signal})}async delete(e,t={}){return this.#t(`/schedules/${encodeURIComponent(z(e,"scheduleId"))}`,"Delete Workflow",{method:"DELETE",signal:t.signal})}async runNow(e,t={},o={}){return this.#t(`/schedules/${encodeURIComponent(z(e,"scheduleId"))}/run`,"Run Workflow",{method:"POST",body:JSON.stringify({clientRequestId:t.clientRequestId?.trim()||ue()}),signal:o.signal})}async#t(e,t,o={}){let n=await y(this.#n,this.#e,`/v1/saved-work${e}`,o);return w(n,t)}};function z(r,e){let t=r.trim();if(!t)throw new Error(`${e} is required`);return t}d(z,"requiredId");var T=a.object({id:l,scope:l,sourceId:l,name:a.string().trim().min(1).max(100),keyPrefix:a.string().min(1).max(100),createdAt:a.iso.datetime(),expiresAt:a.iso.datetime(),revokedAt:a.iso.datetime().nullable()}).strict(),me=a.string().regex(/^opk_key_[A-Za-z0-9]{16}_[A-Za-z0-9]{48}$/),q=a.discriminatedUnion("action",[a.object({action:a.literal("create"),scope:l,sourceId:l,name:a.string().trim().min(1).max(100),expiresAt:a.iso.datetime(),operationId:l,apiKey:me}).strict(),a.object({action:a.literal("list"),scope:l,sourceId:l,afterId:l.optional(),limit:a.number().int().min(1).max(100).default(30)}).strict(),a.object({action:a.literal("revoke"),scope:l,sourceId:l,id:l}).strict()]),ge=a.object({credential:T,apiKey:me}).strict(),he=a.object({items:a.array(T).max(100),nextCursor:l.nullable()}).strict(),fe=a.object({scope:l,sourceId:l}).strict(),ye=a.object({scope:l,source:$,taskDefinition:$,enabled:a.boolean(),allowedSplits:a.array(Y).min(1).max(4)}).strict();var Te=a.object({batchId:a.string().trim().min(1).max(500),modelProjectId:a.string().trim().min(1).max(500)}).strict(),qe=a.object({batchId:a.string().min(1),projectId:a.string().min(1),tasksetId:a.string().min(1),releaseId:a.string().min(1),revision:a.number().int().positive(),contentHash:a.string().regex(/^[a-f0-9]{64}$/)}).strict(),u=class extends Error{constructor(t,o,n,s){super(n);this.status=t;this.code=o;this.details=s;this.name="OpenPondLearningError"}status;code;details;static{d(this,"OpenPondLearningError")}},v=class{static{d(this,"OpenPondLearningClient")}#e;constructor(e){if(!e.apiKey.trim()||!e.scope.trim())throw new Error("Learning API key and scope are required.");let t=new URL(e.baseUrl);if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.search||t.hash)throw new Error("Learning base URL must be an HTTP(S) endpoint without credentials, query, or fragment.");this.#e={...e,baseUrl:t.toString().replace(/\/+$/,"")}}async command(e,t={}){ee(e);let o=te.parse({scope:this.#e.scope,command:e}),n=oe.parse(await this.#t("commands",o,t));if(n.operationId!==e.operationId)throw new u(502,"operation_identity_mismatch","Learning response did not match the submitted operation.",null);return n}submitExample(e,t={}){return this.command({action:"submit_example",operationId:e.idempotencyKey,example:e},t)}submitFeedback(e,t={}){return this.command({action:"submit_feedback",operationId:e.idempotencyKey,feedback:e},t)}async get(e,t,o,n={}){let s=P.parse({action:"get",scope:this.#e.scope,kind:e,id:t,...o===void 0?{}:{revision:o}});return M[e].parse(await this.#t("read",s,n))}async inspectEvidence(e,t={}){let o=P.parse({action:"inspect_evidence",scope:this.#e.scope,evidence:e}),n=ne.parse(await this.#t("read",o,t));if(!F(n.evidence,e))throw new u(502,"evidence_identity_mismatch","Inspection did not match the requested evidence release.",null);return n}async inspectTaskQueue(e=null,t={}){let o=P.parse({action:"inspect_task_queue",scope:this.#e.scope,modelProjectId:e}),n=Q.parse(await this.#t("read",o,t));if(n.modelProjectId!==e)throw new u(502,"model_identity_mismatch","Task queue did not match the requested Model.",null);return n}async inspectPolicy(e,t={}){let o=P.parse({action:"inspect_policy",scope:this.#e.scope,policy:e}),n=G.parse(await this.#t("read",o,t));if(!F(n.policy,e))throw new u(502,"policy_identity_mismatch","Inspection did not match the requested policy release.",null);return n}async createSourceCredential(e,t={}){let o=q.parse({...e,action:"create",scope:this.#e.scope}),n=ge.parse(await this.#t("credentials",o,t));if(this.#n(n.credential,e.sourceId),n.apiKey!==e.apiKey||!e.apiKey.startsWith(`${n.credential.keyPrefix}_`))throw new u(502,"credential_identity_mismatch","Credential response did not match the prepared credential.",null);return n}async listSourceCredentials(e,t={},o={}){let n=q.parse({...t,action:"list",scope:this.#e.scope,sourceId:e}),s=he.parse(await this.#t("credentials",n,o));if(s.items.length>(t.limit??30))throw new u(502,"credential_page_invalid","Credential response exceeded the requested page size.",null);for(let i of s.items)this.#n(i,e);return s}async revokeSourceCredential(e,t,o={}){let n=q.parse({action:"revoke",scope:this.#e.scope,sourceId:e,id:t}),s=T.parse(await this.#t("credentials",n,o));if(this.#n(s,e),s.id!==t||s.revokedAt===null)throw new u(502,"credential_revocation_mismatch","Credential revocation did not match the requested credential.",null);return s}async sourceConfiguration(e,t={}){let o=fe.parse({scope:this.#e.scope,sourceId:e}),n=ye.parse(await this.#t("source-config",o,t));if(n.scope!==this.#e.scope||n.source.id!==e)throw new u(502,"source_identity_mismatch","Source configuration did not match the requested source.",null);return n}#n(e,t){if(e.scope!==this.#e.scope||e.sourceId!==t)throw new u(502,"credential_scope_mismatch","Credential response did not match the requested source.",null)}async list(e,t={},o={}){let n=P.parse({action:"list",scope:this.#e.scope,kind:e,...t});return a.object({items:a.array(M[e]).max(100),nextCursor:a.string().nullable()}).strict().parse(await this.#t("read",n,o))}async publishBatch(e,t={}){let o=Te.parse(e),n=qe.parse(await this.#t("publish-batch",{...o,scope:this.#e.scope},t));if(n.batchId!==o.batchId)throw new u(502,"batch_identity_mismatch","Published batch response did not match the requested batch.",null);return n}async#t(e,t,o){K(t,16777216);let n=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(t),signal:o.signal,redirect:"error"}),s=await Ue(n);if(!n.ok){let i=a.object({code:a.string().optional(),error:a.string().optional()}).passthrough().safeParse(s);throw new u(n.status,i.success?i.data.code??"learning_request_failed":"learning_request_failed",i.success?i.data.error??`Learning request failed (${n.status}).`:`Learning request failed (${n.status}).`,s)}return s}};async function Ue(r){let t=r.body?.getReader();if(!t)throw new u(r.status,"empty_response","Learning response was empty.",null);let o=new TextDecoder,n=0,s="";try{for(;;){let c=await t.read();if(c.done)break;if(n+=c.value.byteLength,n>16777216)throw new u(r.status,"response_too_large","Learning response exceeded 16 MiB; request a smaller page.",null);s+=o.decode(c.value,{stream:!0})}s+=o.decode();let i=JSON.parse(s);return K(i,16777216),i}finally{await t.cancel(),t.releaseLock()}}d(Ue,"readBoundedLearningResponse");var J=class{static{d(this,"OpenPondClient")}sandboxes;work;workflows;actions;profileActions;learning;constructor(e){let t=e.apiKey.trim();if(!t)throw new Error("OpenPond API key is required");let o=e.baseUrl?.trim()||"https://api.openpond.ai";this.learning=n=>new v({apiKey:t,baseUrl:o,scope:n}),this.sandboxes=Z({apiKey:t,baseUrl:o,sandboxApiUrl:e.sandboxApiUrl}),this.work=new x({apiKey:t,apiBaseUrl:o,chatApiBaseUrl:e.chatApiUrl?.trim()||E({apiBaseUrl:o,env:{}}),sandboxes:this.sandboxes}),this.workflows=new I({apiKey:t,apiBaseUrl:o}),this.actions=new R({apiKey:t,apiBaseUrl:o}),this.profileActions=new S({apiKey:t,apiBaseUrl:o})}};function qt(r){return new J(r)}d(qt,"createOpenPondClient");export{qt as a};