@evolvingmachines/daytona 0.0.63 → 0.0.64
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');require('fs');var E=class extends Error{feature;provider;reason;constructor(t,e,s){super(`${e} does not support ${t}${s?`: ${s}`:""}`),this.name="SandboxFeatureUnsupportedError",this.feature=t,this.provider=e,this.reason=s;}},A=class extends Error{path;provider;constructor(t,e){super(`${e}: no such file or directory: ${t}`),this.name="SandboxPathNotFoundError",this.path=t,this.provider=e;}},_=class extends Error{sandboxId;provider;state;constructor(t,e,s){super(`${e} sandbox ${t} is not running (${s}); inspect never starts or resumes a sandbox`),this.name="SandboxNotRunningError",this.sandboxId=t,this.provider=e,this.state=s;}};function L(n,t){return !!n&&typeof n=="object"&&n.name===t}function Xt(n){return L(n,"SandboxFeatureUnsupportedError")}function Vt(n){return L(n,"SandboxPathNotFoundError")}function qt(n){return L(n,"SandboxNotRunningError")}var M=2,N=20;function R(n){return `'${n.replace(/'/g,"'\\''")}'`}function U(n){if(!Number.isInteger(n.offset)||n.offset<0)throw new RangeError(`offset must be a non-negative integer, got ${n.offset}`);if(!Number.isInteger(n.length)||n.length<0)throw new RangeError(`length must be a non-negative integer, got ${n.length}`)}function ct(n){if(typeof n=="number")return lt((n&4095).toString(8));if(/^[0-7]{1,4}$/.test(n))return lt(n);throw new RangeError(`not an octal mode: ${n}`)}function lt(n){return n.padStart(4,"0")}function F(n){let t=n instanceof Date?n:typeof n=="number"?new Date(n*1e3):new Date(n);if(Number.isNaN(t.getTime()))throw new RangeError(`not a timestamp: ${String(n)}`);return t.toISOString()}function ut(n,t){return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}async function ft(n,t,e){if(U(t),t.length===0)return new Uint8Array(0);let s=t.offset+t.length-1,o=await fetch(n,{headers:{Range:`bytes=${t.offset}-${s}`},signal:AbortSignal.timeout(e.timeoutMs)});if(o.status===206){let r=new Uint8Array(await o.arrayBuffer());return r.length>t.length?r.subarray(0,t.length):r}if(o.status===200)return Qt(o,t);if(o.status===416)return await o.body?.cancel().catch(()=>{}),new Uint8Array(0);throw await o.body?.cancel().catch(()=>{}),o.status===404?new A(e.path,e.provider):new Error(`${e.provider}: range read of ${e.path} failed (HTTP ${o.status})`)}async function Qt(n,t){if(!n.body)return new Uint8Array(0);let e=n.body.getReader(),s=[],o=0,r=0,a=t.offset+t.length;try{for(;;){let{done:u,value:m}=await e.read();if(u)break;let c=o;if(o+=m.length,o>t.offset){let f=Math.max(0,t.offset-c),l=Math.min(m.length,a-c);l>f&&(s.push(m.subarray(f,l)),r+=l-f);}if(o>=a)break}}finally{await e.cancel().catch(()=>{});}let i=new Uint8Array(r),d=0;for(let u of s)i.set(u,d),d+=u.length;return i}var O="c-
|
|
1
|
+
'use strict';var sdk=require('@daytonaio/sdk'),crypto=require('crypto');require('fs');var E=class extends Error{feature;provider;reason;constructor(t,e,s){super(`${e} does not support ${t}${s?`: ${s}`:""}`),this.name="SandboxFeatureUnsupportedError",this.feature=t,this.provider=e,this.reason=s;}},A=class extends Error{path;provider;constructor(t,e){super(`${e}: no such file or directory: ${t}`),this.name="SandboxPathNotFoundError",this.path=t,this.provider=e;}},_=class extends Error{sandboxId;provider;state;constructor(t,e,s){super(`${e} sandbox ${t} is not running (${s}); inspect never starts or resumes a sandbox`),this.name="SandboxNotRunningError",this.sandboxId=t,this.provider=e,this.state=s;}};function L(n,t){return !!n&&typeof n=="object"&&n.name===t}function Xt(n){return L(n,"SandboxFeatureUnsupportedError")}function Vt(n){return L(n,"SandboxPathNotFoundError")}function qt(n){return L(n,"SandboxNotRunningError")}var M=2,N=20;function R(n){return `'${n.replace(/'/g,"'\\''")}'`}function U(n){if(!Number.isInteger(n.offset)||n.offset<0)throw new RangeError(`offset must be a non-negative integer, got ${n.offset}`);if(!Number.isInteger(n.length)||n.length<0)throw new RangeError(`length must be a non-negative integer, got ${n.length}`)}function ct(n){if(typeof n=="number")return lt((n&4095).toString(8));if(/^[0-7]{1,4}$/.test(n))return lt(n);throw new RangeError(`not an octal mode: ${n}`)}function lt(n){return n.padStart(4,"0")}function F(n){let t=n instanceof Date?n:typeof n=="number"?new Date(n*1e3):new Date(n);if(Number.isNaN(t.getTime()))throw new RangeError(`not a timestamp: ${String(n)}`);return t.toISOString()}function ut(n,t){return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}async function ft(n,t,e){if(U(t),t.length===0)return new Uint8Array(0);let s=t.offset+t.length-1,o=await fetch(n,{headers:{Range:`bytes=${t.offset}-${s}`},signal:AbortSignal.timeout(e.timeoutMs)});if(o.status===206){let r=new Uint8Array(await o.arrayBuffer());return r.length>t.length?r.subarray(0,t.length):r}if(o.status===200)return Qt(o,t);if(o.status===416)return await o.body?.cancel().catch(()=>{}),new Uint8Array(0);throw await o.body?.cancel().catch(()=>{}),o.status===404?new A(e.path,e.provider):new Error(`${e.provider}: range read of ${e.path} failed (HTTP ${o.status})`)}async function Qt(n,t){if(!n.body)return new Uint8Array(0);let e=n.body.getReader(),s=[],o=0,r=0,a=t.offset+t.length;try{for(;;){let{done:u,value:m}=await e.read();if(u)break;let c=o;if(o+=m.length,o>t.offset){let f=Math.max(0,t.offset-c),l=Math.min(m.length,a-c);l>f&&(s.push(m.subarray(f,l)),r+=l-f);}if(o>=a)break}}finally{await e.cancel().catch(()=>{});}let i=new Uint8Array(r),d=0;for(let u of s)i.set(u,d),d+=u.length;return i}var O="c-ebdfafe2ef1a";var ot={[`evolve-all-${O}`]:`evolvingmachines/evolve-all:${O}`,"evolve-all":"evolvingmachines/evolve-all"},ee=10,pt=10,ht=20,ne=18e4,se=2e3,$t=6e5,It=5e3,oe={pollMinMs:250,pollMaxMs:2e3,drainMs:1e3,killGraceMs:15e3,settleMs:6e4},S=n=>new Promise(t=>setTimeout(t,Math.max(0,n))),re=100,B=1e4;function ae(n){let t=n.lastIndexOf("/");return t>0?n.substring(0,t):"/"}function ie(n){let t=n.lastIndexOf("/");return t>=0?n.substring(t+1):n}var b=class extends Error{reason;destination;constructor(t,e,s){super(e),this.name="DaytonaNetworkPolicyError",this.reason=t,this.destination=s;}},W=class extends Error{image;constructor(t,e){let s=e instanceof Error?e.message:String(e??"unknown error");super(`Failed to pull image "${t}" on Daytona: ${s}. 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;}},wt=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;}},k=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;}},H=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";}},j=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";}},de=new Set(["pending_build","building_snapshot","pulling_snapshot"]);function yt(n){return n!=null&&de.has(n)?"image_pull":"boot"}var z=class extends Error{phase;state;sandboxId;constructor(t,e,s){super(`Daytona sandbox boot abandoned during ${t} (provider state ${e??"not yet reported"}, sandbox ${s??"not yet created"})`),this.name="DaytonaBootAbortedError",this.phase=t,this.state=e,this.sandboxId=s;}},bt="evolve_boot",le=5e3,xt=30;async function Ce(n,t,e={}){let s=crypto.randomUUID(),o=e.pollMs??le,r=null,a=null,i=false,d=(l,g)=>{let p=l==="build_log"?"image_pull":yt(a);e.onProgress?.({signal:l,phase:p,state:a,sandboxId:r?.id??null,...g===void 0?{}:{line:g}});},u=n.create({...t,labels:{...t.labels??{},[bt]:s}},{timeout:0,onSnapshotCreateLogs:l=>{for(let g of l.split(`
|
|
2
2
|
`)){let p=g.trimEnd();p.length>0&&d("build_log",p);}}});(async()=>{for(;!i;){try{if(r===null)for await(let g of n.list({labels:{[bt]:s}})){r=g;break}else await r.refreshData();let l=r?.state??null;l!==a&&(a=l,d("state"));}catch{}i||await S(o);}})();let c=()=>{let l=new z(yt(a),a,r?.id??null);return u.then(g=>g.delete(xt).catch(()=>{}),()=>{}),r!==null&&r.delete(xt).catch(()=>{}),l},f=new Promise((l,g)=>{let p=e.signal;if(p){if(p.aborted){g(c());return}p.addEventListener("abort",()=>{i||g(c());},{once:true});}});try{return await Promise.race([u,f])}finally{i=true;}}var v=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 K(n,t,e,s){let o=s?.timeoutMs??ne,r=s?.pollMs??se;console.log(`[daytona] Snapshot "${t}" is inactive (unused for 2+ weeks) \u2014 reactivating...`);let a;try{a=await n.snapshot.activate(e);}catch(d){throw new v(t,`the activate call failed (${d instanceof Error?d.message:String(d)})`)}let i=Date.now()+o;for(;a?.state!=="active";){if(a?.state==="error"||a?.state==="build_failed")throw new v(t,`it entered state "${a.state}"`);if(Date.now()>=i)throw new v(t,`still "${a?.state??"unknown"}" after ${o}ms`);await S(r);try{a=await n.snapshot.get(t);}catch(d){throw new v(t,`the activation poll failed (${d instanceof Error?d.message:String(d)})`)}}return console.log(`[daytona] Snapshot "${t}" reactivated.`),a}var T=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;}},Et=Symbol("daytona-snapshot-gone"),kt=new Set(["pending","pulling","building","snapshotting"]),ce=3;function rt(n){let t=n;return t?.status??t?.statusCode??t?.response?.status}var St=new Set(["error","build_failed"]),ue=new Set(["latest","lts","stable"]);function X(n){let t=ot[n]??n;if(t.includes("@"))return /@[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[0-9a-f]{32,}$/i.test(t);let e=t.substring(t.lastIndexOf("/")+1),s=e.lastIndexOf(":");if(s<0)return false;let o=e.substring(s+1);return o===""?false:!ue.has(o.toLowerCase())}function V(n){let t=n.toLowerCase();return t.includes("not found")||t.includes("404")||t.includes("does not exist")}var _t=6e4,Mt=2e3;async function vt(n,t,e,s){let o=e.errorReason?`: ${e.errorReason}`:"";console.warn(`[daytona] Deleting dead snapshot "${t}" (state "${e.state??"unknown"}"${o}) before rebuilding it.`);try{await n.snapshot.delete(e);}catch(d){let u=d instanceof Error?d.message:String(d);if(!V(u))return console.warn(`[daytona] Could not delete dead snapshot "${t}" (${u}) \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 r=s?.timeoutMs??_t,a=s?.pollMs??Mt,i=Date.now()+r;for(;;){try{await n.snapshot.get(t);}catch(d){if(V(d instanceof Error?d.message:String(d)))return true}if(Date.now()>=i)return console.warn(`[daytona] Dead snapshot "${t}" still resolves ${r}ms after it was deleted \u2014 leaving the rebuild to the next run rather than racing the removal.`),false;await S(a);}}function Ot(n){if(rt(n)===409)return true;let t=(n instanceof Error?n.message:String(n)).toLowerCase();return t.includes("already exists")||t.includes("conflict")}function fe(n){let t=rt(n);if(t===401||t===403)return true;let e=(n instanceof Error?n.message:String(n)).toLowerCase();return e.includes("unauthorized")||e.includes("forbidden")||e.includes("status code 401")||e.includes("status code 403")}async function Ct(n,t,e){let s=e?.timeoutMs??$t,o=e?.pollMs??It;console.log(`[daytona] Snapshot "${t}" is already being created by another process \u2014 waiting for it (up to ${Math.round(s/1e3)}s) instead of pulling the image directly...`);let r=Date.now()+s,a,i="",d=0;for(;;){try{a=await n.snapshot.get(t),i="",d=0;}catch(u){a=void 0;let m=u instanceof Error?u.message:String(u);if(V(m))return console.log(`[daytona] Snapshot "${t}" no longer exists \u2014 the name is clear, building it.`),Et;if(fe(u))throw new T(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>=ce)throw new T(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&&!kt.has(a.state??""))return a;if(Date.now()>=r)throw new T(t,`it was still "${a?.state??"unknown"}" after ${s}ms \u2014 retry once that build finishes, or check the snapshot in the Daytona dashboard (Snapshots page)`);await S(o);}}function q(n,t){if(!t||t<=0)return n;let e=Buffer.from(n).toString("base64"),s=`/tmp/.evolve-cmd-${Date.now()}-${Math.random().toString(36).slice(2,8)}.sh`;return `sh -c '${`echo ${e} | base64 -d > ${s} && [ -s ${s} ] || { rm -f ${s}; exit 126; }; if command -v timeout >/dev/null 2>&1; then timeout -k 10 ${t} bash ${s}; else bash ${s}; fi; rc=$?; rm -f ${s}; exit $rc`}'`}function At(){return `EVOLVE-EOS-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Q(n,t){return n.trim()?`exec 9>&1 && { :
|
|
3
3
|
${n}
|
|
4
4
|
|
package/dist/index.d.cts
CHANGED
|
@@ -36,7 +36,7 @@ declare function isSandboxNotRunningError(err: unknown): err is SandboxNotRunnin
|
|
|
36
36
|
* packages/daytona/tests/unit/daytona-image-version.test.ts fails the
|
|
37
37
|
* suite whenever this checked-in copy is stale.
|
|
38
38
|
*/
|
|
39
|
-
declare const EVOLVE_IMAGE_VERSION = "c-
|
|
39
|
+
declare const EVOLVE_IMAGE_VERSION = "c-ebdfafe2ef1a";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Daytona Sandbox Provider
|
package/dist/index.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare function isSandboxNotRunningError(err: unknown): err is SandboxNotRunnin
|
|
|
36
36
|
* packages/daytona/tests/unit/daytona-image-version.test.ts fails the
|
|
37
37
|
* suite whenever this checked-in copy is stale.
|
|
38
38
|
*/
|
|
39
|
-
declare const EVOLVE_IMAGE_VERSION = "c-
|
|
39
|
+
declare const EVOLVE_IMAGE_VERSION = "c-ebdfafe2ef1a";
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* 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';import'fs';var E=class extends Error{feature;provider;reason;constructor(t,e,s){super(`${e} does not support ${t}${s?`: ${s}`:""}`),this.name="SandboxFeatureUnsupportedError",this.feature=t,this.provider=e,this.reason=s;}},A=class extends Error{path;provider;constructor(t,e){super(`${e}: no such file or directory: ${t}`),this.name="SandboxPathNotFoundError",this.path=t,this.provider=e;}},_=class extends Error{sandboxId;provider;state;constructor(t,e,s){super(`${e} sandbox ${t} is not running (${s}); inspect never starts or resumes a sandbox`),this.name="SandboxNotRunningError",this.sandboxId=t,this.provider=e,this.state=s;}};function L(n,t){return !!n&&typeof n=="object"&&n.name===t}function Xt(n){return L(n,"SandboxFeatureUnsupportedError")}function Vt(n){return L(n,"SandboxPathNotFoundError")}function qt(n){return L(n,"SandboxNotRunningError")}var M=2,N=20;function R(n){return `'${n.replace(/'/g,"'\\''")}'`}function U(n){if(!Number.isInteger(n.offset)||n.offset<0)throw new RangeError(`offset must be a non-negative integer, got ${n.offset}`);if(!Number.isInteger(n.length)||n.length<0)throw new RangeError(`length must be a non-negative integer, got ${n.length}`)}function ct(n){if(typeof n=="number")return lt((n&4095).toString(8));if(/^[0-7]{1,4}$/.test(n))return lt(n);throw new RangeError(`not an octal mode: ${n}`)}function lt(n){return n.padStart(4,"0")}function F(n){let t=n instanceof Date?n:typeof n=="number"?new Date(n*1e3):new Date(n);if(Number.isNaN(t.getTime()))throw new RangeError(`not a timestamp: ${String(n)}`);return t.toISOString()}function ut(n,t){return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}async function ft(n,t,e){if(U(t),t.length===0)return new Uint8Array(0);let s=t.offset+t.length-1,o=await fetch(n,{headers:{Range:`bytes=${t.offset}-${s}`},signal:AbortSignal.timeout(e.timeoutMs)});if(o.status===206){let r=new Uint8Array(await o.arrayBuffer());return r.length>t.length?r.subarray(0,t.length):r}if(o.status===200)return Qt(o,t);if(o.status===416)return await o.body?.cancel().catch(()=>{}),new Uint8Array(0);throw await o.body?.cancel().catch(()=>{}),o.status===404?new A(e.path,e.provider):new Error(`${e.provider}: range read of ${e.path} failed (HTTP ${o.status})`)}async function Qt(n,t){if(!n.body)return new Uint8Array(0);let e=n.body.getReader(),s=[],o=0,r=0,a=t.offset+t.length;try{for(;;){let{done:u,value:m}=await e.read();if(u)break;let c=o;if(o+=m.length,o>t.offset){let f=Math.max(0,t.offset-c),l=Math.min(m.length,a-c);l>f&&(s.push(m.subarray(f,l)),r+=l-f);}if(o>=a)break}}finally{await e.cancel().catch(()=>{});}let i=new Uint8Array(r),d=0;for(let u of s)i.set(u,d),d+=u.length;return i}var O="c-
|
|
1
|
+
import {STDOUT_PREFIX_BYTES,STDERR_PREFIX_BYTES,MAX_PREFIX_LEN,Daytona,Image}from'@daytonaio/sdk';import {randomUUID}from'crypto';import'fs';var E=class extends Error{feature;provider;reason;constructor(t,e,s){super(`${e} does not support ${t}${s?`: ${s}`:""}`),this.name="SandboxFeatureUnsupportedError",this.feature=t,this.provider=e,this.reason=s;}},A=class extends Error{path;provider;constructor(t,e){super(`${e}: no such file or directory: ${t}`),this.name="SandboxPathNotFoundError",this.path=t,this.provider=e;}},_=class extends Error{sandboxId;provider;state;constructor(t,e,s){super(`${e} sandbox ${t} is not running (${s}); inspect never starts or resumes a sandbox`),this.name="SandboxNotRunningError",this.sandboxId=t,this.provider=e,this.state=s;}};function L(n,t){return !!n&&typeof n=="object"&&n.name===t}function Xt(n){return L(n,"SandboxFeatureUnsupportedError")}function Vt(n){return L(n,"SandboxPathNotFoundError")}function qt(n){return L(n,"SandboxNotRunningError")}var M=2,N=20;function R(n){return `'${n.replace(/'/g,"'\\''")}'`}function U(n){if(!Number.isInteger(n.offset)||n.offset<0)throw new RangeError(`offset must be a non-negative integer, got ${n.offset}`);if(!Number.isInteger(n.length)||n.length<0)throw new RangeError(`length must be a non-negative integer, got ${n.length}`)}function ct(n){if(typeof n=="number")return lt((n&4095).toString(8));if(/^[0-7]{1,4}$/.test(n))return lt(n);throw new RangeError(`not an octal mode: ${n}`)}function lt(n){return n.padStart(4,"0")}function F(n){let t=n instanceof Date?n:typeof n=="number"?new Date(n*1e3):new Date(n);if(Number.isNaN(t.getTime()))throw new RangeError(`not a timestamp: ${String(n)}`);return t.toISOString()}function ut(n,t){return n.endsWith("/")?`${n}${t}`:`${n}/${t}`}async function ft(n,t,e){if(U(t),t.length===0)return new Uint8Array(0);let s=t.offset+t.length-1,o=await fetch(n,{headers:{Range:`bytes=${t.offset}-${s}`},signal:AbortSignal.timeout(e.timeoutMs)});if(o.status===206){let r=new Uint8Array(await o.arrayBuffer());return r.length>t.length?r.subarray(0,t.length):r}if(o.status===200)return Qt(o,t);if(o.status===416)return await o.body?.cancel().catch(()=>{}),new Uint8Array(0);throw await o.body?.cancel().catch(()=>{}),o.status===404?new A(e.path,e.provider):new Error(`${e.provider}: range read of ${e.path} failed (HTTP ${o.status})`)}async function Qt(n,t){if(!n.body)return new Uint8Array(0);let e=n.body.getReader(),s=[],o=0,r=0,a=t.offset+t.length;try{for(;;){let{done:u,value:m}=await e.read();if(u)break;let c=o;if(o+=m.length,o>t.offset){let f=Math.max(0,t.offset-c),l=Math.min(m.length,a-c);l>f&&(s.push(m.subarray(f,l)),r+=l-f);}if(o>=a)break}}finally{await e.cancel().catch(()=>{});}let i=new Uint8Array(r),d=0;for(let u of s)i.set(u,d),d+=u.length;return i}var O="c-ebdfafe2ef1a";var ot={[`evolve-all-${O}`]:`evolvingmachines/evolve-all:${O}`,"evolve-all":"evolvingmachines/evolve-all"},ee=10,pt=10,ht=20,ne=18e4,se=2e3,$t=6e5,It=5e3,oe={pollMinMs:250,pollMaxMs:2e3,drainMs:1e3,killGraceMs:15e3,settleMs:6e4},S=n=>new Promise(t=>setTimeout(t,Math.max(0,n))),re=100,B=1e4;function ae(n){let t=n.lastIndexOf("/");return t>0?n.substring(0,t):"/"}function ie(n){let t=n.lastIndexOf("/");return t>=0?n.substring(t+1):n}var b=class extends Error{reason;destination;constructor(t,e,s){super(e),this.name="DaytonaNetworkPolicyError",this.reason=t,this.destination=s;}},W=class extends Error{image;constructor(t,e){let s=e instanceof Error?e.message:String(e??"unknown error");super(`Failed to pull image "${t}" on Daytona: ${s}. 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;}},wt=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;}},k=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;}},H=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";}},j=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";}},de=new Set(["pending_build","building_snapshot","pulling_snapshot"]);function yt(n){return n!=null&&de.has(n)?"image_pull":"boot"}var z=class extends Error{phase;state;sandboxId;constructor(t,e,s){super(`Daytona sandbox boot abandoned during ${t} (provider state ${e??"not yet reported"}, sandbox ${s??"not yet created"})`),this.name="DaytonaBootAbortedError",this.phase=t,this.state=e,this.sandboxId=s;}},bt="evolve_boot",le=5e3,xt=30;async function Ce(n,t,e={}){let s=randomUUID(),o=e.pollMs??le,r=null,a=null,i=false,d=(l,g)=>{let p=l==="build_log"?"image_pull":yt(a);e.onProgress?.({signal:l,phase:p,state:a,sandboxId:r?.id??null,...g===void 0?{}:{line:g}});},u=n.create({...t,labels:{...t.labels??{},[bt]:s}},{timeout:0,onSnapshotCreateLogs:l=>{for(let g of l.split(`
|
|
2
2
|
`)){let p=g.trimEnd();p.length>0&&d("build_log",p);}}});(async()=>{for(;!i;){try{if(r===null)for await(let g of n.list({labels:{[bt]:s}})){r=g;break}else await r.refreshData();let l=r?.state??null;l!==a&&(a=l,d("state"));}catch{}i||await S(o);}})();let c=()=>{let l=new z(yt(a),a,r?.id??null);return u.then(g=>g.delete(xt).catch(()=>{}),()=>{}),r!==null&&r.delete(xt).catch(()=>{}),l},f=new Promise((l,g)=>{let p=e.signal;if(p){if(p.aborted){g(c());return}p.addEventListener("abort",()=>{i||g(c());},{once:true});}});try{return await Promise.race([u,f])}finally{i=true;}}var v=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 K(n,t,e,s){let o=s?.timeoutMs??ne,r=s?.pollMs??se;console.log(`[daytona] Snapshot "${t}" is inactive (unused for 2+ weeks) \u2014 reactivating...`);let a;try{a=await n.snapshot.activate(e);}catch(d){throw new v(t,`the activate call failed (${d instanceof Error?d.message:String(d)})`)}let i=Date.now()+o;for(;a?.state!=="active";){if(a?.state==="error"||a?.state==="build_failed")throw new v(t,`it entered state "${a.state}"`);if(Date.now()>=i)throw new v(t,`still "${a?.state??"unknown"}" after ${o}ms`);await S(r);try{a=await n.snapshot.get(t);}catch(d){throw new v(t,`the activation poll failed (${d instanceof Error?d.message:String(d)})`)}}return console.log(`[daytona] Snapshot "${t}" reactivated.`),a}var T=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;}},Et=Symbol("daytona-snapshot-gone"),kt=new Set(["pending","pulling","building","snapshotting"]),ce=3;function rt(n){let t=n;return t?.status??t?.statusCode??t?.response?.status}var St=new Set(["error","build_failed"]),ue=new Set(["latest","lts","stable"]);function X(n){let t=ot[n]??n;if(t.includes("@"))return /@[a-z0-9]+(?:[.+_-][a-z0-9]+)*:[0-9a-f]{32,}$/i.test(t);let e=t.substring(t.lastIndexOf("/")+1),s=e.lastIndexOf(":");if(s<0)return false;let o=e.substring(s+1);return o===""?false:!ue.has(o.toLowerCase())}function V(n){let t=n.toLowerCase();return t.includes("not found")||t.includes("404")||t.includes("does not exist")}var _t=6e4,Mt=2e3;async function vt(n,t,e,s){let o=e.errorReason?`: ${e.errorReason}`:"";console.warn(`[daytona] Deleting dead snapshot "${t}" (state "${e.state??"unknown"}"${o}) before rebuilding it.`);try{await n.snapshot.delete(e);}catch(d){let u=d instanceof Error?d.message:String(d);if(!V(u))return console.warn(`[daytona] Could not delete dead snapshot "${t}" (${u}) \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 r=s?.timeoutMs??_t,a=s?.pollMs??Mt,i=Date.now()+r;for(;;){try{await n.snapshot.get(t);}catch(d){if(V(d instanceof Error?d.message:String(d)))return true}if(Date.now()>=i)return console.warn(`[daytona] Dead snapshot "${t}" still resolves ${r}ms after it was deleted \u2014 leaving the rebuild to the next run rather than racing the removal.`),false;await S(a);}}function Ot(n){if(rt(n)===409)return true;let t=(n instanceof Error?n.message:String(n)).toLowerCase();return t.includes("already exists")||t.includes("conflict")}function fe(n){let t=rt(n);if(t===401||t===403)return true;let e=(n instanceof Error?n.message:String(n)).toLowerCase();return e.includes("unauthorized")||e.includes("forbidden")||e.includes("status code 401")||e.includes("status code 403")}async function Ct(n,t,e){let s=e?.timeoutMs??$t,o=e?.pollMs??It;console.log(`[daytona] Snapshot "${t}" is already being created by another process \u2014 waiting for it (up to ${Math.round(s/1e3)}s) instead of pulling the image directly...`);let r=Date.now()+s,a,i="",d=0;for(;;){try{a=await n.snapshot.get(t),i="",d=0;}catch(u){a=void 0;let m=u instanceof Error?u.message:String(u);if(V(m))return console.log(`[daytona] Snapshot "${t}" no longer exists \u2014 the name is clear, building it.`),Et;if(fe(u))throw new T(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>=ce)throw new T(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&&!kt.has(a.state??""))return a;if(Date.now()>=r)throw new T(t,`it was still "${a?.state??"unknown"}" after ${s}ms \u2014 retry once that build finishes, or check the snapshot in the Daytona dashboard (Snapshots page)`);await S(o);}}function q(n,t){if(!t||t<=0)return n;let e=Buffer.from(n).toString("base64"),s=`/tmp/.evolve-cmd-${Date.now()}-${Math.random().toString(36).slice(2,8)}.sh`;return `sh -c '${`echo ${e} | base64 -d > ${s} && [ -s ${s} ] || { rm -f ${s}; exit 126; }; if command -v timeout >/dev/null 2>&1; then timeout -k 10 ${t} bash ${s}; else bash ${s}; fi; rc=$?; rm -f ${s}; exit $rc`}'`}function At(){return `EVOLVE-EOS-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Q(n,t){return n.trim()?`exec 9>&1 && { :
|
|
3
3
|
${n}
|
|
4
4
|
|