@evolvingmachines/sdk 0.0.51 → 0.0.52-launch-round-1.20260803.cb1be5b
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/chunk-VGAGB5J5.js +6 -0
- package/dist/hosted/cli.cjs +19 -0
- package/dist/hosted/cli.d.cts +105 -0
- package/dist/hosted/cli.d.ts +105 -0
- package/dist/hosted/cli.js +14 -0
- package/dist/index.cjs +440 -82
- package/dist/index.d.cts +1207 -478
- package/dist/index.d.ts +1207 -478
- package/dist/index.js +429 -79
- package/dist/managed-modal-CRZFDIRG.js +4 -0
- package/dist/tar-PPIAXEGM.js +1 -0
- package/dist/types-B8wdtDC4.d.cts +1602 -0
- package/dist/types-B8wdtDC4.d.ts +1602 -0
- package/harness-capabilities.json +345 -0
- package/hosted-error-codes.json +57 -0
- package/package.json +35 -10
- package/spec/openapi.yaml +4050 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var g=class extends Error{bytes;constructor(e,t){super(`Managed Modal ${e} body is ${t} bytes; the managed door caps every request at 1048576 bytes (1 MiB) of wire bytes, base64 inflation included. Split the payload into smaller writes.`),this.name="ManagedModalWriteLimitError",this.bytes=t;}};function M(a){if(typeof a=="string")return new TextEncoder().encode(a);if(a instanceof Uint8Array)return new Uint8Array(a);if(a instanceof ArrayBuffer)return new Uint8Array(a);throw new Error(`Unsupported data type: ${typeof a}`)}var m=class{constructor(e){this.config=e;}async request(e,t,n){let r=await fetch(`${this.config.baseUrl}${t}`,{...n,headers:{authorization:`Bearer ${this.config.apiKey}`,...n.headers??{}}});if(!r.ok){let s="";try{s=(await r.json())?.error??"";}catch{}throw new Error(`Managed Modal ${e} failed (${r.status})${s?`: ${s}`:""}`)}return r}json(e){return {method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}}},h=class{constructor(e,t){this.door=e;this.sandboxId=t;}async run(e,t){let n=await this.door.request("exec",`/sandboxes/${encodeURIComponent(this.sandboxId)}/exec`,this.door.json({command:e,...t?.cwd?{cwd:t.cwd}:{},...t?.envs?{envs:t.envs}:{},...t?.timeoutMs!==void 0?{timeoutMs:t.timeoutMs}:{}})),r="",s="",d,l=i=>{if(!i.trim())return;let o;try{o=JSON.parse(i);}catch{throw new Error(`Managed Modal exec stream carried a garbled record: ${i}`)}o.stream==="stdout"&&typeof o.data=="string"?(r+=o.data,t?.onStdout?.(o.data)):o.stream==="stderr"&&typeof o.data=="string"?(s+=o.data,t?.onStderr?.(o.data)):d=o;};if(n.body){let i=n.body.getReader(),o=new TextDecoder,c="";for(;;){let{done:y,value:p}=await i.read();if(y)break;c+=o.decode(p,{stream:true});let f;for(;(f=c.indexOf(`
|
|
2
|
+
`))!==-1;)l(c.slice(0,f)),c=c.slice(f+1);}c+=o.decode(),l(c);}else for(let i of (await n.text()).split(`
|
|
3
|
+
`))l(i);if(d?.error!==void 0)throw new Error(`Managed Modal exec failed: ${d.error}`);if(typeof d?.exitCode!="number")throw new Error("Managed Modal exec stream ended without a terminal record \u2014 the connection died mid-run.");return {exitCode:d.exitCode,stdout:r,stderr:s}}async spawn(e,t){let n=this.run(e,t);return n.catch(()=>{}),{processId:`managed-modal-${Date.now()}-${Math.random().toString(36).slice(2)}`,wait:()=>n,kill:async()=>false}}async list(){return (await this.run("ps -eo pid,comm,args")).stdout.trim().split(`
|
|
4
|
+
`).slice(1).filter(n=>n.trim()).map(n=>{let r=n.trim().split(/\s+/);return {processId:r[0],cmd:r[1]||"",args:r.slice(2),envs:{}}})}async kill(e){return /^\d+$/.test(e)?(await this.run(`kill -9 ${e}`)).exitCode===0:false}},b=class{constructor(e,t){this.door=e;this.sandboxId=t;}filesPath(e){return `/sandboxes/${encodeURIComponent(this.sandboxId)}/files/${e}`}encodeContent(e){return typeof e=="string"?{content:e}:{content:Buffer.from(M(e)).toString("base64"),encoding:"base64"}}boundedJson(e,t){let n=this.door.json(t),r=Buffer.byteLength(n.body,"utf8");if(r>1048576)throw new g(e,r);return n}async read(e){let n=await(await this.door.request("file read",this.filesPath("read"),this.door.json({path:e}))).json();return n.encoding==="base64"?new Uint8Array(Buffer.from(n.content??"","base64")):n.content??""}async write(e,t){await this.door.request("file write",this.filesPath("write"),this.boundedJson("file write",{path:e,...this.encodeContent(t)}));}async writeBatch(e){e.length!==0&&await this.door.request("file writeBatch",this.filesPath("writeBatch"),this.boundedJson("file writeBatch",{files:e.map(t=>({path:t.path,...this.encodeContent(t.data)}))}));}async makeDir(e){await this.door.request("makeDir",this.filesPath("makeDir"),this.door.json({path:e}));}};function x(a){return {sandboxId:a.sandboxId,image:a.image??"",metadata:a.metadata??{},startedAt:a.startedAt??""}}var u=class{constructor(e,t){this.door=e;this.sandboxId=t;this.commands=new h(e,t),this.files=new b(e,t);}commands;files;async getHost(e){throw new Error("Managed Modal sandboxes expose no tunnels, so getHost() is unavailable through the managed door.")}async kill(){try{await this.door.request("kill",`/sandboxes/${encodeURIComponent(this.sandboxId)}`,{method:"DELETE"});}catch(e){if(e instanceof Error&&e.message.includes("(404)"))return;throw e}}async pause(){throw new Error("Modal does not support pause/resume. Persist progress with Evolve checkpoints and resume in a fresh sandbox, or use kill() to terminate.")}async isRunning(){try{return await this.getInfo(),!0}catch(e){if(e instanceof Error&&e.message.includes("(404)"))return false;throw e}}async getInfo(){let e=await this.door.request("get",`/sandboxes/${encodeURIComponent(this.sandboxId)}`,{method:"GET"});return x(await e.json())}},w=class{providerType="modal";name="Managed Modal";door;constructor(e){this.door=new m(e);}async create(e){if(e.resources!==void 0)throw new Error("Managed Modal sandboxes are platform-sized; `resources` cannot be enforced through the managed door.");if(e.network!==void 0)throw new Error("Managed Modal sandboxes run the platform's network policy; `network` cannot be enforced through the managed door.");if(e.user!==void 0)throw new Error("Managed Modal sandboxes run as the platform's sandbox user; `user` cannot be enforced through the managed door.");if(e.idleTimeoutMs!==void 0)throw new Error("The managed Modal door takes no idle timeout; bound the sandbox with `timeoutMs` instead.");let n=await(await this.door.request("create","/sandboxes",this.door.json({...e.image?{image:e.image}:{},...e.timeoutMs!==void 0?{timeoutMs:e.timeoutMs}:{},...e.workingDirectory?{workingDirectory:e.workingDirectory}:{},...e.envs?{envs:e.envs}:{},...e.metadata?{metadata:e.metadata}:{}}))).json();return new u(this.door,n.sandboxId)}async connect(e,t){let n=new u(this.door,e);return await n.getInfo(),n}async list(e){if(e?.state&&!e.state.includes("running"))return [];let r=((await(await this.door.request("list","/sandboxes",{method:"GET"})).json()).sandboxes??[]).map(x);if(e?.metadata){let s=Object.entries(e.metadata);r=r.filter(d=>s.every(([l,i])=>d.metadata[l]===i));}return e?.limit!==void 0&&(r=r.slice(0,e.limit)),r}async listAll(e){if(e?.state&&!e.state.includes("running"))return {sandboxes:[],complete:true,pagesFetched:0};let t;try{t=await this.list({...e,limit:void 0});}catch(s){return {sandboxes:[],complete:false,pagesFetched:0,error:`sandbox list failed: ${s instanceof Error?s.message:String(s)}`}}let n=e?.limit!==void 0?t.slice(0,e.limit):t,r=n.length<t.length;return {sandboxes:n,complete:!r,pagesFetched:1,...r?{error:`stopped at the requested limit of ${e?.limit} with more sandboxes available`}:{}}}},S=(a,e)=>new u(new m(a),e);export{w as ManagedModalProvider,g as ManagedModalWriteLimitError,S as _testManagedModalSandbox};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {createGzip}from'zlib';import {createReadStream}from'fs';import {readdir,lstat}from'fs/promises';import {join}from'path';import {pipeline}from'stream/promises';import {pack}from'tar-stream';var h=new Set([".git",".DS_Store",".venv"]);async function S(s){let a=[],r=async e=>{let i=e===""?s:join(s,e),c=await readdir(i,{withFileTypes:true});c.sort((t,n)=>t.name<n.name?-1:t.name>n.name?1:0);for(let t of c){if(h.has(t.name))continue;let n=e===""?t.name:`${e}/${t.name}`,m=join(i,t.name),o=await lstat(m);o.isSymbolicLink()||(o.isDirectory()?await r(n):o.isFile()&&a.push({rel:n,abs:m,mode:o.mode&73?493:420,size:o.size}));}};return await r(""),a.sort((e,i)=>e.rel<i.rel?-1:e.rel>i.rel?1:0)}async function F(s){let a=await S(s),r=pack(),e=createGzip({level:9}),i=[],c=(async()=>{for await(let n of e)i.push(Buffer.from(n));})(),t=(async()=>{for(let{rel:n,abs:m,mode:o,size:u}of a){let p=r.entry({name:n,size:u,mode:o,mtime:new Date(0),uid:0,gid:0,uname:"",gname:"",type:"file"});await pipeline(createReadStream(m),p);}r.finalize();})();return await Promise.all([pipeline(r,e),t,c]),Buffer.concat(i)}export{F as tarGzipDirectory};
|