coding-agents-sdk 0.2.0 → 0.4.0
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/README.md +56 -1
- package/dist/SdkAgent-Coq-LSHU.mjs +1 -0
- package/dist/adapters/claude-code-cli/index.d.mts +1 -1
- package/dist/adapters/claude-code-cli/index.mjs +2 -490
- package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
- package/dist/adapters/claude-code-sdk/index.mjs +4 -483
- package/dist/adapters/codex-cli/index.d.mts +1 -1
- package/dist/adapters/codex-cli/index.mjs +2 -626
- package/dist/adapters/codex-sdk/index.d.mts +1 -1
- package/dist/adapters/codex-sdk/index.mjs +1 -286
- package/dist/adapters/gemini-cli/index.d.mts +1 -1
- package/dist/adapters/gemini-cli/index.mjs +1 -292
- package/dist/classify-error-DXvCSvRY.mjs +8 -0
- package/dist/container/index.d.mts +2 -2
- package/dist/container/index.mjs +1 -24
- package/dist/container--0TOW4sB.mjs +1 -0
- package/dist/container-BuaAmhBf.mjs +1 -0
- package/dist/container-C5h5Bdf_.mjs +1 -0
- package/dist/container-RMYjapoN.mjs +1 -0
- package/dist/diff-DkMPJCxL.mjs +1 -0
- package/dist/env-DIXTVzTs.mjs +1 -0
- package/dist/errors-XV0frS3r.mjs +1 -0
- package/dist/execution-target-DdEbRqUx.mjs +4 -0
- package/dist/{index-C3ZxLAd0.d.mts → index-BDJms3ZX.d.mts} +6 -6
- package/dist/{index-nzo1sBiK.d.mts → index-BWtmcPDz.d.mts} +8 -8
- package/dist/{index-ByAOGMUM.d.mts → index-BgsYjENi.d.mts} +23 -5
- package/dist/{index-CFpNOmdA.d.mts → index-C-uiS3g-.d.mts} +2 -1
- package/dist/{index-dRVpEAr8.d.mts → index-CZbHe6Xs.d.mts} +5 -5
- package/dist/{index-B3YqrgIp.d.mts → index-CmVxarAz.d.mts} +3 -2
- package/dist/index-DbXtKldz.d.mts +85 -0
- package/dist/index.d.mts +10 -9
- package/dist/index.mjs +1 -61
- package/dist/oci-BVYPHn7b.mjs +1 -0
- package/dist/sandbox/index.d.mts +2 -0
- package/dist/sandbox/index.mjs +1 -0
- package/dist/sandbox-_As0qZWn.mjs +4 -0
- package/dist/schemas/index.d.mts +1 -1
- package/dist/schemas/index.mjs +1 -2
- package/dist/schemas-CXVWDOoT.mjs +1 -0
- package/dist/shell-Dewbmt9R.mjs +1 -0
- package/dist/spawner-BJesLc8I.mjs +1 -0
- package/dist/structured-output-nPFh_ZoY.mjs +1 -0
- package/dist/{types-Cb_EXIEe.d.mts → types-BHP0wiJg.d.mts} +9 -24
- package/dist/types-CwvWHEpy.mjs +1 -0
- package/dist/util-CGg8cK92.mjs +1 -0
- package/package.json +7 -3
- package/dist/Agent-D8WkUilj.mjs +0 -262
- package/dist/SdkAgent-B47mJiIE.mjs +0 -38
- package/dist/classify-error-pL6jeu4T.mjs +0 -456
- package/dist/container-2UmPZ0CI.mjs +0 -22
- package/dist/container-CHxKIonn.mjs +0 -440
- package/dist/container-D2Z0ITDJ.mjs +0 -22
- package/dist/diff-De8d3MVb.mjs +0 -333
- package/dist/errors-BAmHDQu8.mjs +0 -45
- package/dist/oci-DMZZQZ47.mjs +0 -438
- package/dist/schemas-DwD4pwJB.mjs +0 -96
- package/dist/spawner-Bw9UBEGX.mjs +0 -54
- package/dist/structured-output-BHtr_zpz.mjs +0 -19
- package/dist/types-aNMD8h3x.mjs +0 -19
- package/dist/util-B4RQZkKr.mjs +0 -77
- /package/dist/{events-nxuRbYIu.d.mts → events-BE9s04ko.d.mts} +0 -0
package/dist/container/index.mjs
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
//#region src/container/index.ts
|
|
3
|
-
async function createContainer(config) {
|
|
4
|
-
switch (config.type) {
|
|
5
|
-
case "docker": {
|
|
6
|
-
const { createDockerContainer } = await import("../container-2UmPZ0CI.mjs");
|
|
7
|
-
return createDockerContainer(config);
|
|
8
|
-
}
|
|
9
|
-
case "e2b": try {
|
|
10
|
-
const { createE2BContainer } = await import("../container-CHxKIonn.mjs");
|
|
11
|
-
return await createE2BContainer(config);
|
|
12
|
-
} catch (error) {
|
|
13
|
-
if (error instanceof Error && error.message.includes("e2b") && (error.code === "ERR_MODULE_NOT_FOUND" || error.code === "MODULE_NOT_FOUND")) throw new ContainerCreateError("Container type \"e2b\" requires the optional peer dependency \"e2b\". Install it to use this provider.");
|
|
14
|
-
throw error;
|
|
15
|
-
}
|
|
16
|
-
case "podman": {
|
|
17
|
-
const { createPodmanContainer } = await import("../container-D2Z0ITDJ.mjs");
|
|
18
|
-
return createPodmanContainer(config);
|
|
19
|
-
}
|
|
20
|
-
default: throw new ContainerCreateError("Unsupported container type.");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//#endregion
|
|
24
|
-
export { ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, createContainer };
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"../errors-XV0frS3r.mjs";async function s(e){switch(e.type){case`docker`:{let{createDockerContainer:t}=await import(`../container-C5h5Bdf_.mjs`);return t(e)}case`e2b`:try{let{createE2BContainer:t}=await import(`../container-BuaAmhBf.mjs`);return await t(e)}catch(e){throw e instanceof Error&&e.message.includes(`e2b`)&&(e.code===`ERR_MODULE_NOT_FOUND`||e.code===`MODULE_NOT_FOUND`)?new o(`Container type "e2b" requires the optional peer dependency "e2b". Install it to use this provider.`):e}case`nerdctl`:{let{createNerdctlContainer:t}=await import(`../container-RMYjapoN.mjs`);return t(e)}case`podman`:{let{createPodmanContainer:t}=await import(`../container--0TOW4sB.mjs`);return t(e)}default:throw new o(`Unsupported container type.`)}}export{o as ContainerCreateError,n as ContainerDiffError,i as ContainerDisposedError,t as ContainerError,e as ContainerExecError,r as ContainerNotRunningError,a as ContainerStartError,s as createContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./oci-BVYPHn7b.mjs";const n=async n=>{let r={binary:n.binary??`podman`},i=await e(r,n);return t(`podman`,{commandContext:r,containerName:n.name,workdir:n.workdir,user:n.user,network:n.network,platform:n.platform,env:n.env,ports:n.ports,mounts:n.mounts,extraArgs:n.extraArgs,image:i,builtImage:n.build!==void 0&&!n.build.tag},n)};export{n as createPodmanContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{n as t,o as n,r,s as i,t as a}from"./errors-XV0frS3r.mjs";import{t as o}from"./shell-Dewbmt9R.mjs";import{n as s}from"./diff-DkMPJCxL.mjs";import{basename as c,dirname as l,join as u,posix as d}from"node:path";import{mkdir as f,readFile as p,readdir as m,stat as h,writeFile as g}from"node:fs/promises";import{CommandExitError as _,FileType as v,Sandbox as y}from"e2b";const b=(e,t)=>[e,...t].map(o).join(` `),x=e=>e.user,S=(e,t)=>{let n={...e.env,...t};return Object.keys(n).length>0?n:void 0},C=(e,t)=>t??e.workdir,w=new TextEncoder,T=e=>e instanceof Error?e:Error(String(e)),E=e=>typeof e==`string`?e:`SIGKILL`,D=(e,t)=>{let n=e?.stdio?.[t];return n===`ignore`||n===`inherit`||n===`pipe`?n:n===void 0?`pipe`:`ignore`},O=()=>{let e=[],t=[],n=!1,r,i=()=>{for(;t.length>0&&e.length>0;)t.shift().resolve({done:!1,value:e.shift()});if(r){for(;t.length>0;)t.shift().reject(r);return}if(n)for(;t.length>0;)t.shift().resolve({done:!0,value:void 0})};return{iterable:{async*[Symbol.asyncIterator](){for(;;){if(e.length>0){yield e.shift();continue}if(r)throw T(r);if(n)return;let i=await new Promise((e,n)=>{t.push({resolve:e,reject:n})});if(i.done)return;yield i.value}}},push(t){t.length===0||n||r||(e.push(w.encode(t)),i())},end(){n||r||(n=!0,i())},fail(e){n||r||(r=e,i())}}},k=(e,t)=>({spawn:(n,r,i={})=>{let a=D(i,0),o=D(i,1),s=D(i,2),c=o===`pipe`?O():void 0,l=s===`pipe`?O():void 0,u=null,d={background:!0,stdin:a===`pipe`,cwd:C(t,i.cwd),envs:S(t,i.env),user:x(t),requestTimeoutMs:t.requestTimeoutMs,onStdout:e=>{if(o===`inherit`){process.stdout.write(e);return}c?.push(e)},onStderr:e=>{if(s===`inherit`){process.stderr.write(e);return}l?.push(e)}},f=e.commands.run(b(n,r),d);return f.catch(e=>{c?.fail(e),l?.fail(e)}),{stdout:c?.iterable??null,stderr:l?.iterable??null,stdin:a===`pipe`?{write:n=>{f.then(r=>{e.commands.sendStdin(r.pid,n,{requestTimeoutMs:t.requestTimeoutMs})}).catch(()=>{})},end:()=>{f.then(n=>{e.commands.closeStdin(n.pid,{requestTimeoutMs:t.requestTimeoutMs})}).catch(()=>{})}}:null,kill:e=>{u=E(e),f.then(e=>e.kill()).catch(()=>{})},wait:async()=>{try{let e=await(await f).wait();return c?.end(),l?.end(),u?{exitCode:null,signal:u}:{exitCode:e.exitCode,signal:null}}catch(e){if(c?.end(),l?.end(),e instanceof _)return u?{exitCode:null,signal:u}:{exitCode:e.exitCode,signal:null};throw e}}}}}),A=e=>({apiKey:e.apiKey,accessToken:e.accessToken,domain:e.domain,requestTimeoutMs:e.requestTimeoutMs,headers:e.headers}),j=e=>`sandboxId`in e&&typeof e.sandboxId==`string`,M=e=>{let t=A(e);return j(e)?t:{...t,envs:e.env,timeoutMs:e.timeoutMs,metadata:e.metadata,secure:e.secure,allowInternetAccess:e.allowInternetAccess,network:e.network,lifecycle:e.lifecycle}},N=async(e,t)=>{await e.files.makeDir(t.workdir,{user:x(t)})},P=e=>e instanceof Error&&e.name===`AbortError`,F=e=>Uint8Array.from(e).buffer,I=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;return d.basename(t)},L=async e=>{try{return await h(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}},R=async(e,t,n)=>{if(await e.files.exists(t,{user:n}))return e.files.getInfo(t,{user:n})},z=async(e,t,n,r)=>(await R(e,n,r))?.type===v.DIR?d.join(n,c(t)):n,B=async(e,t)=>(await L(t))?.isDirectory()?u(t,I(e)):t,V=async(e,t,n,r)=>{let i=await h(t);if(i.isDirectory()){await e.files.makeDir(n,{user:r});let i=await m(t);await Promise.all(i.map(i=>V(e,u(t,i),d.join(n,i),r)));return}if(!i.isFile())throw Error(`Unsupported local filesystem entry at ${t}.`);let a=await p(t);await e.files.write(n,F(a),{user:r})},H=async(e,t,n,r)=>{if((await e.files.getInfo(t,{user:r})).type===v.DIR){await f(n,{recursive:!0});let i=await e.files.list(t,{user:r});await Promise.all(i.map(t=>H(e,t.path,u(n,t.name),r)));return}let i=await e.files.read(t,{format:`bytes`,user:r});await f(l(n),{recursive:!0}),await g(n,i)},U=async e=>{if(j(e))return y.connect(e.sandboxId,A(e));let t=M(e);return e.template?y.create(e.template,t):y.create(t)},W=async(e,t)=>e.connect(A(t)),G=async(e,t)=>{let n=t.signal;if(n?.aborted){let e=n.reason;throw e instanceof Error?e:new DOMException(`The operation was aborted.`,`AbortError`)}let r=!1,i=()=>{r=!0,e.kill()};n?.addEventListener(`abort`,i,{once:!0});try{let t=await e.wait();if(r)throw new DOMException(`The operation was aborted.`,`AbortError`);return{exitCode:t.exitCode,stdout:t.stdout,stderr:t.stderr}}catch(e){if(r||P(e))throw new DOMException(`The operation was aborted.`,`AbortError`);if(e instanceof _)return{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr};throw e}finally{n?.removeEventListener(`abort`,i)}},K=async o=>{let c;try{c=await U(o),await N(c,o)}catch(t){throw new a(`E2B create failed: ${e(t)}`)}let l=o.name??c.sandboxId,d=`running`,p=k(c,o),m={},h=()=>{if(d===`disposed`)throw new r},g=()=>{if(h(),d!==`running`)throw new n},_=s({owner:m,workdir:o.workdir,materialize:async(e,n)=>{g();let r=x(o),i=await R(c,e,r);if(!i)throw new t(`Target path does not exist: ${e}`);if(i.type!==v.DIR)throw new t(`Target path is not a directory: ${e}`);await f(n,{recursive:!0});for(let t of await c.files.list(e,{user:r}))await H(c,t.path,u(n,t.name),r)}}),y={get type(){return`e2b`},get id(){return c.sandboxId},get name(){return l},get config(){return o},get status(){return d},get workdir(){return o.workdir},get spawner(){return p},async start(){if(h(),d!==`running`)try{c=await W(c,o),await N(c,o),p=k(c,o),d=`running`}catch(t){throw new i(`E2B start failed: ${e(t)}`)}},async stop(){h(),d===`running`&&(await c.pause({requestTimeoutMs:o.requestTimeoutMs}),d=`stopped`)},async dispose(){if(d!==`disposed`){try{await c.kill({requestTimeoutMs:o.requestTimeoutMs})}catch{}await _.disposeSnapshots().catch(()=>{}),d=`disposed`}},async exec(e,t,n={}){g();let r={background:!0,cwd:C(o,n.cwd),envs:S(o,n.env),user:x(o),timeoutMs:n.timeoutMs,requestTimeoutMs:o.requestTimeoutMs};return G(await c.commands.run(b(e,t),r),n)},async copyTo(e,t){g();let n=await z(c,e,t,x(o));await V(c,e,n,x(o))},async copyFrom(e,t){g();let n=await B(e,t);await H(c,e,n,x(o))},async writeFile(e,t){g(),await c.files.write(e,typeof t==`string`?t:F(t),{user:x(o)})},async readFile(e){return g(),c.files.read(e,{format:`text`,user:x(o)})},async fileExists(e){return g(),c.files.exists(e,{user:x(o)})},async mkdir(e){g(),await c.files.makeDir(e,{user:x(o)})},async execShell(e,t={}){return y.exec(`sh`,[`-c`,e],t)},async logs(){return``},async syncStatus(){return d},async snapshotWorkdir(e={}){return _.snapshotWorkdir(e)},async diffWorkdir(e){return _.diffWorkdir(e)},async releaseWorkdirSnapshot(e){return _.releaseWorkdirSnapshot(e)},getHost(e){return g(),c.getHost(e)},[Symbol.asyncDispose](){return y.dispose()}};return y};export{K as createE2BContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./oci-BVYPHn7b.mjs";const n=async n=>{let r={binary:n.binary??`docker`},i=await e(r,n);return t(`docker`,{commandContext:r,containerName:n.name,workdir:n.workdir,user:n.user,network:n.network,platform:n.platform,env:n.env,ports:n.ports,mounts:n.mounts,extraArgs:n.extraArgs,image:i,builtImage:n.build!==void 0&&!n.build.tag},n)};export{n as createDockerContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./oci-BVYPHn7b.mjs";const n=e=>{let t={};return e.address&&(t.CONTAINERD_ADDRESS=e.address),e.namespace&&(t.CONTAINERD_NAMESPACE=e.namespace),e.buildkitHost&&(t.BUILDKIT_HOST=e.buildkitHost),Object.keys(t).length>0?t:void 0},r=e=>{let t=[];return e.namespace&&t.push(`--namespace`,e.namespace),e.address&&t.push(`--address`,e.address),e.snapshotter&&t.push(`--snapshotter`,e.snapshotter),e.args&&t.push(...e.args),t.length>0?t:void 0},i=e=>({binary:e.binary??`nerdctl`,baseArgs:r(e),env:n(e)}),a=async n=>{let r=i(n),a=await e(r,n);return t(`nerdctl`,{commandContext:r,containerName:n.name,workdir:n.workdir,user:n.user,network:n.network,platform:n.platform,env:n.env,ports:n.ports,mounts:n.mounts,extraArgs:n.extraArgs,image:a,builtImage:n.build!==void 0&&!n.build.tag},n)};export{a as createNerdctlContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{n as t,o as n,r}from"./errors-XV0frS3r.mjs";import{execFile as i}from"node:child_process";import{dirname as a,isAbsolute as o,join as s,posix as c,relative as l,sep as u}from"node:path";import{promisify as d}from"node:util";import{createReadStream as f}from"node:fs";import{tmpdir as p}from"node:os";import{copyFile as m,lstat as h,mkdir as g,mkdtemp as _,readdir as v,readlink as y,rm as b,stat as x,symlink as S}from"node:fs/promises";import{createHash as C}from"node:crypto";import{pipeline as w}from"node:stream/promises";const T=e=>e instanceof Error&&`code`in e&&(`stdout`in e||`stderr`in e),E=d(i),D=e=>e!==`..`&&!e.startsWith(`..${u}`)&&!o(e),O=(e,t)=>{let n=l(e,t);if(D(n))return n.split(u).join(c.sep)},k=(e,n,r)=>{let i=O(n,e);if(i!==void 0)return i;let a=O(r,e);if(a!==void 0)return a;throw new t(`Git diff produced a path outside the materialized trees: ${e}`)},A=e=>e.sort((e,t)=>e.path===t.path?(e.previousPath??``).localeCompare(t.previousPath??``):e.path.localeCompare(t.path)),j=async e=>{let t=await v(e,{withFileTypes:!0});for(let n of t){let t=s(e,n.name);if(n.name===`.git`){await b(t,{recursive:!0,force:!0});continue}n.isDirectory()&&await j(t)}},M=()=>_(s(p(),`cw-workdir-diff-`)),N=async e=>{e&&await b(e,{recursive:!0,force:!0}).catch(()=>{})},P=(e,t)=>{let n={cwd:e.cwd,createdAt:new Date};return t.set(n,e),n},F=(e,n,r)=>{if(typeof n!=`object`||!n)throw new t(`Invalid workdir snapshot.`);let i=r.get(n);if(!i)throw new t(`Invalid workdir snapshot.`);if(i.owner!==e)throw new t(`Workdir snapshot was created by a different container instance.`);return i},I=(e,n)=>{if(!n.has(e))throw new t(`Workdir snapshot has been released.`)},L=e=>C(`sha256`).update(e).digest(`hex`),R=e=>Buffer.isBuffer(e)?e:Buffer.from(e,`utf8`),z=async e=>{let t=C(`sha256`);return await w(f(e),t),t.digest(`hex`)},B=async(e,n,r)=>{let i=`${e}:${n}`;if(r.has(i))return r.get(i);let a=s(e,...n.split(c.sep));try{let e=await h(a),n,o;if(e.isSymbolicLink()){let e=Buffer.from(await y(a));n=L(e),o=e.byteLength}else if(e.isFile())n=await z(a),o=e.size;else throw new t(`Unsupported filesystem entry in diff metadata: ${a}`);let s={hash:n,size:o};return r.set(i,s),s}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`){r.set(i,void 0);return}throw e}},V=(e,n,r)=>{if(e.byteLength===0)return[];let i=e.toString(`utf8`).split(`\0`);i[i.length-1]===``&&i.pop();let a=[];for(let e=0;e<i.length;){let o=i[e++];if(!o)continue;if(o.startsWith(`R`)){let o=i[e++],s=i[e++];if(!o||!s)throw new t(`Failed to parse git rename entry.`);a.push({kind:`renamed`,previousPath:k(o,n,r),path:k(s,n,r)});continue}let s=i[e++];if(!s)throw new t(`Failed to parse git diff entry.`);switch(o){case`A`:a.push({kind:`added`,path:k(s,n,r)});break;case`D`:a.push({kind:`deleted`,path:k(s,n,r)});break;case`M`:a.push({kind:`modified`,path:k(s,n,r)});break;case`T`:a.push({kind:`modified`,path:k(s,n,r)});break;default:throw new t(`Unsupported git diff change kind: ${o}`)}}return a},H=async(n,r)=>{try{return V(R((await E(`git`,[`diff`,`--no-index`,`-z`,`--name-status`,`-M`,`--find-renames=100%`,n,r],{cwd:p(),encoding:`buffer`,maxBuffer:50*1024*1024})).stdout),n,r)}catch(i){if(!T(i))throw new t(`Failed to run git diff: ${e(i)}`);let a=i.code??1,o=Buffer.isBuffer(i.stdout)?i.stdout:Buffer.from(String(i.stdout??``),`utf8`),s=Buffer.isBuffer(i.stderr)?i.stderr:Buffer.from(String(i.stderr??``),`utf8`);if(a===0||a===1)return V(o,n,r);throw new t(`Failed to run git diff: ${s.toString(`utf8`).trim()||o.toString(`utf8`).trim()||`exit code ${a}`}`)}},U=async(e,t,n)=>{let r=new Map;return A(await Promise.all(e.map(async e=>{let i;i=e.kind===`added`?void 0:e.kind===`renamed`?e.previousPath:e.path;let a=e.kind===`deleted`?void 0:e.path,[o,s]=await Promise.all([i===void 0?void 0:B(t,i,r),a===void 0?void 0:B(n,a,r)]);return{path:e.path,previousPath:e.previousPath,kind:e.kind,beforeHash:o?.hash,afterHash:s?.hash,beforeSize:o?.size,afterSize:s?.size}})))},W=e=>{let t=new Set;for(let n of e)t.add(n.path),n.kind===`renamed`&&n.previousPath&&t.add(n.previousPath);return[...t].sort((e,t)=>e.localeCompare(t))},G=(i,a)=>{throw a instanceof t||a instanceof r||a instanceof n?a:new t(`${i}: ${e(a)}`)},K=async(e,n)=>{if(!(await x(e)).isDirectory())throw new t(`Target path is not a directory: ${e}`);await g(n,{recursive:!0});let r=await v(e,{withFileTypes:!0});await Promise.all(r.filter(e=>e.name!==`.git`).map(async r=>{let i=s(e,r.name),o=s(n,r.name);if(r.isDirectory()){await K(i,o);return}if(r.isSymbolicLink()){await g(a(o),{recursive:!0}),await S(await y(i),o);return}if(r.isFile()){await g(a(o),{recursive:!0}),await m(i,o);return}throw new t(`Unsupported filesystem entry in workdir diff: ${i}`)}))},q=e=>{let t=new Set,n=new WeakMap,r=async(r={})=>{let i=r.cwd??e.workdir,a;try{a=await M(),await e.materialize(i,a),await j(a);let r={owner:e.owner,tempDir:a,cwd:i,inFlightDiffs:0,released:!1};return t.add(r),a=void 0,P(r,n)}catch(e){return await N(a),G(`Failed to materialize workdir snapshot`,e)}},i=async r=>{let i=Date.now(),a=F(e.owner,r,n);I(a,t),a.inFlightDiffs++;let o;try{o=await M(),await e.materialize(a.cwd,o),await j(o);let t=await U(await H(a.tempDir,o),a.tempDir,o),n=W(t);return{cwd:a.cwd,changedFiles:n,fileChanges:t,stats:{durationMs:Date.now()-i,filesCompared:n.length}}}catch(e){return G(`Failed to diff workdir snapshot`,e)}finally{a.inFlightDiffs--,a.inFlightDiffs===0&&(a.resolveIdle?.(),a.resolveIdle=void 0),await N(o)}},a=e=>{let n=e;return n.releasePromise?n.releasePromise:(n.released=!0,t.delete(n),n.releasePromise=(async()=>{n.inFlightDiffs>0&&await new Promise(e=>{n.resolveIdle=e}),await N(n.tempDir)})(),n.releasePromise)};return{snapshotWorkdir:r,diffWorkdir:i,releaseWorkdirSnapshot:async t=>{await a(F(e.owner,t,n))},disposeSnapshots:async()=>{await Promise.all(Array.from(t).map(a))}}};export{q as n,T as r,K as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{delimiter as e}from"node:path";const t=e=>Object.keys(e).find(e=>e.toLowerCase()===`path`)??`PATH`,n=()=>Object.fromEntries(Object.entries(process.env).filter(e=>e[1]!==void 0)),r=(r={})=>{let i=r.propagateEnv===!1?{}:n(),a=r.extraPaths??[];if(a.length>0){let n=t(i),r=i[n]??``;i[n]=[...a,r].filter(Boolean).join(e)}return i};export{n,t as r,r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`ContainerError`}},t=class extends e{constructor(e){super(e),this.name=`ContainerCreateError`}},n=class extends e{constructor(e){super(e),this.name=`ContainerStartError`}},r=class extends e{constructor(e){super(e),this.name=`ContainerExecError`}},i=class extends e{constructor(e=`Container is not running.`){super(e),this.name=`ContainerNotRunningError`}},a=class extends e{constructor(e=`Container has been disposed.`){super(e),this.name=`ContainerDisposedError`}},o=class extends e{constructor(e){super(e),this.name=`ContainerDiffError`}};export{r as a,e as i,o as n,i as o,a as r,n as s,t};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as e}from"./types-CwvWHEpy.mjs";import{t}from"./util-CGg8cK92.mjs";import{t as n}from"./env-DIXTVzTs.mjs";import{t as r}from"./spawner-BJesLc8I.mjs";import{a as i,i as a,n as o,t as s}from"./classify-error-DXvCSvRY.mjs";import{dirname as c}from"node:path";import{createWriteStream as l,mkdirSync as u}from"node:fs";async function*d(e){let t=new TextDecoder,n=``;for await(let r of e){let e=t.decode(r,{stream:!0});n+=e;let i=n.split(`
|
|
2
|
+
`);n=i.pop()??``;for(let e of i){let t=e.trim();t&&(yield t)}}let r=t.decode();r&&(n+=r);let i=n.trim();i&&(yield i)}const f=e=>e.status===`rejected`?t(e.reason):void 0,p=(e,t)=>{if(e.stopReason)return;let n=f(t.stdoutResult);if(n)return{kind:`process`,message:n};let r=f(t.stderrResult);if(r)return{kind:`process`,message:r};let i=f(t.processResult);if(i)return{kind:`spawn`,message:i};if(!e.status&&!e.error){let t=e.processResult,n=e.stderrLines.join(`
|
|
3
|
+
`);if(t&&t.exitCode!==null&&t.exitCode!==0)return{kind:`process`,message:n||`Process exited with code ${t.exitCode}.`};if(!a(e)&&e.stderrLines.length>0)return{kind:`process`,message:n}}},m=e=>{let t=s(e);return t.kind===`provider`?{kind:`process`,message:t.message}:t};var h=class extends o{spawner;defaults;executionTargetRef;autoStartExecutionTarget;autoStopExecutionTarget;executionTargetStopPromise;logStream;sigkillTimer;constructor(e){super({type:e.type,capabilities:e.capabilities,sessionId:e.defaults?.sessionId,onEvent:e.onEvent}),this.spawner=e.spawner??r,this.defaults=e.defaults??{},this.executionTargetRef=e.executionTarget,this.autoStartExecutionTarget=e.autoStartExecutionTarget??!0,this.autoStopExecutionTarget=e.autoStopExecutionTarget??!1,e.logPath&&this.initLogStream(e.logPath)}onParseError(e,n){this.appendRawLog(`[parse-error] ${t(n)} ${e.slice(0,200)}`)}buildDefaultEnv(e){let t=n({propagateEnv:e});return t.CI=t.CI??`true`,this.defaults.env&&Object.assign(t,this.defaults.env),t}async executeRunCore(e,n){let r=this.setupRunLifecycle(e);try{if(r.abortedBeforeStart)return this.buildResult(e,new Date);try{await this.onBeforeRun(e);let t={...n,...e.normalizedRequest},r=this.buildArgs(t,e),i=this.buildEnv(t,e),a=this.defaults.command?.[0]??`claude`,o=[...this.defaults.command?.slice(1)??[],...r];if(e.stopReason)return this.buildResult(e,new Date);this.emitSessionStart(e),e.process=this.spawner.spawn(a,o,{cwd:e.normalizedRequest.cwd,env:i,stdio:[`pipe`,`pipe`,`pipe`]}),e.process.stdin?.end();let[s,c,l]=await Promise.allSettled([this.watchStdout(e),this.watchStderr(e),e.process.wait()]);l.status===`fulfilled`&&(e.processResult=l.value);let u=p(e,{stdoutResult:s,stderrResult:c,processResult:l});u&&(e.error=u)}catch(t){!e.stopReason&&!e.error&&(e.error=m(t))}return this.buildResult(e,new Date)}finally{r.cleanup(),this.sigkillTimer&&=(clearTimeout(this.sigkillTimer),void 0);try{await this.onRunFinished(e)}catch(e){this.appendRawLog(`[cleanup-error] ${t(e)}`)}}}async watchStdout(e){let t=e.process?.stdout;if(t)for await(let n of d(t))this.appendLog(`stdout`,n),this.processLine(e,n)}async watchStderr(e){let t=e.process?.stderr;if(t)for await(let n of d(t))this.appendLog(`stderr`,n),e.stderrLines.push(n),this.emit(e,i(e.runId,`stderr`,{sessionId:e.sessionId,text:n}))}processLine(e,t){let n;try{n=JSON.parse(t)}catch(e){this.onParseError(t,e);return}let r;try{r=this.mapRawEvent(n,{runId:e.runId,requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,schemaRequested:e.normalizedRequest.schema.kind!==`none`,toolCalls:e.toolCalls})}catch(e){this.onParseError(t,e);return}this.applyBatch(e,r)}get runRequestDefaults(){return this.defaults}onHandlerError(e){this.appendRawLog(`[handler-error] ${t(e)}`)}async onDispose(){let e=this.logStream;this.logStream=void 0,e&&await new Promise(t=>{e.end(t)})}onStopRequested(e){e.process?.kill(),this.sigkillTimer=setTimeout(()=>{e.process?.kill(`SIGKILL`)},5e3),this.sigkillTimer.unref?.()}onBeforeRun(e){return this.ensureExecutionTarget()}async onRunFinished(e){this.autoStopExecutionTarget&&this.executionTargetRef&&this.executionTargetRef.status===`running`&&(this.executionTargetStopPromise=this.executionTargetRef.stop().catch(e=>{this.appendRawLog(`[auto-stop-error] ${t(e)}`)}),await this.executionTargetStopPromise)}appendRawLog(e){if(!this.logStream)return;let t=typeof e==`string`?e:JSON.stringify(e);this.logStream.write(`${t}\n`)}initLogStream(e){try{u(c(e),{recursive:!0}),this.logStream=l(e,{flags:`a`}),this.logStream.write(`\n--- ${new Date().toISOString()} ---\n`)}catch{this.logStream=void 0}}appendLog(e,t){if(!this.logStream||!t)return;let n=e===`stderr`?`STDERR`:`STDOUT`,r=new Date().toISOString();for(let e of t.split(`
|
|
4
|
+
`))e&&this.logStream.write(`[${r}] ${n} ${e}\n`)}async ensureExecutionTarget(){this.executionTargetStopPromise&&=(await this.executionTargetStopPromise,void 0),this.autoStartExecutionTarget&&this.executionTargetRef&&this.executionTargetRef.status!==`running`&&await this.executionTargetRef.start()}};const g=t=>{if(t){if(t.container&&t.sandbox)throw new e(`Pass either "container" or "sandbox", not both.`);return t.container??t.sandbox}},_=e=>{let t=g(e);return!e||!t?{executionTarget:t,options:e}:{executionTarget:t,options:{...e,cwd:e.cwd??t.workdir,propagateEnv:e.container&&e.propagateEnv===void 0?!1:e.propagateEnv,spawner:t.spawner}}};export{h as n,_ as t};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Container } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BE9s04ko.mjs";
|
|
2
|
+
import { D as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BHP0wiJg.mjs";
|
|
3
|
+
import { t as Container } from "./index-BgsYjENi.mjs";
|
|
4
|
+
import { c as Sandbox } from "./index-DbXtKldz.mjs";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
|
|
6
7
|
//#region src/adapters/claude-code-cli/events/schemas.d.ts
|
|
@@ -289,7 +290,7 @@ interface ClaudeCodeCliRunOptions {
|
|
|
289
290
|
forkSession?: boolean;
|
|
290
291
|
extraArgs?: string[];
|
|
291
292
|
}
|
|
292
|
-
|
|
293
|
+
type ClaudeCodeCliAgentOptions = ClaudeCodeCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
293
294
|
command?: string[] | string;
|
|
294
295
|
cwd?: string;
|
|
295
296
|
env?: Record<string, string>;
|
|
@@ -299,10 +300,9 @@ interface ClaudeCodeCliAgentOptions extends ClaudeCodeCliRunOptions {
|
|
|
299
300
|
systemPrompt?: string;
|
|
300
301
|
logPath?: string;
|
|
301
302
|
ci?: boolean;
|
|
302
|
-
container?: Container;
|
|
303
303
|
spawner?: ProcessSpawner;
|
|
304
304
|
onEvent?: AgentEventHandler;
|
|
305
|
-
}
|
|
305
|
+
};
|
|
306
306
|
interface ClaudeCodeCliAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliRunOptions>> {
|
|
307
307
|
readonly type: "claude-code-cli";
|
|
308
308
|
fork: () => ClaudeCodeCliAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Container } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BE9s04ko.mjs";
|
|
2
|
+
import { D as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BHP0wiJg.mjs";
|
|
3
|
+
import { t as Container } from "./index-BgsYjENi.mjs";
|
|
4
|
+
import { c as Sandbox } from "./index-DbXtKldz.mjs";
|
|
4
5
|
import { z } from "zod/v4";
|
|
5
6
|
|
|
6
7
|
//#region src/adapters/codex-cli/events/schemas.d.ts
|
|
@@ -76,9 +77,9 @@ type CodexErrorEvent = z.infer<typeof codexErrorEventSchema>;
|
|
|
76
77
|
//#endregion
|
|
77
78
|
//#region src/adapters/codex-cli/types.d.ts
|
|
78
79
|
type CodexCliSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
79
|
-
type CodexCliPermissionMode = "
|
|
80
|
+
type CodexCliPermissionMode = "auto-approve" | "bypass-sandbox" | "default";
|
|
80
81
|
interface CodexCliRunOptions {
|
|
81
|
-
|
|
82
|
+
codexSandboxMode?: CodexCliSandboxMode;
|
|
82
83
|
additionalDirectories?: string[];
|
|
83
84
|
skipGitRepoCheck?: boolean;
|
|
84
85
|
permissionMode?: CodexCliPermissionMode;
|
|
@@ -88,7 +89,7 @@ interface CodexCliRunOptions {
|
|
|
88
89
|
extraArgs?: string[];
|
|
89
90
|
systemPrompt?: never;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
type CodexCliAgentOptions = CodexCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
92
93
|
command?: string[] | string;
|
|
93
94
|
cwd?: string;
|
|
94
95
|
env?: Record<string, string>;
|
|
@@ -96,10 +97,9 @@ interface CodexCliAgentOptions extends CodexCliRunOptions {
|
|
|
96
97
|
sessionId?: string;
|
|
97
98
|
model?: string;
|
|
98
99
|
logPath?: string;
|
|
99
|
-
container?: Container;
|
|
100
100
|
spawner?: ProcessSpawner;
|
|
101
101
|
onEvent?: AgentEventHandler;
|
|
102
|
-
}
|
|
102
|
+
};
|
|
103
103
|
interface CodexCliAgent extends BaseAgent<EnsureDisjoint<CodexCliRunOptions>> {
|
|
104
104
|
readonly type: "codex-cli";
|
|
105
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as ProcessSpawner } from "./types-BHP0wiJg.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/container/types.d.ts
|
|
4
|
-
type ContainerType = "docker" | "e2b" | "podman";
|
|
4
|
+
type ContainerType = "docker" | "e2b" | "nerdctl" | "podman";
|
|
5
5
|
interface PortMapping {
|
|
6
6
|
container: number;
|
|
7
7
|
host?: number;
|
|
@@ -181,6 +181,23 @@ interface E2BContainer extends ContainerBase<"e2b", E2BContainerConfig> {
|
|
|
181
181
|
getHost: (port: number) => string;
|
|
182
182
|
}
|
|
183
183
|
//#endregion
|
|
184
|
+
//#region src/container/nerdctl/types.d.ts
|
|
185
|
+
type NerdctlBuildBase = OciBuildBase;
|
|
186
|
+
type NerdctlBuildConfig = OciBuildConfig;
|
|
187
|
+
type NerdctlContainerBase = NerdctlProviderBase;
|
|
188
|
+
interface NerdctlProviderBase extends OciProviderBase {
|
|
189
|
+
namespace?: string;
|
|
190
|
+
address?: string;
|
|
191
|
+
buildkitHost?: string;
|
|
192
|
+
snapshotter?: string;
|
|
193
|
+
args?: string[];
|
|
194
|
+
}
|
|
195
|
+
type NerdctlProviderConfig = NerdctlProviderBase & OciProviderConfig;
|
|
196
|
+
type NerdctlContainerConfig = ContainerConfigBase<"nerdctl"> & NerdctlProviderConfig;
|
|
197
|
+
interface NerdctlContainer extends ContainerBase<"nerdctl", NerdctlContainerConfig> {
|
|
198
|
+
getMappedPort: (containerPort: number) => number | undefined;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
184
201
|
//#region src/container/podman/types.d.ts
|
|
185
202
|
type PodmanBuildBase = OciBuildBase;
|
|
186
203
|
type PodmanBuildConfig = OciBuildConfig;
|
|
@@ -215,10 +232,11 @@ declare class ContainerDiffError extends ContainerError {
|
|
|
215
232
|
}
|
|
216
233
|
//#endregion
|
|
217
234
|
//#region src/container/index.d.ts
|
|
218
|
-
type ContainerConfig = DockerContainerConfig | E2BContainerConfig | PodmanContainerConfig;
|
|
219
|
-
type Container = DockerContainer | E2BContainer | PodmanContainer;
|
|
235
|
+
type ContainerConfig = DockerContainerConfig | E2BContainerConfig | NerdctlContainerConfig | PodmanContainerConfig;
|
|
236
|
+
type Container = DockerContainer | E2BContainer | NerdctlContainer | PodmanContainer;
|
|
220
237
|
declare function createContainer(config: DockerContainerConfig): Promise<DockerContainer>;
|
|
221
238
|
declare function createContainer(config: E2BContainerConfig): Promise<E2BContainer>;
|
|
239
|
+
declare function createContainer(config: NerdctlContainerConfig): Promise<NerdctlContainer>;
|
|
222
240
|
declare function createContainer(config: PodmanContainerConfig): Promise<PodmanContainer>;
|
|
223
241
|
//#endregion
|
|
224
|
-
export {
|
|
242
|
+
export { WorkdirFileChange as $, E2BProviderConfig as A, ContainerFileSystem as B, NerdctlProviderConfig as C, E2BContainerBase as D, E2BContainer as E, DockerContainerConfig as F, ContainerType as G, ContainerLifecycle as H, DockerProviderConfig as I, PortMapping as J, ExecOptions as K, ContainerBase as L, DockerBuildConfig as M, DockerContainer as N, E2BContainerConfig as O, DockerContainerBase as P, WorkdirDiffStats as Q, ContainerConfigBase as R, NerdctlProviderBase as S, E2BConnectionConfig as T, ContainerObservability as U, ContainerIdentity as V, ContainerStatus as W, WorkdirChangeKind as X, VolumeMount as Y, WorkdirDiff as Z, NerdctlBuildBase as _, ContainerDiffError as a, NerdctlContainerBase as b, ContainerExecError as c, PodmanBuildBase as d, WorkdirSnapshot as et, PodmanBuildConfig as f, PodmanProviderConfig as g, PodmanContainerConfig as h, ContainerCreateError as i, DockerBuildBase as j, E2BCreateConfig as k, ContainerNotRunningError as l, PodmanContainerBase as m, ContainerConfig as n, ContainerDisposedError as o, PodmanContainer as p, ExecResult as q, createContainer as r, ContainerError as s, Container as t, WorkdirSnapshotOptions as tt, ContainerStartError as u, NerdctlBuildConfig as v, E2BConnectConfig as w, NerdctlContainerConfig as x, NerdctlContainer as y, ContainerExecution as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-
|
|
1
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-BHP0wiJg.mjs";
|
|
2
2
|
//#region src/adapters/codex-sdk/types.d.ts
|
|
3
3
|
type CodexSdkSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
4
4
|
type CodexSdkModelReasoningEffort = "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
@@ -128,6 +128,7 @@ interface CodexSdkAgentOptions extends CodexSdkRunOptions {
|
|
|
128
128
|
env?: Record<string, string>;
|
|
129
129
|
propagateEnv?: boolean;
|
|
130
130
|
container?: never;
|
|
131
|
+
sandbox?: never;
|
|
131
132
|
cwd?: string;
|
|
132
133
|
sessionId?: string;
|
|
133
134
|
model?: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Container } from "./index-
|
|
1
|
+
import { D as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BHP0wiJg.mjs";
|
|
2
|
+
import { t as Container } from "./index-BgsYjENi.mjs";
|
|
3
|
+
import { c as Sandbox } from "./index-DbXtKldz.mjs";
|
|
3
4
|
import { z } from "zod/v4";
|
|
4
5
|
|
|
5
6
|
//#region src/adapters/gemini-cli/events/schemas.d.ts
|
|
@@ -16,7 +17,7 @@ interface GeminiCliRunOptions {
|
|
|
16
17
|
permissionMode?: GeminiCliPermissionMode;
|
|
17
18
|
extraArgs?: string[];
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
type GeminiCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbox> & GeminiCliRunOptions & {
|
|
20
21
|
command?: string[] | string;
|
|
21
22
|
cwd?: string;
|
|
22
23
|
env?: Record<string, string>;
|
|
@@ -25,10 +26,9 @@ interface GeminiCliAgentOptions extends GeminiCliRunOptions {
|
|
|
25
26
|
model?: string;
|
|
26
27
|
systemPrompt?: string;
|
|
27
28
|
logPath?: string;
|
|
28
|
-
container?: Container;
|
|
29
29
|
spawner?: ProcessSpawner;
|
|
30
30
|
onEvent?: AgentEventHandler;
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
interface GeminiCliAgent extends BaseAgent<EnsureDisjoint<GeminiCliRunOptions>> {
|
|
33
33
|
readonly type: "gemini-cli";
|
|
34
34
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BE9s04ko.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-BHP0wiJg.mjs";
|
|
3
3
|
//#region src/adapters/claude-code-sdk/types.d.ts
|
|
4
4
|
type ClaudeCodeSdkPermissionMode = "acceptEdits" | "bypassPermissions" | "default" | "dontAsk" | "plan";
|
|
5
5
|
type ClaudeCodeSdkExecutable = "bun" | "deno" | "node";
|
|
@@ -23,6 +23,7 @@ interface ClaudeCodeSdkAgentOptions extends ClaudeCodeSdkRunOptions {
|
|
|
23
23
|
settings?: ClaudeCodeSdkSettings;
|
|
24
24
|
settingSources?: ClaudeCodeSdkSettingSource[];
|
|
25
25
|
container?: never;
|
|
26
|
+
sandbox?: never;
|
|
26
27
|
cwd?: string;
|
|
27
28
|
sessionId?: string;
|
|
28
29
|
model?: string;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { D as ProcessSpawner } from "./types-BHP0wiJg.mjs";
|
|
2
|
+
import { Y as VolumeMount } from "./index-BgsYjENi.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/sandbox/types.d.ts
|
|
5
|
+
type SandboxType = "bubblewrap" | "firejail" | "nsjail";
|
|
6
|
+
type SandboxStatus = "created" | "disposed" | "running" | "stopped";
|
|
7
|
+
interface SandboxConfigBase<TType extends SandboxType> {
|
|
8
|
+
type: TType;
|
|
9
|
+
workdir: string;
|
|
10
|
+
}
|
|
11
|
+
interface SandboxIdentity<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> {
|
|
12
|
+
readonly type: TType;
|
|
13
|
+
readonly config: TConfig;
|
|
14
|
+
readonly status: SandboxStatus;
|
|
15
|
+
readonly workdir: string;
|
|
16
|
+
}
|
|
17
|
+
interface SandboxLifecycle {
|
|
18
|
+
start: () => Promise<void>;
|
|
19
|
+
stop: () => Promise<void>;
|
|
20
|
+
dispose: () => Promise<void>;
|
|
21
|
+
[Symbol.asyncDispose]: () => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
interface SandboxExecution {
|
|
24
|
+
readonly spawner: ProcessSpawner;
|
|
25
|
+
}
|
|
26
|
+
interface SandboxBase<TType extends SandboxType, TConfig extends SandboxConfigBase<TType>> extends SandboxExecution, SandboxIdentity<TType, TConfig>, SandboxLifecycle {}
|
|
27
|
+
interface BubblewrapSandboxConfig extends SandboxConfigBase<"bubblewrap"> {
|
|
28
|
+
binary?: string;
|
|
29
|
+
binds?: VolumeMount[];
|
|
30
|
+
clearEnv?: boolean;
|
|
31
|
+
setEnv?: Record<string, string>;
|
|
32
|
+
unsetEnv?: string[];
|
|
33
|
+
unshareAll?: boolean;
|
|
34
|
+
shareNetwork?: boolean;
|
|
35
|
+
hostname?: string;
|
|
36
|
+
uid?: number;
|
|
37
|
+
gid?: number;
|
|
38
|
+
tmpfs?: string[];
|
|
39
|
+
remountReadonly?: string[];
|
|
40
|
+
proc?: false | string;
|
|
41
|
+
dev?: false | string;
|
|
42
|
+
args?: string[];
|
|
43
|
+
}
|
|
44
|
+
interface BubblewrapSandbox extends SandboxBase<"bubblewrap", BubblewrapSandboxConfig> {}
|
|
45
|
+
interface FirejailSandboxConfig extends SandboxConfigBase<"firejail"> {
|
|
46
|
+
binary?: string;
|
|
47
|
+
clearEnv?: boolean;
|
|
48
|
+
setEnv?: Record<string, string>;
|
|
49
|
+
unsetEnv?: string[];
|
|
50
|
+
shareNetwork?: boolean;
|
|
51
|
+
whitelist?: string[];
|
|
52
|
+
blacklist?: string[];
|
|
53
|
+
readOnly?: string[];
|
|
54
|
+
readWrite?: string[];
|
|
55
|
+
privateTmp?: boolean;
|
|
56
|
+
args?: string[];
|
|
57
|
+
}
|
|
58
|
+
interface FirejailSandbox extends SandboxBase<"firejail", FirejailSandboxConfig> {}
|
|
59
|
+
interface NsjailSandboxConfig extends SandboxConfigBase<"nsjail"> {
|
|
60
|
+
binary?: string;
|
|
61
|
+
binds?: VolumeMount[];
|
|
62
|
+
readOnly?: string[];
|
|
63
|
+
clearEnv?: boolean;
|
|
64
|
+
setEnv?: Record<string, string>;
|
|
65
|
+
unsetEnv?: string[];
|
|
66
|
+
shareNetwork?: boolean;
|
|
67
|
+
uid?: number;
|
|
68
|
+
gid?: number;
|
|
69
|
+
hostname?: string;
|
|
70
|
+
tmpfs?: string[];
|
|
71
|
+
timeLimitSec?: number;
|
|
72
|
+
disableRlimits?: boolean;
|
|
73
|
+
seccompString?: string;
|
|
74
|
+
args?: string[];
|
|
75
|
+
}
|
|
76
|
+
interface NsjailSandbox extends SandboxBase<"nsjail", NsjailSandboxConfig> {}
|
|
77
|
+
type SandboxConfig = BubblewrapSandboxConfig | FirejailSandboxConfig | NsjailSandboxConfig;
|
|
78
|
+
type Sandbox = BubblewrapSandbox | FirejailSandbox | NsjailSandbox;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/sandbox/index.d.ts
|
|
81
|
+
declare function createSandbox(config: BubblewrapSandboxConfig): Promise<BubblewrapSandbox>;
|
|
82
|
+
declare function createSandbox(config: FirejailSandboxConfig): Promise<FirejailSandbox>;
|
|
83
|
+
declare function createSandbox(config: NsjailSandboxConfig): Promise<NsjailSandbox>;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { FirejailSandboxConfig as a, Sandbox as c, SandboxConfigBase as d, SandboxExecution as f, SandboxType as g, SandboxStatus as h, FirejailSandbox as i, SandboxBase as l, SandboxLifecycle as m, BubblewrapSandbox as n, NsjailSandbox as o, SandboxIdentity as p, BubblewrapSandboxConfig as r, NsjailSandboxConfig as s, createSandbox as t, SandboxConfig as u };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { C as OutputSchema, S as McpServerConfig, T as agentCapabilitiesSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, i as SessionEndEvent, n as MessageEvent, o as StderrEvent, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "./events-
|
|
2
|
-
import { C as
|
|
3
|
-
import { A as
|
|
4
|
-
import { a as
|
|
5
|
-
import { a as
|
|
6
|
-
import { a as
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as
|
|
1
|
+
import { C as OutputSchema, S as McpServerConfig, T as agentCapabilitiesSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, i as SessionEndEvent, n as MessageEvent, o as StderrEvent, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "./events-BE9s04ko.mjs";
|
|
2
|
+
import { C as RunTiming, E as ZodRunRequest, S as RunStatus, T as StructuredRunRequest, _ as RunProcessInfo, a as AgentValidationError, b as RunResultBase, c as AnyRunResult, d as CompletedRunResult, f as EnsureDisjoint, g as RunError, h as JsonSchemaRunRequest, i as AgentType, l as BaseAgent, m as FailedRunResult, n as AgentMetrics, o as AnyCompletedRunResult, r as AgentRunError, s as AnyRunRequest, t as AgentEventHandler, u as CancelledRunResult, v as RunRequest, w as StopReason, x as RunStats, y as RunResult } from "./types-BHP0wiJg.mjs";
|
|
3
|
+
import { $ as WorkdirFileChange, A as E2BProviderConfig, B as ContainerFileSystem, C as NerdctlProviderConfig, D as E2BContainerBase, E as E2BContainer, F as DockerContainerConfig, G as ContainerType, H as ContainerLifecycle, I as DockerProviderConfig, J as PortMapping, K as ExecOptions, L as ContainerBase, M as DockerBuildConfig, N as DockerContainer, O as E2BContainerConfig, P as DockerContainerBase, Q as WorkdirDiffStats, R as ContainerConfigBase, S as NerdctlProviderBase, T as E2BConnectionConfig, U as ContainerObservability, V as ContainerIdentity, W as ContainerStatus, X as WorkdirChangeKind, Y as VolumeMount, Z as WorkdirDiff, _ as NerdctlBuildBase, a as ContainerDiffError, b as NerdctlContainerBase, c as ContainerExecError, d as PodmanBuildBase, et as WorkdirSnapshot, f as PodmanBuildConfig, g as PodmanProviderConfig, h as PodmanContainerConfig, i as ContainerCreateError, j as DockerBuildBase, k as E2BCreateConfig, l as ContainerNotRunningError, m as PodmanContainerBase, n as ContainerConfig, o as ContainerDisposedError, p as PodmanContainer, q as ExecResult, r as createContainer, s as ContainerError, t as Container, tt as WorkdirSnapshotOptions, u as ContainerStartError, v as NerdctlBuildConfig, w as E2BConnectConfig, x as NerdctlContainerConfig, y as NerdctlContainer, z as ContainerExecution } from "./index-BgsYjENi.mjs";
|
|
4
|
+
import { a as FirejailSandboxConfig, c as Sandbox, d as SandboxConfigBase, f as SandboxExecution, g as SandboxType, h as SandboxStatus, i as FirejailSandbox, l as SandboxBase, m as SandboxLifecycle, n as BubblewrapSandbox, o as NsjailSandbox, p as SandboxIdentity, r as BubblewrapSandboxConfig, s as NsjailSandboxConfig, t as createSandbox, u as SandboxConfig } from "./index-DbXtKldz.mjs";
|
|
5
|
+
import { a as ClaudeCodeCliRunOptions, c as ClaudeRateLimitEvent, d as ClaudeUserEvent, i as ClaudeCodeCliPermissionMode, l as ClaudeResultEvent, n as ClaudeCodeCliAgent, o as ClaudeAssistantEvent, r as ClaudeCodeCliAgentOptions, s as ClaudeEvent, u as ClaudeSystemEvent } from "./index-BDJms3ZX.mjs";
|
|
6
|
+
import { a as ClaudeCodeSdkExecutable, c as ClaudeCodeSdkSettingSource, i as ClaudeCodeSdkEvent, l as ClaudeCodeSdkSettings, n as ClaudeCodeSdkAgent, o as ClaudeCodeSdkPermissionMode, r as ClaudeCodeSdkAgentOptions, s as ClaudeCodeSdkRunOptions } from "./index-CmVxarAz.mjs";
|
|
7
|
+
import { a as CodexCliRunOptions, c as CodexEvent, d as CodexItemUpdatedEvent, f as CodexThreadStartedEvent, i as CodexCliPermissionMode, l as CodexItemCompletedEvent, m as CodexTurnFailedEvent, n as CodexCliAgent, o as CodexCliSandboxMode, p as CodexTurnCompletedEvent, r as CodexCliAgentOptions, s as CodexErrorEvent, u as CodexItemStartedEvent } from "./index-BWtmcPDz.mjs";
|
|
8
|
+
import { a as CodexSdkItem, i as CodexSdkEvent, n as CodexSdkAgent, o as CodexSdkPermissionMode, r as CodexSdkAgentOptions, s as CodexSdkRunOptions } from "./index-C-uiS3g-.mjs";
|
|
9
|
+
import { a as GeminiCliRunOptions, i as GeminiCliPermissionMode, n as GeminiCliAgent, o as GeminiEvent, r as GeminiCliAgentOptions } from "./index-CZbHe6Xs.mjs";
|
|
9
10
|
//#region src/core/agent/create-agent.d.ts
|
|
10
11
|
declare function createAgent(type: "claude-code-cli", options?: ClaudeCodeCliAgentOptions): Promise<ClaudeCodeCliAgent>;
|
|
11
12
|
declare function createAgent(type: "claude-code-sdk", options?: ClaudeCodeSdkAgentOptions): Promise<ClaudeCodeSdkAgent>;
|
|
@@ -13,4 +14,4 @@ declare function createAgent(type: "codex-cli", options?: CodexCliAgentOptions):
|
|
|
13
14
|
declare function createAgent(type: "codex-sdk", options?: CodexSdkAgentOptions): Promise<CodexSdkAgent>;
|
|
14
15
|
declare function createAgent(type: "gemini-cli", options?: GeminiCliAgentOptions): Promise<GeminiCliAgent>;
|
|
15
16
|
//#endregion
|
|
16
|
-
export { type AgentCapabilities, type AgentEvent, type AgentEventHandler, type AgentMetrics, AgentRunError, type AgentType, AgentValidationError, type AnyCompletedRunResult, type AnyRunRequest, type AnyRunResult, type BaseAgent, type CancelledRunResult, type ClaudeAssistantEvent, type ClaudeCodeCliAgent, type ClaudeCodeCliAgentOptions, type ClaudeCodeCliPermissionMode, type ClaudeCodeCliRunOptions, type ClaudeCodeSdkAgent, type ClaudeCodeSdkAgentOptions, type ClaudeCodeSdkEvent, type ClaudeCodeSdkExecutable, type ClaudeCodeSdkPermissionMode, type ClaudeCodeSdkRunOptions, type ClaudeCodeSdkSettingSource, type ClaudeCodeSdkSettings, type ClaudeEvent, type ClaudeRateLimitEvent, type ClaudeResultEvent, type ClaudeSystemEvent, type ClaudeUserEvent, type CodexCliAgent, type CodexCliAgentOptions, type CodexCliPermissionMode, type CodexCliRunOptions, type CodexCliSandboxMode, type CodexErrorEvent, type CodexEvent, type CodexItemCompletedEvent, type CodexItemStartedEvent, type CodexItemUpdatedEvent, type CodexSdkAgent, type CodexSdkAgentOptions, type CodexSdkEvent, type CodexSdkItem, type CodexSdkPermissionMode, type CodexSdkRunOptions, type CodexThreadStartedEvent, type CodexTurnCompletedEvent, type CodexTurnFailedEvent, type CompletedRunResult, type Container, type ContainerBase, type ContainerConfig, type ContainerConfigBase, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, type ContainerExecution, type ContainerFileSystem, type ContainerIdentity, type ContainerLifecycle, ContainerNotRunningError, type ContainerObservability, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type DockerBuildBase, type DockerBuildConfig, type DockerContainer, type DockerContainerBase, type DockerContainerConfig, type DockerProviderConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerBase, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type EnsureDisjoint, type ExecOptions, type ExecResult, type FailedRunResult, type GeminiCliAgent, type GeminiCliAgentOptions, type GeminiCliPermissionMode, type GeminiCliRunOptions, type GeminiEvent, type ImageContentPart, type JsonSchema, type JsonSchemaRunRequest, type McpServerConfig, type MessageEvent, type OutputSchema, type PodmanBuildBase, type PodmanBuildConfig, type PodmanContainer, type PodmanContainerBase, type PodmanContainerConfig, type PodmanProviderConfig, type PortMapping, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunResultBase, type RunStats, type RunStatus, type RunTiming, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type StopReason, type StructuredRunRequest, type TextContentPart, type ToolCallEvent, type ToolResultEvent, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, type ZodRunRequest, agentCapabilitiesSchema, createAgent, createContainer, eventSchema };
|
|
17
|
+
export { type AgentCapabilities, type AgentEvent, type AgentEventHandler, type AgentMetrics, AgentRunError, type AgentType, AgentValidationError, type AnyCompletedRunResult, type AnyRunRequest, type AnyRunResult, type BaseAgent, type BubblewrapSandbox, type BubblewrapSandboxConfig, type CancelledRunResult, type ClaudeAssistantEvent, type ClaudeCodeCliAgent, type ClaudeCodeCliAgentOptions, type ClaudeCodeCliPermissionMode, type ClaudeCodeCliRunOptions, type ClaudeCodeSdkAgent, type ClaudeCodeSdkAgentOptions, type ClaudeCodeSdkEvent, type ClaudeCodeSdkExecutable, type ClaudeCodeSdkPermissionMode, type ClaudeCodeSdkRunOptions, type ClaudeCodeSdkSettingSource, type ClaudeCodeSdkSettings, type ClaudeEvent, type ClaudeRateLimitEvent, type ClaudeResultEvent, type ClaudeSystemEvent, type ClaudeUserEvent, type CodexCliAgent, type CodexCliAgentOptions, type CodexCliPermissionMode, type CodexCliRunOptions, type CodexCliSandboxMode, type CodexErrorEvent, type CodexEvent, type CodexItemCompletedEvent, type CodexItemStartedEvent, type CodexItemUpdatedEvent, type CodexSdkAgent, type CodexSdkAgentOptions, type CodexSdkEvent, type CodexSdkItem, type CodexSdkPermissionMode, type CodexSdkRunOptions, type CodexThreadStartedEvent, type CodexTurnCompletedEvent, type CodexTurnFailedEvent, type CompletedRunResult, type Container, type ContainerBase, type ContainerConfig, type ContainerConfigBase, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, type ContainerExecution, type ContainerFileSystem, type ContainerIdentity, type ContainerLifecycle, ContainerNotRunningError, type ContainerObservability, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type DockerBuildBase, type DockerBuildConfig, type DockerContainer, type DockerContainerBase, type DockerContainerConfig, type DockerProviderConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerBase, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type EnsureDisjoint, type ExecOptions, type ExecResult, type FailedRunResult, type FirejailSandbox, type FirejailSandboxConfig, type GeminiCliAgent, type GeminiCliAgentOptions, type GeminiCliPermissionMode, type GeminiCliRunOptions, type GeminiEvent, type ImageContentPart, type JsonSchema, type JsonSchemaRunRequest, type McpServerConfig, type MessageEvent, type NerdctlBuildBase, type NerdctlBuildConfig, type NerdctlContainer, type NerdctlContainerBase, type NerdctlContainerConfig, type NerdctlProviderBase, type NerdctlProviderConfig, type NsjailSandbox, type NsjailSandboxConfig, type OutputSchema, type PodmanBuildBase, type PodmanBuildConfig, type PodmanContainer, type PodmanContainerBase, type PodmanContainerConfig, type PodmanProviderConfig, type PortMapping, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunResultBase, type RunStats, type RunStatus, type RunTiming, type Sandbox, type SandboxBase, type SandboxConfig, type SandboxConfigBase, type SandboxExecution, type SandboxIdentity, type SandboxLifecycle, type SandboxStatus, type SandboxType, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type StopReason, type StructuredRunRequest, type TextContentPart, type ToolCallEvent, type ToolResultEvent, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, type ZodRunRequest, agentCapabilitiesSchema, createAgent, createContainer, createSandbox, eventSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -1,61 +1 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { a as ContainerExecError, i as ContainerError, n as ContainerDiffError, o as ContainerNotRunningError, r as ContainerDisposedError, s as ContainerStartError, t as ContainerCreateError } from "./errors-BAmHDQu8.mjs";
|
|
3
|
-
import { createContainer } from "./container/index.mjs";
|
|
4
|
-
import { n as eventSchema, u as agentCapabilitiesSchema } from "./schemas-DwD4pwJB.mjs";
|
|
5
|
-
//#region src/core/agent/create-agent.ts
|
|
6
|
-
function resolveContainerOptions(options) {
|
|
7
|
-
if (!options?.container) return options;
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
10
|
-
cwd: options.cwd ?? options.container.workdir
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
const isMissingModuleError = (error, packageName) => {
|
|
14
|
-
if (!(error instanceof Error) || !error.message.includes(packageName)) return false;
|
|
15
|
-
const code = typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
|
|
16
|
-
return code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND";
|
|
17
|
-
};
|
|
18
|
-
const wrapMissingPeerDependency = (type, packageName, error) => {
|
|
19
|
-
if (isMissingModuleError(error, packageName)) throw new AgentValidationError(`Agent type "${type}" requires the optional peer dependency "${packageName}". Install it to use this adapter.`);
|
|
20
|
-
throw error;
|
|
21
|
-
};
|
|
22
|
-
async function createAgent(type, options) {
|
|
23
|
-
switch (type) {
|
|
24
|
-
case "claude-code-cli": {
|
|
25
|
-
const typedOptions = resolveContainerOptions(options);
|
|
26
|
-
const { createClaudeCodeCliAgent } = await import("./adapters/claude-code-cli/index.mjs");
|
|
27
|
-
return createClaudeCodeCliAgent(typedOptions);
|
|
28
|
-
}
|
|
29
|
-
case "claude-code-sdk": {
|
|
30
|
-
const typedOptions = options;
|
|
31
|
-
try {
|
|
32
|
-
const { createClaudeCodeSdkAgent } = await import("./adapters/claude-code-sdk/index.mjs");
|
|
33
|
-
return createClaudeCodeSdkAgent(typedOptions);
|
|
34
|
-
} catch (error) {
|
|
35
|
-
return wrapMissingPeerDependency("claude-code-sdk", "@anthropic-ai/claude-agent-sdk", error);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
case "codex-cli": {
|
|
39
|
-
const typedOptions = resolveContainerOptions(options);
|
|
40
|
-
const { createCodexCliAgent } = await import("./adapters/codex-cli/index.mjs");
|
|
41
|
-
return createCodexCliAgent(typedOptions);
|
|
42
|
-
}
|
|
43
|
-
case "codex-sdk": {
|
|
44
|
-
const typedOptions = options;
|
|
45
|
-
try {
|
|
46
|
-
const { createCodexSdkAgent } = await import("./adapters/codex-sdk/index.mjs");
|
|
47
|
-
return createCodexSdkAgent(typedOptions);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
return wrapMissingPeerDependency("codex-sdk", "@openai/codex-sdk", error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
case "gemini-cli": {
|
|
53
|
-
const typedOptions = resolveContainerOptions(options);
|
|
54
|
-
const { createGeminiCliAgent } = await import("./adapters/gemini-cli/index.mjs");
|
|
55
|
-
return createGeminiCliAgent(typedOptions);
|
|
56
|
-
}
|
|
57
|
-
default: throw new AgentValidationError("Unsupported agent type.");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//#endregion
|
|
61
|
-
export { AgentRunError, AgentValidationError, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, agentCapabilitiesSchema, createAgent, createContainer, eventSchema };
|
|
1
|
+
import{n as e,t}from"./types-CwvWHEpy.mjs";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./errors-XV0frS3r.mjs";import{createContainer as l}from"./container/index.mjs";import{t as u}from"./sandbox-_As0qZWn.mjs";import{n as d,u as f}from"./schemas-CXVWDOoT.mjs";const p=(e,t)=>{if(!(e instanceof Error)||!e.message.includes(t))return!1;let n=typeof e==`object`&&e&&`code`in e?e.code:void 0;return n===`ERR_MODULE_NOT_FOUND`||n===`MODULE_NOT_FOUND`},m=(t,n,r)=>{throw p(r,n)?new e(`Agent type "${t}" requires the optional peer dependency "${n}". Install it to use this adapter.`):r};async function h(t,n){switch(t){case`claude-code-cli`:{let{createClaudeCodeCliAgent:e}=await import(`./adapters/claude-code-cli/index.mjs`);return e(n)}case`claude-code-sdk`:{let e=n;try{let{createClaudeCodeSdkAgent:t}=await import(`./adapters/claude-code-sdk/index.mjs`);return t(e)}catch(e){return m(`claude-code-sdk`,`@anthropic-ai/claude-agent-sdk`,e)}}case`codex-cli`:{let{createCodexCliAgent:e}=await import(`./adapters/codex-cli/index.mjs`);return e(n)}case`codex-sdk`:{let e=n;try{let{createCodexSdkAgent:t}=await import(`./adapters/codex-sdk/index.mjs`);return t(e)}catch(e){return m(`codex-sdk`,`@openai/codex-sdk`,e)}}case`gemini-cli`:{let{createGeminiCliAgent:e}=await import(`./adapters/gemini-cli/index.mjs`);return e(n)}default:throw new e(`Unsupported agent type.`)}}export{t as AgentRunError,e as AgentValidationError,c as ContainerCreateError,i as ContainerDiffError,o as ContainerDisposedError,r as ContainerError,n as ContainerExecError,a as ContainerNotRunningError,s as ContainerStartError,f as agentCapabilitiesSchema,h as createAgent,l as createContainer,u as createSandbox,d as eventSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{a as t,n,o as r,r as i,s as a,t as o}from"./errors-XV0frS3r.mjs";import{n as s}from"./env-DIXTVzTs.mjs";import{t as c}from"./spawner-BJesLc8I.mjs";import{t as l}from"./shell-Dewbmt9R.mjs";import{n as u,r as d,t as f}from"./diff-DkMPJCxL.mjs";import{execFile as p}from"node:child_process";import{isAbsolute as m,join as h,posix as g}from"node:path";import{promisify as _}from"node:util";import{tmpdir as v}from"node:os";import{mkdtemp as y,rm as b,writeFile as x}from"node:fs/promises";import{randomBytes as S}from"node:crypto";const C=(e,t)=>{let n=g.relative(e,t);return n===``||!n.startsWith(`..`)&&!g.isAbsolute(n)},w=(e,t)=>{if(!e||e.length===0)return;let n=g.normalize(t),r;for(let t of e){if(!m(t.source))continue;let e=g.normalize(t.target);C(e,n)&&(!r||e.length>g.normalize(r.target).length)&&(r=t)}if(!r)return;let i=g.relative(g.normalize(r.target),n);return i===``?r.source:h(r.source,...i.split(`/`))},T=_(p),E=()=>`cw-${S(6).toString(`hex`)}`,D=(e,t)=>e.baseArgs?[...e.baseArgs,...t]:t,O=e=>{if(e.env)return{...s(),...e.env}},k=async(e,t,n)=>{let r=await T(e.binary,D(e,t),{encoding:`utf8`,env:O(e),timeout:n?.timeoutMs,signal:n?.signal,maxBuffer:50*1024*1024});return{stdout:r.stdout,stderr:r.stderr}},A=async(t,n)=>{let r=n.tag??`cw-build-${S(4).toString(`hex`)}`,i=[`build`,`-t`,r];if(n.args)for(let[e,t]of Object.entries(n.args))i.push(`--build-arg`,`${e}=${t}`);`dockerfile`in n&&n.dockerfile&&(i.push(`-f`,n.dockerfile),i.push(n.context??`.`));let a;if(`content`in n&&n.content){a=await y(h(v(),`cw-oci-build-`));let e=h(a,`Dockerfile`);await x(e,n.content,{encoding:`utf8`,mode:384}),i.push(`-f`,e),i.push(n.context??a)}try{await k(t,i)}catch(t){throw new o(`Image build failed: ${e(t)}`)}finally{a&&await b(a,{recursive:!0,force:!0}).catch(()=>{})}return r},j=async(e,t,n)=>{let r=await Promise.all(n.map(async n=>{try{let{container:r,protocol:i=`tcp`}=n,{stdout:a}=await k(e,[`port`,t,`${r}/${i}`]),o=/:(\d+)$/m.exec(a.trim());if(o?.[1])return[r,Number(o[1])]}catch{}})),i=new Map;for(let e of r)e&&i.set(e[0],e[1]);return i},M=(e,t)=>({spawn:(n,r,i={})=>{let a=[`exec`,`-i`];if(i.cwd&&a.push(`-w`,i.cwd),i.env)for(let[e,t]of Object.entries(i.env))a.push(`-e`,`${e}=${t}`);return a.push(e,n,...r),c.spawn(t.binary,D(t,a),{env:O(t),stdio:i.stdio})}}),N=async(s,p,m)=>{let{commandContext:h,builtImage:_,containerName:v,workdir:y,user:b,network:x,platform:S,env:C,ports:T,mounts:A,extraArgs:N,image:P}=p,F=v??E(),I=[`create`,`--name`,F];if(b&&I.push(`--user`,b),x&&I.push(`--network`,x),S&&I.push(`--platform`,S),C)for(let[e,t]of Object.entries(C))I.push(`-e`,`${e}=${t}`);if(T)for(let e of T){let{host:t,container:n,protocol:r=`tcp`}=e;I.push(`-p`,`${t??``}:${n}/${r}`)}if(A)for(let e of A){let{readonly:t,source:n,target:r}=e,i=t?`ro`:`rw`;I.push(`-v`,`${n}:${r}:${i}`)}N&&I.push(...N),I.push(P,`sleep`,`infinity`);let L;try{let{stdout:e}=await k(h,I);L=e.trim()}catch(t){throw new o(`Container create failed: ${e(t)}`)}let R=`created`,z=new Map,B=()=>{if(R===`disposed`)throw new i},V=()=>{if(B(),R!==`running`)throw new r},H=M(L,h),U=u({owner:{},workdir:y,materialize:async(t,r)=>{B();let i=w(A,t);if(i){await f(i,r);return}V();try{await k(h,[`exec`,L,`sh`,`-c`,`test -d ${l(t)}`])}catch{throw new n(`Target path is not a directory: ${t}`)}try{await k(h,[`cp`,`${L}:${t}/.`,r])}catch(r){throw new n(`Failed to materialize container path ${t}: ${e(r)}`)}}}),W={get type(){return s},get id(){return L},get name(){return F},get config(){return m},get status(){return R},get workdir(){return y},get spawner(){return H},async start(){if(B(),R!==`running`){try{await k(h,[`start`,L])}catch(t){throw new a(`Container start failed: ${e(t)}`)}try{await k(h,[`exec`,L,`mkdir`,`-p`,y])}catch(t){try{await k(h,[`stop`,`-t`,`0`,L]),R=`stopped`}catch{try{let{stdout:e}=await k(h,[`inspect`,`--format`,`{{.State.Status}}`,L]);R=e.trim()===`running`?`running`:`stopped`}catch{R=`disposed`}}throw new a(`Container start failed: ${e(t)}`)}R=`running`,T?.length&&(z=await j(h,L,T))}},async stop(){if(B(),R===`running`){try{await k(h,[`stop`,`-t`,`2`,L])}catch{try{let{stdout:e}=await k(h,[`inspect`,`--format`,`{{.State.Status}}`,L]);if(e.trim()===`running`)return}catch{R=`disposed`;return}}R=`stopped`}},async dispose(){if(R!==`disposed`){try{await k(h,[`stop`,`-t`,`0`,L])}catch{}try{await k(h,[`rm`,`-f`,L])}catch{}_&&await k(h,[`rmi`,P]).catch(()=>{}),await U.disposeSnapshots().catch(()=>{}),R=`disposed`}},async exec(e,t,n={}){V();let r=[`exec`];if(n.cwd&&r.push(`-w`,n.cwd),n.env)for(let[e,t]of Object.entries(n.env))r.push(`-e`,`${e}=${t}`);r.push(L,e,...t);try{let{stdout:e,stderr:t}=await k(h,r,{timeoutMs:n.timeoutMs,signal:n.signal});return{exitCode:0,stdout:e,stderr:t}}catch(e){if(d(e))return{exitCode:typeof e.code==`number`?e.code:-1,stdout:String(e.stdout??``),stderr:String(e.stderr??``)};throw e}},async copyTo(e,t){V(),await k(h,[`cp`,e,`${L}:${t}`])},async copyFrom(e,t){V(),await k(h,[`cp`,`${L}:${e}`,t])},async writeFile(e,n){V();let r=g.isAbsolute(e)?e:g.resolve(y,e),i=g.dirname(r),a=typeof n==`string`?Buffer.from(n,`utf8`):n,o=[`exec`,`-i`];b&&o.push(`--user`,b),o.push(L,`sh`,`-c`,`mkdir -p ${l(i)} && cat > ${l(r)}`);let s=c.spawn(h.binary,D(h,o),{env:O(h),stdio:[`pipe`,`ignore`,`ignore`]});s.stdin?.write?.(a),s.stdin?.end();let u=await s.wait();if(u.exitCode!==0)throw new t(`writeFile failed for ${r} (exit ${u.exitCode})`)},async readFile(e){V();let t=g.isAbsolute(e)?e:g.resolve(y,e),{stdout:n}=await k(h,[`exec`,L,`cat`,t]);return n},async fileExists(e){V();let t=g.isAbsolute(e)?e:g.resolve(y,e);try{return await k(h,[`exec`,L,`test`,`-e`,t]),!0}catch{return!1}},async mkdir(e){V();let t=g.isAbsolute(e)?e:g.resolve(y,e);await k(h,[`exec`,L,`mkdir`,`-p`,t])},async execShell(e,t={}){return W.exec(`sh`,[`-c`,e],t)},async logs(e={}){B();let t=[`logs`];e.tail!==void 0&&t.push(`--tail`,String(e.tail)),t.push(L);let{stdout:n}=await k(h,t);return n},async syncStatus(){B();try{let{stdout:e}=await k(h,[`inspect`,`--format`,`{{.State.Status}}`,L]),t=e.trim();R=t===`running`?`running`:t===`created`?`created`:`stopped`}catch{R=`disposed`}return R},async snapshotWorkdir(e={}){return U.snapshotWorkdir(e)},async diffWorkdir(e){return U.diffWorkdir(e)},async releaseWorkdirSnapshot(e){return U.releaseWorkdirSnapshot(e)},getMappedPort(e){return z.get(e)},[Symbol.asyncDispose](){return W.dispose()}};return W},P=async(e,t)=>{if(t.image)return t.image;if(t.build)return A(e,t.build);throw new o(`Either image or build must be provided.`)};export{P as n,N as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as FirejailSandboxConfig, c as Sandbox, d as SandboxConfigBase, f as SandboxExecution, g as SandboxType, h as SandboxStatus, i as FirejailSandbox, l as SandboxBase, m as SandboxLifecycle, n as BubblewrapSandbox, o as NsjailSandbox, p as SandboxIdentity, r as BubblewrapSandboxConfig, s as NsjailSandboxConfig, t as createSandbox, u as SandboxConfig } from "../index-DbXtKldz.mjs";
|
|
2
|
+
export { BubblewrapSandbox, BubblewrapSandboxConfig, FirejailSandbox, FirejailSandboxConfig, NsjailSandbox, NsjailSandboxConfig, Sandbox, SandboxBase, SandboxConfig, SandboxConfigBase, SandboxExecution, SandboxIdentity, SandboxLifecycle, SandboxStatus, SandboxType, createSandbox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../sandbox-_As0qZWn.mjs";export{e as createSandbox};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{n as t,r as n,t as r}from"./env-DIXTVzTs.mjs";import{t as i}from"./spawner-BJesLc8I.mjs";import{t as a}from"./shell-Dewbmt9R.mjs";import{execFile as o}from"node:child_process";import{delimiter as s,isAbsolute as c,join as l,posix as u,resolve as d}from"node:path";import{promisify as f}from"node:util";import{accessSync as p,constants as m,mkdtempSync as h,realpathSync as g,rmSync as _,writeFileSync as v}from"node:fs";import{tmpdir as ee}from"node:os";const y=e=>{let t=e.type.charAt(0).toUpperCase()+e.type.slice(1),n=`created`,r=new Set,i=()=>{if(n===`disposed`)throw Error(`${t} sandbox has been disposed.`)},a=()=>{if(i(),n!==`running`)throw Error(`${t} sandbox is not running.`)},o=e=>{let t={process:e,waitPromise:e.wait().finally(()=>{r.delete(t)})};return r.add(t),{...e,wait:()=>t.waitPromise}},s=async()=>{let e=Array.from(r,e=>(e.process.kill(`SIGKILL`),e.waitPromise));await Promise.allSettled(e)},c=e.createSpawner(a,o),l={type:e.type,config:e.config,get status(){return n},get workdir(){return e.config.workdir},get spawner(){return c},async start(){i(),n!==`running`&&(await e.onValidate(),n=`running`)},async stop(){i(),n===`running`&&(n=`stopped`,await s())},async dispose(){n!==`disposed`&&(n=`disposed`,await s(),await e.onDispose?.())},[Symbol.asyncDispose](){return l.dispose()}};return e.extend?e.extend(l):l},b=`bwrap`,x=[`/tmp`],S=f(o),C=(e,t)=>e.binds?.some(e=>e.target===t)??!1,w=(e,t)=>{let n=u.relative(e,t);return n===``||!n.startsWith(`..`)&&!u.isAbsolute(n)},T=(e,t)=>e.target.length-t.target.length,te=e=>{let t=C(e,e.workdir)?[...e.binds??[]]:[{source:e.workdir,target:e.workdir},...e.binds??[]],n=e.tmpfs??x,r=t.filter(e=>!n.some(t=>w(t,e.target))).toSorted(T),i=t.filter(e=>n.some(t=>w(t,e.target))).toSorted(T);return[...r,...i]},ne=e=>{let t=[`--ro-bind`,`/`,`/`];for(let n of te(e))t.push(n.readonly?`--ro-bind`:`--bind`,n.source,n.target);return t},re=(e,t)=>{let n=[];(e.clearEnv??!0)&&n.push(`--clearenv`);for(let t of e.unsetEnv??[])n.push(`--unsetenv`,t);let r={...e.setEnv,...t.env};for(let[e,t]of Object.entries(r))n.push(`--setenv`,e,t);return n},ie=e=>{let t=[`--die-with-parent`,`--new-session`];return(e.unshareAll??!0)&&t.push(`--unshare-all`),e.shareNetwork&&t.push(`--share-net`),e.uid!==void 0&&t.push(`--uid`,String(e.uid)),e.gid!==void 0&&t.push(`--gid`,String(e.gid)),e.hostname&&t.push(`--hostname`,e.hostname),t},ae=e=>{let t=[`--ro-bind`,`/`,`/`];e.proc!==!1&&t.push(`--proc`,e.proc??`/proc`),e.dev!==!1&&t.push(`--dev`,e.dev??`/dev`);for(let n of e.tmpfs??x)t.push(`--tmpfs`,n);t.push(...ne(e).slice(3));for(let n of e.remountReadonly??[])t.push(`--remount-ro`,n);return t},E=(e,t,n,r={})=>[...ie(e),...ae(e),...re(e,r),`--chdir`,r.cwd??e.workdir,...e.args??[],`--`,t,...n],D=async t=>{try{await S(t,[`--version`],{env:r(),encoding:`utf8`})}catch(t){throw Error(`Bubblewrap start failed: ${e(t)}`)}},O=(e,t,n,i)=>({spawn(a,o,s={}){return t(),n(i.spawn(e.binary??b,E(e,a,o,s),{env:r(),stdio:s.stdio}))}}),k=async(e,t=i)=>y({type:`bubblewrap`,config:e,onValidate:()=>D(e.binary??b),createSpawner:(n,r)=>O(e,n,r,t)}),A=e=>new Set((e??[]).flatMap(e=>[e,e.toUpperCase(),e.toLowerCase()])),j=(e,t)=>{let n=A(t);return n.size===0?e:Object.fromEntries(Object.entries(e).filter(([e])=>!n.has(e)))},M=e=>{try{return p(e,m.X_OK),!0}catch{return!1}},N=(e,t)=>c(e)?e:d(t,e),P=(e,t,r)=>{if(c(e)||e.includes(`/`))return e;let i=t[n(t)];if(!i)return e;for(let t of i.split(s)){let n=l(N(t,r),e);if(M(n))return n}return e},F=(e,r)=>{if((r??[]).some(e=>e.toLowerCase()===`path`))return;let i=n(e);if(i in e)return;let a=t(),o=a[n(a)];o&&Object.assign(e,{[i]:o})},I=[`/run/wrappers/bin`,`/usr/local/bin`,`/usr/bin`,`/bin`],L=f(o),R=e=>e.binary??`firejail`,z=()=>{let e=t();return e[n(e)]},B=e=>{if(e.clearEnv===!1)return r({extraPaths:I});let t=r({propagateEnv:!1,extraPaths:I}),i=z();return i&&(t[n(t)]=[...I,i].filter(Boolean).join(s)),t},V=(e,t,n)=>{let r=j({...n,...e.setEnv,...t.env},e.unsetEnv);return F(r,e.unsetEnv),r},H=(e,t,n)=>{let r=[];for(let t of e.unsetEnv??[])r.push(`--rmenv=${t}`);let i={...e.setEnv,...t.env};for(let[e,t]of Object.entries(i))n[e]!==t&&r.push(`--env=${e}=${t}`);return r},U=(e,t,n,r={},i={})=>{let a=[`--noprofile`];e.shareNetwork||a.push(`--net=none`);for(let t of e.whitelist??[])a.push(`--whitelist=${t}`);for(let t of e.blacklist??[])a.push(`--blacklist=${t}`);for(let t of e.readOnly??[])a.push(`--read-only=${t}`);for(let t of e.readWrite??[])a.push(`--read-write=${t}`);return e.privateTmp&&a.push(`--private-tmp`),a.push(...H(e,r,i)),e.args?.length&&a.push(...e.args),a.push(`--`,t,...n),a},W=async t=>{try{await L(t,[`--version`],{env:r({extraPaths:I}),encoding:`utf8`})}catch(t){throw Error(`Firejail start failed: ${e(t)}`)}},G=(e,t,n,r)=>({spawn(i,o,s={}){t();let c=s.cwd??e.workdir,l=B(e),u=`exec ${[P(i,V(e,s,l),c),...o].map(a).join(` `)}`;return n(r.spawn(R(e),U(e,`sh`,[`-c`,u],s,l),{cwd:c,env:l,stdio:s.stdio}))}}),oe=async(e,t=i)=>y({type:`firejail`,config:e,onValidate:()=>W(R(e)),createSpawner:(n,r)=>G(e,n,r,t)}),K=`nsjail`,q=[`/tmp`],se=f(o),J=e=>JSON.stringify(e),Y=(e,t)=>e.target.length-t.target.length||Number(!!e.readonly)-Number(!!t.readonly),ce=(e,t)=>e.binds?.some(e=>e.target===t)??!1,X=e=>e.tmpfs??[...q],le=(e,t)=>X(e).includes(t),ue=e=>{let t=ce(e,e.workdir)?[...e.binds??[]]:[{source:e.workdir,target:e.workdir},...e.binds??[]],n=(e.readOnly??[]).map(e=>({source:e,target:e,readonly:!0,type:`bind`}));return[...t.map(e=>({source:e.source,target:e.target,readonly:e.readonly,type:`bind`})),...n].filter(t=>!le(e,t.target)).toSorted(Y)},de=e=>X(e).map(t=>({target:t,readonly:e.readOnly?.includes(t),type:`tmpfs`})).toSorted(Y),fe=e=>[{source:`/`,target:`/`,readonly:!0,type:`bind`},...de(e),...ue(e)],Z=(e,t)=>{let n=j(e.clearEnv===!1?r():r({propagateEnv:!1}),e.unsetEnv);return Object.assign(n,e.setEnv,t.env),F(n,e.unsetEnv),n},Q=(e,t,n)=>[`${e} {`,` inside_id: ${J(String(t))}`,` outside_id: ${J(String(n))}`,` count: 1`,`}`].join(`
|
|
2
|
+
`),pe=e=>{if(e!==void 0)try{return g(e)}catch{return e}},$=e=>{let t=[`mount {`],n=pe(e.source);return n!==void 0&&t.push(` src: ${J(n)}`),t.push(` dst: ${J(e.target)}`),e.type===`tmpfs`?t.push(` fstype: ${J(`tmpfs`)}`):t.push(` is_bind: true`),t.push(` rw: ${e.readonly?`false`:`true`}`),t.push(` mandatory: true`),t.push(`}`),t.join(`
|
|
3
|
+
`)},me=(e,t,n)=>{let r=t.cwd??e.workdir,i=n??Z(e,t),a=e.hostname??`NSJAIL`,o=typeof process.getuid==`function`?process.getuid():0,s=typeof process.getgid==`function`?process.getgid():0,c=e.uid??o,l=e.gid??s,u=e.clearEnv===!1&&(e.unsetEnv?.length??0)===0,d=[`name: "coding-agents-sdk"`,`mode: ONCE`,`hostname: ${J(a)}`,`cwd: ${J(r)}`,`keep_env: ${u?`true`:`false`}`,`clone_newnet: ${e.shareNetwork?`false`:`true`}`,`clone_newuser: true`,`clone_newns: true`,`clone_newpid: true`,`clone_newipc: true`,`clone_newuts: true`,`mount_proc: true`,`time_limit: ${String(e.timeLimitSec??0)}`,Q(`uidmap`,c,o),Q(`gidmap`,l,s)];e.seccompString&&d.push(`seccomp_string: ${J(e.seccompString)}`);for(let[e,t]of Object.entries(i)){let n=`${e}=${t}`;d.push(`envar: ${J(n)}`)}for(let t of fe(e))d.push($(t));return`${d.join(`
|
|
4
|
+
`)}\n`},he=(e,t,n,r)=>{let i=[`-C`,t];return(e.disableRlimits??!0)&&i.push(`--disable_rlimits`),i.push(...e.args??[],`--`,n,...r),i},ge=async t=>{try{await se(t,[`--help`],{env:r(),encoding:`utf8`})}catch(t){throw Error(`Nsjail start failed: ${e(t)}`)}},_e=(e,t,n,i,a)=>({spawn(o,s,c={}){n();let u=t(),d=Z(e,c),f=P(o,d,c.cwd??e.workdir),p=l(u.configDir,`spawn-${Date.now()}-${Math.random().toString(16).slice(2)}.cfg`);v(p,me(e,c,d),{encoding:`utf8`,mode:384});try{let t=i(a.spawn(e.binary??K,he(e,p,f,s),{env:r(),stdio:c.stdio})),n=t.wait().finally(()=>{_(p,{force:!0})});return{...t,wait:()=>n}}catch(e){throw _(p,{force:!0}),e}}}),ve=async(e,t=i)=>{let n,r=()=>{if(!n)throw Error(`Nsjail sandbox has not been started.`);return n};return y({type:`nsjail`,config:e,async onValidate(){await ge(e.binary??K),n??={configDir:h(l(ee(),`cw-nsjail-`))}},onDispose(){n&&_(n.configDir,{recursive:!0,force:!0})},createSpawner:(n,i)=>_e(e,r,n,i,t)})};async function ye(e){switch(e.type){case`bubblewrap`:return k(e);case`firejail`:return oe(e);case`nsjail`:return ve(e);default:throw Error(`Unsupported sandbox type.`)}}export{ye as t};
|
package/dist/schemas/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as OutputSchema, D as imageContentPartSchema, E as contentPartSchema, O as textContentPartSchema, S as McpServerConfig, T as agentCapabilitiesSchema, _ as toolResultEventSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, d as messageEventSchema, f as reasoningEventSchema, g as toolCallEventSchema, h as stderrEventSchema, i as SessionEndEvent, l as baseEventSchema, m as sessionStartEventSchema, n as MessageEvent, o as StderrEvent, p as sessionEndEventSchema, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "../events-
|
|
1
|
+
import { C as OutputSchema, D as imageContentPartSchema, E as contentPartSchema, O as textContentPartSchema, S as McpServerConfig, T as agentCapabilitiesSchema, _ as toolResultEventSchema, a as SessionStartEvent, b as ImageContentPart, c as ToolResultEvent, d as messageEventSchema, f as reasoningEventSchema, g as toolCallEventSchema, h as stderrEventSchema, i as SessionEndEvent, l as baseEventSchema, m as sessionStartEventSchema, n as MessageEvent, o as StderrEvent, p as sessionEndEventSchema, r as ReasoningEvent, s as ToolCallEvent, t as AgentEvent, u as eventSchema, v as AgentCapabilities, w as TextContentPart, x as JsonSchema, y as ContentPart } from "../events-BE9s04ko.mjs";
|
|
2
2
|
export { type AgentCapabilities, type AgentEvent, type ContentPart, type ImageContentPart, type JsonSchema, type McpServerConfig, type MessageEvent, type OutputSchema, type ReasoningEvent, type SessionEndEvent, type SessionStartEvent, type StderrEvent, type TextContentPart, type ToolCallEvent, type ToolResultEvent, agentCapabilitiesSchema, baseEventSchema, contentPartSchema, eventSchema, imageContentPartSchema, messageEventSchema, reasoningEventSchema, sessionEndEventSchema, sessionStartEventSchema, stderrEventSchema, textContentPartSchema, toolCallEventSchema, toolResultEventSchema };
|
package/dist/schemas/index.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { agentCapabilitiesSchema, baseEventSchema, contentPartSchema, eventSchema, imageContentPartSchema, messageEventSchema, reasoningEventSchema, sessionEndEventSchema, sessionStartEventSchema, stderrEventSchema, textContentPartSchema, toolCallEventSchema, toolResultEventSchema };
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"../schemas-CXVWDOoT.mjs";export{f as agentCapabilitiesSchema,d as baseEventSchema,n as contentPartSchema,o as eventSchema,r as imageContentPartSchema,l as messageEventSchema,i as reasoningEventSchema,e as sessionEndEventSchema,s as sessionStartEventSchema,u as stderrEventSchema,c as textContentPartSchema,t as toolCallEventSchema,a as toolResultEventSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as e}from"zod/v4";const t=e.object({type:e.literal(`text`),text:e.string()}),n=e.object({type:e.literal(`image`),path:e.string(),mediaType:e.string().optional()}),r=e.discriminatedUnion(`type`,[t,n]),i=e.object({structuredOutput:e.boolean(),sessionResume:e.boolean(),imageInput:e.boolean(),mcp:e.boolean(),eventStreaming:e.boolean(),sessionFork:e.boolean().optional()}),a=e.object({id:e.string(),runId:e.string(),timestamp:e.date()}),o=a.extend({type:e.literal(`session-start`),requestedSessionId:e.string().optional(),sessionId:e.string().optional(),resumed:e.boolean()}),s=a.extend({type:e.literal(`message`),sessionId:e.string().optional(),model:e.string().nullable(),role:e.enum([`system`,`user`,`assistant`]),content:e.array(r),text:e.string().optional()}),c=a.extend({type:e.literal(`reasoning`),sessionId:e.string().optional(),model:e.string().nullable(),content:e.array(r),text:e.string().optional()}),l=a.extend({type:e.literal(`tool-call`),sessionId:e.string().optional(),model:e.string().nullable(),toolCallId:e.string(),toolName:e.string(),input:e.unknown().optional()}),u=a.extend({type:e.literal(`tool-result`),sessionId:e.string().optional(),toolCallId:e.string(),toolName:e.string().optional(),input:e.unknown().optional(),output:e.unknown(),isError:e.boolean().optional(),error:e.string().optional()}),d=a.extend({type:e.literal(`stderr`),sessionId:e.string().optional(),text:e.string()}),f=a.extend({type:e.literal(`session-end`),sessionId:e.string().optional(),status:e.enum([`completed`,`failed`,`cancelled`]),error:e.string().optional()}),p=e.discriminatedUnion(`type`,[o,s,c,l,u,d,f]);export{f as a,l as c,r as d,n as f,c as i,u as l,p as n,o,t as p,s as r,d as s,a as t,i as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>`'${e.replace(/'/g,`'\\''`)}'`;export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{spawn as e}from"node:child_process";const t=e=>({async*[Symbol.asyncIterator](){for await(let t of e){if(t instanceof Buffer){yield new Uint8Array(t);continue}if(typeof t==`string`){yield new TextEncoder().encode(t);continue}if(t instanceof Uint8Array){yield t;continue}throw Error(`Unsupported stdout/stderr chunk type: ${typeof t}`)}}}),n={spawn:(n,r,i={})=>{let a=e(n,r,{cwd:i.cwd,env:i.env,stdio:i.stdio}),o=new Promise((e,t)=>{let n=(t,n)=>{a.removeListener(`error`,r),e({exitCode:t,signal:n})},r=e=>{a.removeListener(`close`,n),t(e)};a.once(`error`,r),a.once(`close`,n)});return{stdout:a.stdout?t(a.stdout):null,stderr:a.stderr?t(a.stderr):null,stdin:a.stdin?{write:e=>a.stdin?.write(e),end:()=>a.stdin?.end()}:null,kill:e=>a.kill(e),wait:()=>o}}};export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{let t;for(let[,n]of e)n.toolName===`StructuredOutput`&&n.input!==void 0&&(t=n.input);return t},t=(t,n,r,i)=>{if(t!==void 0)return{value:t};if(!n.schemaRequested)return{};let a=e(n.toolCalls);return a===void 0?r.isSuccess?{error:{kind:`parse`,message:i}}:{}:{value:a}};export{t};
|