coding-agents-sdk 0.13.0 → 0.14.1
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 +19 -2
- 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-46QA1d3v.mjs → container-B3SrSQYp.mjs} +1 -1
- package/dist/{container-DBXaA-Iv.mjs → container-B5suwmUQ.mjs} +1 -1
- package/dist/{container-DRj7xq5x.mjs → container-BH5So6E_.mjs} +1 -1
- package/dist/{container-gJ8B-Z5B.mjs → container-BPllAKd8.mjs} +1 -1
- package/dist/{container-Dg68bfte.mjs → container-DQzVZjLd.mjs} +1 -1
- package/dist/diff-Bh8JPwVM.mjs +1 -0
- package/dist/{events-B0BpIsW2.d.mts → events-BxEB6zHt.d.mts} +7 -10
- package/dist/{index-C9XD71QR.d.mts → index-BQwDFirP.d.mts} +2 -25
- package/dist/{index-CG2m7pFJ.d.mts → index-BXgvYZSv.d.mts} +10 -1
- package/dist/{index-DdyD2ji1.d.mts → index-CGGPY1qE.d.mts} +3 -2
- package/dist/{index-BKK-3gye.d.mts → index-CSfb-Q3A.d.mts} +29 -16
- package/dist/{index-BQ8cUo2i.d.mts → index-CSty5NNW.d.mts} +39 -29
- package/dist/{index-B5NFoNlS.d.mts → index-C_WwuF3E.d.mts} +3 -4
- package/dist/{index-XWqpUSBc.d.mts → index-Cxegh1Rs.d.mts} +27 -17
- package/dist/{index-DPP4zoiJ.d.mts → index-D1IlwEGE.d.mts} +23 -14
- package/dist/{index-B9ze9hTN.d.mts → index-Dm9HCmWK.d.mts} +3 -2
- package/dist/{index-CG5DS_NB.d.mts → index-TzOW2t1h.d.mts} +20 -12
- package/dist/{index-DzFF15zC.d.mts → index-f1x-Ugwa.d.mts} +26 -16
- package/dist/{index-5bx9TIY_.d.mts → index-tmvnx5wp.d.mts} +22 -13
- package/dist/index.d.mts +16 -15
- package/dist/index.mjs +1 -1
- package/dist/{oci-DmEG3Ia3.mjs → oci-C5y_whHx.mjs} +1 -1
- package/dist/{parser-DNYBLV_4.mjs → parser-CTagqQyR.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-Bfzi3RU4.mjs +1 -0
- package/dist/{types-CGzSzwfB.d.mts → types-CeIQCAFV.d.mts} +24 -9
- package/package.json +29 -16
- package/dist/Agent-4TZ8JK66.mjs +0 -4
- package/dist/diff-BJWXJsjx.mjs +0 -1
- package/dist/spawner-BB6W3FVi.mjs +0 -1
- package/dist/structured-output-DsMPRckW.mjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n}from"../../util-DcPzh_0u.mjs";import{c as r,l as i,
|
|
1
|
+
import{a as e,i 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=e=>{if(typeof e==`string`)return e;if(e===null)return``;try{return JSON.stringify(e)}catch{return String(e)}},p=()=>crypto.randomUUID(),m=()=>({steps:0,cost:0,inputTokens:0,outputTokens:0,reasoningTokens:0,cacheReadTokens:0,cacheWriteTokens:0}),h=e=>{let t=e;return u(t.sessionID)??u(t.session_id)},g=(e,t)=>{let r=n(e.part)?e.part:void 0,i=u(r?.text)??``;return i.trim()?{events:[a(t.runId,`message`,{sessionId:t.sessionId,model:null,role:`assistant`,content:[o(i)],text:i})]}:{events:[]}},_=(e,t)=>{let r=n(e.part)?e.part:void 0,i=u(r?.text)??``;return i.trim()?{events:[a(t.runId,`reasoning`,{sessionId:t.sessionId,model:null,content:[o(i)],text:i})]}:{events:[]}},v=(e,t)=>{let r=n(e.part)?e.part:void 0;if(!r)return{events:[]};let i=u(r.callID)??p(),o=u(r.tool)??`tool`,s=n(r.state)?r.state:void 0;if(!s)return{events:[]};let c=n(s.input)?s.input:void 0,l=s.status===`error`,d=l?u(s.error)??f(s.output)??`Tool call failed.`:f(s.output);return{events:[a(t.runId,`tool-call`,{sessionId:t.sessionId,model:null,toolCallId:i,toolName:o,input:c}),a(t.runId,`tool-result`,{sessionId:t.sessionId,toolCallId:i,toolName:o,input:c,output:d,isError:l||void 0,error:l?d:void 0})],toolCalls:[{toolCallId:i,toolName:o,input:c}]}},y=(e,r,i)=>{let a=n(e.part)?e.part:void 0;if(!a)return{events:[]};let o=u(a.reason),s=d(a.cost)??0,c=n(a.tokens)?a.tokens:void 0,l=n(c?.cache)?c.cache:void 0;return i.steps+=1,i.cost+=s,i.inputTokens+=d(c?.input)??0,i.outputTokens+=d(c?.output)??0,i.reasoningTokens+=d(c?.reasoning)??0,i.cacheReadTokens+=d(l?.read)??0,i.cacheWriteTokens+=d(l?.write)??0,o===`stop`?{events:[],state:{stats:{turns:i.steps,costUsd:i.cost,inputTokens:i.inputTokens,outputTokens:i.outputTokens,reasoningOutputTokens:i.reasoningTokens,cacheReadInputTokens:i.cacheReadTokens,cacheCreationInputTokens:i.cacheWriteTokens,totalTokens:t(i.inputTokens,i.outputTokens,i.cacheReadTokens,i.cacheWriteTokens)},status:`completed`}}:{events:[]}},b=(e,t)=>{let r=n(e.error)?e.error:void 0,i=n(r?.data)?r.data:void 0,o=u(i?.message)??u(r?.message)??u(r?.name)??`unknown error`;return{events:[a(t.runId,`stderr`,{sessionId:t.sessionId,text:o})],state:{status:`failed`,error:{kind:`provider`,message:o}}}},x=(e,t,n)=>{let r=e;switch(e.type){case`text`:return g(r,t);case`reasoning`:return _(r,t);case`tool_use`:return v(r,t);case`step_finish`:return y(r,t,n);case`error`:return b(r,t);default:return{events:[]}}},S=r(l.object({type:l.string()}).passthrough()),C={structuredOutput:!1,sessionResume:!0,sessionFork:!0,imageInput:!1,mcp:!0,eventStreaming:!0};var w=class extends c{type=`opencode-cli`;creationOptions;runDefaults;stepAccumulators=new Map;constructor(t={}){super({type:`opencode-cli`,capabilities:C,defaults:{cwd:t.cwd,env:t.env,command:e(t.command??`opencode`),sessionId:t.sessionId,model:t.model},spawner:t.spawner,executionTarget:t.container??t.sandbox,logPath:t.logPath,onEvent:t.onEvent}),this.creationOptions=t,this.runDefaults={agent:t.agent,files:t.files?[...t.files]:void 0,forkSession:t.forkSession,share:t.share,thinking:t.thinking,title:t.title,variant:t.variant,extraArgs:t.extraArgs?[...t.extraArgs]:void 0}}buildArgs(e,t){let n=[`run`,`--format`,`json`],r=i(e.input),a=e.agent??this.runDefaults.agent,o=e.files??this.runDefaults.files,s=e.forkSession??this.runDefaults.forkSession,c=e.share??this.runDefaults.share,l=e.thinking??this.runDefaults.thinking,u=e.title??this.runDefaults.title,d=e.variant??this.runDefaults.variant,f=e.extraArgs??this.runDefaults.extraArgs;if(e.model&&n.push(`--model`,e.model),a&&n.push(`--agent`,a),o&&o.length>0)for(let e of o)n.push(`--file`,e);return t.requestedSessionId&&(n.push(`--session`,t.requestedSessionId),s&&n.push(`--fork`)),c&&n.push(`--share`),l&&n.push(`--thinking`),u!==void 0&&n.push(`--title`,u),d&&n.push(`--variant`,d),f&&f.length>0&&n.push(...f),n.push(`--`,r),n}buildEnv(e,t){return this.buildDefaultEnv(this.creationOptions.propagateEnv)}mapRawEvent(e,t){this.appendRawLog(e);let n=S(e);if(!n)return this.onParseError(JSON.stringify(e).slice(0,200),Error(`schema validation failed`)),{events:[]};let r=h(n)??t.sessionId,i=this.stepAccumulators.get(t.runId);i||(i=m(),this.stepAccumulators.set(t.runId,i));let a=x(n,{...t,sessionId:r},i);return r&&a.sessionId===void 0&&(a.sessionId=r),a}async onRunFinished(e){await super.onRunFinished(e),this.stepAccumulators.delete(e.runId)}};const T=e=>new w(s(e));export{T as createOpencodeCliAgent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as PiCliThinkingLevel, i as PiCliRunOptions, n as PiCliAgent, o as PiEvent, r as PiCliAgentOptions, t as createPiCliAgent } from "../../index-
|
|
1
|
+
import { a as PiCliThinkingLevel, i as PiCliRunOptions, n as PiCliAgent, o as PiEvent, r as PiCliAgentOptions, t as createPiCliAgent } from "../../index-D1IlwEGE.mjs";
|
|
2
2
|
export { type PiCliAgent, type PiCliAgentOptions, type PiCliRunOptions, type PiCliThinkingLevel, type PiEvent, createPiCliAgent };
|
|
@@ -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=this.runAccumulatedStats.get(t.runId),n=E(e,a.state.stats);this.runAccumulatedStats.set(t.runId,n),a.state.stats=n}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-BQwDFirP.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-B5suwmUQ.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-C5y_whHx.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
|
-
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-B3SrSQYp.mjs`);return t(e)}case`e2b`:try{let{createE2BContainer:t}=await import(`./container-BH5So6E_.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-BPllAKd8.mjs`);return t(e)}case`podman`:{let{createPodmanContainer:t}=await import(`./container-DQzVZjLd.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{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-B5suwmUQ.mjs";import{t as o}from"./shell-DvWFuFKb.mjs";import{n as s}from"./diff-Bh8JPwVM.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},i=await c.commands.run(b(e,t),r);return G(i,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
|
-
import{n as e,t}from"./oci-
|
|
1
|
+
import{n as e,t}from"./oci-C5y_whHx.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-C5y_whHx.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-DcPzh_0u.mjs";import{i as t,r as n,s as r}from"./container-B5suwmUQ.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{let e=await E(`git`,[`diff`,`--no-index`,`-z`,`--name-status`,`-M`,`--find-renames=100%`,t,r],{cwd:p(),encoding:`buffer`,maxBuffer:50*1024*1024});return V(R(e.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,i=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}}));return A(i)},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 H(a.tempDir,o),n=await U(t,a.tempDir,o),r=W(n);return{cwd:a.cwd,changedFiles:r,fileChanges:n,stats:{durationMs:Date.now()-i,filesCompared:r.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=>{let r=F(e.owner,t,n);await a(r)},disposeSnapshots:async()=>{await Promise.all(Array.from(t).map(a))}}};export{q as n,T as r,K as t};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ZodType, z } from "zod/v4";
|
|
2
|
-
|
|
3
2
|
//#region src/schemas/agent.d.ts
|
|
4
3
|
/** Plain text content block in a {@link ContentPart} array. */
|
|
5
4
|
declare const textContentPartSchema: z.ZodObject<{
|
|
@@ -63,8 +62,6 @@ declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
|
63
62
|
type AgentCapabilities = z.infer<typeof agentCapabilitiesSchema>;
|
|
64
63
|
/** JSON Schema (Draft 7+) object, or a value produced by `z.toJSONSchema(...)`. */
|
|
65
64
|
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
65
|
/**
|
|
69
66
|
* Common shape for MCP (Model Context Protocol) server configurations passed
|
|
70
67
|
* through to adapters. Adapters interpret the fields as needed — most accept
|
|
@@ -125,8 +122,8 @@ declare const messageEventSchema: z.ZodObject<{
|
|
|
125
122
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
126
123
|
model: z.ZodNullable<z.ZodString>;
|
|
127
124
|
role: z.ZodEnum<{
|
|
128
|
-
system: "system";
|
|
129
125
|
assistant: "assistant";
|
|
126
|
+
system: "system";
|
|
130
127
|
user: "user";
|
|
131
128
|
}>;
|
|
132
129
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -247,9 +244,9 @@ declare const sessionEndEventSchema: z.ZodObject<{
|
|
|
247
244
|
type: z.ZodLiteral<"session-end">;
|
|
248
245
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
249
246
|
status: z.ZodEnum<{
|
|
250
|
-
failed: "failed";
|
|
251
|
-
completed: "completed";
|
|
252
247
|
cancelled: "cancelled";
|
|
248
|
+
completed: "completed";
|
|
249
|
+
failed: "failed";
|
|
253
250
|
}>;
|
|
254
251
|
error: z.ZodOptional<z.ZodString>;
|
|
255
252
|
}, z.core.$strip>;
|
|
@@ -289,8 +286,8 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
289
286
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
290
287
|
model: z.ZodNullable<z.ZodString>;
|
|
291
288
|
role: z.ZodEnum<{
|
|
292
|
-
system: "system";
|
|
293
289
|
assistant: "assistant";
|
|
290
|
+
system: "system";
|
|
294
291
|
user: "user";
|
|
295
292
|
}>;
|
|
296
293
|
content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -354,9 +351,9 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
354
351
|
type: z.ZodLiteral<"session-end">;
|
|
355
352
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
356
353
|
status: z.ZodEnum<{
|
|
357
|
-
failed: "failed";
|
|
358
|
-
completed: "completed";
|
|
359
354
|
cancelled: "cancelled";
|
|
355
|
+
completed: "completed";
|
|
356
|
+
failed: "failed";
|
|
360
357
|
}>;
|
|
361
358
|
error: z.ZodOptional<z.ZodString>;
|
|
362
359
|
}, z.core.$strip>], "type">;
|
|
@@ -376,4 +373,4 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
376
373
|
*/
|
|
377
374
|
type AgentEvent = z.infer<typeof eventSchema>;
|
|
378
375
|
//#endregion
|
|
379
|
-
export {
|
|
376
|
+
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,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { k as ProcessSpawner } from "./types-CeIQCAFV.mjs";
|
|
3
2
|
//#region src/container/types.d.ts
|
|
4
3
|
/** Which provider backs a container. Selects which CLI/SDK the adapter speaks. */
|
|
5
4
|
type ContainerType = "docker" | "e2b" | "nerdctl" | "podman";
|
|
@@ -188,14 +187,6 @@ type OciProviderConfig = OciProviderBase & ({
|
|
|
188
187
|
});
|
|
189
188
|
//#endregion
|
|
190
189
|
//#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
190
|
/** Full config passed to `createContainer({ type: "docker", ... })`. */
|
|
200
191
|
type DockerContainerConfig = ContainerConfigBase<"docker"> & OciProviderConfig;
|
|
201
192
|
/** Docker container instance. */
|
|
@@ -280,12 +271,6 @@ interface E2BContainer extends ContainerBase<"e2b", E2BContainerConfig> {
|
|
|
280
271
|
}
|
|
281
272
|
//#endregion
|
|
282
273
|
//#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
274
|
/** Provider-specific fields for nerdctl, layered on top of generic OCI provider options. */
|
|
290
275
|
interface NerdctlProviderBase extends OciProviderBase {
|
|
291
276
|
/** containerd namespace. Defaults to `"default"`. */
|
|
@@ -310,14 +295,6 @@ interface NerdctlContainer extends ContainerBase<"nerdctl", NerdctlContainerConf
|
|
|
310
295
|
}
|
|
311
296
|
//#endregion
|
|
312
297
|
//#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
298
|
/** Full config passed to `createContainer({ type: "podman", ... })`. */
|
|
322
299
|
type PodmanContainerConfig = ContainerConfigBase<"podman"> & OciProviderConfig;
|
|
323
300
|
/** Podman container instance. */
|
|
@@ -426,4 +403,4 @@ declare function createContainer(config: E2BContainerConfig): Promise<E2BContain
|
|
|
426
403
|
declare function createContainer(config: NerdctlContainerConfig): Promise<NerdctlContainer>;
|
|
427
404
|
declare function createContainer(config: PodmanContainerConfig): Promise<PodmanContainer>;
|
|
428
405
|
//#endregion
|
|
429
|
-
export {
|
|
406
|
+
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,4 +1,5 @@
|
|
|
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-CeIQCAFV.mjs";
|
|
2
|
+
import "@openai/codex-sdk";
|
|
2
3
|
//#region src/adapters/codex-sdk/types.d.ts
|
|
3
4
|
type CodexSdkSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
4
5
|
type CodexSdkModelReasoningEffort = "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
@@ -16,10 +17,18 @@ type CodexSdkConfigObject = {
|
|
|
16
17
|
* - `"untrusted"`: prompt for every potentially destructive action (most restrictive).
|
|
17
18
|
*/
|
|
18
19
|
type CodexSdkPermissionMode = "never" | "on-failure" | "on-request" | "untrusted";
|
|
20
|
+
/**
|
|
21
|
+
* Token counts for a completed turn, as reported by Codex.
|
|
22
|
+
*
|
|
23
|
+
* `cached_input_tokens` and `cache_write_input_tokens` are subsets of `input_tokens`, and
|
|
24
|
+
* `reasoning_output_tokens` a subset of `output_tokens`; summing them double-counts.
|
|
25
|
+
*/
|
|
19
26
|
interface CodexSdkUsage {
|
|
20
27
|
input_tokens: number;
|
|
21
28
|
cached_input_tokens: number;
|
|
29
|
+
cache_write_input_tokens: number;
|
|
22
30
|
output_tokens: number;
|
|
31
|
+
reasoning_output_tokens: number;
|
|
23
32
|
}
|
|
24
33
|
interface CodexSdkCommandExecutionItem {
|
|
25
34
|
id: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
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-CeIQCAFV.mjs";
|
|
2
|
+
import "@cursor/sdk";
|
|
2
3
|
//#region src/adapters/cursor-sdk/types.d.ts
|
|
3
4
|
/** OAuth-style credentials for HTTP/SSE MCP servers configured for the agent. */
|
|
4
5
|
interface CursorSdkMcpHttpAuth {
|
|
@@ -190,4 +191,4 @@ interface CursorSdkAgent extends BaseAgent<EnsureDisjoint<CursorSdkRunOptions>>
|
|
|
190
191
|
//#region src/adapters/cursor-sdk/adapter.d.ts
|
|
191
192
|
declare const createCursorSdkAgent: (options?: CursorSdkAgentOptions) => CursorSdkAgent;
|
|
192
193
|
//#endregion
|
|
193
|
-
export { CursorSdkMcpHttpAuth as a,
|
|
194
|
+
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,9 +1,8 @@
|
|
|
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-BxEB6zHt.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-CeIQCAFV.mjs";
|
|
3
|
+
import { t as Container } from "./index-BQwDFirP.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-C_WwuF3E.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
|
-
|
|
7
6
|
//#region src/adapters/codex-cli/events/schemas.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Permissive shape for any raw event Codex CLI emits — `{ type: string }`
|
|
@@ -26,6 +25,7 @@ declare const codexTurnCompletedEventSchema: z.ZodObject<{
|
|
|
26
25
|
usage: z.ZodOptional<z.ZodObject<{
|
|
27
26
|
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
28
27
|
cached_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
cache_write_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
29
29
|
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
30
30
|
reasoning_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
31
31
|
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
@@ -40,6 +40,7 @@ declare const codexTurnFailedEventSchema: z.ZodObject<{
|
|
|
40
40
|
usage: z.ZodOptional<z.ZodObject<{
|
|
41
41
|
input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
42
42
|
cached_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
cache_write_input_tokens: z.ZodOptional<z.ZodNumber>;
|
|
43
44
|
output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
44
45
|
reasoning_output_tokens: z.ZodOptional<z.ZodNumber>;
|
|
45
46
|
total_tokens: z.ZodOptional<z.ZodNumber>;
|
|
@@ -93,13 +94,16 @@ type CodexCliSandboxMode = "danger-full-access" | "read-only" | "workspace-write
|
|
|
93
94
|
/**
|
|
94
95
|
* How Codex CLI handles approval prompts.
|
|
95
96
|
* - `"default"`: leave Codex CLI's own default approval behavior in place (this adapter does not bridge approvals to a permission handler).
|
|
96
|
-
* - `"auto-approve"`: pass `--
|
|
97
|
-
* - `"bypass-sandbox"`: pass `--dangerously-bypass-approvals-and-sandbox`;
|
|
97
|
+
* - `"auto-approve"`: pass `--approve-for-me`; Codex uses automatic review in the `workspace-write` sandbox.
|
|
98
|
+
* - `"bypass-sandbox"`: pass `--dangerously-bypass-approvals-and-sandbox`; disable approvals and Codex's sandbox for externally isolated execution.
|
|
98
99
|
*/
|
|
99
100
|
type CodexCliPermissionMode = "auto-approve" | "bypass-sandbox" | "default";
|
|
100
101
|
/** Per-run options for the `codex-cli` adapter. */
|
|
101
102
|
interface CodexCliRunOptions {
|
|
102
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Filesystem sandbox policy for the default approval strategy.
|
|
105
|
+
* Other permission modes select their own sandbox behavior.
|
|
106
|
+
*/
|
|
103
107
|
sandboxMode?: CodexCliSandboxMode;
|
|
104
108
|
/** Extra directories outside `cwd` writable under `workspace-write`. */
|
|
105
109
|
additionalDirectories?: string[];
|
|
@@ -120,14 +124,23 @@ interface CodexCliRunOptions {
|
|
|
120
124
|
}
|
|
121
125
|
/** Constructor options for `createAgent("codex-cli", ...)`. */
|
|
122
126
|
type CodexCliAgentOptions = CodexCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
123
|
-
/** Path or argv to the `codex` binary. */
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
/** Path or argv to the `codex` binary. */
|
|
128
|
+
command?: string[] | string;
|
|
129
|
+
/** Working directory the agent operates against. */
|
|
130
|
+
cwd?: string;
|
|
131
|
+
/** Environment variables for the subprocess. Layered on top of host env when `propagateEnv` is `true` (default). */
|
|
132
|
+
env?: Record<string, string>;
|
|
133
|
+
/** Default `true`: `process.env` is inherited and `env` overlays it. Set `false` to suppress host-env propagation. */
|
|
134
|
+
propagateEnv?: boolean;
|
|
135
|
+
/** Existing Codex thread ID to resume via `codex resume`. */
|
|
136
|
+
sessionId?: string;
|
|
137
|
+
/** Codex model identifier. */
|
|
138
|
+
model?: string;
|
|
139
|
+
/** File path to write the raw CLI log to (useful for debugging). */
|
|
140
|
+
logPath?: string;
|
|
141
|
+
/** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
142
|
+
spawner?: ProcessSpawner;
|
|
143
|
+
/** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
131
144
|
onEvent?: AgentEventHandler;
|
|
132
145
|
};
|
|
133
146
|
/** Agent instance returned by `createAgent("codex-cli", ...)`. */
|
|
@@ -1,20 +1,19 @@
|
|
|
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-BxEB6zHt.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, k as ProcessSpawner, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-CeIQCAFV.mjs";
|
|
3
|
+
import { t as Container } from "./index-BQwDFirP.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-C_WwuF3E.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
|
-
|
|
7
6
|
//#region src/adapters/claude-code-cli/events/schemas.d.ts
|
|
8
7
|
declare const claudeSystemEventSchema: z.ZodObject<{
|
|
9
8
|
type: z.ZodLiteral<"system">;
|
|
10
9
|
session_id: z.ZodString;
|
|
11
10
|
subtype: z.ZodEnum<{
|
|
12
|
-
init: "init";
|
|
13
|
-
hook_response: "hook_response";
|
|
14
|
-
hook_started: "hook_started";
|
|
15
|
-
hook_finished: "hook_finished";
|
|
16
11
|
hook_failed: "hook_failed";
|
|
12
|
+
hook_finished: "hook_finished";
|
|
13
|
+
hook_response: "hook_response";
|
|
17
14
|
hook_skipped: "hook_skipped";
|
|
15
|
+
hook_started: "hook_started";
|
|
16
|
+
init: "init";
|
|
18
17
|
}>;
|
|
19
18
|
uuid: z.ZodString;
|
|
20
19
|
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -60,10 +59,10 @@ declare const claudeAssistantEventSchema: z.ZodObject<{
|
|
|
60
59
|
signature: z.ZodOptional<z.ZodString>;
|
|
61
60
|
}, z.core.$strip>]>>;
|
|
62
61
|
stop_reason: z.ZodNullable<z.ZodEnum<{
|
|
63
|
-
tool_use: "tool_use";
|
|
64
62
|
end_turn: "end_turn";
|
|
65
63
|
max_tokens: "max_tokens";
|
|
66
64
|
stop_sequence: "stop_sequence";
|
|
65
|
+
tool_use: "tool_use";
|
|
67
66
|
}>>;
|
|
68
67
|
stop_sequence: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
68
|
context_management: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
@@ -109,9 +108,9 @@ declare const claudeResultEventSchema: z.ZodObject<{
|
|
|
109
108
|
session_id: z.ZodString;
|
|
110
109
|
uuid: z.ZodString;
|
|
111
110
|
subtype: z.ZodEnum<{
|
|
112
|
-
success: "success";
|
|
113
|
-
error_max_turns: "error_max_turns";
|
|
114
111
|
error_during_execution: "error_during_execution";
|
|
112
|
+
error_max_turns: "error_max_turns";
|
|
113
|
+
success: "success";
|
|
115
114
|
}>;
|
|
116
115
|
duration_ms: z.ZodNumber;
|
|
117
116
|
duration_api_ms: z.ZodNumber;
|
|
@@ -155,12 +154,12 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
155
154
|
type: z.ZodLiteral<"system">;
|
|
156
155
|
session_id: z.ZodString;
|
|
157
156
|
subtype: z.ZodEnum<{
|
|
158
|
-
init: "init";
|
|
159
|
-
hook_response: "hook_response";
|
|
160
|
-
hook_started: "hook_started";
|
|
161
|
-
hook_finished: "hook_finished";
|
|
162
157
|
hook_failed: "hook_failed";
|
|
158
|
+
hook_finished: "hook_finished";
|
|
159
|
+
hook_response: "hook_response";
|
|
163
160
|
hook_skipped: "hook_skipped";
|
|
161
|
+
hook_started: "hook_started";
|
|
162
|
+
init: "init";
|
|
164
163
|
}>;
|
|
165
164
|
uuid: z.ZodString;
|
|
166
165
|
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
@@ -204,10 +203,10 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
204
203
|
signature: z.ZodOptional<z.ZodString>;
|
|
205
204
|
}, z.core.$strip>]>>;
|
|
206
205
|
stop_reason: z.ZodNullable<z.ZodEnum<{
|
|
207
|
-
tool_use: "tool_use";
|
|
208
206
|
end_turn: "end_turn";
|
|
209
207
|
max_tokens: "max_tokens";
|
|
210
208
|
stop_sequence: "stop_sequence";
|
|
209
|
+
tool_use: "tool_use";
|
|
211
210
|
}>>;
|
|
212
211
|
stop_sequence: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
213
212
|
context_management: z.ZodOptional<z.ZodNullable<z.ZodUnknown>>;
|
|
@@ -249,9 +248,9 @@ declare const claudeEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
249
248
|
session_id: z.ZodString;
|
|
250
249
|
uuid: z.ZodString;
|
|
251
250
|
subtype: z.ZodEnum<{
|
|
252
|
-
success: "success";
|
|
253
|
-
error_max_turns: "error_max_turns";
|
|
254
251
|
error_during_execution: "error_during_execution";
|
|
252
|
+
error_max_turns: "error_max_turns";
|
|
253
|
+
success: "success";
|
|
255
254
|
}>;
|
|
256
255
|
duration_ms: z.ZodNumber;
|
|
257
256
|
duration_api_ms: z.ZodNumber;
|
|
@@ -316,16 +315,27 @@ interface ClaudeCodeCliRunOptions {
|
|
|
316
315
|
}
|
|
317
316
|
/** Constructor options for `createAgent("claude-code-cli", ...)`. */
|
|
318
317
|
type ClaudeCodeCliAgentOptions = ClaudeCodeCliRunOptions & ExclusiveExecutionTargetOptions<Container, Sandbox> & {
|
|
319
|
-
/** Path or argv to the `claude` binary. Defaults to looking up `claude` on `PATH`. */
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
318
|
+
/** Path or argv to the `claude` binary. Defaults to looking up `claude` on `PATH`. */
|
|
319
|
+
command?: string[] | string;
|
|
320
|
+
/** Working directory the agent operates against. */
|
|
321
|
+
cwd?: string;
|
|
322
|
+
/** Environment variables for the subprocess. */
|
|
323
|
+
env?: Record<string, string>;
|
|
324
|
+
/** Inherit `process.env` and overlay `env` on top, instead of replacing. */
|
|
325
|
+
propagateEnv?: boolean;
|
|
326
|
+
/** Existing session ID to resume via `--resume`. */
|
|
327
|
+
sessionId?: string;
|
|
328
|
+
/** Model identifier (e.g. `"claude-sonnet-4-6"`). */
|
|
329
|
+
model?: string;
|
|
330
|
+
/** Replaces the default system prompt entirely. */
|
|
331
|
+
systemPrompt?: string;
|
|
332
|
+
/** File path to write the raw CLI log to (useful for debugging). */
|
|
333
|
+
logPath?: string;
|
|
334
|
+
/** Sets `CI=true` in the subprocess env unless explicitly `false`. Default: `true`. Does not change Claude Code's output formatting on its own. */
|
|
335
|
+
ci?: boolean;
|
|
336
|
+
/** Custom process spawner; set by `createContainer`/`createSandbox`, rarely needed manually. */
|
|
337
|
+
spawner?: ProcessSpawner;
|
|
338
|
+
/** Convenience: equivalent to calling `agent.onEvent(handler)` post-construction. */
|
|
329
339
|
onEvent?: AgentEventHandler;
|
|
330
340
|
};
|
|
331
341
|
/** Agent instance returned by `createAgent("claude-code-cli", ...)`. */
|