@evolvingmachines/daytona 0.0.59 → 0.0.60
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/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var sdk=require('@daytonaio/sdk'),crypto=require('crypto');var I="c-
|
|
1
|
+
'use strict';var sdk=require('@daytonaio/sdk'),crypto=require('crypto');var I="c-4bfce70a407f";var z={[`evolve-all-${I}`]:`evolvingmachines/evolve-all:${I}`,"evolve-all":"evolvingmachines/evolve-all"},Lt=10,tt=10,et=20,Nt=18e4,Bt=2e3,ut=6e5,ft=5e3,Rt={pollMinMs:250,pollMaxMs:2e3,drainMs:1e3,killGraceMs:15e3,settleMs:6e4},S=s=>new Promise(t=>setTimeout(t,Math.max(0,s))),Ut=100,C=1e4;function Ft(s){let t=s.lastIndexOf("/");return t>0?s.substring(0,t):"/"}function Yt(s){let t=s.lastIndexOf("/");return t>=0?s.substring(t+1):s}var b=class extends Error{reason;destination;constructor(t,e,n){super(e),this.name="DaytonaNetworkPolicyError",this.reason=t,this.destination=n;}},M=class extends Error{image;constructor(t,e){let n=e instanceof Error?e.message:String(e??"unknown error");super(`Failed to pull image "${t}" on Daytona: ${n}. Private registry images require the registry pre-registered in the Daytona dashboard (Registries page) before sandbox creation \u2014 Daytona has no per-call image pull secret; AWS ECR registrations name an IAM role Daytona assumes (no password). Register the registry at https://app.daytona.io, then retry. Also ensure the image is linux/amd64 and pinned to a tag or digest (floating tags like "latest" are rejected by Daytona's snapshot builder).`),this.name="DaytonaImagePullError",this.image=t;}},nt=class extends Error{snapshot;constructor(t){super(`Daytona cannot constrain the GPU type for "${t}": the snapshot already exists and pins its resources \u2014 pre-build a snapshot with the desired GPU type under its own name.`),this.name="DaytonaGpuTypeError",this.snapshot=t;}},T=class extends Error{snapshot;constructor(t){super(`Daytona snapshot "${t}" already exists and pins its cpu/memory/disk sizing \u2014 create-from-snapshot cannot resize it, so the requested \`resources\` cannot be enforced. Pre-build a snapshot with the desired sizing under its own name (sizing-addressed), or omit \`resources\` to accept the snapshot's pinned sizing.`),this.name="DaytonaResourcesError",this.snapshot=t;}},O=class extends Error{constructor(){super("Daytona takes no create-time boot command: it never runs an image entrypoint or any argv at boot (harbor daytona/environment.py:706-708 works around exactly that, starting dockerd by hand). The boot is already inert \u2014 run the process by exec after create."),this.name="DaytonaBootCommandError";}},E=class extends Error{constructor(){super("Daytona has no separate idle timeout: auto-stop IS its only clock and it already measures inactivity, so `timeoutMs` is what sets it (autoStopInterval). Set the inactivity bound with `timeoutMs`; a hard bound on the process itself is enforced in-box instead (see withInBoxTimeout)."),this.name="DaytonaIdleTimeoutError";}},Gt=new Set(["pending_build","building_snapshot","pulling_snapshot"]);function st(s){return s!=null&&Gt.has(s)?"image_pull":"boot"}var L=class extends Error{phase;state;sandboxId;constructor(t,e,n){super(`Daytona sandbox boot abandoned during ${t} (provider state ${e??"not yet reported"}, sandbox ${n??"not yet created"})`),this.name="DaytonaBootAbortedError",this.phase=t,this.state=e,this.sandboxId=n;}},ot="evolve_boot",Wt=5e3,rt=30;async function oe(s,t,e={}){let n=crypto.randomUUID(),r=e.pollMs??Wt,o=null,a=null,i=false,d=(l,u)=>{let h=l==="build_log"?"image_pull":st(a);e.onProgress?.({signal:l,phase:h,state:a,sandboxId:o?.id??null,...u===void 0?{}:{line:u}});},f=s.create({...t,labels:{...t.labels??{},[ot]:n}},{timeout:0,onSnapshotCreateLogs:l=>{for(let u of l.split(`
|
|
2
2
|
`)){let h=u.trimEnd();h.length>0&&d("build_log",h);}}});(async()=>{for(;!i;){try{if(o===null)for await(let u of s.list({labels:{[ot]:n}})){o=u;break}else await o.refreshData();let l=o?.state??null;l!==a&&(a=l,d("state"));}catch{}i||await S(r);}})();let c=()=>{let l=new L(st(a),a,o?.id??null);return f.then(u=>u.delete(rt).catch(()=>{}),()=>{}),o!==null&&o.delete(rt).catch(()=>{}),l},g=new Promise((l,u)=>{let h=e.signal;if(h){if(h.aborted){u(c());return}h.addEventListener("abort",()=>{i||u(c());},{once:true});}});try{return await Promise.race([f,g])}finally{i=true;}}var A=class extends Error{snapshot;constructor(t,e){super(`Daytona snapshot "${t}" exists but could not be activated: ${e}. Daytona deactivates snapshots unused for 2 weeks; activation normally completes in seconds. Retry, or activate it manually in the Daytona dashboard (Snapshots page).`),this.name="DaytonaSnapshotActivationError",this.snapshot=t;}};async function N(s,t,e,n){let r=n?.timeoutMs??Nt,o=n?.pollMs??Bt;console.log(`[daytona] Snapshot "${t}" is inactive (unused for 2+ weeks) \u2014 reactivating...`);let a;try{a=await s.snapshot.activate(e);}catch(d){throw new A(t,`the activate call failed (${d instanceof Error?d.message:String(d)})`)}let i=Date.now()+r;for(;a?.state!=="active";){if(a?.state==="error"||a?.state==="build_failed")throw new A(t,`it entered state "${a.state}"`);if(Date.now()>=i)throw new A(t,`still "${a?.state??"unknown"}" after ${r}ms`);await S(o);try{a=await s.snapshot.get(t);}catch(d){throw new A(t,`the activation poll failed (${d instanceof Error?d.message:String(d)})`)}}return console.log(`[daytona] Snapshot "${t}" reactivated.`),a}var D=class extends Error{snapshot;constructor(t,e){super(`Daytona snapshot "${t}" is being created by another process and this run could not wait it out: ${e}.`),this.name="DaytonaSnapshotConflictError",this.snapshot=t;}},gt=Symbol("daytona-snapshot-gone"),mt=new Set(["pending","pulling","building","snapshotting"]),jt=3;function V(s){let t=s;return t?.status??t?.statusCode??t?.response?.status}var at=new Set(["error","build_failed"]),Ht=new Set(["latest","lts","stable"]);function B(s){let t=z[s]??s;if(t.includes("@"))return /@[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[0-9a-f]{32,}$/i.test(t);let e=t.substring(t.lastIndexOf("/")+1),n=e.lastIndexOf(":");if(n<0)return false;let r=e.substring(n+1);return r===""?false:!Ht.has(r.toLowerCase())}function R(s){let t=s.toLowerCase();return t.includes("not found")||t.includes("404")||t.includes("does not exist")}var pt=6e4,ht=2e3;async function it(s,t,e,n){let r=e.errorReason?`: ${e.errorReason}`:"";console.warn(`[daytona] Deleting dead snapshot "${t}" (state "${e.state??"unknown"}"${r}) before rebuilding it.`);try{await s.snapshot.delete(e);}catch(d){let f=d instanceof Error?d.message:String(d);if(!R(f))return console.warn(`[daytona] Could not delete dead snapshot "${t}" (${f}) \u2014 delete it in the Daytona dashboard (Snapshots page) to restore the fast path; falling back to a direct image pull for now.`),false}let o=n?.timeoutMs??pt,a=n?.pollMs??ht,i=Date.now()+o;for(;;){try{await s.snapshot.get(t);}catch(d){if(R(d instanceof Error?d.message:String(d)))return true}if(Date.now()>=i)return console.warn(`[daytona] Dead snapshot "${t}" still resolves ${o}ms after it was deleted \u2014 leaving the rebuild to the next run rather than racing the removal.`),false;await S(a);}}function wt(s){if(V(s)===409)return true;let t=(s instanceof Error?s.message:String(s)).toLowerCase();return t.includes("already exists")||t.includes("conflict")}function Kt(s){let t=V(s);if(t===401||t===403)return true;let e=(s instanceof Error?s.message:String(s)).toLowerCase();return e.includes("unauthorized")||e.includes("forbidden")||e.includes("status code 401")||e.includes("status code 403")}async function bt(s,t,e){let n=e?.timeoutMs??ut,r=e?.pollMs??ft;console.log(`[daytona] Snapshot "${t}" is already being created by another process \u2014 waiting for it (up to ${Math.round(n/1e3)}s) instead of pulling the image directly...`);let o=Date.now()+n,a,i="",d=0;for(;;){try{a=await s.snapshot.get(t),i="",d=0;}catch(f){a=void 0;let m=f instanceof Error?f.message:String(f);if(R(m))return console.log(`[daytona] Snapshot "${t}" no longer exists \u2014 the name is clear, building it.`),gt;if(Kt(f))throw new D(t,`the poll was refused (${m}) \u2014 these credentials cannot read the snapshot, so waiting longer cannot help`);if(d=m===i?d+1:1,i=m,d>=jt)throw new D(t,`${d} consecutive polls failed the same way (${m}) \u2014 the control plane is not answering, so waiting longer cannot help`);console.warn(`[daytona] Poll of contended snapshot "${t}" failed, retrying: ${m}`);}if(a!==void 0&&!mt.has(a.state??""))return a;if(Date.now()>=o)throw new D(t,`it was still "${a?.state??"unknown"}" after ${n}ms \u2014 retry once that build finishes, or check the snapshot in the Daytona dashboard (Snapshots page)`);await S(r);}}function U(s,t){if(!t||t<=0)return s;let e=Buffer.from(s).toString("base64"),n=`/tmp/.evolve-cmd-${Date.now()}-${Math.random().toString(36).slice(2,8)}.sh`;return `sh -c '${`echo ${e} | base64 -d > ${n} && [ -s ${n} ] || { rm -f ${n}; exit 126; }; if command -v timeout >/dev/null 2>&1; then timeout -k 10 ${t} bash ${n}; else bash ${n}; fi; rc=$?; rm -f ${n}; exit $rc`}'`}function dt(){return `EVOLVE-EOS-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function F(s,t){return s.trim()?`exec 9>&1 && { :
|
|
3
3
|
${s}
|
|
4
4
|
|
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ import { CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, Sandbox,
|
|
|
9
9
|
* packages/daytona/tests/unit/daytona-image-version.test.ts fails the
|
|
10
10
|
* suite whenever this checked-in copy is stale.
|
|
11
11
|
*/
|
|
12
|
-
declare const EVOLVE_IMAGE_VERSION = "c-
|
|
12
|
+
declare const EVOLVE_IMAGE_VERSION = "c-4bfce70a407f";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Daytona Sandbox Provider
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, Sandbox,
|
|
|
9
9
|
* packages/daytona/tests/unit/daytona-image-version.test.ts fails the
|
|
10
10
|
* suite whenever this checked-in copy is stale.
|
|
11
11
|
*/
|
|
12
|
-
declare const EVOLVE_IMAGE_VERSION = "c-
|
|
12
|
+
declare const EVOLVE_IMAGE_VERSION = "c-4bfce70a407f";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Daytona Sandbox Provider
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {STDOUT_PREFIX_BYTES,STDERR_PREFIX_BYTES,MAX_PREFIX_LEN,Daytona,Image}from'@daytonaio/sdk';import {randomUUID}from'crypto';var I="c-
|
|
1
|
+
import {STDOUT_PREFIX_BYTES,STDERR_PREFIX_BYTES,MAX_PREFIX_LEN,Daytona,Image}from'@daytonaio/sdk';import {randomUUID}from'crypto';var I="c-4bfce70a407f";var z={[`evolve-all-${I}`]:`evolvingmachines/evolve-all:${I}`,"evolve-all":"evolvingmachines/evolve-all"},Lt=10,tt=10,et=20,Nt=18e4,Bt=2e3,ut=6e5,ft=5e3,Rt={pollMinMs:250,pollMaxMs:2e3,drainMs:1e3,killGraceMs:15e3,settleMs:6e4},S=s=>new Promise(t=>setTimeout(t,Math.max(0,s))),Ut=100,C=1e4;function Ft(s){let t=s.lastIndexOf("/");return t>0?s.substring(0,t):"/"}function Yt(s){let t=s.lastIndexOf("/");return t>=0?s.substring(t+1):s}var b=class extends Error{reason;destination;constructor(t,e,n){super(e),this.name="DaytonaNetworkPolicyError",this.reason=t,this.destination=n;}},M=class extends Error{image;constructor(t,e){let n=e instanceof Error?e.message:String(e??"unknown error");super(`Failed to pull image "${t}" on Daytona: ${n}. Private registry images require the registry pre-registered in the Daytona dashboard (Registries page) before sandbox creation \u2014 Daytona has no per-call image pull secret; AWS ECR registrations name an IAM role Daytona assumes (no password). Register the registry at https://app.daytona.io, then retry. Also ensure the image is linux/amd64 and pinned to a tag or digest (floating tags like "latest" are rejected by Daytona's snapshot builder).`),this.name="DaytonaImagePullError",this.image=t;}},nt=class extends Error{snapshot;constructor(t){super(`Daytona cannot constrain the GPU type for "${t}": the snapshot already exists and pins its resources \u2014 pre-build a snapshot with the desired GPU type under its own name.`),this.name="DaytonaGpuTypeError",this.snapshot=t;}},T=class extends Error{snapshot;constructor(t){super(`Daytona snapshot "${t}" already exists and pins its cpu/memory/disk sizing \u2014 create-from-snapshot cannot resize it, so the requested \`resources\` cannot be enforced. Pre-build a snapshot with the desired sizing under its own name (sizing-addressed), or omit \`resources\` to accept the snapshot's pinned sizing.`),this.name="DaytonaResourcesError",this.snapshot=t;}},O=class extends Error{constructor(){super("Daytona takes no create-time boot command: it never runs an image entrypoint or any argv at boot (harbor daytona/environment.py:706-708 works around exactly that, starting dockerd by hand). The boot is already inert \u2014 run the process by exec after create."),this.name="DaytonaBootCommandError";}},E=class extends Error{constructor(){super("Daytona has no separate idle timeout: auto-stop IS its only clock and it already measures inactivity, so `timeoutMs` is what sets it (autoStopInterval). Set the inactivity bound with `timeoutMs`; a hard bound on the process itself is enforced in-box instead (see withInBoxTimeout)."),this.name="DaytonaIdleTimeoutError";}},Gt=new Set(["pending_build","building_snapshot","pulling_snapshot"]);function st(s){return s!=null&&Gt.has(s)?"image_pull":"boot"}var L=class extends Error{phase;state;sandboxId;constructor(t,e,n){super(`Daytona sandbox boot abandoned during ${t} (provider state ${e??"not yet reported"}, sandbox ${n??"not yet created"})`),this.name="DaytonaBootAbortedError",this.phase=t,this.state=e,this.sandboxId=n;}},ot="evolve_boot",Wt=5e3,rt=30;async function oe(s,t,e={}){let n=randomUUID(),r=e.pollMs??Wt,o=null,a=null,i=false,d=(l,u)=>{let h=l==="build_log"?"image_pull":st(a);e.onProgress?.({signal:l,phase:h,state:a,sandboxId:o?.id??null,...u===void 0?{}:{line:u}});},f=s.create({...t,labels:{...t.labels??{},[ot]:n}},{timeout:0,onSnapshotCreateLogs:l=>{for(let u of l.split(`
|
|
2
2
|
`)){let h=u.trimEnd();h.length>0&&d("build_log",h);}}});(async()=>{for(;!i;){try{if(o===null)for await(let u of s.list({labels:{[ot]:n}})){o=u;break}else await o.refreshData();let l=o?.state??null;l!==a&&(a=l,d("state"));}catch{}i||await S(r);}})();let c=()=>{let l=new L(st(a),a,o?.id??null);return f.then(u=>u.delete(rt).catch(()=>{}),()=>{}),o!==null&&o.delete(rt).catch(()=>{}),l},g=new Promise((l,u)=>{let h=e.signal;if(h){if(h.aborted){u(c());return}h.addEventListener("abort",()=>{i||u(c());},{once:true});}});try{return await Promise.race([f,g])}finally{i=true;}}var A=class extends Error{snapshot;constructor(t,e){super(`Daytona snapshot "${t}" exists but could not be activated: ${e}. Daytona deactivates snapshots unused for 2 weeks; activation normally completes in seconds. Retry, or activate it manually in the Daytona dashboard (Snapshots page).`),this.name="DaytonaSnapshotActivationError",this.snapshot=t;}};async function N(s,t,e,n){let r=n?.timeoutMs??Nt,o=n?.pollMs??Bt;console.log(`[daytona] Snapshot "${t}" is inactive (unused for 2+ weeks) \u2014 reactivating...`);let a;try{a=await s.snapshot.activate(e);}catch(d){throw new A(t,`the activate call failed (${d instanceof Error?d.message:String(d)})`)}let i=Date.now()+r;for(;a?.state!=="active";){if(a?.state==="error"||a?.state==="build_failed")throw new A(t,`it entered state "${a.state}"`);if(Date.now()>=i)throw new A(t,`still "${a?.state??"unknown"}" after ${r}ms`);await S(o);try{a=await s.snapshot.get(t);}catch(d){throw new A(t,`the activation poll failed (${d instanceof Error?d.message:String(d)})`)}}return console.log(`[daytona] Snapshot "${t}" reactivated.`),a}var D=class extends Error{snapshot;constructor(t,e){super(`Daytona snapshot "${t}" is being created by another process and this run could not wait it out: ${e}.`),this.name="DaytonaSnapshotConflictError",this.snapshot=t;}},gt=Symbol("daytona-snapshot-gone"),mt=new Set(["pending","pulling","building","snapshotting"]),jt=3;function V(s){let t=s;return t?.status??t?.statusCode??t?.response?.status}var at=new Set(["error","build_failed"]),Ht=new Set(["latest","lts","stable"]);function B(s){let t=z[s]??s;if(t.includes("@"))return /@[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[0-9a-f]{32,}$/i.test(t);let e=t.substring(t.lastIndexOf("/")+1),n=e.lastIndexOf(":");if(n<0)return false;let r=e.substring(n+1);return r===""?false:!Ht.has(r.toLowerCase())}function R(s){let t=s.toLowerCase();return t.includes("not found")||t.includes("404")||t.includes("does not exist")}var pt=6e4,ht=2e3;async function it(s,t,e,n){let r=e.errorReason?`: ${e.errorReason}`:"";console.warn(`[daytona] Deleting dead snapshot "${t}" (state "${e.state??"unknown"}"${r}) before rebuilding it.`);try{await s.snapshot.delete(e);}catch(d){let f=d instanceof Error?d.message:String(d);if(!R(f))return console.warn(`[daytona] Could not delete dead snapshot "${t}" (${f}) \u2014 delete it in the Daytona dashboard (Snapshots page) to restore the fast path; falling back to a direct image pull for now.`),false}let o=n?.timeoutMs??pt,a=n?.pollMs??ht,i=Date.now()+o;for(;;){try{await s.snapshot.get(t);}catch(d){if(R(d instanceof Error?d.message:String(d)))return true}if(Date.now()>=i)return console.warn(`[daytona] Dead snapshot "${t}" still resolves ${o}ms after it was deleted \u2014 leaving the rebuild to the next run rather than racing the removal.`),false;await S(a);}}function wt(s){if(V(s)===409)return true;let t=(s instanceof Error?s.message:String(s)).toLowerCase();return t.includes("already exists")||t.includes("conflict")}function Kt(s){let t=V(s);if(t===401||t===403)return true;let e=(s instanceof Error?s.message:String(s)).toLowerCase();return e.includes("unauthorized")||e.includes("forbidden")||e.includes("status code 401")||e.includes("status code 403")}async function bt(s,t,e){let n=e?.timeoutMs??ut,r=e?.pollMs??ft;console.log(`[daytona] Snapshot "${t}" is already being created by another process \u2014 waiting for it (up to ${Math.round(n/1e3)}s) instead of pulling the image directly...`);let o=Date.now()+n,a,i="",d=0;for(;;){try{a=await s.snapshot.get(t),i="",d=0;}catch(f){a=void 0;let m=f instanceof Error?f.message:String(f);if(R(m))return console.log(`[daytona] Snapshot "${t}" no longer exists \u2014 the name is clear, building it.`),gt;if(Kt(f))throw new D(t,`the poll was refused (${m}) \u2014 these credentials cannot read the snapshot, so waiting longer cannot help`);if(d=m===i?d+1:1,i=m,d>=jt)throw new D(t,`${d} consecutive polls failed the same way (${m}) \u2014 the control plane is not answering, so waiting longer cannot help`);console.warn(`[daytona] Poll of contended snapshot "${t}" failed, retrying: ${m}`);}if(a!==void 0&&!mt.has(a.state??""))return a;if(Date.now()>=o)throw new D(t,`it was still "${a?.state??"unknown"}" after ${n}ms \u2014 retry once that build finishes, or check the snapshot in the Daytona dashboard (Snapshots page)`);await S(r);}}function U(s,t){if(!t||t<=0)return s;let e=Buffer.from(s).toString("base64"),n=`/tmp/.evolve-cmd-${Date.now()}-${Math.random().toString(36).slice(2,8)}.sh`;return `sh -c '${`echo ${e} | base64 -d > ${n} && [ -s ${n} ] || { rm -f ${n}; exit 126; }; if command -v timeout >/dev/null 2>&1; then timeout -k 10 ${t} bash ${n}; else bash ${n}; fi; rc=$?; rm -f ${n}; exit $rc`}'`}function dt(){return `EVOLVE-EOS-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function F(s,t){return s.trim()?`exec 9>&1 && { :
|
|
3
3
|
${s}
|
|
4
4
|
|