coding-agents-sdk 0.9.0 → 0.11.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 +9 -3
- package/dist/Agent-BD2xHVi0.mjs +4 -0
- package/dist/{SdkAgent-CxDlEycD.mjs → SdkAgent-DQfLwPwY.mjs} +1 -1
- package/dist/adapters/claude-code-cli/index.d.mts +1 -1
- package/dist/adapters/claude-code-cli/index.mjs +1 -2
- package/dist/adapters/claude-code-cli-pty/index.d.mts +3 -0
- package/dist/adapters/claude-code-cli-pty/index.mjs +35 -0
- package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
- package/dist/adapters/claude-code-sdk/index.mjs +3 -3
- package/dist/adapters/codex-cli/index.d.mts +1 -1
- package/dist/adapters/codex-cli/index.mjs +2 -2
- package/dist/adapters/codex-sdk/index.d.mts +1 -1
- package/dist/adapters/codex-sdk/index.mjs +1 -1
- package/dist/adapters/cursor-cli/index.d.mts +1 -1
- package/dist/adapters/cursor-cli/index.mjs +1 -1
- package/dist/adapters/cursor-sdk/index.d.mts +1 -1
- package/dist/adapters/cursor-sdk/index.mjs +1 -1
- package/dist/adapters/gemini-cli/index.d.mts +1 -1
- package/dist/adapters/gemini-cli/index.mjs +1 -1
- package/dist/adapters/opencode-cli/index.d.mts +1 -1
- package/dist/adapters/opencode-cli/index.mjs +1 -1
- package/dist/adapters/pi-cli/index.d.mts +1 -1
- package/dist/adapters/pi-cli/index.mjs +1 -1
- package/dist/{classify-error-DoH0BqEA.mjs → classify-error-BcWmNftw.mjs} +1 -1
- package/dist/container/index.d.mts +2 -2
- package/dist/container/index.mjs +1 -1
- package/dist/container-BhXUiAiK.mjs +1 -0
- package/dist/{container-BuaAmhBf.mjs → container-BurV5WG9.mjs} +1 -1
- package/dist/container-D31bbA4L.mjs +1 -0
- package/dist/{container-RMYjapoN.mjs → container-TizHce_7.mjs} +1 -1
- package/dist/{diff-DkMPJCxL.mjs → diff-DWM1ciiV.mjs} +1 -1
- package/dist/errors-CeKI_bYK.mjs +1 -0
- package/dist/{events-BE9s04ko.d.mts → events-Bwfw__Q3.d.mts} +140 -0
- package/dist/execution-target-CGTSqVEP.mjs +1 -0
- package/dist/index-B0x76PaA.d.mts +104 -0
- package/dist/{index-BC_KQvvz.d.mts → index-BQNj8DHq.d.mts} +46 -15
- package/dist/index-B_MIEnNS.d.mts +60 -0
- package/dist/index-BeejNCvc.d.mts +429 -0
- package/dist/index-C8wbKjj3.d.mts +188 -0
- package/dist/index-CEHYyi4k.d.mts +68 -0
- package/dist/{index-DM6yXz_N.d.mts → index-ClURbAqF.d.mts} +67 -1
- package/dist/index-CyxdNK5W.d.mts +58 -0
- package/dist/{index-BTcDyVsX.d.mts → index-D5zrCo6s.d.mts} +43 -12
- package/dist/index-ILgtPW1P.d.mts +97 -0
- package/dist/index-dPV54_sZ.d.mts +69 -0
- package/dist/{index-nx85iU6i.d.mts → index-p8MJ49dZ.d.mts} +77 -1
- package/dist/index.d.mts +69 -17
- package/dist/index.mjs +1 -1
- package/dist/oci-tjdSZfTm.mjs +1 -0
- package/dist/parser-BBJPNGZ2.mjs +2 -0
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/schemas/index.d.mts +1 -1
- package/dist/schemas/index.mjs +1 -1
- package/dist/schemas-mNF2Xlg_.mjs +1 -0
- package/dist/types-Bk-YpdbX.d.mts +476 -0
- package/package.json +25 -20
- package/dist/container--0TOW4sB.mjs +0 -1
- package/dist/container-C5h5Bdf_.mjs +0 -1
- package/dist/errors-XV0frS3r.mjs +0 -1
- package/dist/execution-target-Dr2SFmkz.mjs +0 -4
- package/dist/index-BsTS0n1I.d.mts +0 -46
- package/dist/index-BsWb681o.d.mts +0 -85
- package/dist/index-CK9BK1t2.d.mts +0 -42
- package/dist/index-CkX15fCQ.d.mts +0 -242
- package/dist/index-Cpz-hhM0.d.mts +0 -42
- package/dist/index-CzjmvgZI.d.mts +0 -39
- package/dist/index-l1U15W0k.d.mts +0 -46
- package/dist/oci-BVYPHn7b.mjs +0 -1
- package/dist/schemas-CXVWDOoT.mjs +0 -1
- package/dist/types-BnnsL3U5.d.mts +0 -162
|
@@ -5,4 +5,4 @@ import{n as e,t}from"./types-CwvWHEpy.mjs";import{z as n}from"zod/v4";const r=()
|
|
|
5
5
|
`);if(e.stopReason===`user`)return{kind:`abort`,message:`Run stopped by user.`};if(e.stopReason===`abort`)return{kind:`abort`,message:`Run aborted.`};if(e.stopReason===`timeout`)return{kind:`abort`,message:`Run timed out after ${e.normalizedRequest.timeoutMs}ms.`};if(e.error)return e.error;if(n&&n.exitCode!==null&&n.exitCode!==0)return{kind:`process`,message:r||`Process exited with code ${n.exitCode}.`};if(t===`failed`&&e.stderrLines.length>0)return{kind:`process`,message:r};if(t===`failed`&&e.normalizedRequest.schema.kind!==`none`&&e.output.value===void 0)return{kind:`parse`,message:`Structured output was requested but no structured output value was produced.`}},b=(e,t,n,r,i)=>{let a=t.stderrLines.join(`
|
|
6
6
|
`),o={type:e,runId:t.runId,sessionId:t.sessionId,text:t.output.text??t.assistantTexts.join(`
|
|
7
7
|
|
|
8
|
-
`),events:[...t.events],stats:t.stats,timing:{startedAt:t.startedAt,endedAt:n,durationMs:n.getTime()-t.startedAt.getTime()},process:t.processResult?{exitCode:t.processResult.exitCode,signal:t.processResult.signal,stderr:a}:void 0};switch(r){case`completed`:return t.normalizedRequest.schema.kind===`none`?{...o,status:r,error:void 0,cancelReason:void 0}:{...o,status:r,output:t.output.value,error:void 0,cancelReason:void 0};case`failed`:return{...o,status:r,output:void 0,error:i??{kind:`process`,message:`Unknown error.`},cancelReason:void 0};case`cancelled`:return{...o,status:r,output:void 0,error:i??{kind:`abort`,message:`Run cancelled.`},cancelReason:t.stopReason??`user`};default:throw Error(`Unsupported run status.`)}},x=()=>{let e=new Date;return{runCount:0,messagesReceived:0,toolCalls:0,errors:0,startedAt:e,lastActivityAt:e}};var S=class{type;capabilities;currentRun;eventHandlers=[];_sessionId;_metrics;constructor(e){this.type=e.type,this.capabilities=e.capabilities,this._sessionId=e.sessionId,this._metrics=x(),e.onEvent&&this.onEvent(e.onEvent)}onValidateRun(e,t){}async onDispose(){}onHandlerError(e){}get sessionId(){return this._sessionId}get metrics(){return this._metrics}get isRunning(){return this.currentRun?.running??!1}onEvent(e){return this.eventHandlers.push(e),()=>{let t=this.eventHandlers.indexOf(e);t>=0&&this.eventHandlers.splice(t,1)}}async run(t){if(this.currentRun?.running)throw new e(`This agent is already running. Wait for it to finish first.`);let n=f(this.type,this.capabilities,this.runRequestDefaults,t);this.onValidateRun(t,n);let i={runId:r(),startedAt:new Date,requestedSessionId:this._sessionId,sessionId:this._sessionId,normalizedRequest:n,events:[],stderrLines:[],assistantTexts:[],toolCalls:new Map,output:{}},a={context:i,running:!0,promise:new Promise(()=>{})};this._metrics.runCount++;let o=Promise.resolve().then(()=>this.executeRunCore(i,t)).finally(()=>{a.running=!1});return a.promise=o,this.currentRun=a,o}async runOrThrow(e){let n=await this.run(e);if(n.status!==`completed`)throw new t(n);return n}async stop(){let e=this.currentRun?.context;if(!(!e||!this.currentRun?.running)){this.requestStop(e,`user`);try{return await this.currentRun.promise}catch{return}}}reset(){if(this.currentRun?.running)throw new e(`Cannot reset agent state while a run is active. Call stop() and wait() first.`);this.currentRun=void 0,this._sessionId=void 0,this._metrics=x()}wait(){if(!this.currentRun)throw new e(`There is no run to wait for.`);return this.currentRun.promise}async dispose(){if(this.currentRun?.running){this.requestStop(this.currentRun.context,`user`);try{await this.currentRun.promise}catch{}}await this.onDispose()}async[Symbol.asyncDispose](){await this.dispose()}applyBatch(e,t){g(e,t,{onSessionId:e=>{this.setSessionId(e)}}),e.sessionId&&this.emitSessionStart(e);for(let n of t.events)this.emit(e,n)}setupRunLifecycle(e){let t=!1,n=()=>{t||this.requestStop(e,`abort`)},r=e.normalizedRequest.timeoutMs===void 0?void 0:setTimeout(()=>{t||this.requestStop(e,`timeout`)},e.normalizedRequest.timeoutMs);r?.unref?.(),e.normalizedRequest.signal?.addEventListener(`abort`,n,{once:!0});let i=e.normalizedRequest.signal?.aborted===!0;return i&&this.requestStop(e,`abort`),{abortedBeforeStart:i,cleanup:()=>{t=!0,r&&clearTimeout(r),e.normalizedRequest.signal?.removeEventListener(`abort`,n)}}}emitSessionStart(e){e.sessionStarted||(e.sessionStarted=!0,this.emit(e,l(e.runId,`session-start`,{requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,resumed:e.requestedSessionId!==void 0})))}emit(e,t){h(e,t),this.updateMetrics(t);for(let e of this.eventHandlers)try{e(t)}catch(e){this.onHandlerError(e)}}requestStop(e,t){e.stopReason||(e.stopReason=t,this.onStopRequested(e))}buildResult(e,t){p(e,t);let n=v(e),r=y(e,n);return e.sessionStarted&&this.emit(e,l(e.runId,`session-end`,{sessionId:e.sessionId,status:n,error:r?.message})),b(this.type,e,t,n,r)}setSessionId(e){this._sessionId=e}updateMetrics(e){switch(this._metrics.lastActivityAt=e.timestamp,e.type){case`message`:e.role===`assistant`&&this._metrics.messagesReceived++;break;case`tool-call`:this._metrics.toolCalls++;break;case`session-end`:e.status===`failed`&&this._metrics.errors++;break;default:break}}};const C=new Set([`ENOENT`,`ERR_MODULE_NOT_FOUND`]),w=e=>`code`in e,T=(e,t)=>{let n=t??(e instanceof Error?e.message:String(e));if(e instanceof Error){if(e.name===`AbortError`)return{kind:`abort`,message:n};if(w(e)&&C.has(String(e.code)))return{kind:`spawn`,message:n};if(e instanceof SyntaxError)return{kind:`parse`,message:n}}return{kind:`provider`,message:n}};export{l as a,a as c,_ as i,S as n,c as o,g as r,s,T as t};
|
|
8
|
+
`),events:[...t.events],stats:t.stats,timing:{startedAt:t.startedAt,endedAt:n,durationMs:n.getTime()-t.startedAt.getTime()},process:t.processResult?{exitCode:t.processResult.exitCode,signal:t.processResult.signal,stderr:a}:void 0};switch(r){case`completed`:return t.normalizedRequest.schema.kind===`none`?{...o,status:r,error:void 0,cancelReason:void 0}:{...o,status:r,output:t.output.value,error:void 0,cancelReason:void 0};case`failed`:return{...o,status:r,output:void 0,error:i??{kind:`process`,message:`Unknown error.`},cancelReason:void 0};case`cancelled`:return{...o,status:r,output:void 0,error:i??{kind:`abort`,message:`Run cancelled.`},cancelReason:t.stopReason??`user`};default:throw Error(`Unsupported run status.`)}},x=()=>{let e=new Date;return{runCount:0,messagesReceived:0,toolCalls:0,errors:0,startedAt:e,lastActivityAt:e}};var S=class{type;capabilities;currentRun;eventHandlers=[];permissionHandler;_sessionId;_metrics;constructor(e){this.type=e.type,this.capabilities=e.capabilities,this._sessionId=e.sessionId,this._metrics=x(),e.onEvent&&this.onEvent(e.onEvent)}onValidateRun(e,t){}async onDispose(){}onHandlerError(e){}get sessionId(){return this._sessionId}get metrics(){return this._metrics}get isRunning(){return this.currentRun?.running??!1}onEvent(e){return this.eventHandlers.push(e),()=>{let t=this.eventHandlers.indexOf(e);t>=0&&this.eventHandlers.splice(t,1)}}onPermissionRequest(e){return this.permissionHandler=e,()=>{this.permissionHandler===e&&(this.permissionHandler=void 0)}}getPermissionHandler(){return this.permissionHandler}async run(t){if(this.currentRun?.running)throw new e(`This agent is already running. Wait for it to finish first.`);let n=f(this.type,this.capabilities,this.runRequestDefaults,t);this.onValidateRun(t,n);let i={runId:r(),startedAt:new Date,requestedSessionId:this._sessionId,sessionId:this._sessionId,normalizedRequest:n,events:[],stderrLines:[],assistantTexts:[],toolCalls:new Map,output:{}},a={context:i,running:!0,promise:new Promise(()=>{})};this._metrics.runCount++;let o=Promise.resolve().then(()=>this.executeRunCore(i,t)).finally(()=>{a.running=!1});return a.promise=o,this.currentRun=a,o}async runOrThrow(e){let n=await this.run(e);if(n.status!==`completed`)throw new t(n);return n}async stop(){let e=this.currentRun?.context;if(!(!e||!this.currentRun?.running)){this.requestStop(e,`user`);try{return await this.currentRun.promise}catch{return}}}reset(){if(this.currentRun?.running)throw new e(`Cannot reset agent state while a run is active. Call stop() and wait() first.`);this.currentRun=void 0,this._sessionId=void 0,this._metrics=x()}wait(){if(!this.currentRun)throw new e(`There is no run to wait for.`);return this.currentRun.promise}async dispose(){if(this.currentRun?.running){this.requestStop(this.currentRun.context,`user`);try{await this.currentRun.promise}catch{}}await this.onDispose()}async[Symbol.asyncDispose](){await this.dispose()}applyBatch(e,t){g(e,t,{onSessionId:e=>{this.setSessionId(e)}}),e.sessionId&&this.emitSessionStart(e);for(let n of t.events)this.emit(e,n)}setupRunLifecycle(e){let t=!1,n=()=>{t||this.requestStop(e,`abort`)},r=e.normalizedRequest.timeoutMs===void 0?void 0:setTimeout(()=>{t||this.requestStop(e,`timeout`)},e.normalizedRequest.timeoutMs);r?.unref?.(),e.normalizedRequest.signal?.addEventListener(`abort`,n,{once:!0});let i=e.normalizedRequest.signal?.aborted===!0;return i&&this.requestStop(e,`abort`),{abortedBeforeStart:i,cleanup:()=>{t=!0,r&&clearTimeout(r),e.normalizedRequest.signal?.removeEventListener(`abort`,n)}}}emitSessionStart(e){e.sessionStarted||(e.sessionStarted=!0,this.emit(e,l(e.runId,`session-start`,{requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,resumed:e.requestedSessionId!==void 0})))}emit(e,t){h(e,t),this.updateMetrics(t);for(let e of this.eventHandlers)try{e(t)}catch(e){this.onHandlerError(e)}}requestStop(e,t){e.stopReason||(e.stopReason=t,this.onStopRequested(e))}buildResult(e,t){p(e,t);let n=v(e),r=y(e,n);return e.sessionStarted&&this.emit(e,l(e.runId,`session-end`,{sessionId:e.sessionId,status:n,error:r?.message})),b(this.type,e,t,n,r)}setSessionId(e){this._sessionId=e}updateMetrics(e){switch(this._metrics.lastActivityAt=e.timestamp,e.type){case`message`:e.role===`assistant`&&this._metrics.messagesReceived++;break;case`tool-call`:this._metrics.toolCalls++;break;case`session-end`:e.status===`failed`&&this._metrics.errors++;break;default:break}}};const C=new Set([`ENOENT`,`ERR_MODULE_NOT_FOUND`]),w=e=>`code`in e,T=(e,t)=>{let n=t??(e instanceof Error?e.message:String(e));if(e instanceof Error){if(e.name===`AbortError`)return{kind:`abort`,message:n};if(w(e)&&C.has(String(e.code)))return{kind:`spawn`,message:n};if(e instanceof SyntaxError)return{kind:`parse`,message:n}}return{kind:`provider`,message:n}};export{l as a,a as c,_ as i,S as n,c as o,g as r,s,T as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { Container, ContainerBase, ContainerConfig, ContainerConfigBase, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerExecution, ContainerFileSystem, ContainerIdentity, ContainerLifecycle, ContainerNotRunningError, ContainerObservability, ContainerStartError, ContainerStatus, ContainerType, DockerBuildBase, DockerBuildConfig, DockerContainer, DockerContainerBase, DockerContainerConfig, DockerProviderConfig, E2BConnectConfig, E2BConnectionConfig, E2BContainer, E2BContainerBase, E2BContainerConfig, E2BCreateConfig, E2BProviderConfig, ExecOptions, ExecResult, NerdctlBuildBase, NerdctlBuildConfig, NerdctlContainer, NerdctlContainerBase, NerdctlContainerConfig, NerdctlProviderBase, NerdctlProviderConfig, PodmanBuildBase, PodmanBuildConfig, PodmanContainer, PodmanContainerBase, PodmanContainerConfig, PodmanProviderConfig, PortMapping, VolumeMount, WorkdirChangeKind, WorkdirDiff, WorkdirDiffStats, WorkdirFileChange, WorkdirSnapshot, WorkdirSnapshotOptions, createContainer };
|
|
1
|
+
import { $ as WorkdirDiffStats, A as E2BCreateConfig, B as ContainerExecution, C as NerdctlProviderBase, D as E2BContainer, E as E2BConnectionConfig, F as DockerContainerBase, G as ContainerStatus, H as ContainerIdentity, I as DockerContainerConfig, J as ExecResult, K as ContainerType, L as DockerProviderConfig, M as DockerBuildBase, N as DockerBuildConfig, O as E2BContainerBase, P as DockerContainer, Q as WorkdirDiff, R as ContainerBase, S as NerdctlContainerConfig, T as E2BConnectConfig, U as ContainerLifecycle, V as ContainerFileSystem, W as ContainerObservability, X as VolumeMount, Y as PortMapping, Z as WorkdirChangeKind, _ as PodmanProviderConfig, a as ContainerDiffError, b as NerdctlContainer, c as ContainerExecError, d as MountValidationError, et as WorkdirFileChange, f as PodmanBuildBase, g as PodmanContainerConfig, h as PodmanContainerBase, i as ContainerCreateError, j as E2BProviderConfig, k as E2BContainerConfig, l as ContainerNotRunningError, m as PodmanContainer, n as ContainerConfig, nt as WorkdirSnapshotOptions, o as ContainerDisposedError, p as PodmanBuildConfig, q as ExecOptions, r as createContainer, s as ContainerError, t as Container, tt as WorkdirSnapshot, u as ContainerStartError, v as NerdctlBuildBase, w as NerdctlProviderConfig, x as NerdctlContainerBase, y as NerdctlBuildConfig, z as ContainerConfigBase } from "../index-BeejNCvc.mjs";
|
|
2
|
+
export { Container, ContainerBase, ContainerConfig, ContainerConfigBase, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerExecution, ContainerFileSystem, ContainerIdentity, ContainerLifecycle, ContainerNotRunningError, ContainerObservability, ContainerStartError, ContainerStatus, ContainerType, DockerBuildBase, DockerBuildConfig, DockerContainer, DockerContainerBase, DockerContainerConfig, DockerProviderConfig, E2BConnectConfig, E2BConnectionConfig, E2BContainer, E2BContainerBase, E2BContainerConfig, E2BCreateConfig, E2BProviderConfig, ExecOptions, ExecResult, MountValidationError, NerdctlBuildBase, NerdctlBuildConfig, NerdctlContainer, NerdctlContainerBase, NerdctlContainerConfig, NerdctlProviderBase, NerdctlProviderConfig, PodmanBuildBase, PodmanBuildConfig, PodmanContainer, PodmanContainerBase, PodmanContainerConfig, PodmanProviderConfig, PortMapping, VolumeMount, WorkdirChangeKind, WorkdirDiff, WorkdirDiffStats, WorkdirFileChange, WorkdirSnapshot, WorkdirSnapshotOptions, createContainer };
|
package/dist/container/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"../errors-CeKI_bYK.mjs";async function c(e){switch(e.type){case`docker`:{let{createDockerContainer:t}=await import(`../container-D31bbA4L.mjs`);return t(e)}case`e2b`:try{let{createE2BContainer:t}=await import(`../container-BurV5WG9.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 s(`Container type "e2b" requires the optional peer dependency "e2b". Install it to use this provider.`):e}case`nerdctl`:{let{createNerdctlContainer:t}=await import(`../container-TizHce_7.mjs`);return t(e)}case`podman`:{let{createPodmanContainer:t}=await import(`../container-BhXUiAiK.mjs`);return t(e)}default:throw new s(`Unsupported container type.`)}}export{s as ContainerCreateError,r as ContainerDiffError,a as ContainerDisposedError,n as ContainerError,e as ContainerExecError,i as ContainerNotRunningError,o as ContainerStartError,t as MountValidationError,c as createContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,t}from"./oci-tjdSZfTm.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,mountCwd:n.mountCwd,extraArgs:n.extraArgs,image:i,builtImage:n.build!==void 0&&!n.build.tag},n)};export{n as createPodmanContainer};
|
|
@@ -1 +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-
|
|
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-CeKI_bYK.mjs";import{t as o}from"./shell-Dewbmt9R.mjs";import{n as s}from"./diff-DWM1ciiV.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-tjdSZfTm.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,mountCwd:n.mountCwd,extraArgs:n.extraArgs,image:i,builtImage:n.build!==void 0&&!n.build.tag},n)};export{n as createDockerContainer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./oci-
|
|
1
|
+
import{n as e,t}from"./oci-tjdSZfTm.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,mountCwd:n.mountCwd,extraArgs:n.extraArgs,image:a,builtImage:n.build!==void 0&&!n.build.tag},n)};export{a as createNerdctlContainer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./util-CGg8cK92.mjs";import{n as t,o as n,r}from"./errors-
|
|
1
|
+
import{t as e}from"./util-CGg8cK92.mjs";import{n as t,o as n,r}from"./errors-CeKI_bYK.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
|
+
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=`MountValidationError`}},r=class extends e{constructor(e){super(e),this.name=`ContainerStartError`}},i=class extends e{constructor(e){super(e),this.name=`ContainerExecError`}},a=class extends e{constructor(e=`Container is not running.`){super(e),this.name=`ContainerNotRunningError`}},o=class extends e{constructor(e=`Container has been disposed.`){super(e),this.name=`ContainerDisposedError`}},s=class extends e{constructor(e){super(e),this.name=`ContainerDiffError`}};export{i as a,n as c,e as i,s as n,a as o,o as r,r as s,t};
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { ZodType, z } from "zod/v4";
|
|
2
2
|
|
|
3
3
|
//#region src/schemas/agent.d.ts
|
|
4
|
+
/** Plain text content block in a {@link ContentPart} array. */
|
|
4
5
|
declare const textContentPartSchema: z.ZodObject<{
|
|
5
6
|
type: z.ZodLiteral<"text">;
|
|
6
7
|
text: z.ZodString;
|
|
7
8
|
}, z.core.$strip>;
|
|
9
|
+
/** Plain text content block in a {@link ContentPart} array. */
|
|
8
10
|
type TextContentPart = z.infer<typeof textContentPartSchema>;
|
|
11
|
+
/**
|
|
12
|
+
* Image content block. `path` is a filesystem path readable by the adapter
|
|
13
|
+
* (local images for `local_image`-style SDKs); `mediaType` defaults to being
|
|
14
|
+
* inferred from the file extension.
|
|
15
|
+
*/
|
|
9
16
|
declare const imageContentPartSchema: z.ZodObject<{
|
|
10
17
|
type: z.ZodLiteral<"image">;
|
|
11
18
|
path: z.ZodString;
|
|
12
19
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
13
20
|
}, z.core.$strip>;
|
|
21
|
+
/**
|
|
22
|
+
* Image content block. `path` is a filesystem path readable by the adapter;
|
|
23
|
+
* `mediaType` defaults to being inferred from the file extension.
|
|
24
|
+
*/
|
|
14
25
|
type ImageContentPart = z.infer<typeof imageContentPartSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Multimodal content union. Pass an array of these as `RunRequest.input` to
|
|
28
|
+
* include images alongside text; pass a plain string for text-only input.
|
|
29
|
+
*/
|
|
15
30
|
declare const contentPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
16
31
|
type: z.ZodLiteral<"text">;
|
|
17
32
|
text: z.ZodString;
|
|
@@ -20,7 +35,17 @@ declare const contentPartSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
20
35
|
path: z.ZodString;
|
|
21
36
|
mediaType: z.ZodOptional<z.ZodString>;
|
|
22
37
|
}, z.core.$strip>], "type">;
|
|
38
|
+
/**
|
|
39
|
+
* Multimodal content union — the discriminated shape of `RunRequest.input`
|
|
40
|
+
* when passed as an array. Pass a plain string for text-only input; pass
|
|
41
|
+
* `ContentPart[]` to include images alongside text. Narrow on `part.type`.
|
|
42
|
+
*/
|
|
23
43
|
type ContentPart = z.infer<typeof contentPartSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* Feature flags published by an adapter via `agent.capabilities`. Use to
|
|
46
|
+
* branch on capability before sending a request the adapter doesn't support
|
|
47
|
+
* (e.g. structured output, image input, MCP servers).
|
|
48
|
+
*/
|
|
24
49
|
declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
25
50
|
structuredOutput: z.ZodBoolean;
|
|
26
51
|
sessionResume: z.ZodBoolean;
|
|
@@ -28,25 +53,50 @@ declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
|
28
53
|
mcp: z.ZodBoolean;
|
|
29
54
|
eventStreaming: z.ZodBoolean;
|
|
30
55
|
sessionFork: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
permissionRequests: z.ZodOptional<z.ZodBoolean>;
|
|
31
57
|
}, z.core.$strip>;
|
|
58
|
+
/**
|
|
59
|
+
* Feature flags published by an adapter via `agent.capabilities`. Use to
|
|
60
|
+
* branch on capability before sending a request the adapter doesn't support
|
|
61
|
+
* (e.g. structured output, image input, MCP servers, permission handlers).
|
|
62
|
+
*/
|
|
32
63
|
type AgentCapabilities = z.infer<typeof agentCapabilitiesSchema>;
|
|
64
|
+
/** JSON Schema (Draft 7+) object, or a value produced by `z.toJSONSchema(...)`. */
|
|
33
65
|
type JsonSchema = Record<string, unknown> | ReturnType<typeof z.toJSONSchema>;
|
|
66
|
+
/** Either a JSON Schema or a Zod schema. Accepted by structured-output requests. */
|
|
34
67
|
type OutputSchema = JsonSchema | ZodType;
|
|
68
|
+
/**
|
|
69
|
+
* Common shape for MCP (Model Context Protocol) server configurations passed
|
|
70
|
+
* through to adapters. Adapters interpret the fields as needed — most accept
|
|
71
|
+
* both stdio (`command` + `args`) and HTTP (`url`) transports.
|
|
72
|
+
*/
|
|
35
73
|
interface McpServerConfig {
|
|
74
|
+
/** Executable for stdio-transport MCP servers. */
|
|
36
75
|
command?: string;
|
|
76
|
+
/** Arguments for the stdio executable. */
|
|
37
77
|
args?: string[];
|
|
78
|
+
/** Endpoint URL for HTTP/SSE-transport MCP servers. */
|
|
38
79
|
url?: string;
|
|
80
|
+
/** Working directory for the stdio MCP server subprocess. */
|
|
39
81
|
cwd?: string;
|
|
82
|
+
/** Environment variables for the stdio MCP server subprocess. */
|
|
40
83
|
env?: Record<string, string>;
|
|
84
|
+
/** HTTP headers for HTTP/SSE-transport MCP servers. */
|
|
41
85
|
headers?: Record<string, string>;
|
|
42
86
|
}
|
|
43
87
|
//#endregion
|
|
44
88
|
//#region src/schemas/events.d.ts
|
|
89
|
+
/** Fields shared by every {@link AgentEvent}. */
|
|
45
90
|
declare const baseEventSchema: z.ZodObject<{
|
|
46
91
|
id: z.ZodString;
|
|
47
92
|
runId: z.ZodString;
|
|
48
93
|
timestamp: z.ZodDate;
|
|
49
94
|
}, z.core.$strip>;
|
|
95
|
+
/**
|
|
96
|
+
* Emitted once at the start of a run, after the session has been created or
|
|
97
|
+
* resumed but before any model output. `resumed` is `true` when the run
|
|
98
|
+
* attached to an existing session via `requestedSessionId`.
|
|
99
|
+
*/
|
|
50
100
|
declare const sessionStartEventSchema: z.ZodObject<{
|
|
51
101
|
id: z.ZodString;
|
|
52
102
|
runId: z.ZodString;
|
|
@@ -56,7 +106,17 @@ declare const sessionStartEventSchema: z.ZodObject<{
|
|
|
56
106
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
57
107
|
resumed: z.ZodBoolean;
|
|
58
108
|
}, z.core.$strip>;
|
|
109
|
+
/**
|
|
110
|
+
* Emitted once at the start of a run, after the session has been created or
|
|
111
|
+
* resumed but before any model output. `resumed` is `true` when the run
|
|
112
|
+
* attached to an existing session via `requestedSessionId`.
|
|
113
|
+
*/
|
|
59
114
|
type SessionStartEvent = z.infer<typeof sessionStartEventSchema>;
|
|
115
|
+
/**
|
|
116
|
+
* A complete chat message — assistant, user echo, or system. Adapters that
|
|
117
|
+
* emit assistant messages mid-stream coalesce them into one event per logical
|
|
118
|
+
* message; consumers should not expect per-token deltas.
|
|
119
|
+
*/
|
|
60
120
|
declare const messageEventSchema: z.ZodObject<{
|
|
61
121
|
id: z.ZodString;
|
|
62
122
|
runId: z.ZodString;
|
|
@@ -79,7 +139,18 @@ declare const messageEventSchema: z.ZodObject<{
|
|
|
79
139
|
}, z.core.$strip>], "type">>;
|
|
80
140
|
text: z.ZodOptional<z.ZodString>;
|
|
81
141
|
}, z.core.$strip>;
|
|
142
|
+
/**
|
|
143
|
+
* A complete chat message — assistant, user echo, or system. Adapters that
|
|
144
|
+
* stream assistant text coalesce chunks into one event per logical message;
|
|
145
|
+
* consumers should not expect per-token deltas. The `text` field is a flat
|
|
146
|
+
* convenience concatenation of all text blocks in `content`.
|
|
147
|
+
*/
|
|
82
148
|
type MessageEvent = z.infer<typeof messageEventSchema>;
|
|
149
|
+
/**
|
|
150
|
+
* Model reasoning / chain-of-thought output, emitted by providers that
|
|
151
|
+
* support it (Claude extended thinking, Codex reasoning summaries). Not all
|
|
152
|
+
* adapters emit these.
|
|
153
|
+
*/
|
|
83
154
|
declare const reasoningEventSchema: z.ZodObject<{
|
|
84
155
|
id: z.ZodString;
|
|
85
156
|
runId: z.ZodString;
|
|
@@ -97,7 +168,16 @@ declare const reasoningEventSchema: z.ZodObject<{
|
|
|
97
168
|
}, z.core.$strip>], "type">>;
|
|
98
169
|
text: z.ZodOptional<z.ZodString>;
|
|
99
170
|
}, z.core.$strip>;
|
|
171
|
+
/**
|
|
172
|
+
* Model reasoning / chain-of-thought output, emitted by providers that
|
|
173
|
+
* support it (Claude extended thinking, Codex reasoning summaries). Not all
|
|
174
|
+
* adapters emit these.
|
|
175
|
+
*/
|
|
100
176
|
type ReasoningEvent = z.infer<typeof reasoningEventSchema>;
|
|
177
|
+
/**
|
|
178
|
+
* Model invoked a tool with the given input. Pair with the subsequent
|
|
179
|
+
* {@link ToolResultEvent} sharing the same `toolCallId`.
|
|
180
|
+
*/
|
|
101
181
|
declare const toolCallEventSchema: z.ZodObject<{
|
|
102
182
|
id: z.ZodString;
|
|
103
183
|
runId: z.ZodString;
|
|
@@ -109,7 +189,16 @@ declare const toolCallEventSchema: z.ZodObject<{
|
|
|
109
189
|
toolName: z.ZodString;
|
|
110
190
|
input: z.ZodOptional<z.ZodUnknown>;
|
|
111
191
|
}, z.core.$strip>;
|
|
192
|
+
/**
|
|
193
|
+
* The model invoked a tool with the given input. Pair with the subsequent
|
|
194
|
+
* {@link ToolResultEvent} sharing the same `toolCallId`.
|
|
195
|
+
*/
|
|
112
196
|
type ToolCallEvent = z.infer<typeof toolCallEventSchema>;
|
|
197
|
+
/**
|
|
198
|
+
* Result of a tool invocation. `isError`/`error` populated when the tool
|
|
199
|
+
* itself returned a failure (not when the framework couldn't dispatch the
|
|
200
|
+
* call — that yields a {@link StderrEvent} or a failed run instead).
|
|
201
|
+
*/
|
|
113
202
|
declare const toolResultEventSchema: z.ZodObject<{
|
|
114
203
|
id: z.ZodString;
|
|
115
204
|
runId: z.ZodString;
|
|
@@ -123,7 +212,16 @@ declare const toolResultEventSchema: z.ZodObject<{
|
|
|
123
212
|
isError: z.ZodOptional<z.ZodBoolean>;
|
|
124
213
|
error: z.ZodOptional<z.ZodString>;
|
|
125
214
|
}, z.core.$strip>;
|
|
215
|
+
/**
|
|
216
|
+
* Result of a tool invocation. `isError` / `error` are populated when the
|
|
217
|
+
* tool itself reported failure (framework-level dispatch failures yield a
|
|
218
|
+
* {@link StderrEvent} or a failed run instead).
|
|
219
|
+
*/
|
|
126
220
|
type ToolResultEvent = z.infer<typeof toolResultEventSchema>;
|
|
221
|
+
/**
|
|
222
|
+
* Captured stderr text from the underlying CLI subprocess (CLI adapters
|
|
223
|
+
* only). Useful for surfacing provider diagnostics.
|
|
224
|
+
*/
|
|
127
225
|
declare const stderrEventSchema: z.ZodObject<{
|
|
128
226
|
id: z.ZodString;
|
|
129
227
|
runId: z.ZodString;
|
|
@@ -132,7 +230,16 @@ declare const stderrEventSchema: z.ZodObject<{
|
|
|
132
230
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
133
231
|
text: z.ZodString;
|
|
134
232
|
}, z.core.$strip>;
|
|
233
|
+
/**
|
|
234
|
+
* Captured stderr text from the underlying CLI subprocess (CLI adapters
|
|
235
|
+
* only). Useful for surfacing provider diagnostics.
|
|
236
|
+
*/
|
|
135
237
|
type StderrEvent = z.infer<typeof stderrEventSchema>;
|
|
238
|
+
/**
|
|
239
|
+
* Emitted exactly once at the end of a run, just before the `RunResult`
|
|
240
|
+
* promise resolves. Mirrors the run's terminal status; on failure, `error`
|
|
241
|
+
* carries a human-readable summary.
|
|
242
|
+
*/
|
|
136
243
|
declare const sessionEndEventSchema: z.ZodObject<{
|
|
137
244
|
id: z.ZodString;
|
|
138
245
|
runId: z.ZodString;
|
|
@@ -146,7 +253,26 @@ declare const sessionEndEventSchema: z.ZodObject<{
|
|
|
146
253
|
}>;
|
|
147
254
|
error: z.ZodOptional<z.ZodString>;
|
|
148
255
|
}, z.core.$strip>;
|
|
256
|
+
/**
|
|
257
|
+
* Emitted exactly once at the end of a run, just before the `RunResult`
|
|
258
|
+
* promise resolves. Mirrors the run's terminal status; on failure, `error`
|
|
259
|
+
* carries a human-readable summary.
|
|
260
|
+
*/
|
|
149
261
|
type SessionEndEvent = z.infer<typeof sessionEndEventSchema>;
|
|
262
|
+
/**
|
|
263
|
+
* Discriminated union over every event type. Listeners registered via
|
|
264
|
+
* `agent.onEvent(...)` receive one of these. Narrow on `event.type`:
|
|
265
|
+
*
|
|
266
|
+
* ```ts
|
|
267
|
+
* agent.onEvent((event) => {
|
|
268
|
+
* switch (event.type) {
|
|
269
|
+
* case "message": console.log(event.role, event.text); break;
|
|
270
|
+
* case "tool-call": console.log(event.toolName, event.input); break;
|
|
271
|
+
* case "session-end": console.log("done", event.status); break;
|
|
272
|
+
* }
|
|
273
|
+
* });
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
150
276
|
declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
151
277
|
id: z.ZodString;
|
|
152
278
|
runId: z.ZodString;
|
|
@@ -234,6 +360,20 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
234
360
|
}>;
|
|
235
361
|
error: z.ZodOptional<z.ZodString>;
|
|
236
362
|
}, z.core.$strip>], "type">;
|
|
363
|
+
/**
|
|
364
|
+
* Discriminated union over every event the SDK emits during a run.
|
|
365
|
+
* Registered via `agent.onEvent(handler)`. Narrow on `event.type`:
|
|
366
|
+
*
|
|
367
|
+
* ```ts
|
|
368
|
+
* agent.onEvent((event) => {
|
|
369
|
+
* switch (event.type) {
|
|
370
|
+
* case "message": console.log(event.role, event.text); break;
|
|
371
|
+
* case "tool-call": console.log(event.toolName, event.input); break;
|
|
372
|
+
* case "session-end": console.log("done", event.status); break;
|
|
373
|
+
* }
|
|
374
|
+
* });
|
|
375
|
+
* ```
|
|
376
|
+
*/
|
|
237
377
|
type AgentEvent = z.infer<typeof eventSchema>;
|
|
238
378
|
//#endregion
|
|
239
379
|
export { OutputSchema as C, imageContentPartSchema as D, contentPartSchema as E, textContentPartSchema as O, McpServerConfig as S, agentCapabilitiesSchema as T, toolResultEventSchema as _, SessionStartEvent as a, ImageContentPart as b, ToolResultEvent as c, messageEventSchema as d, reasoningEventSchema as f, toolCallEventSchema as g, stderrEventSchema as h, SessionEndEvent as i, baseEventSchema as l, sessionStartEventSchema as m, MessageEvent as n, StderrEvent as o, sessionEndEventSchema as p, ReasoningEvent as r, ToolCallEvent as s, AgentEvent as t, eventSchema as u, AgentCapabilities as v, TextContentPart as w, JsonSchema as x, ContentPart as y };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./types-CwvWHEpy.mjs";const t=t=>{if(t){if(t.container&&t.sandbox)throw new e(`Pass either "container" or "sandbox", not both.`);return t.container??t.sandbox}},n=e=>{let n=t(e);return!e||!n?{executionTarget:n,options:e}:{executionTarget:n,options:{...e,cwd:e.cwd??n.workdir,propagateEnv:e.container&&e.propagateEnv===void 0?!1:e.propagateEnv,spawner:n.spawner}}};export{n as t};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { S as McpServerConfig } from "./events-Bwfw__Q3.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
3
|
+
import { t as Container } from "./index-BeejNCvc.mjs";
|
|
4
|
+
import { c as Sandbox } from "./index-C8wbKjj3.mjs";
|
|
5
|
+
import { i as ClaudeCodeCliPermissionMode } from "./index-BQNj8DHq.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/adapters/claude-code-cli-pty/types.d.ts
|
|
8
|
+
/** Same modes as {@link ClaudeCodeCliPermissionMode}; re-exported for convenience. */
|
|
9
|
+
type ClaudeCodeCliPtyPermissionMode = ClaudeCodeCliPermissionMode;
|
|
10
|
+
interface ClaudeCodeCliPtyExitEvent {
|
|
11
|
+
exitCode: number;
|
|
12
|
+
signal?: number | string;
|
|
13
|
+
}
|
|
14
|
+
/** Minimal pseudo-terminal handle the adapter speaks to. Returned by {@link ClaudeCodeCliPtyModule.spawn}. */
|
|
15
|
+
interface ClaudeCodeCliPtyProcess {
|
|
16
|
+
/** Send bytes (typically input or a control sequence) to the PTY. May buffer; not required to flush synchronously. */
|
|
17
|
+
write: (data: string) => void;
|
|
18
|
+
/** Send a signal (default `"SIGTERM"`) to the underlying process. Idempotent — repeat calls after exit are ignored. */
|
|
19
|
+
kill: (signal?: string) => void;
|
|
20
|
+
/** Subscribe to raw stdout/stderr chunks from the PTY. Returns a disposer that unsubscribes. */
|
|
21
|
+
onData: (handler: (data: string) => void) => {
|
|
22
|
+
dispose: () => void;
|
|
23
|
+
};
|
|
24
|
+
/** Subscribe to the PTY's exit event. Fires once with exit code and optional signal. Returns a disposer. */
|
|
25
|
+
onExit: (handler: (event: ClaudeCodeCliPtyExitEvent) => void) => {
|
|
26
|
+
dispose: () => void;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Bring-your-own PTY backend. Supply a module exposing `spawn` to use a
|
|
31
|
+
* specific PTY implementation (e.g. `node-pty`); the adapter will use it
|
|
32
|
+
* instead of falling back to the bundled spawner.
|
|
33
|
+
*/
|
|
34
|
+
interface ClaudeCodeCliPtyModule {
|
|
35
|
+
spawn: (command: string, args: string[], options: {
|
|
36
|
+
cols?: number;
|
|
37
|
+
rows?: number;
|
|
38
|
+
cwd?: string;
|
|
39
|
+
env?: Record<string, string>;
|
|
40
|
+
initialInputBootstrapPath?: string;
|
|
41
|
+
initialInputPath?: string;
|
|
42
|
+
}) => ClaudeCodeCliPtyProcess;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Per-run options for the `claude-code-cli-pty` adapter — same as
|
|
46
|
+
* `claude-code-cli` plus PTY-specific timing knobs.
|
|
47
|
+
*/
|
|
48
|
+
interface ClaudeCodeCliPtyRunOptions {
|
|
49
|
+
/** Allowlist of tool names. */
|
|
50
|
+
allowedTools?: string[];
|
|
51
|
+
/** Denylist of tool names. */
|
|
52
|
+
disallowedTools?: string[];
|
|
53
|
+
/** Text appended to Claude Code's default system prompt. */
|
|
54
|
+
appendSystemPrompt?: string;
|
|
55
|
+
/** Permission strategy for this run. See {@link ClaudeCodeCliPtyPermissionMode}. */
|
|
56
|
+
permissionMode?: ClaudeCodeCliPtyPermissionMode;
|
|
57
|
+
/** Path(s) to MCP server config files passed via `--mcp-config`. */
|
|
58
|
+
mcpConfig?: string[] | string;
|
|
59
|
+
/** Inline MCP server config map. */
|
|
60
|
+
mcpServers?: Record<string, McpServerConfig>;
|
|
61
|
+
/** Start a fresh fork off the current session rather than continuing it. */
|
|
62
|
+
forkSession?: boolean;
|
|
63
|
+
/** Extra CLI flags appended verbatim. */
|
|
64
|
+
extraArgs?: string[];
|
|
65
|
+
/** How long to wait for the PTY to report ready, in milliseconds. */
|
|
66
|
+
readinessTimeoutMs?: number;
|
|
67
|
+
/** How long to wait for Claude Code's Stop hook to drain, in milliseconds. */
|
|
68
|
+
stopHookTimeoutMs?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Constructor options for `createAgent("claude-code-cli-pty", ...)`. */
|
|
71
|
+
type ClaudeCodeCliPtyAgentOptions = ClaudeCodeCliPtyRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
72
|
+
/** Path or argv to the `claude` binary. */command?: string[] | string; /** Working directory the agent operates against. */
|
|
73
|
+
cwd?: string; /** Environment variables for the subprocess. */
|
|
74
|
+
env?: Record<string, string>; /** Inherit `process.env` and overlay `env` on top, instead of replacing. */
|
|
75
|
+
propagateEnv?: boolean; /** Existing session ID to resume via `--resume`. */
|
|
76
|
+
sessionId?: string; /** Model identifier (e.g. `"claude-sonnet-4-6"`). */
|
|
77
|
+
model?: string; /** Replaces Claude Code's default system prompt entirely. */
|
|
78
|
+
systemPrompt?: string; /** File path to write the raw CLI log to (useful for debugging). */
|
|
79
|
+
logPath?: string; /** Sets `CI=true` in the subprocess env unless explicitly `false`. Default: `true`. */
|
|
80
|
+
ci?: boolean; /** Optional PTY module override. See {@link ClaudeCodeCliPtyModule}. */
|
|
81
|
+
pty?: ClaudeCodeCliPtyModule; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
82
|
+
onEvent?: AgentEventHandler;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Agent instance returned by `createAgent("claude-code-cli-pty", ...)`.
|
|
86
|
+
*
|
|
87
|
+
* Runs Claude Code under a pseudo-terminal — required for permission prompts
|
|
88
|
+
* to render interactively. Prefer `claude-code-cli` for non-interactive use.
|
|
89
|
+
*/
|
|
90
|
+
interface ClaudeCodeCliPtyAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliPtyRunOptions>> {
|
|
91
|
+
readonly type: "claude-code-cli-pty";
|
|
92
|
+
/**
|
|
93
|
+
* Branch a sibling agent from the current session.
|
|
94
|
+
*
|
|
95
|
+
* Throws `AgentValidationError` when called before this agent has
|
|
96
|
+
* acquired a session ID — run at least one prompt first.
|
|
97
|
+
*/
|
|
98
|
+
fork: () => ClaudeCodeCliPtyAgent;
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/adapters/claude-code-cli-pty/adapter.d.ts
|
|
102
|
+
declare const createClaudeCodeCliPtyAgent: (options?: ClaudeCodeCliPtyAgentOptions) => ClaudeCodeCliPtyAgent;
|
|
103
|
+
//#endregion
|
|
104
|
+
export { ClaudeCodeCliPtyPermissionMode as a, ClaudeCodeCliPtyModule as i, ClaudeCodeCliPtyAgent as n, ClaudeCodeCliPtyProcess as o, ClaudeCodeCliPtyAgentOptions as r, ClaudeCodeCliPtyRunOptions as s, createClaudeCodeCliPtyAgent as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Container } from "./index-
|
|
4
|
-
import { c as Sandbox } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-Bwfw__Q3.mjs";
|
|
2
|
+
import { A as ProcessSpawner, f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-Bk-YpdbX.mjs";
|
|
3
|
+
import { t as Container } from "./index-BeejNCvc.mjs";
|
|
4
|
+
import { c as Sandbox } from "./index-C8wbKjj3.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/claude-code-cli/events/schemas.d.ts
|
|
@@ -145,6 +145,12 @@ declare const claudeRateLimitEventSchema: z.ZodObject<{
|
|
|
145
145
|
}, z.core.$strip>;
|
|
146
146
|
}, z.core.$strip>;
|
|
147
147
|
type ClaudeRateLimitEvent = z.infer<typeof claudeRateLimitEventSchema>;
|
|
148
|
+
/**
|
|
149
|
+
* Discriminated union of the raw stream-JSON events Claude Code CLI emits
|
|
150
|
+
* before this adapter normalizes them. Surfaced for callers that want
|
|
151
|
+
* provider-specific fidelity (rate-limit signals, init metadata, etc.) that
|
|
152
|
+
* the normalized `AgentEvent` shape drops. Narrow on `event.type`.
|
|
153
|
+
*/
|
|
148
154
|
declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
149
155
|
type: z.ZodLiteral<"system">;
|
|
150
156
|
session_id: z.ZodString;
|
|
@@ -279,34 +285,59 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
279
285
|
type ClaudeEvent = z.infer<typeof claudeEventSchema>;
|
|
280
286
|
//#endregion
|
|
281
287
|
//#region src/adapters/claude-code-cli/types.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* How Claude Code CLI handles tool-permission prompts.
|
|
290
|
+
* - `"default"`: stop and ask via the permission handler.
|
|
291
|
+
* - `"acceptEdits"`: auto-accept file edits, still ask for shell commands.
|
|
292
|
+
* - `"auto"`: a model classifier decides per-call whether to approve.
|
|
293
|
+
* - `"dontAsk"`: don't prompt; deny anything not pre-approved.
|
|
294
|
+
* - `"bypassPermissions"`: disable the permission system entirely (dangerous).
|
|
295
|
+
* - `"plan"`: read-only planning mode; no edits, no shell.
|
|
296
|
+
*/
|
|
282
297
|
type ClaudeCodeCliPermissionMode = "acceptEdits" | "auto" | "bypassPermissions" | "default" | "dontAsk" | "plan";
|
|
298
|
+
/** Per-run options for the `claude-code-cli` adapter. */
|
|
283
299
|
interface ClaudeCodeCliRunOptions {
|
|
300
|
+
/** Allowlist of tool names. */
|
|
284
301
|
allowedTools?: string[];
|
|
302
|
+
/** Denylist of tool names. */
|
|
285
303
|
disallowedTools?: string[];
|
|
304
|
+
/** Text appended to Claude Code's default system prompt. */
|
|
286
305
|
appendSystemPrompt?: string;
|
|
306
|
+
/** Permission strategy for this run. */
|
|
287
307
|
permissionMode?: ClaudeCodeCliPermissionMode;
|
|
308
|
+
/** Path(s) to MCP server config files passed via `--mcp-config`. */
|
|
288
309
|
mcpConfig?: string[] | string;
|
|
310
|
+
/** Inline MCP server config map. Merged with `mcpConfig` file contents. */
|
|
289
311
|
mcpServers?: Record<string, McpServerConfig>;
|
|
312
|
+
/** Start a fresh fork off the current session rather than continuing it. */
|
|
290
313
|
forkSession?: boolean;
|
|
314
|
+
/** Extra CLI flags appended verbatim. Use sparingly — the adapter sets most flags. */
|
|
291
315
|
extraArgs?: string[];
|
|
292
316
|
}
|
|
317
|
+
/** Constructor options for `createAgent("claude-code-cli", ...)`. */
|
|
293
318
|
type ClaudeCodeCliAgentOptions = ClaudeCodeCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
294
|
-
command?: string[] | string;
|
|
295
|
-
cwd?: string;
|
|
296
|
-
env?: Record<string, string>;
|
|
297
|
-
propagateEnv?: boolean;
|
|
298
|
-
sessionId?: string;
|
|
299
|
-
model?: string;
|
|
300
|
-
systemPrompt?: string;
|
|
301
|
-
logPath?: string;
|
|
302
|
-
ci?: boolean;
|
|
303
|
-
spawner?: ProcessSpawner;
|
|
319
|
+
/** Path or argv to the `claude` binary. Defaults to looking up `claude` on `PATH`. */command?: string[] | string; /** Working directory the agent operates against. */
|
|
320
|
+
cwd?: string; /** Environment variables for the subprocess. */
|
|
321
|
+
env?: Record<string, string>; /** Inherit `process.env` and overlay `env` on top, instead of replacing. */
|
|
322
|
+
propagateEnv?: boolean; /** Existing session ID to resume via `--resume`. */
|
|
323
|
+
sessionId?: string; /** Model identifier (e.g. `"claude-sonnet-4-6"`). */
|
|
324
|
+
model?: string; /** Replaces the default system prompt entirely. */
|
|
325
|
+
systemPrompt?: string; /** File path to write the raw CLI log to (useful for debugging). */
|
|
326
|
+
logPath?: string; /** Sets `CI=true` in the subprocess env unless explicitly `false`. Default: `true`. Does not change Claude Code's output formatting on its own. */
|
|
327
|
+
ci?: boolean; /** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
328
|
+
spawner?: ProcessSpawner; /** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
304
329
|
onEvent?: AgentEventHandler;
|
|
305
330
|
};
|
|
331
|
+
/** Agent instance returned by `createAgent("claude-code-cli", ...)`. */
|
|
306
332
|
interface ClaudeCodeCliAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliRunOptions>> {
|
|
307
333
|
readonly type: "claude-code-cli";
|
|
334
|
+
/**
|
|
335
|
+
* Branch a sibling agent from the current session.
|
|
336
|
+
*
|
|
337
|
+
* Throws `AgentValidationError` when called before this agent has
|
|
338
|
+
* acquired a session ID — run at least one prompt first.
|
|
339
|
+
*/
|
|
308
340
|
fork: () => ClaudeCodeCliAgent;
|
|
309
|
-
dispose: () => Promise<void>;
|
|
310
341
|
}
|
|
311
342
|
//#endregion
|
|
312
343
|
//#region src/adapters/claude-code-cli/adapter.d.ts
|