coding-agents-sdk 0.13.0 → 0.14.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 +11 -1
- package/dist/Agent-YQZmTatB.mjs +4 -0
- package/dist/{SdkAgent-p0nJ6dWV.mjs → SdkAgent-Dv3I0OW2.mjs} +1 -1
- package/dist/adapters/claude-code-cli/index.d.mts +1 -1
- package/dist/adapters/claude-code-cli/index.mjs +1 -1
- package/dist/adapters/claude-code-cli-pty/index.d.mts +2 -2
- package/dist/adapters/claude-code-cli-pty/index.mjs +5 -5
- package/dist/adapters/claude-code-sdk/index.d.mts +1 -1
- package/dist/adapters/claude-code-sdk/index.mjs +4 -4
- 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 +2 -2
- package/dist/adapters/cursor-cli/index.mjs +1 -1
- package/dist/adapters/cursor-sdk/index.d.mts +2 -2
- 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-BPQtzEVV.mjs → classify-error-UZrj89Yi.mjs} +3 -3
- package/dist/container/index.d.mts +2 -2
- package/dist/container/index.mjs +1 -1
- package/dist/{container-Dg68bfte.mjs → container-BYRWV-A_.mjs} +1 -1
- package/dist/{container-DRj7xq5x.mjs → container-CNM4U7vL.mjs} +1 -1
- package/dist/{container-DBXaA-Iv.mjs → container-D5P0tyx7.mjs} +1 -1
- package/dist/{container-gJ8B-Z5B.mjs → container-mzyYSG7P.mjs} +1 -1
- package/dist/{container-46QA1d3v.mjs → container-oGViyTTR.mjs} +1 -1
- package/dist/{diff-BJWXJsjx.mjs → diff-ByicTI7l.mjs} +1 -1
- package/dist/{events-B0BpIsW2.d.mts → events-BF6ELG7c.d.mts} +1 -3
- package/dist/{index-BKK-3gye.d.mts → index-62Ld65Q8.d.mts} +4 -4
- package/dist/{index-CG2m7pFJ.d.mts → index-68ih5kFM.d.mts} +1 -1
- package/dist/{index-B5NFoNlS.d.mts → index-ByyejuZo.d.mts} +3 -3
- package/dist/{index-BQ8cUo2i.d.mts → index-CAWun0L4.d.mts} +6 -6
- package/dist/{index-C9XD71QR.d.mts → index-CGMqyNOd.d.mts} +2 -24
- package/dist/{index-XWqpUSBc.d.mts → index-CPnH6YAO.d.mts} +10 -8
- package/dist/{index-B9ze9hTN.d.mts → index-CW1kBJ3d.d.mts} +2 -2
- package/dist/{index-DPP4zoiJ.d.mts → index-CzvAiGC9.d.mts} +4 -4
- package/dist/{index-CG5DS_NB.d.mts → index-DCbDnTQ_.d.mts} +3 -3
- package/dist/{index-DdyD2ji1.d.mts → index-DwlwQ9R0.d.mts} +2 -2
- package/dist/{index-5bx9TIY_.d.mts → index-DzfIudMp.d.mts} +3 -3
- package/dist/{index-DzFF15zC.d.mts → index-GW5zKifI.d.mts} +5 -5
- package/dist/index.d.mts +15 -15
- package/dist/index.mjs +1 -1
- package/dist/{oci-DmEG3Ia3.mjs → oci-FTrEF0I6.mjs} +1 -1
- package/dist/{parser-DNYBLV_4.mjs → parser-CfDBEv7A.mjs} +2 -2
- package/dist/sandbox/index.d.mts +2 -2
- package/dist/sandbox/index.mjs +1 -1
- package/dist/{sandbox-C5vzNxZR.mjs → sandbox-DQWTg5YL.mjs} +1 -1
- package/dist/schemas/index.d.mts +2 -2
- package/dist/spawner-BE2hAC0w.mjs +1 -0
- package/dist/structured-output-BeZPb2QW.mjs +1 -0
- package/dist/{types-CGzSzwfB.d.mts → types-BQeZnkDv.d.mts} +2 -3
- package/package.json +20 -8
- package/dist/Agent-4TZ8JK66.mjs +0 -4
- package/dist/spawner-BB6W3FVi.mjs +0 -1
- package/dist/structured-output-DsMPRckW.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"../../types-B72tDMEZ.mjs";import{a as t,n}from"../../util-DcPzh_0u.mjs";import{c as r,l as i,
|
|
1
|
+
import{n as e}from"../../types-B72tDMEZ.mjs";import{a as t,n}from"../../util-DcPzh_0u.mjs";import{c as r,l as i,s as a,u as o}from"../../classify-error-UZrj89Yi.mjs";import{t as s}from"../../execution-target-CdlYXh6Z.mjs";import{t as c}from"../../Agent-YQZmTatB.mjs";import{z as l}from"zod/v4";const u=e=>typeof e==`string`?e:void 0,d=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,f=()=>crypto.randomUUID(),p=e=>{if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}},m=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return``;let t=[];for(let r of e)n(r)&&r.type===`text`&&typeof r.text==`string`&&t.push(r.text);return t.join(``)},h=e=>{let t=e;if(t.type===`session`)return u(t.id)},g=e=>({events:[],sessionId:u(e.id)??void 0}),_=()=>({events:[]}),v=(e,t,r)=>{let i=n(e.message)?e.message:void 0;if(!i||u(i.role)!==`assistant`)return{events:[]};let s=m(i.content),c=u(i.model)??r.model??null,l=[];return r.reasoningText&&l.push(a(t.runId,`reasoning`,{sessionId:t.sessionId,model:c,content:[o(r.reasoningText)],text:r.reasoningText})),s&&l.push(a(t.runId,`message`,{sessionId:t.sessionId,model:c,role:`assistant`,content:[o(s)],text:s})),u(i.stopReason)===`error`?{events:l,state:{output:{text:s||void 0},status:`failed`,error:{kind:`provider`,message:`Pi model returned an error stop reason.`}}}:s?{events:l,state:{output:{text:s}}}:{events:l}},y=(e,t,n)=>{let r=u(e.toolCallId)??f(),i=u(e.toolName)??`tool`,o=e.args===void 0?void 0:e.args;return{events:[a(t.runId,`tool-call`,{sessionId:t.sessionId,model:n.model??null,toolCallId:r,toolName:i,input:o})],toolCalls:[{toolCallId:r,toolName:i,input:o}]}},b=(e,t)=>{let n=u(e.toolCallId)??f(),r=!!e.isError,i=e.result,o=t.toolCalls.get(n),s=u(e.toolName)??o?.toolName;return{events:[a(t.runId,`tool-result`,{sessionId:t.sessionId,toolCallId:n,toolName:s,input:o?.input,output:i,isError:r||void 0,error:r?p(i):void 0})]}},x=e=>{let t=n(e.message)?e.message:void 0;if(!t)return;let r=n(t.usage)?t.usage:void 0;if(!r)return;let i=d(r.input),a=d(r.output),o=d(r.cacheRead)||void 0,s=d(r.cacheWrite)||void 0;return{turns:1,durationMs:0,costUsd:n(r.cost)?d(r.cost.total)??0:d(r.cost)??0,inputTokens:i,outputTokens:a,cacheReadInputTokens:o,cacheCreationInputTokens:s,totalTokens:(i??0)+(a??0)+(o??0)+(s??0)||void 0}},S=e=>{let t=x(e);return t?{events:[],state:{stats:t}}:{events:[]}},C=(e,t,n={})=>{let r=e;switch(e.type){case`session`:return g(r);case`message_update`:return _();case`message_end`:return v(r,t,n);case`tool_execution_start`:return y(r,t,n);case`tool_execution_end`:return b(r,t);case`turn_end`:return S(r);default:return{events:[]}}},w=r(l.object({type:l.string()}).passthrough()),T={structuredOutput:!1,sessionResume:!0,imageInput:!0,mcp:!1,eventStreaming:!0,sessionFork:!0},E=(e,t)=>({turns:(e?.turns??0)+t.turns,durationMs:(e?.durationMs??0)+(t.durationMs??0),apiDurationMs:(e?.apiDurationMs??0)+(t.apiDurationMs??0),costUsd:(e?.costUsd??0)+t.costUsd,inputTokens:t.inputTokens!==void 0||e?.inputTokens!==void 0?(e?.inputTokens??0)+(t.inputTokens??0):void 0,outputTokens:t.outputTokens!==void 0||e?.outputTokens!==void 0?(e?.outputTokens??0)+(t.outputTokens??0):void 0,cacheReadInputTokens:t.cacheReadInputTokens!==void 0||e?.cacheReadInputTokens!==void 0?(e?.cacheReadInputTokens??0)+(t.cacheReadInputTokens??0):void 0,cacheCreationInputTokens:t.cacheCreationInputTokens!==void 0||e?.cacheCreationInputTokens!==void 0?(e?.cacheCreationInputTokens??0)+(t.cacheCreationInputTokens??0):void 0,totalTokens:t.totalTokens!==void 0||e?.totalTokens!==void 0?(e?.totalTokens??0)+(t.totalTokens??0):void 0});var D=class n extends c{type=`pi-cli`;creationOptions;runDefaults;runTextBuffers=new Map;runReasoningBuffers=new Map;runAccumulatedStats=new Map;forkOnNextRun;constructor(e={}){super({type:`pi-cli`,capabilities:T,defaults:{cwd:e.cwd,env:e.env,command:t(e.command??`pi`),sessionId:e.sessionId,model:e.model,systemPrompt:e.systemPrompt},spawner:e.spawner,executionTarget:e.container??e.sandbox,logPath:e.logPath,onEvent:e.onEvent}),this.creationOptions=e,this.runDefaults={provider:e.provider,thinking:e.thinking,appendSystemPrompt:e.appendSystemPrompt,allowedTools:e.allowedTools?[...e.allowedTools]:void 0,noTools:e.noTools,noSession:e.noSession,sessionDir:e.sessionDir,forkSession:e.forkSession,extraArgs:e.extraArgs?[...e.extraArgs]:void 0},this.forkOnNextRun=e.forkOnNextRun??!1}fork(){if(!this.sessionId)throw new e(`Cannot fork a Pi CLI agent before it has a sessionId.`);return new n({...this.creationOptions,sessionId:this.sessionId,forkSession:void 0,forkOnNextRun:!0})}onValidateRun(t,n){if((t.forkSession??this.runDefaults.forkSession??this.forkOnNextRun)&&!this.sessionId)throw new e(`forkSession requires an existing sessionId on the agent.`)}buildArgs(e,t){let n=[`--mode`,`json`],r=e.provider??this.runDefaults.provider,a=e.thinking??this.runDefaults.thinking,o=e.appendSystemPrompt??this.runDefaults.appendSystemPrompt,s=e.allowedTools??this.runDefaults.allowedTools,c=e.noTools??this.runDefaults.noTools,l=e.noSession??this.runDefaults.noSession,u=e.sessionDir??this.runDefaults.sessionDir,d=e.forkSession??this.runDefaults.forkSession??this.forkOnNextRun,f=e.extraArgs??this.runDefaults.extraArgs;e.model?r?n.push(`--model`,`${r}/${e.model}`):n.push(`--model`,e.model):r&&n.push(`--provider`,r),e.systemPrompt&&n.push(`--system-prompt`,e.systemPrompt),o&&n.push(`--append-system-prompt`,o),a&&n.push(`--thinking`,a),c?n.push(`--no-tools`):s&&s.length>0&&n.push(`--tools`,s.join(`,`)),t.requestedSessionId?d?n.push(`--fork`,t.requestedSessionId):n.push(`--session`,t.requestedSessionId):l?n.push(`--no-session`):u&&n.push(`--session-dir`,u),f&&f.length>0&&n.push(...f);for(let t of e.input)t.type===`image`&&n.push(`@${t.path}`);let p=i(e.input);return n.push(p),n}buildEnv(e,t){return this.buildDefaultEnv(this.creationOptions.propagateEnv)}mapRawEvent(e,t){this.appendRawLog(e);let n=w(e);if(!n)return this.onParseError(JSON.stringify(e).slice(0,200),Error(`schema validation failed`)),{events:[]};let r=h(n)??t.sessionId;if(this.forkOnNextRun&&t.requestedSessionId&&r&&r!==t.requestedSessionId&&(this.forkOnNextRun=!1),n.type===`message_update`){let e=n.assistantMessageEvent,r=typeof e?.type==`string`?e.type:void 0,i=typeof e?.delta==`string`?e.delta:``;if(r===`text_delta`&&i){let e=`${this.runTextBuffers.get(t.runId)??``}${i}`;this.runTextBuffers.set(t.runId,e)}else if(r===`thinking_delta`&&i){let e=`${this.runReasoningBuffers.get(t.runId)??``}${i}`;this.runReasoningBuffers.set(t.runId,e)}}let i={model:void 0};n.type===`message_end`&&(i.reasoningText=this.runReasoningBuffers.get(t.runId),this.runReasoningBuffers.delete(t.runId));let a=C(n,{...t,sessionId:r},i);if(r&&a.sessionId===void 0&&(a.sessionId=r),a.state?.output?.text!==void 0&&this.runTextBuffers.set(t.runId,a.state.output.text),n.type===`turn_end`&&a.state?.stats){let e=E(this.runAccumulatedStats.get(t.runId),a.state.stats);this.runAccumulatedStats.set(t.runId,e),a.state.stats=e}return a}async onRunFinished(e){await super.onRunFinished(e),this.runTextBuffers.delete(e.runId),this.runReasoningBuffers.delete(e.runId),this.runAccumulatedStats.delete(e.runId)}};const O=e=>new D(s(e));export{O as createPiCliAgent};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import{n as e,t}from"./types-B72tDMEZ.mjs";import{z as n}from"zod/v4";const r=()=>crypto.randomUUID(),i=()=>`evt_${crypto.randomUUID()}`,a=e=>({type:`text`,text:e}),o=e=>e.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
2
2
|
`),s=e=>e.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
3
3
|
|
|
4
|
-
`),c=e=>t=>{let n=e.safeParse(t);return n.success?n.data:null},l=(e,t,n)=>({id:n.id??i(),runId:e,timestamp:new Date,type:t,...n}),
|
|
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.`}},
|
|
4
|
+
`),c=e=>t=>{let n=e.safeParse(t);return n.success?n.data:null},l=(e,t,n,r)=>{let i;for(let t of e.events){if(t.type!==`message`||t.role!==`assistant`||!t.text)continue;let e=`${n.get(r)??``}${t.text}`;n.set(r,e),i=e}return t&&e.state?.output?.text!==void 0?n.set(r,e.state.output.text):i!==void 0&&(e.state={...e.state,output:{...e.state?.output,text:i}}),e},u=(e,t,n)=>({id:n.id??i(),runId:e,timestamp:new Date,type:t,...n}),d=e=>e instanceof n.ZodType,f=e=>{if(!(`schema`in e))return{kind:`none`};let{schema:t}=e;return d(t)?{kind:`zod`,jsonSchema:n.toJSONSchema(t),zodSchema:t}:{kind:`json-schema`,jsonSchema:t}},p=(t,n,r,i)=>{let a=typeof i.input==`string`?[{type:`text`,text:i.input}]:i.input;if(a.length===0||a.every(e=>e.type===`text`&&e.text.trim()===``))throw new e(`Run input cannot be empty.`);if(!n.imageInput&&a.some(e=>e.type===`image`))throw new e(`${t} does not support image input.`);let o=f(i);if(!n.structuredOutput&&o.kind!==`none`)throw new e(`${t} does not support structured output.`);if(i.timeoutMs!==void 0&&(!Number.isFinite(i.timeoutMs)||i.timeoutMs<=0))throw new e(`timeoutMs must be a positive finite number.`);return{input:a,schema:o,cwd:i.cwd??r?.cwd,model:i.model??r?.model,systemPrompt:i.systemPrompt??r?.systemPrompt,timeoutMs:i.timeoutMs,signal:i.signal}},m=(e,t)=>({runId:e.runId,requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,schemaRequested:e.normalizedRequest.schema.kind!==`none`,toolCalls:e.toolCalls,...t}),h=(e,t)=>{if(!e.stats)return;let n=Math.max(0,t.getTime()-e.startedAt.getTime());e.stats={...e.stats,durationMs:e.stats.durationMs??n,apiDurationMs:e.stats.apiDurationMs??n}},g=(e,t)=>{let n=e.normalizedRequest.schema;if(n.kind!==`none`){if(n.kind===`zod`){let r=n.zodSchema.safeParse(t);if(!r.success){e.status=`failed`,e.error={kind:`parse`,message:r.error.message};return}e.output.value=r.data;return}e.output.value=t}},_=(e,t)=>{if(e.events.push(t),t.type!==`message`||t.role!==`assistant`)return;let n=t.text??o(t.content);n&&e.assistantTexts.push(n)},v=(e,t,n={})=>{t.sessionId&&(e.sessionId=t.sessionId,n.onSessionId?.(t.sessionId));for(let n of t.toolCalls??[])e.toolCalls.set(n.toolCallId,{toolName:n.toolName,input:n.input});if(!t.state)return;let r=t.state;r.output&&(`text`in r.output&&(e.output.text=r.output.text),`value`in r.output&&g(e,r.output.value)),`stats`in r&&(e.stats=r.stats),`status`in r&&(e.status=r.status),`error`in r&&(e.error=r.error)},y=e=>e.events.some(e=>e.type===`message`||e.type===`reasoning`||e.type===`tool-call`||e.type===`tool-result`),b=e=>{let t=e.normalizedRequest.schema.kind!==`none`&&e.output.value===void 0;return e.stopReason===`user`||e.stopReason===`abort`||e.stopReason===`timeout`?`cancelled`:e.error?e.error.kind===`abort`?`cancelled`:`failed`:e.status?e.status===`completed`&&t?`failed`:e.status:e.processResult&&e.processResult.exitCode!==null&&e.processResult.exitCode!==0||!y(e)&&e.stderrLines.length>0||t?`failed`:`completed`},x=(e,t)=>{let n=e.processResult,r=e.stderrLines.join(`
|
|
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.`}},S=(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.`)}},
|
|
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.`)}},C=()=>{let e=new Date;return{runCount:0,messagesReceived:0,toolCalls:0,errors:0,startedAt:e,lastActivityAt:e}};var w=class{type;capabilities;currentRun;eventHandlers=[];permissionHandler;_sessionId;_metrics;constructor(e){this.type=e.type,this.capabilities=e.capabilities,this._sessionId=e.sessionId,this._metrics=C(),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=p(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=C()}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){v(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,u(e.runId,`session-start`,{requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,resumed:e.requestedSessionId!==void 0})))}emit(e,t){_(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){h(e,t);let n=b(e),r=x(e,n);return e.sessionStarted&&this.emit(e,u(e.runId,`session-end`,{sessionId:e.sessionId,status:n,error:r?.message})),S(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 T=new Set([`ENOENT`,`ERR_MODULE_NOT_FOUND`]),E=e=>`code`in e,D=(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(E(e)&&T.has(String(e.code)))return{kind:`spawn`,message:n};if(e instanceof SyntaxError)return{kind:`parse`,message:n}}return{kind:`provider`,message:n}};export{y as a,c,m as i,s as l,w as n,l as o,v as r,u as s,D as t,a as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { Container,
|
|
1
|
+
import { A as VolumeMount, C as DockerContainer, D as ExecOptions, E as ContainerType, F as WorkdirSnapshot, I as WorkdirSnapshotOptions, M as WorkdirDiff, N as WorkdirDiffStats, O as ExecResult, P as WorkdirFileChange, S as E2BProviderConfig, T as ContainerStatus, _ as E2BConnectConfig, a as ContainerDiffError, b as E2BContainerConfig, c as ContainerExecError, d as MountValidationError, f as PodmanContainer, g as NerdctlProviderConfig, h as NerdctlContainerConfig, i as ContainerCreateError, j as WorkdirChangeKind, k as PortMapping, l as ContainerNotRunningError, m as NerdctlContainer, n as ContainerConfig, o as ContainerDisposedError, p as PodmanContainerConfig, r as createContainer, s as ContainerError, t as Container, u as ContainerStartError, v as E2BConnectionConfig, w as DockerContainerConfig, x as E2BCreateConfig, y as E2BContainer } from "../index-CGMqyNOd.mjs";
|
|
2
|
+
export { Container, ContainerConfig, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, type ContainerStatus, type ContainerType, type DockerContainer, type DockerContainerConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, type ExecOptions, type ExecResult, MountValidationError, type NerdctlContainer, type NerdctlContainerConfig, type NerdctlProviderConfig, type PodmanContainer, type PodmanContainerConfig, type PortMapping, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, createContainer };
|
package/dist/container/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"../container-
|
|
1
|
+
import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c}from"../container-D5P0tyx7.mjs";export{i as ContainerCreateError,o as ContainerDiffError,n as ContainerDisposedError,e as ContainerError,a as ContainerExecError,s as ContainerNotRunningError,t as ContainerStartError,r as MountValidationError,c as createContainer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./oci-
|
|
1
|
+
import{n as e,t}from"./oci-FTrEF0I6.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-DcPzh_0u.mjs";import{c as t,i as n,n as r,r as i,s as a}from"./container-
|
|
1
|
+
import{t as e}from"./util-DcPzh_0u.mjs";import{c as t,i as n,n as r,r as i,s as a}from"./container-D5P0tyx7.mjs";import{t as o}from"./shell-DvWFuFKb.mjs";import{n as s}from"./diff-ByicTI7l.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 r(`E2B create failed: ${e(t)}`)}let l=o.name??c.sandboxId,d=`running`,p=k(c,o),m={},h=()=>{if(d===`disposed`)throw new n},g=()=>{if(h(),d!==`running`)throw new a},_=s({owner:m,workdir:o.workdir,materialize:async(e,t)=>{g();let n=x(o),r=await R(c,e,n);if(!r)throw new i(`Target path does not exist: ${e}`);if(r.type!==v.DIR)throw new i(`Target path is not a directory: ${e}`);await f(t,{recursive:!0});for(let r of await c.files.list(e,{user:n}))await H(c,r.path,u(t,r.name),n)}}),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(n){throw new t(`E2B start failed: ${e(n)}`)}},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};
|
|
@@ -1 +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`}};async function c(e){switch(e.type){case`docker`:{let{createDockerContainer:t}=await import(`./container-
|
|
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`}};async function c(e){switch(e.type){case`docker`:{let{createDockerContainer:t}=await import(`./container-oGViyTTR.mjs`);return t(e)}case`e2b`:try{let{createE2BContainer:t}=await import(`./container-CNM4U7vL.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 t(`Container type "e2b" requires the optional peer dependency "e2b". Install it to use this provider.`):e}case`nerdctl`:{let{createNerdctlContainer:t}=await import(`./container-mzyYSG7P.mjs`);return t(e)}case`podman`:{let{createPodmanContainer:t}=await import(`./container-BYRWV-A_.mjs`);return t(e)}default:throw new t(`Unsupported container type.`)}}export{e as a,r as c,o as i,n as l,t as n,i as o,s as r,a as s,c as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./oci-
|
|
1
|
+
import{n as e,t}from"./oci-FTrEF0I6.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{n as e,t}from"./oci-
|
|
1
|
+
import{n as e,t}from"./oci-FTrEF0I6.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{t as e}from"./util-DcPzh_0u.mjs";import{i as t,r as n,s as r}from"./container-
|
|
1
|
+
import{t as e}from"./util-DcPzh_0u.mjs";import{i as t,r as n,s as r}from"./container-D5P0tyx7.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,t,r)=>{let i=O(t,e);if(i!==void 0)return i;let a=O(r,e);if(a!==void 0)return a;throw new n(`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,t,r)=>{if(typeof t!=`object`||!t)throw new n(`Invalid workdir snapshot.`);let i=r.get(t);if(!i)throw new n(`Invalid workdir snapshot.`);if(i.owner!==e)throw new n(`Workdir snapshot was created by a different container instance.`);return i},I=(e,t)=>{if(!t.has(e))throw new n(`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,t,r)=>{let i=`${e}:${t}`;if(r.has(i))return r.get(i);let a=s(e,...t.split(c.sep));try{let e=await h(a),t,o;if(e.isSymbolicLink()){let e=Buffer.from(await y(a));t=L(e),o=e.byteLength}else if(e.isFile())t=await z(a),o=e.size;else throw new n(`Unsupported filesystem entry in diff metadata: ${a}`);let s={hash:t,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,t,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 n(`Failed to parse git rename entry.`);a.push({kind:`renamed`,previousPath:k(o,t,r),path:k(s,t,r)});continue}let s=i[e++];if(!s)throw new n(`Failed to parse git diff entry.`);switch(o){case`A`:a.push({kind:`added`,path:k(s,t,r)});break;case`D`:a.push({kind:`deleted`,path:k(s,t,r)});break;case`M`:a.push({kind:`modified`,path:k(s,t,r)});break;case`T`:a.push({kind:`modified`,path:k(s,t,r)});break;default:throw new n(`Unsupported git diff change kind: ${o}`)}}return a},H=async(t,r)=>{try{return V(R((await E(`git`,[`diff`,`--no-index`,`-z`,`--name-status`,`-M`,`--find-renames=100%`,t,r],{cwd:p(),encoding:`buffer`,maxBuffer:50*1024*1024})).stdout),t,r)}catch(i){if(!T(i))throw new n(`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,t,r);throw new n(`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 n||a instanceof t||a instanceof r?a:new n(`${i}: ${e(a)}`)},K=async(e,t)=>{if(!(await x(e)).isDirectory())throw new n(`Target path is not a directory: ${e}`);await g(t,{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(t,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 n(`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};
|
|
@@ -63,8 +63,6 @@ declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
|
63
63
|
type AgentCapabilities = z.infer<typeof agentCapabilitiesSchema>;
|
|
64
64
|
/** JSON Schema (Draft 7+) object, or a value produced by `z.toJSONSchema(...)`. */
|
|
65
65
|
type JsonSchema = Record<string, unknown> | ReturnType<typeof z.toJSONSchema>;
|
|
66
|
-
/** Either a JSON Schema or a Zod schema. Accepted by structured-output requests. */
|
|
67
|
-
type OutputSchema = JsonSchema | ZodType;
|
|
68
66
|
/**
|
|
69
67
|
* Common shape for MCP (Model Context Protocol) server configurations passed
|
|
70
68
|
* through to adapters. Adapters interpret the fields as needed — most accept
|
|
@@ -376,4 +374,4 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
376
374
|
*/
|
|
377
375
|
type AgentEvent = z.infer<typeof eventSchema>;
|
|
378
376
|
//#endregion
|
|
379
|
-
export {
|
|
377
|
+
export { TextContentPart as C, textContentPartSchema as D, imageContentPartSchema as E, McpServerConfig as S, contentPartSchema 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, agentCapabilitiesSchema as w, JsonSchema as x, ContentPart as y };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Container } from "./index-
|
|
4
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BF6ELG7c.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
3
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/codex-cli/events/schemas.d.ts
|
|
@@ -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-BQeZnkDv.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";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { k as ProcessSpawner } from "./types-BQeZnkDv.mjs";
|
|
2
|
+
import { A as VolumeMount } from "./index-CGMqyNOd.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/sandbox/types.d.ts
|
|
5
5
|
/** Which sandbox binary backs the policy. The binary must be installed on the host. */
|
|
@@ -192,4 +192,4 @@ declare function createSandbox(config: BubblewrapSandboxConfig): Promise<Bubblew
|
|
|
192
192
|
declare function createSandbox(config: FirejailSandboxConfig): Promise<FirejailSandbox>;
|
|
193
193
|
declare function createSandbox(config: NsjailSandboxConfig): Promise<NsjailSandbox>;
|
|
194
194
|
//#endregion
|
|
195
|
-
export {
|
|
195
|
+
export { FirejailSandbox as a, NsjailSandboxConfig as c, SandboxStatus as d, SandboxType as f, BubblewrapSandboxConfig as i, Sandbox as l, createSandbox as n, FirejailSandboxConfig as o, BubblewrapSandbox as r, NsjailSandbox as s, SandboxCreateError as t, SandboxConfig as u };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import {
|
|
3
|
-
import { t as Container } from "./index-
|
|
4
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BF6ELG7c.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
3
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/claude-code-cli/events/schemas.d.ts
|
|
@@ -21,9 +21,9 @@ declare const claudeSystemEventSchema: z.ZodObject<{
|
|
|
21
21
|
mcp_servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
22
22
|
name: z.ZodString;
|
|
23
23
|
status: z.ZodEnum<{
|
|
24
|
+
error: "error";
|
|
24
25
|
connected: "connected";
|
|
25
26
|
disconnected: "disconnected";
|
|
26
|
-
error: "error";
|
|
27
27
|
failed: "failed";
|
|
28
28
|
}>;
|
|
29
29
|
}, z.core.$strip>>>;
|
|
@@ -167,9 +167,9 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
167
167
|
mcp_servers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
168
168
|
name: z.ZodString;
|
|
169
169
|
status: z.ZodEnum<{
|
|
170
|
+
error: "error";
|
|
170
171
|
connected: "connected";
|
|
171
172
|
disconnected: "disconnected";
|
|
172
|
-
error: "error";
|
|
173
173
|
failed: "failed";
|
|
174
174
|
}>;
|
|
175
175
|
}, z.core.$strip>>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as ProcessSpawner } from "./types-BQeZnkDv.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/container/types.d.ts
|
|
4
4
|
/** Which provider backs a container. Selects which CLI/SDK the adapter speaks. */
|
|
@@ -188,14 +188,6 @@ type OciProviderConfig = OciProviderBase & ({
|
|
|
188
188
|
});
|
|
189
189
|
//#endregion
|
|
190
190
|
//#region src/container/docker/types.d.ts
|
|
191
|
-
/** Inline Dockerfile content and build-context shape (re-exported from OCI). */
|
|
192
|
-
type DockerBuildBase = OciBuildBase;
|
|
193
|
-
/** Docker `docker build` configuration: image tag, context, build args. */
|
|
194
|
-
type DockerBuildConfig = OciBuildConfig;
|
|
195
|
-
/** Common provider fields shared with other OCI-style providers. */
|
|
196
|
-
type DockerContainerBase = OciProviderBase;
|
|
197
|
-
/** Provider-specific fields for Docker (image, build, mounts, ports, env). */
|
|
198
|
-
type DockerProviderConfig = OciProviderConfig;
|
|
199
191
|
/** Full config passed to `createContainer({ type: "docker", ... })`. */
|
|
200
192
|
type DockerContainerConfig = ContainerConfigBase<"docker"> & OciProviderConfig;
|
|
201
193
|
/** Docker container instance. */
|
|
@@ -280,12 +272,6 @@ interface E2BContainer extends ContainerBase<"e2b", E2BContainerConfig> {
|
|
|
280
272
|
}
|
|
281
273
|
//#endregion
|
|
282
274
|
//#region src/container/nerdctl/types.d.ts
|
|
283
|
-
/** Inline Dockerfile content and build-context shape (re-exported from OCI). */
|
|
284
|
-
type NerdctlBuildBase = OciBuildBase;
|
|
285
|
-
/** nerdctl `nerdctl build` configuration: image tag, context, build args. */
|
|
286
|
-
type NerdctlBuildConfig = OciBuildConfig;
|
|
287
|
-
/** Common provider fields shared with other OCI-style providers. */
|
|
288
|
-
type NerdctlContainerBase = NerdctlProviderBase;
|
|
289
275
|
/** Provider-specific fields for nerdctl, layered on top of generic OCI provider options. */
|
|
290
276
|
interface NerdctlProviderBase extends OciProviderBase {
|
|
291
277
|
/** containerd namespace. Defaults to `"default"`. */
|
|
@@ -310,14 +296,6 @@ interface NerdctlContainer extends ContainerBase<"nerdctl", NerdctlContainerConf
|
|
|
310
296
|
}
|
|
311
297
|
//#endregion
|
|
312
298
|
//#region src/container/podman/types.d.ts
|
|
313
|
-
/** Inline Dockerfile content and build-context shape (re-exported from OCI). */
|
|
314
|
-
type PodmanBuildBase = OciBuildBase;
|
|
315
|
-
/** Podman `podman build` configuration: image tag, context, build args. */
|
|
316
|
-
type PodmanBuildConfig = OciBuildConfig;
|
|
317
|
-
/** Common provider fields shared with other OCI-style providers. */
|
|
318
|
-
type PodmanContainerBase = OciProviderBase;
|
|
319
|
-
/** Provider-specific fields for Podman (image, build, mounts, ports, env). */
|
|
320
|
-
type PodmanProviderConfig = OciProviderConfig;
|
|
321
299
|
/** Full config passed to `createContainer({ type: "podman", ... })`. */
|
|
322
300
|
type PodmanContainerConfig = ContainerConfigBase<"podman"> & OciProviderConfig;
|
|
323
301
|
/** Podman container instance. */
|
|
@@ -426,4 +404,4 @@ declare function createContainer(config: E2BContainerConfig): Promise<E2BContain
|
|
|
426
404
|
declare function createContainer(config: NerdctlContainerConfig): Promise<NerdctlContainer>;
|
|
427
405
|
declare function createContainer(config: PodmanContainerConfig): Promise<PodmanContainer>;
|
|
428
406
|
//#endregion
|
|
429
|
-
export {
|
|
407
|
+
export { VolumeMount as A, DockerContainer as C, ExecOptions as D, ContainerType as E, WorkdirSnapshot as F, WorkdirSnapshotOptions as I, WorkdirDiff as M, WorkdirDiffStats as N, ExecResult as O, WorkdirFileChange as P, E2BProviderConfig as S, ContainerStatus as T, E2BConnectConfig as _, ContainerDiffError as a, E2BContainerConfig as b, ContainerExecError as c, MountValidationError as d, PodmanContainer as f, NerdctlProviderConfig as g, NerdctlContainerConfig as h, ContainerCreateError as i, WorkdirChangeKind as j, PortMapping as k, ContainerNotRunningError as l, NerdctlContainer as m, ContainerConfig as n, ContainerDisposedError as o, PodmanContainerConfig as p, createContainer as r, ContainerError as s, Container as t, ContainerStartError as u, E2BConnectionConfig as v, DockerContainerConfig as w, E2BCreateConfig as x, E2BContainer as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Container } from "./index-
|
|
3
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
2
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
3
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/cursor-cli/events/schemas.d.ts
|
|
@@ -15,11 +15,13 @@ type CursorCliEvent = z.infer<typeof cursorCliEventSchema>;
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/adapters/cursor-cli/types.d.ts
|
|
17
17
|
/**
|
|
18
|
-
* Cursor CLI run
|
|
18
|
+
* Cursor CLI permission mode — the run's approval/planning strategy. Named
|
|
19
|
+
* `permissionMode` for consistency with the other adapters; the value union is
|
|
20
|
+
* Cursor-specific.
|
|
19
21
|
* - `"ask"`: interactive question-answering mode (default).
|
|
20
22
|
* - `"plan"`: read-only planning mode; the agent proposes changes but doesn't apply them.
|
|
21
23
|
*/
|
|
22
|
-
type
|
|
24
|
+
type CursorCliPermissionMode = "ask" | "plan";
|
|
23
25
|
/**
|
|
24
26
|
* Cursor CLI sandbox toggle. Cursor's CLI exposes a binary on/off knob; for
|
|
25
27
|
* granular policy, use the `sandbox` option from `createSandbox(...)`.
|
|
@@ -37,8 +39,8 @@ interface CursorCliRunOptions {
|
|
|
37
39
|
* sends should leave this unset.
|
|
38
40
|
*/
|
|
39
41
|
force?: boolean;
|
|
40
|
-
/**
|
|
41
|
-
|
|
42
|
+
/** Permission/run mode (`"ask"` or `"plan"`). */
|
|
43
|
+
permissionMode?: CursorCliPermissionMode;
|
|
42
44
|
/** Sandbox toggle. See {@link CursorCliSandboxMode}. */
|
|
43
45
|
sandboxMode?: CursorCliSandboxMode;
|
|
44
46
|
/** Mark the working directory as trusted, bypassing first-run trust prompts. */
|
|
@@ -66,4 +68,4 @@ interface CursorCliAgent extends BaseAgent<EnsureDisjoint<CursorCliRunOptions>>
|
|
|
66
68
|
//#region src/adapters/cursor-cli/adapter.d.ts
|
|
67
69
|
declare const createCursorCliAgent: (options?: CursorCliAgentOptions) => CursorCliAgent;
|
|
68
70
|
//#endregion
|
|
69
|
-
export { CursorCliRunOptions as a,
|
|
71
|
+
export { CursorCliRunOptions as a, CursorCliPermissionMode as i, CursorCliAgent as n, CursorCliSandboxMode as o, CursorCliAgentOptions as r, CursorCliEvent as s, createCursorCliAgent as t };
|
|
@@ -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-BF6ELG7c.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
3
3
|
//#region src/adapters/claude-code-sdk/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* How Claude Code handles tool-permission prompts.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Container } from "./index-
|
|
3
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
2
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
3
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/pi-cli/events/schemas.d.ts
|
|
@@ -25,7 +25,7 @@ interface PiCliRunOptions {
|
|
|
25
25
|
/** Text appended to Pi's default system prompt. */
|
|
26
26
|
appendSystemPrompt?: string;
|
|
27
27
|
/** Allowlist of tool names. */
|
|
28
|
-
|
|
28
|
+
allowedTools?: string[];
|
|
29
29
|
/** Disable all tool use for this run. */
|
|
30
30
|
noTools?: boolean;
|
|
31
31
|
/** Run without persisting session history. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Container } from "./index-
|
|
3
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
2
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
3
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/opencode-cli/events/schemas.d.ts
|
|
@@ -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-BQeZnkDv.mjs";
|
|
2
2
|
//#region src/adapters/cursor-sdk/types.d.ts
|
|
3
3
|
/** OAuth-style credentials for HTTP/SSE MCP servers configured for the agent. */
|
|
4
4
|
interface CursorSdkMcpHttpAuth {
|
|
@@ -190,4 +190,4 @@ interface CursorSdkAgent extends BaseAgent<EnsureDisjoint<CursorSdkRunOptions>>
|
|
|
190
190
|
//#region src/adapters/cursor-sdk/adapter.d.ts
|
|
191
191
|
declare const createCursorSdkAgent: (options?: CursorSdkAgentOptions) => CursorSdkAgent;
|
|
192
192
|
//#endregion
|
|
193
|
-
export { CursorSdkMcpHttpAuth as a,
|
|
193
|
+
export { CursorSdkMcpHttpAuth as a, CursorSdkSettingSource as c, CursorSdkEvent as i, CursorSdkAgent as n, CursorSdkMcpServerConfig as o, CursorSdkAgentOptions as r, CursorSdkRunOptions as s, createCursorSdkAgent as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as Container } from "./index-
|
|
3
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
2
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
3
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/gemini-cli/events/schemas.d.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as McpServerConfig } from "./events-
|
|
2
|
-
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-
|
|
3
|
-
import { t as Container } from "./index-
|
|
4
|
-
import { l as Sandbox } from "./index-
|
|
5
|
-
import { i as ClaudeCodeCliPermissionMode } from "./index-
|
|
1
|
+
import { S as McpServerConfig } from "./events-BF6ELG7c.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-BQeZnkDv.mjs";
|
|
3
|
+
import { t as Container } from "./index-CGMqyNOd.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-ByyejuZo.mjs";
|
|
5
|
+
import { i as ClaudeCodeCliPermissionMode } from "./index-CAWun0L4.mjs";
|
|
6
6
|
|
|
7
7
|
//#region src/adapters/claude-code-cli-pty/types.d.ts
|
|
8
8
|
/** Same modes as {@link ClaudeCodeCliPermissionMode}; re-exported for convenience. */
|
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
import { C as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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-
|
|
6
|
-
import { a as ClaudeCodeCliPtyPermissionMode, i as ClaudeCodeCliPtyModule, n as ClaudeCodeCliPtyAgent, o as ClaudeCodeCliPtyProcess, r as ClaudeCodeCliPtyAgentOptions, s as ClaudeCodeCliPtyRunOptions } from "./index-
|
|
7
|
-
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-
|
|
8
|
-
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-
|
|
9
|
-
import { a as CodexSdkItem, i as CodexSdkEvent, n as CodexSdkAgent, o as CodexSdkPermissionMode, r as CodexSdkAgentOptions, s as CodexSdkRunOptions } from "./index-
|
|
10
|
-
import { a as CursorCliRunOptions, i as
|
|
11
|
-
import { a as CursorSdkMcpHttpAuth, c as
|
|
12
|
-
import { a as GeminiCliRunOptions, i as GeminiCliPermissionMode, n as GeminiCliAgent, o as GeminiEvent, r as GeminiCliAgentOptions } from "./index-
|
|
13
|
-
import { a as OpencodeEvent, i as OpencodeCliRunOptions, n as OpencodeCliAgent, r as OpencodeCliAgentOptions } from "./index-
|
|
14
|
-
import { a as PiCliThinkingLevel, i as PiCliRunOptions, n as PiCliAgent, o as PiEvent, r as PiCliAgentOptions } from "./index-
|
|
1
|
+
import { C as TextContentPart, S as McpServerConfig, 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 agentCapabilitiesSchema, x as JsonSchema, y as ContentPart } from "./events-BF6ELG7c.mjs";
|
|
2
|
+
import { C as StopReason, D as PermissionHandler, E as PermissionDecision, O as PermissionRequest, S as RunTiming, T as ZodRunRequest, _ as RunProcessInfo, a as AgentValidationError, b as RunStats, c as AnyRunResult, d as CompletedRunResult, 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 StructuredRunRequest, x as RunStatus, y as RunResult } from "./types-BQeZnkDv.mjs";
|
|
3
|
+
import { A as VolumeMount, C as DockerContainer, D as ExecOptions, E as ContainerType, F as WorkdirSnapshot, I as WorkdirSnapshotOptions, M as WorkdirDiff, N as WorkdirDiffStats, O as ExecResult, P as WorkdirFileChange, S as E2BProviderConfig, T as ContainerStatus, _ as E2BConnectConfig, a as ContainerDiffError, b as E2BContainerConfig, c as ContainerExecError, d as MountValidationError, f as PodmanContainer, g as NerdctlProviderConfig, h as NerdctlContainerConfig, i as ContainerCreateError, j as WorkdirChangeKind, k as PortMapping, l as ContainerNotRunningError, m as NerdctlContainer, n as ContainerConfig, o as ContainerDisposedError, p as PodmanContainerConfig, r as createContainer, s as ContainerError, t as Container, u as ContainerStartError, v as E2BConnectionConfig, w as DockerContainerConfig, x as E2BCreateConfig, y as E2BContainer } from "./index-CGMqyNOd.mjs";
|
|
4
|
+
import { a as FirejailSandbox, c as NsjailSandboxConfig, d as SandboxStatus, f as SandboxType, i as BubblewrapSandboxConfig, l as Sandbox, n as createSandbox, o as FirejailSandboxConfig, r as BubblewrapSandbox, s as NsjailSandbox, t as SandboxCreateError, u as SandboxConfig } from "./index-ByyejuZo.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-CAWun0L4.mjs";
|
|
6
|
+
import { a as ClaudeCodeCliPtyPermissionMode, i as ClaudeCodeCliPtyModule, n as ClaudeCodeCliPtyAgent, o as ClaudeCodeCliPtyProcess, r as ClaudeCodeCliPtyAgentOptions, s as ClaudeCodeCliPtyRunOptions } from "./index-GW5zKifI.mjs";
|
|
7
|
+
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-CW1kBJ3d.mjs";
|
|
8
|
+
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-62Ld65Q8.mjs";
|
|
9
|
+
import { a as CodexSdkItem, i as CodexSdkEvent, n as CodexSdkAgent, o as CodexSdkPermissionMode, r as CodexSdkAgentOptions, s as CodexSdkRunOptions } from "./index-68ih5kFM.mjs";
|
|
10
|
+
import { a as CursorCliRunOptions, i as CursorCliPermissionMode, n as CursorCliAgent, o as CursorCliSandboxMode, r as CursorCliAgentOptions, s as CursorCliEvent } from "./index-CPnH6YAO.mjs";
|
|
11
|
+
import { a as CursorSdkMcpHttpAuth, c as CursorSdkSettingSource, i as CursorSdkEvent, n as CursorSdkAgent, o as CursorSdkMcpServerConfig, r as CursorSdkAgentOptions, s as CursorSdkRunOptions } from "./index-DwlwQ9R0.mjs";
|
|
12
|
+
import { a as GeminiCliRunOptions, i as GeminiCliPermissionMode, n as GeminiCliAgent, o as GeminiEvent, r as GeminiCliAgentOptions } from "./index-DzfIudMp.mjs";
|
|
13
|
+
import { a as OpencodeEvent, i as OpencodeCliRunOptions, n as OpencodeCliAgent, r as OpencodeCliAgentOptions } from "./index-DCbDnTQ_.mjs";
|
|
14
|
+
import { a as PiCliThinkingLevel, i as PiCliRunOptions, n as PiCliAgent, o as PiEvent, r as PiCliAgentOptions } from "./index-CzvAiGC9.mjs";
|
|
15
15
|
//#region src/core/agent/create-agent.d.ts
|
|
16
16
|
interface AgentOptionsByType {
|
|
17
17
|
"claude-code-cli-pty": ClaudeCodeCliPtyAgentOptions;
|
|
@@ -77,4 +77,4 @@ declare function createAgent(type: "opencode-cli", options?: OpencodeCliAgentOpt
|
|
|
77
77
|
declare function createAgent(type: "pi-cli", options?: PiCliAgentOptions): Promise<PiCliAgent>;
|
|
78
78
|
declare function createAgent<T extends AgentType>(type: T, options?: AgentOptionsByType[T]): Promise<AgentInstanceByType[T]>;
|
|
79
79
|
//#endregion
|
|
80
|
-
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 ClaudeCodeCliPtyAgent, type ClaudeCodeCliPtyAgentOptions, type ClaudeCodeCliPtyModule, type ClaudeCodeCliPtyPermissionMode, type ClaudeCodeCliPtyProcess, type ClaudeCodeCliPtyRunOptions, 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
|
|
80
|
+
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 ClaudeCodeCliPtyAgent, type ClaudeCodeCliPtyAgentOptions, type ClaudeCodeCliPtyModule, type ClaudeCodeCliPtyPermissionMode, type ClaudeCodeCliPtyProcess, type ClaudeCodeCliPtyRunOptions, 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 ContainerConfig, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotRunningError, ContainerStartError, type ContainerStatus, type ContainerType, type ContentPart, type CursorCliAgent, type CursorCliAgentOptions, type CursorCliEvent, type CursorCliPermissionMode, type CursorCliRunOptions, type CursorCliSandboxMode, type CursorSdkAgent, type CursorSdkAgentOptions, type CursorSdkEvent, type CursorSdkMcpHttpAuth, type CursorSdkMcpServerConfig, type CursorSdkRunOptions, type CursorSdkSettingSource, type DockerContainer, type DockerContainerConfig, type E2BConnectConfig, type E2BConnectionConfig, type E2BContainer, type E2BContainerConfig, type E2BCreateConfig, type E2BProviderConfig, 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, MountValidationError, type NerdctlContainer, type NerdctlContainerConfig, type NerdctlProviderConfig, type NsjailSandbox, type NsjailSandboxConfig, type OpencodeCliAgent, type OpencodeCliAgentOptions, type OpencodeCliRunOptions, type OpencodeEvent, type PermissionDecision, type PermissionHandler, type PermissionRequest, type PiCliAgent, type PiCliAgentOptions, type PiCliRunOptions, type PiCliThinkingLevel, type PiEvent, type PodmanContainer, type PodmanContainerConfig, type PortMapping, type ReasoningEvent, type RunError, type RunProcessInfo, type RunRequest, type RunResult, type RunStats, type RunStatus, type RunTiming, type Sandbox, type SandboxConfig, SandboxCreateError, 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 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./types-B72tDMEZ.mjs";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./container-
|
|
1
|
+
import{n as e,t}from"./types-B72tDMEZ.mjs";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./container-D5P0tyx7.mjs";import{n as d,t as f}from"./sandbox-DQWTg5YL.mjs";import{n as p,u as m}from"./schemas-CkdQXAep.mjs";const h=(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`},g=(t,n,r)=>{throw h(r,n)?new e(`Agent type "${t}" requires the optional peer dependency "${n}". Install it to use this adapter.`):r};async function _(t,n){switch(t){case`claude-code-cli-pty`:{let{createClaudeCodeCliPtyAgent:e}=await import(`./adapters/claude-code-cli-pty/index.mjs`);return e(n)}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 g(`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 g(`codex-sdk`,`@openai/codex-sdk`,e)}}case`cursor-cli`:{let{createCursorCliAgent:e}=await import(`./adapters/cursor-cli/index.mjs`);return e(n)}case`cursor-sdk`:{let e=n;try{let{createCursorSdkAgent:t}=await import(`./adapters/cursor-sdk/index.mjs`);return t(e)}catch(e){return g(`cursor-sdk`,`@cursor/sdk`,e)}}case`gemini-cli`:{let{createGeminiCliAgent:e}=await import(`./adapters/gemini-cli/index.mjs`);return e(n)}case`opencode-cli`:{let{createOpencodeCliAgent:e}=await import(`./adapters/opencode-cli/index.mjs`);return e(n)}case`pi-cli`:{let{createPiCliAgent:e}=await import(`./adapters/pi-cli/index.mjs`);return e(n)}default:throw new e(`Unsupported agent type.`)}}export{t as AgentRunError,e as AgentValidationError,o as ContainerCreateError,c as ContainerDiffError,i as ContainerDisposedError,n as ContainerError,s as ContainerExecError,l as ContainerNotRunningError,r as ContainerStartError,a as MountValidationError,f as SandboxCreateError,m as agentCapabilitiesSchema,_ as createAgent,u as createContainer,d as createSandbox,p as eventSchema};
|