coding-agents-sdk 0.18.0 → 0.21.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 +292 -7
- package/dist/Agent-BsDJsgJa.mjs +4 -0
- package/dist/SdkAgent-jwighP_b.mjs +1 -0
- package/dist/adapters/antigravity-cli/index.d.mts +2 -0
- package/dist/adapters/antigravity-cli/index.mjs +2 -0
- package/dist/adapters/claude-code-cli/index.d.mts +2 -2
- 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 +4 -2
- package/dist/adapters/codex-sdk/index.d.mts +1 -1
- package/dist/adapters/codex-sdk/index.mjs +1 -1
- package/dist/adapters/cursor-cli/index.d.mts +1 -1
- package/dist/adapters/cursor-cli/index.mjs +1 -1
- package/dist/adapters/cursor-sdk/index.d.mts +1 -1
- package/dist/adapters/cursor-sdk/index.mjs +1 -1
- package/dist/adapters/drac-cli/index.d.mts +2 -0
- package/dist/adapters/drac-cli/index.mjs +1 -0
- 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-_WNZMhMY.mjs +8 -0
- package/dist/container/index.d.mts +2 -2
- package/dist/container/index.mjs +1 -1
- package/dist/container-BlsSoBe1.mjs +1 -0
- package/dist/container-C7oWwLGK.mjs +1 -0
- package/dist/container-DUoj_mnh.mjs +1 -0
- package/dist/container-DXQ92RVu.mjs +1 -0
- package/dist/container-MazMFZg8.mjs +1 -0
- package/dist/control-requests-DtjV0e4o.mjs +1 -0
- package/dist/core/process/index.d.mts +2 -2
- package/dist/core/process/index.mjs +1 -1
- package/dist/diff-CMWH9a0d.mjs +1 -0
- package/dist/{errors-aYGbvsaq.mjs → errors-BauhTL3l.mjs} +1 -1
- package/dist/{events-BxEB6zHt.d.mts → events-DmlAPVpd.d.mts} +172 -5
- package/dist/{index-DH2vDD3l.d.mts → index-5XiyFBcK.d.mts} +5 -9
- package/dist/index-BimeR91j.d.mts +6 -0
- package/dist/{index-DWv7tLOX.d.mts → index-Bl9DtOcy.d.mts} +4 -10
- package/dist/{index-BWAsLSN3.d.mts → index-Brx5CEx7.d.mts} +4 -10
- package/dist/{index-DB0fLwpu.d.mts → index-CCsw4G4N.d.mts} +1 -5
- package/dist/{index-CmRm10Lo.d.mts → index-CZiWvyn3.d.mts} +3 -7
- package/dist/{index-CPhcEEAp.d.mts → index-DQYRy7xl.d.mts} +4 -10
- package/dist/index-DUTtolch.d.mts +63 -0
- package/dist/{index-DCQu5ZAu.d.mts → index-DilMV_1s.d.mts} +182 -36
- package/dist/{index-DpPNo3dX.d.mts → index-DpG9mouj.d.mts} +33 -18
- package/dist/{index-Ssb7kE6D.d.mts → index-DqNl8zYj.d.mts} +1 -5
- package/dist/index-Du99OLj6.d.mts +65 -0
- package/dist/{index-DWmHDEQL.d.mts → index-Q5jNyQHD.d.mts} +88 -25
- package/dist/{index-BrFs4M0Z.d.mts → index-X-W5isMp.d.mts} +3 -7
- package/dist/{index-BEEVpHOg.d.mts → index-oUIMXZIp.d.mts} +4 -10
- package/dist/index.d.mts +28 -21
- package/dist/index.mjs +1 -1
- package/dist/oci-t88M5ODN.mjs +2 -0
- package/dist/parser-BY3CZGmc.mjs +2 -0
- package/dist/permission-updates-CkFvevWQ.mjs +1 -0
- package/dist/permissions-BjNU9GCH.mjs +1 -0
- package/dist/questions-CaEwN4JQ.mjs +1 -0
- package/dist/sandbox/index.d.mts +1 -1
- package/dist/sandbox/index.mjs +1 -1
- package/dist/{sandbox-CYA69miM.mjs → sandbox-BemAIoIo.mjs} +2 -2
- package/dist/schemas/index.d.mts +2 -2
- package/dist/schemas/index.mjs +1 -1
- package/dist/schemas-CzJM9p-0.mjs +1 -0
- package/dist/spawner-CYAQQABs.mjs +1 -0
- package/dist/{types-COmjfh8B.d.mts → types-BetgZysV.d.mts} +0 -2
- package/dist/{types-D0ejXDa9.d.mts → types-D_QP9PC-.d.mts} +98 -17
- package/dist/util-CCXryPDO.mjs +1 -0
- package/package.json +20 -10
- package/dist/Agent-WqGee5TR.mjs +0 -4
- package/dist/SdkAgent-BjdSrtFe.mjs +0 -1
- package/dist/classify-error-DK2WpxiL.mjs +0 -8
- package/dist/container-Bdb90GJb.mjs +0 -1
- package/dist/container-DMFxf-kn.mjs +0 -1
- package/dist/container-Dvr-p53c.mjs +0 -1
- package/dist/container-dCRMBvQw.mjs +0 -1
- package/dist/container-w0rl1QMH.mjs +0 -1
- package/dist/diff-Dqyk2cdt.mjs +0 -1
- package/dist/index-DvwVRB7K.d.mts +0 -10
- package/dist/oci-DTNwW-WH.mjs +0 -1
- package/dist/parser-jSS5vOTN.mjs +0 -2
- package/dist/schemas-CkdQXAep.mjs +0 -1
- package/dist/session-markers-BHsJLWJk.mjs +0 -1
- package/dist/spawner-CgfyvnR4.mjs +0 -1
- package/dist/util-B4HTdOSc.mjs +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as OpencodeEvent, i as OpencodeCliRunOptions, n as OpencodeCliAgent, r as OpencodeCliAgentOptions, t as createOpencodeCliAgent } from "../../index-
|
|
1
|
+
import { a as OpencodeEvent, i as OpencodeCliRunOptions, n as OpencodeCliAgent, r as OpencodeCliAgentOptions, t as createOpencodeCliAgent } from "../../index-Bl9DtOcy.mjs";
|
|
2
2
|
export { type OpencodeCliAgent, type OpencodeCliAgentOptions, type OpencodeCliRunOptions, type OpencodeEvent, createOpencodeCliAgent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../../Agent-BsDJsgJa.mjs";import{t}from"../../execution-target-CdlYXh6Z.mjs";import{f as n,l as r,p as i,u as a}from"../../classify-error-_WNZMhMY.mjs";import{a as o,i as s,n as c}from"../../util-CCXryPDO.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 n=c(e.part)?e.part:void 0,a=u(n?.text)??``;return a.trim()?{events:[r(t.runId,`message`,{sessionId:t.sessionId,model:null,role:`assistant`,content:[i(a)],text:a})]}:{events:[]}},_=(e,t)=>{let n=c(e.part)?e.part:void 0,a=u(n?.text)??``;return a.trim()?{events:[r(t.runId,`reasoning`,{sessionId:t.sessionId,model:null,content:[i(a)],text:a})]}:{events:[]}},v=(e,t)=>{let n=c(e.part)?e.part:void 0;if(!n)return{events:[]};let i=u(n.callID)??p(),a=u(n.tool)??`tool`,o=c(n.state)?n.state:void 0;if(!o)return{events:[]};let s=c(o.input)?o.input:void 0,l=o.status===`error`,d=l?u(o.error)??f(o.output)??`Tool call failed.`:f(o.output);return{events:[r(t.runId,`tool-call`,{sessionId:t.sessionId,model:null,toolCallId:i,toolName:a,input:s}),r(t.runId,`tool-result`,{sessionId:t.sessionId,toolCallId:i,toolName:a,input:s,output:d,isError:l||void 0,error:l?d:void 0})],toolCalls:[{toolCallId:i,toolName:a,input:s}]}},y=(e,t,n)=>{let r=c(e.part)?e.part:void 0;if(!r)return{events:[]};let i=u(r.reason),a=d(r.cost)??0,o=c(r.tokens)?r.tokens:void 0,l=c(o?.cache)?o.cache:void 0;return n.steps+=1,n.cost+=a,n.inputTokens+=d(o?.input)??0,n.outputTokens+=d(o?.output)??0,n.reasoningTokens+=d(o?.reasoning)??0,n.cacheReadTokens+=d(l?.read)??0,n.cacheWriteTokens+=d(l?.write)??0,i===`stop`?{events:[],state:{stats:{turns:n.steps,costUsd:n.cost,inputTokens:n.inputTokens,outputTokens:n.outputTokens,reasoningOutputTokens:n.reasoningTokens,cacheReadInputTokens:n.cacheReadTokens,cacheCreationInputTokens:n.cacheWriteTokens,totalTokens:s(n.inputTokens,n.outputTokens,n.cacheReadTokens,n.cacheWriteTokens)},status:`completed`}}:{events:[]}},b=(e,t)=>{let n=c(e.error)?e.error:void 0,i=c(n?.data)?n.data:void 0,a=u(i?.message)??u(n?.message)??u(n?.name)??`unknown error`;return{events:[r(t.runId,`stderr`,{sessionId:t.sessionId,text:a})],state:{status:`failed`,error:{kind:`provider`,message:a}}}},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=l.object({type:l.string()}).passthrough(),C=a(S),w={structuredOutput:!1,sessionResume:!0,sessionFork:!0,imageInput:!1,mcp:!0,eventStreaming:!0};var T=class extends e{type=`opencode-cli`;creationOptions;runDefaults;stepAccumulators=/* @__PURE__ */ new Map;constructor(e={}){super({type:`opencode-cli`,capabilities:w,defaults:{cwd:e.cwd,env:e.env,command:o(e.command??`opencode`),sessionId:e.sessionId,model:e.model},spawner:e.spawner,executionTarget:e.container??e.sandbox,logPath:e.logPath,onEvent:e.onEvent}),this.creationOptions=e,this.runDefaults={agent:e.agent,files:e.files?[...e.files]:void 0,forkSession:e.forkSession,share:e.share,thinking:e.thinking,title:e.title,variant:e.variant,extraArgs:e.extraArgs?[...e.extraArgs]:void 0}}buildArgs(e,t){let r=[`run`,`--format`,`json`],i=n(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&&r.push(`--model`,e.model),a&&r.push(`--agent`,a),o&&o.length>0)for(let e of o)r.push(`--file`,e);return t.requestedSessionId&&(r.push(`--session`,t.requestedSessionId),s&&r.push(`--fork`)),c&&r.push(`--share`),l&&r.push(`--thinking`),u!==void 0&&r.push(`--title`,u),d&&r.push(`--variant`,d),f&&f.length>0&&r.push(...f),r.push(`--`,i),r}buildEnv(e,t){return this.buildDefaultEnv(this.creationOptions.propagateEnv)}mapRawEvent(e,t){this.appendRawLog(e);let n=C(e);if(!n)return this.onParseError(JSON.stringify(e).slice(0,200),/* @__PURE__ */ 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 E=e=>new T(t(e));export{E 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-oUIMXZIp.mjs";
|
|
2
2
|
export { type PiCliAgent, type PiCliAgentOptions, type PiCliRunOptions, type PiCliThinkingLevel, type PiEvent, createPiCliAgent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../../Agent-BsDJsgJa.mjs";import{t}from"../../execution-target-CdlYXh6Z.mjs";import{n}from"../../types-B72tDMEZ.mjs";import{f as r,l as i,p as a,u as o}from"../../classify-error-_WNZMhMY.mjs";import{a as s,n as c}from"../../util-CCXryPDO.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 n of e)c(n)&&n.type===`text`&&typeof n.text==`string`&&t.push(n.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,n)=>{let r=c(e.message)?e.message:void 0;if(!r||u(r.role)!==`assistant`)return{events:[]};let o=m(r.content),s=u(r.model)??n.model??null,l=[];return n.reasoningText&&l.push(i(t.runId,`reasoning`,{sessionId:t.sessionId,model:s,content:[a(n.reasoningText)],text:n.reasoningText})),o&&l.push(i(t.runId,`message`,{sessionId:t.sessionId,model:s,role:`assistant`,content:[a(o)],text:o})),u(r.stopReason)===`error`?{events:l,state:{output:{text:o||void 0},status:`failed`,error:{kind:`provider`,message:`Pi model returned an error stop reason.`}}}:o?{events:l,state:{output:{text:o}}}:{events:l}},y=(e,t,n)=>{let r=u(e.toolCallId)??f(),a=u(e.toolName)??`tool`,o=e.args===void 0?void 0:e.args;return{events:[i(t.runId,`tool-call`,{sessionId:t.sessionId,model:n.model??null,toolCallId:r,toolName:a,input:o})],toolCalls:[{toolCallId:r,toolName:a,input:o}]}},b=(e,t)=>{let n=u(e.toolCallId)??f(),r=!!e.isError,a=e.result,o=t.toolCalls.get(n),s=u(e.toolName)??o?.toolName;return{events:[i(t.runId,`tool-result`,{sessionId:t.sessionId,toolCallId:n,toolName:s,input:o?.input,output:a,isError:r||void 0,error:r?p(a):void 0})]}},x=e=>{let t=c(e.message)?e.message:void 0;if(!t)return;let n=c(t.usage)?t.usage:void 0;if(!n)return;let r=d(n.input),i=d(n.output),a=d(n.cacheRead)||void 0,o=d(n.cacheWrite)||void 0;return{turns:1,durationMs:0,costUsd:c(n.cost)?d(n.cost.total)??0:d(n.cost)??0,inputTokens:r,outputTokens:i,cacheReadInputTokens:a,cacheCreationInputTokens:o,totalTokens:(r??0)+(i??0)+(a??0)+(o??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=l.object({type:l.string()}).passthrough(),T=o(w),E={structuredOutput:!1,sessionResume:!0,imageInput:!0,mcp:!1,eventStreaming:!0,sessionFork:!0},D=(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 O=class t extends e{type=`pi-cli`;creationOptions;runDefaults;runTextBuffers=/* @__PURE__ */ new Map;runReasoningBuffers=/* @__PURE__ */ new Map;runAccumulatedStats=/* @__PURE__ */ new Map;forkOnNextRun;constructor(e={}){super({type:`pi-cli`,capabilities:E,defaults:{cwd:e.cwd,env:e.env,command:s(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 n(`Cannot fork a Pi CLI agent before it has a sessionId.`);return new t({...this.creationOptions,sessionId:this.sessionId,forkSession:void 0,forkOnNextRun:!0})}onValidateRun(e,t){if((e.forkSession??this.runDefaults.forkSession??this.forkOnNextRun)&&!this.sessionId)throw new n(`forkSession requires an existing sessionId on the agent.`)}buildArgs(e,t){let n=[`--mode`,`json`],i=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?i?n.push(`--model`,`${i}/${e.model}`):n.push(`--model`,e.model):i&&n.push(`--provider`,i),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=r(e.input);return n.push(p),n}buildEnv(e,t){return this.buildDefaultEnv(this.creationOptions.propagateEnv)}mapRawEvent(e,t){this.appendRawLog(e);let n=T(e);if(!n)return this.onParseError(JSON.stringify(e).slice(0,200),/* @__PURE__ */ 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=D(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 k=e=>new O(t(e));export{k as createPiCliAgent};
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
`),s=e=>e.flatMap(e=>e.type===`text`?[e.text]:[]).join(`
|
|
3
|
+
|
|
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:/* @__PURE__ */ 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)=>{let i=typeof r==`string`?[{type:`text`,text:r}]:r;if(i.length===0||i.every(e=>e.type===`text`&&e.text.trim()===``))throw new e(`Run input cannot be empty.`);if(!n.imageInput&&i.some(e=>e.type===`image`))throw new e(`${t} does not support image input.`);return i},m=t=>new e(`The active run is not accepting input: ${t}`),h=(t,n,r,i)=>{let a=p(t,n,i.input),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}},g=(e,t)=>({runId:e.runId,requestedSessionId:e.requestedSessionId,sessionId:e.sessionId,schemaRequested:e.normalizedRequest.schema.kind!==`none`,toolCalls:e.toolCalls,...t}),_=({requestedSessionId:e,sessionId:t,normalizedRequest:n})=>({runId:r(),startedAt:/* @__PURE__ */ new Date,requestedSessionId:e,sessionId:t,normalizedRequest:n,events:[],stderrLines:[],assistantTexts:[],toolCalls:/* @__PURE__ */ new Map,output:{}}),v=(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}},y=(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}else e.output.value=t}},b=(e,t)=>{if(e.events.push(t),t.type!==`message`||t.role!==`assistant`||t.parentToolCallId!==void 0)return;let n=t.text??o(t.content);n&&e.assistantTexts.push(n)},x=(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;`error`in r&&r.error===void 0&&(e.error=void 0),r.output&&(`text`in r.output&&(e.output.text=r.output.text),`value`in r.output&&y(e,r.output.value)),`stats`in r&&(e.stats=r.stats),`status`in r&&(e.status=r.status),r.error&&(e.error=r.error)},S=e=>e.events.some(e=>e.type===`message`||e.type===`reasoning`||e.type===`tool-call`||e.type===`tool-result`),C=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||!S(e)&&e.stderrLines.length>0||t?`failed`:`completed`},w=(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.`}},T=(e,t,n,r,i)=>{let a=t.stderrLines.join(`
|
|
6
|
+
`),o={type:e,runId:t.runId,sessionId:t.sessionId,text:t.output.text??t.assistantTexts.join(`
|
|
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.`)}},E=()=>{let e=/* @__PURE__ */ new Date;return{runCount:0,messagesReceived:0,toolCalls:0,errors:0,startedAt:e,lastActivityAt:e}};var D=class{type;capabilities;currentRun;eventHandlers=[];permissionHandler;questionHandler;_sessionId;_metrics;constructor(e){this.type=e.type,this.capabilities=e.capabilities,this._sessionId=e.sessionId,this._metrics=E(),e.onEvent&&this.onEvent(e.onEvent)}onValidateRun(e,t){}async onDispose(){}onHandlerError(e){}sendRunInput(e,t){throw Error(`${this.type} reports midRunInput but does not implement sendRunInput.`)}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}onQuestionRequest(e){return this.questionHandler=e,()=>{this.questionHandler===e&&(this.questionHandler=void 0)}}getQuestionHandler(){return this.questionHandler}async sendInput(t){if(!this.capabilities.midRunInput)throw new e(`${this.type} does not support sending input into an active run.`);let n=this.currentRun;if(!n?.running)throw new e(`There is no active run to send input to.`);if(n.context.stopReason!==void 0)throw m(`the run is stopping.`);await this.sendRunInput(n.context,p(this.type,this.capabilities,t))}async run(t){if(this.currentRun?.running)throw new e(`This agent is already running. Wait for it to finish first.`);let n=h(this.type,this.capabilities,this.runRequestDefaults,t);this.onValidateRun(t,n);let r=_({requestedSessionId:this._sessionId,sessionId:this._sessionId,normalizedRequest:n}),i={context:r,running:!0,promise:new Promise(()=>{})};this._metrics.runCount++;let a=Promise.resolve().then(()=>this.executeRunCore(r,t)).finally(()=>{i.running=!1});return i.promise=a,this.currentRun=i,a}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.hasRunInFlight())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=E()}hasRunInFlight(){return this.currentRun?.running===!0}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){x(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){b(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){v(e,t);let n=C(e),r=w(e,n);return e.sessionStarted&&this.emit(e,u(e.runId,`session-end`,{sessionId:e.sessionId,status:n,error:r?.message})),T(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++}}};const O=/* @__PURE__ */ new Set([`ENOENT`,`ERR_MODULE_NOT_FOUND`]),k=e=>`code`in e,A=(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(k(e)&&O.has(String(e.code)))return{kind:`spawn`,message:n};if(e instanceof SyntaxError)return{kind:`parse`,message:n}}return{kind:`provider`,message:n}};export{_ as a,l as c,i as d,s as f,g as i,u as l,D as n,S as o,a as p,x as r,m as s,A as t,c as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
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 };
|
|
1
|
+
import { A as DockerAttachConfig, B as WorkdirDiff, C as E2BConnectConfig, D as E2BCreateConfig, E as E2BContainerConfig, F as ExecOptions, H as WorkdirFileChange, I as ExecResult, L as PortMapping, M as DockerContainerConfig, N as ContainerStatus, O as E2BProviderConfig, P as ContainerType, R as VolumeMount, S as NerdctlProviderConfig, T as E2BContainer, U as WorkdirSnapshot, V as WorkdirDiffStats, W as WorkdirSnapshotOptions, _ as PodmanAttachConfig, a as ContainerAttachError, b as NerdctlContainer, c as ContainerDisposedError, d as ContainerNotFoundError, f as ContainerNotRunningError, g as AttachedPodmanContainer, h as MountValidationError, i as createContainer, j as DockerContainer, k as AttachedDockerContainer, l as ContainerError, m as ContainerStartError, n as ContainerConfig, o as ContainerCreateError, p as ContainerRemoveError, r as attachContainer, s as ContainerDiffError, t as Container, u as ContainerExecError, v as PodmanContainer, w as E2BConnectionConfig, x as NerdctlContainerConfig, y as PodmanContainerConfig, z as WorkdirChangeKind } from "../index-Q5jNyQHD.mjs";
|
|
2
|
+
export { type AttachedDockerContainer, type AttachedPodmanContainer, Container, ContainerAttachError, ContainerConfig, ContainerCreateError, ContainerDiffError, ContainerDisposedError, ContainerError, ContainerExecError, ContainerNotFoundError, ContainerNotRunningError, ContainerRemoveError, ContainerStartError, type ContainerStatus, type ContainerType, type DockerAttachConfig, 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 PodmanAttachConfig, type PodmanContainer, type PodmanContainerConfig, type PortMapping, type VolumeMount, type WorkdirChangeKind, type WorkdirDiff, type WorkdirDiffStats, type WorkdirFileChange, type WorkdirSnapshot, type WorkdirSnapshotOptions, attachContainer, createContainer };
|
package/dist/container/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{r as ContainerAttachError,i as ContainerCreateError,a as ContainerDiffError,o as ContainerDisposedError,s as ContainerError,c as ContainerExecError,l as ContainerNotFoundError,u as ContainerNotRunningError,d as ContainerRemoveError,f as ContainerStartError,p as MountValidationError,t as attachContainer,n as createContainer}from"../container-DUoj_mnh.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./oci-t88M5ODN.mjs";const r=`docker`,i=async n=>{let i={binary:n.binary??r},a=await t(i,n);return e(`docker`,{commandContext:i,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)},a=e=>n({binary:e.binary??r},e);export{a as attachDockerContainer,i as createDockerContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t,t as n}from"./oci-t88M5ODN.mjs";const r=`podman`,i=async n=>{let i={binary:n.binary??r},a=await t(i,n);return e(`podman`,{commandContext:i,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)},a=e=>n({binary:e.binary??r},e);export{a as attachPodmanContainer,i as createPodmanContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{constructor(e){super(e),this.name=`ContainerError`}},t=class extends e{constructor(e){super(e),this.name=`ContainerCreateError`}},n=class extends e{constructor(e){super(e),this.name=`ContainerNotFoundError`}},r=class extends e{constructor(e){super(e),this.name=`ContainerAttachError`}},i=class extends e{constructor(e){super(e),this.name=`ContainerRemoveError`}},a=class extends e{constructor(e){super(e),this.name=`MountValidationError`}},o=class extends e{constructor(e){super(e),this.name=`ContainerStartError`}},s=class extends e{constructor(e){super(e),this.name=`ContainerExecError`}},c=class extends e{constructor(e=`Container is not running.`){super(e),this.name=`ContainerNotRunningError`}},l=class extends e{constructor(e=`Container has been disposed.`){super(e),this.name=`ContainerDisposedError`}},u=class extends e{constructor(e){super(e),this.name=`ContainerDiffError`}};async function d(e){switch(e.type){case`docker`:{let{createDockerContainer:t}=await import(`./container-BlsSoBe1.mjs`);return t(e)}case`e2b`:try{let{createE2BContainer:t}=await import(`./container-DXQ92RVu.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-MazMFZg8.mjs`);return t(e)}case`podman`:{let{createPodmanContainer:t}=await import(`./container-C7oWwLGK.mjs`);return t(e)}default:throw new t(`Unsupported container type.`)}}async function f(e){switch(e.type){case`docker`:{let{attachDockerContainer:t}=await import(`./container-BlsSoBe1.mjs`);return t(e)}case`podman`:{let{attachPodmanContainer:t}=await import(`./container-C7oWwLGK.mjs`);return t(e)}default:throw new r(`Unsupported container type.`)}}export{u as a,s as c,i as d,o as f,t as i,n as l,d as n,l as o,a as p,r,e as s,f as t,c as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CCXryPDO.mjs";import{n as t}from"./diff-CMWH9a0d.mjs";import{a as n,f as r,i,o as a,u as o}from"./container-DUoj_mnh.mjs";import{t as s}from"./shell-DvWFuFKb.mjs";import{t as c}from"./errors-BauhTL3l.mjs";import{basename as l,dirname as u,join as d,posix as f}from"node:path";import{mkdir as p,readFile as m,readdir as h,stat as g,writeFile as _}from"node:fs/promises";import{CommandExitError as v,FileType as y,Sandbox as b}from"e2b";const x=(e,t)=>[e,...t].map(s).join(` `),S=e=>e.user,C=(e,t)=>{let n={...e.env,...t};return Object.keys(n).length>0?n:void 0},w=(e,t)=>t??e.workdir,T=new TextEncoder,E=e=>e instanceof Error?e:Error(String(e)),D=e=>typeof e==`string`?e:`SIGKILL`,O=(e,t)=>{let n=e?.stdio?.[t];return n===`ignore`||n===`inherit`||n===`pipe`?n:n===void 0?`pipe`:`ignore`},k=()=>{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);else 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 E(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(T.encode(t)),i())},end(){n||r||(n=!0,i())},fail(e){n||r||(r=e,i())}}},A=(e,t)=>({spawn:(n,r,i={})=>{let a=O(i,0),o=O(i,1),s=O(i,2),l=o===`pipe`?k():void 0,u=s===`pipe`?k():void 0,d=null,f={background:!0,stdin:a===`pipe`,cwd:w(t,i.cwd),envs:C(t,i.env),user:S(t),requestTimeoutMs:t.requestTimeoutMs,onStdout:e=>{o===`inherit`?process.stdout.write(e):l?.push(e)},onStderr:e=>{s===`inherit`?process.stderr.write(e):u?.push(e)}},p=e.commands.run(x(n,r),f),m=Promise.resolve(),h,g=e=>{let t=m.then(async()=>{await e((await p).pid)});return m=t.catch(e=>{h??=new c(e)}),t};return p.catch(e=>{l?.fail(e),u?.fail(e)}),{stdout:l?.iterable??null,stderr:u?.iterable??null,stdin:a===`pipe`?{write:n=>g(r=>e.commands.sendStdin(r,n,{requestTimeoutMs:t.requestTimeoutMs})),end:()=>g(n=>e.commands.closeStdin(n,{requestTimeoutMs:t.requestTimeoutMs}))}:null,kill:e=>{d=D(e),p.then(e=>e.kill()).catch(()=>{})},wait:async()=>{try{let e=await(await p).wait();if(await m,h)throw h;return l?.end(),u?.end(),d?{exitCode:null,signal:d}:{exitCode:e.exitCode,signal:null}}catch(e){if(l?.end(),u?.end(),e instanceof v)return d?{exitCode:null,signal:d}:{exitCode:e.exitCode,signal:null};throw e}}}}}),j=e=>({apiKey:e.apiKey,domain:e.domain,requestTimeoutMs:e.requestTimeoutMs,apiHeaders:e.headers}),M=e=>`sandboxId`in e&&typeof e.sandboxId==`string`,N=e=>{let t=j(e);return M(e)?t:{...t,envs:e.env,timeoutMs:e.timeoutMs,metadata:e.metadata,secure:e.secure,allowInternetAccess:e.allowInternetAccess,network:e.network,lifecycle:e.lifecycle}},P=async(e,t)=>{await e.files.makeDir(t.workdir,{user:S(t)})},F=e=>e instanceof Error&&e.name===`AbortError`,I=e=>Uint8Array.from(e).buffer,L=e=>{let t=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e;return f.basename(t)},R=async e=>{try{return await g(e)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`ENOENT`)return;throw e}},z=async(e,t,n)=>{if(await e.files.exists(t,{user:n}))return e.files.getInfo(t,{user:n})},B=async(e,t,n,r)=>(await z(e,n,r))?.type===y.DIR?f.join(n,l(t)):n,V=async(e,t)=>(await R(t))?.isDirectory()?d(t,L(e)):t,H=async(e,t,n,r)=>{let i=await g(t);if(i.isDirectory()){await e.files.makeDir(n,{user:r});let i=await h(t);await Promise.all(i.map(i=>H(e,d(t,i),f.join(n,i),r)));return}if(!i.isFile())throw Error(`Unsupported local filesystem entry at ${t}.`);let a=await m(t);await e.files.write(n,I(a),{user:r})},U=async(e,t,n,r)=>{if((await e.files.getInfo(t,{user:r})).type===y.DIR){await p(n,{recursive:!0});let i=await e.files.list(t,{user:r});await Promise.all(i.map(t=>U(e,t.path,d(n,t.name),r)));return}let i=await e.files.read(t,{format:`bytes`,user:r});await p(u(n),{recursive:!0}),await _(n,i)},W=async e=>{if(M(e))return b.connect(e.sandboxId,j(e));let t=N(e);return e.template?b.create(e.template,t):b.create(t)},G=async(e,t)=>e.connect(j(t)),K=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||F(e))throw new DOMException(`The operation was aborted.`,`AbortError`);if(e instanceof v)return{exitCode:e.exitCode,stdout:e.stdout,stderr:e.stderr};throw e}finally{n?.removeEventListener(`abort`,i)}},q=async s=>{let c;try{c=await W(s),await P(c,s)}catch(t){throw new i(`E2B create failed: ${e(t)}`)}let l=s.name??c.sandboxId,u=`running`,f=A(c,s),m={},h=()=>{if(u===`disposed`)throw new a},g=()=>{if(h(),u!==`running`)throw new o},_=t({owner:m,workdir:s.workdir,materialize:async(e,t)=>{g();let r=S(s),i=await z(c,e,r);if(!i)throw new n(`Target path does not exist: ${e}`);if(i.type!==y.DIR)throw new n(`Target path is not a directory: ${e}`);await p(t,{recursive:!0});for(let n of await c.files.list(e,{user:r}))await U(c,n.path,d(t,n.name),r)}}),v={get type(){return`e2b`},get id(){return c.sandboxId},get name(){return l},get config(){return s},get status(){return u},get workdir(){return s.workdir},get spawner(){return f},async start(){if(h(),u!==`running`)try{c=await G(c,s),await P(c,s),f=A(c,s),u=`running`}catch(t){throw new r(`E2B start failed: ${e(t)}`)}},async stop(){h(),u===`running`&&(await c.pause({requestTimeoutMs:s.requestTimeoutMs}),u=`stopped`)},async dispose(){if(u!==`disposed`){try{await c.kill({requestTimeoutMs:s.requestTimeoutMs})}catch{}await _.disposeSnapshots().catch(()=>{}),u=`disposed`}},async exec(e,t,n={}){g();let r={background:!0,cwd:w(s,n.cwd),envs:C(s,n.env),user:S(s),timeoutMs:n.timeoutMs,requestTimeoutMs:s.requestTimeoutMs},i=await c.commands.run(x(e,t),r);return K(i,n)},async copyTo(e,t){g();let n=await B(c,e,t,S(s));await H(c,e,n,S(s))},async copyFrom(e,t){g();let n=await V(e,t);await U(c,e,n,S(s))},async writeFile(e,t){g(),await c.files.write(e,typeof t==`string`?t:I(t),{user:S(s)})},async readFile(e){return g(),c.files.read(e,{format:`text`,user:S(s)})},async fileExists(e){return g(),c.files.exists(e,{user:S(s)})},async mkdir(e){g(),await c.files.makeDir(e,{user:S(s)})},async execShell(e,t={}){return v.exec(`sh`,[`-c`,e],t)},async logs(){return``},async syncStatus(){return u},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 v.dispose()}};return v};export{q as createE2BContainer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e,r as t}from"./oci-t88M5ODN.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 t(r,n);return e(`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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends Error{reason;constructor(e,t){super(t),this.name=`ClaudeControlRequestError`,this.reason=e}};export{e as t};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as SpawnOptions, i as ProcessSpawner, n as ProcessResult, r as ProcessSignal, t as AgentProcess } from "../../types-
|
|
2
|
-
import { n as spawnProcess, t as ProcessStdinError } from "../../index-
|
|
1
|
+
import { a as SpawnOptions, i as ProcessSpawner, n as ProcessResult, r as ProcessSignal, t as AgentProcess } from "../../types-BetgZysV.mjs";
|
|
2
|
+
import { n as spawnProcess, t as ProcessStdinError } from "../../index-BimeR91j.mjs";
|
|
3
3
|
export { type AgentProcess, type ProcessResult, type ProcessSignal, type ProcessSpawner, ProcessStdinError, type SpawnOptions, spawnProcess };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e}from"../../spawner-CYAQQABs.mjs";import{t}from"../../errors-BauhTL3l.mjs";export{t as ProcessStdinError,e as spawnProcess};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./util-CCXryPDO.mjs";import{n as t}from"./errors-BauhTL3l.mjs";import{a as n,o as r,u as i}from"./container-DUoj_mnh.mjs";import{execFile as a}from"node:child_process";import{dirname as o,isAbsolute as s,join as c,posix as l,relative as u,sep as d}from"node:path";import{promisify as f}from"node:util";import{createReadStream as p}from"node:fs";import{tmpdir as m}from"node:os";import{copyFile as h,lstat as g,mkdir as _,mkdtemp as v,readdir as y,readlink as b,rm as x,stat as S,symlink as C}from"node:fs/promises";import{createHash as w}from"node:crypto";import{pipeline as T}from"node:stream/promises";const E=f(a),D=e=>e!==`..`&&!e.startsWith(`..${d}`)&&!s(e),O=(e,t)=>{let n=u(e,t);if(D(n))return n.split(d).join(l.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 y(e,{withFileTypes:!0});for(let n of t){let t=c(e,n.name);n.name===`.git`?await x(t,{recursive:!0,force:!0}):n.isDirectory()&&await j(t)}},M=()=>v(c(m(),`cw-workdir-diff-`)),N=async e=>{e&&await x(e,{recursive:!0,force:!0}).catch(()=>{})},P=(e,t)=>{let n={cwd:e.cwd,createdAt:/* @__PURE__ */ 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=>w(`sha256`).update(e).digest(`hex`),R=e=>Buffer.isBuffer(e)?e:Buffer.from(e,`utf8`),z=async e=>{let t=w(`sha256`);return await T(p(e),t),t.digest(`hex`)},B=async(e,t,r)=>{let i=`${e}:${t}`;if(r.has(i))return r.get(i);let a=c(e,...t.split(l.sep));try{let e=await g(a),t,o;if(e.isSymbolicLink()){let e=Buffer.from(await b(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(r,i)=>{try{let e=await E(`git`,[`diff`,`--no-index`,`-z`,`--name-status`,`-M`,`--find-renames=100%`,r,i],{cwd:m(),encoding:`buffer`,maxBuffer:52428800});return V(R(e.stdout),r,i)}catch(a){if(!t(a))throw new n(`Failed to run git diff: ${e(a)}`);let o=a.code??1,s=Buffer.isBuffer(a.stdout)?a.stdout:Buffer.from(String(a.stdout??``),`utf8`),c=Buffer.isBuffer(a.stderr)?a.stderr:Buffer.from(String(a.stderr??``),`utf8`);if(o===0||o===1)return V(s,r,i);let l=c.toString(`utf8`).trim()||s.toString(`utf8`).trim()||`exit code ${o}`;throw new n(`Failed to run git diff: ${l}`)}},U=async(e,t,n)=>{let r=/* @__PURE__ */ 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=/* @__PURE__ */ 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=(t,a)=>{throw a instanceof n||a instanceof r||a instanceof i?a:new n(`${t}: ${e(a)}`)},K=async(e,t)=>{if(!(await S(e)).isDirectory())throw new n(`Target path is not a directory: ${e}`);await _(t,{recursive:!0});let r=await y(e,{withFileTypes:!0});await Promise.all(r.filter(e=>e.name!==`.git`).map(async r=>{let i=c(e,r.name),a=c(t,r.name);if(r.isDirectory())await K(i,a);else if(r.isSymbolicLink())await _(o(a),{recursive:!0}),await C(await b(i),a);else if(r.isFile())await _(o(a),{recursive:!0}),await h(i,a);else throw new n(`Unsupported filesystem entry in workdir diff: ${i}`)}))},q=e=>{let t=/* @__PURE__ */ new Set,n=/* @__PURE__ */ 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.released=!0,t.delete(n),(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,K as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./util-
|
|
1
|
+
import{t as e}from"./util-CCXryPDO.mjs";const t=e=>e instanceof Error&&`code`in e&&(`stdout`in e||`stderr`in e);var n=class extends Error{constructor(t){super(e(t),{cause:t}),this.name=`ProcessStdinError`}};export{t as n,n as t};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ZodType, z } from "zod/v4";
|
|
2
|
-
//#region src/schemas/agent.d.ts
|
|
3
2
|
/** Plain text content block in a {@link ContentPart} array. */
|
|
4
3
|
declare const textContentPartSchema: z.ZodObject<{
|
|
5
4
|
type: z.ZodLiteral<"text">;
|
|
@@ -53,6 +52,9 @@ declare const agentCapabilitiesSchema: z.ZodObject<{
|
|
|
53
52
|
eventStreaming: z.ZodBoolean;
|
|
54
53
|
sessionFork: z.ZodOptional<z.ZodBoolean>;
|
|
55
54
|
permissionRequests: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
textStreaming: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
midRunInput: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
questionRequests: z.ZodOptional<z.ZodBoolean>;
|
|
56
58
|
}, z.core.$strip>;
|
|
57
59
|
/**
|
|
58
60
|
* Feature flags published by an adapter via `agent.capabilities`. Use to
|
|
@@ -81,8 +83,6 @@ interface McpServerConfig {
|
|
|
81
83
|
/** HTTP headers for HTTP/SSE-transport MCP servers. */
|
|
82
84
|
headers?: Record<string, string>;
|
|
83
85
|
}
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/schemas/events.d.ts
|
|
86
86
|
/** Fields shared by every {@link AgentEvent}. */
|
|
87
87
|
declare const baseEventSchema: z.ZodObject<{
|
|
88
88
|
id: z.ZodString;
|
|
@@ -118,6 +118,7 @@ declare const messageEventSchema: z.ZodObject<{
|
|
|
118
118
|
id: z.ZodString;
|
|
119
119
|
runId: z.ZodString;
|
|
120
120
|
timestamp: z.ZodDate;
|
|
121
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
121
122
|
type: z.ZodLiteral<"message">;
|
|
122
123
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
123
124
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -152,6 +153,7 @@ declare const reasoningEventSchema: z.ZodObject<{
|
|
|
152
153
|
id: z.ZodString;
|
|
153
154
|
runId: z.ZodString;
|
|
154
155
|
timestamp: z.ZodDate;
|
|
156
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
155
157
|
type: z.ZodLiteral<"reasoning">;
|
|
156
158
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
157
159
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -171,6 +173,52 @@ declare const reasoningEventSchema: z.ZodObject<{
|
|
|
171
173
|
* adapters emit these.
|
|
172
174
|
*/
|
|
173
175
|
type ReasoningEvent = z.infer<typeof reasoningEventSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Partial text of an assistant message that is still being generated. Emitted only by agents that report
|
|
178
|
+
* `capabilities.textStreaming`. `messageId` is the `id` of the {@link MessageEvent} that later carries the whole
|
|
179
|
+
* text; that event stays authoritative, so replace the text accumulated from deltas with it. A message whose
|
|
180
|
+
* generation is cut short, for example by stopping the run, gets no `message` event.
|
|
181
|
+
*/
|
|
182
|
+
declare const messageDeltaEventSchema: z.ZodObject<{
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
runId: z.ZodString;
|
|
185
|
+
timestamp: z.ZodDate;
|
|
186
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
187
|
+
type: z.ZodLiteral<"message-delta">;
|
|
188
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
189
|
+
messageId: z.ZodString;
|
|
190
|
+
text: z.ZodString;
|
|
191
|
+
}, z.core.$strip>;
|
|
192
|
+
/**
|
|
193
|
+
* Partial text of an assistant message that is still being generated. Emitted only by agents that report
|
|
194
|
+
* `capabilities.textStreaming`. `messageId` is the `id` of the {@link MessageEvent} that later carries the whole
|
|
195
|
+
* text; that event stays authoritative, so replace the text accumulated from deltas with it. A message whose
|
|
196
|
+
* generation is cut short, for example by stopping the run, gets no `message` event.
|
|
197
|
+
*/
|
|
198
|
+
type MessageDeltaEvent = z.infer<typeof messageDeltaEventSchema>;
|
|
199
|
+
/**
|
|
200
|
+
* Partial reasoning text that is still being generated. Emitted only by agents that report
|
|
201
|
+
* `capabilities.textStreaming`. `reasoningId` is the `id` of the {@link ReasoningEvent} that later carries the whole
|
|
202
|
+
* text; that event stays authoritative, so replace the text accumulated from deltas with it. Reasoning whose
|
|
203
|
+
* generation is cut short, for example by stopping the run, gets no `reasoning` event.
|
|
204
|
+
*/
|
|
205
|
+
declare const reasoningDeltaEventSchema: z.ZodObject<{
|
|
206
|
+
id: z.ZodString;
|
|
207
|
+
runId: z.ZodString;
|
|
208
|
+
timestamp: z.ZodDate;
|
|
209
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
210
|
+
type: z.ZodLiteral<"reasoning-delta">;
|
|
211
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
212
|
+
reasoningId: z.ZodString;
|
|
213
|
+
text: z.ZodString;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
/**
|
|
216
|
+
* Partial reasoning text that is still being generated. Emitted only by agents that report
|
|
217
|
+
* `capabilities.textStreaming`. `reasoningId` is the `id` of the {@link ReasoningEvent} that later carries the whole
|
|
218
|
+
* text; that event stays authoritative, so replace the text accumulated from deltas with it. Reasoning whose
|
|
219
|
+
* generation is cut short, for example by stopping the run, gets no `reasoning` event.
|
|
220
|
+
*/
|
|
221
|
+
type ReasoningDeltaEvent = z.infer<typeof reasoningDeltaEventSchema>;
|
|
174
222
|
/**
|
|
175
223
|
* Model invoked a tool with the given input. Pair with the subsequent
|
|
176
224
|
* {@link ToolResultEvent} sharing the same `toolCallId`.
|
|
@@ -179,6 +227,7 @@ declare const toolCallEventSchema: z.ZodObject<{
|
|
|
179
227
|
id: z.ZodString;
|
|
180
228
|
runId: z.ZodString;
|
|
181
229
|
timestamp: z.ZodDate;
|
|
230
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
182
231
|
type: z.ZodLiteral<"tool-call">;
|
|
183
232
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
184
233
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -200,6 +249,7 @@ declare const toolResultEventSchema: z.ZodObject<{
|
|
|
200
249
|
id: z.ZodString;
|
|
201
250
|
runId: z.ZodString;
|
|
202
251
|
timestamp: z.ZodDate;
|
|
252
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
203
253
|
type: z.ZodLiteral<"tool-result">;
|
|
204
254
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
205
255
|
toolCallId: z.ZodString;
|
|
@@ -232,6 +282,65 @@ declare const stderrEventSchema: z.ZodObject<{
|
|
|
232
282
|
* only). Useful for surfacing provider diagnostics.
|
|
233
283
|
*/
|
|
234
284
|
type StderrEvent = z.infer<typeof stderrEventSchema>;
|
|
285
|
+
/**
|
|
286
|
+
* How much of one of the provider account's usage limits is used, as the provider reported it during the run.
|
|
287
|
+
* `claude-code-cli` and `claude-code-sdk` report the limit that applies to the run; `codex-cli` on the app-server
|
|
288
|
+
* transport reports the more used of Codex's two limit windows.
|
|
289
|
+
*/
|
|
290
|
+
declare const rateLimitEventSchema: z.ZodObject<{
|
|
291
|
+
id: z.ZodString;
|
|
292
|
+
runId: z.ZodString;
|
|
293
|
+
timestamp: z.ZodDate;
|
|
294
|
+
type: z.ZodLiteral<"rate-limit">;
|
|
295
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
296
|
+
status: z.ZodEnum<{
|
|
297
|
+
allowed: "allowed";
|
|
298
|
+
rejected: "rejected";
|
|
299
|
+
warning: "warning";
|
|
300
|
+
}>;
|
|
301
|
+
limitType: z.ZodOptional<z.ZodString>;
|
|
302
|
+
windowMinutes: z.ZodOptional<z.ZodNumber>;
|
|
303
|
+
utilization: z.ZodOptional<z.ZodNumber>;
|
|
304
|
+
resetsAt: z.ZodOptional<z.ZodDate>;
|
|
305
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
306
|
+
overageStatus: z.ZodOptional<z.ZodEnum<{
|
|
307
|
+
allowed: "allowed";
|
|
308
|
+
rejected: "rejected";
|
|
309
|
+
warning: "warning";
|
|
310
|
+
}>>;
|
|
311
|
+
isUsingOverage: z.ZodOptional<z.ZodBoolean>;
|
|
312
|
+
overageDisabledReason: z.ZodOptional<z.ZodString>;
|
|
313
|
+
}, z.core.$strip>;
|
|
314
|
+
/**
|
|
315
|
+
* How much of one of the provider account's usage limits is used, as the provider reported it during the run.
|
|
316
|
+
* `claude-code-cli` and `claude-code-sdk` report the limit that applies to the run; `codex-cli` on the app-server
|
|
317
|
+
* transport reports the more used of Codex's two limit windows.
|
|
318
|
+
*/
|
|
319
|
+
type RateLimitEvent = z.infer<typeof rateLimitEventSchema>;
|
|
320
|
+
/**
|
|
321
|
+
* Something that failed around the run without failing it, which the agent cannot see but the developer should:
|
|
322
|
+
* an MCP server that did not connect, so its tools are missing, or a hook whose command failed.
|
|
323
|
+
*/
|
|
324
|
+
declare const noticeEventSchema: z.ZodObject<{
|
|
325
|
+
id: z.ZodString;
|
|
326
|
+
runId: z.ZodString;
|
|
327
|
+
timestamp: z.ZodDate;
|
|
328
|
+
type: z.ZodLiteral<"notice">;
|
|
329
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
330
|
+
notice: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
331
|
+
kind: z.ZodLiteral<"mcp-server-failed">;
|
|
332
|
+
server: z.ZodString;
|
|
333
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
334
|
+
kind: z.ZodLiteral<"hook-failed">;
|
|
335
|
+
hook: z.ZodString;
|
|
336
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
337
|
+
}, z.core.$strip>], "kind">;
|
|
338
|
+
}, z.core.$strip>;
|
|
339
|
+
/**
|
|
340
|
+
* Something that failed around the run without failing it, which the agent cannot see but the developer should:
|
|
341
|
+
* an MCP server that did not connect, so its tools are missing, or a hook whose command failed.
|
|
342
|
+
*/
|
|
343
|
+
type NoticeEvent = z.infer<typeof noticeEventSchema>;
|
|
235
344
|
/**
|
|
236
345
|
* Emitted exactly once at the end of a run, just before the `RunResult`
|
|
237
346
|
* promise resolves. Mirrors the run's terminal status; on failure, `error`
|
|
@@ -282,6 +391,7 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
282
391
|
id: z.ZodString;
|
|
283
392
|
runId: z.ZodString;
|
|
284
393
|
timestamp: z.ZodDate;
|
|
394
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
285
395
|
type: z.ZodLiteral<"message">;
|
|
286
396
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
287
397
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -303,6 +413,7 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
303
413
|
id: z.ZodString;
|
|
304
414
|
runId: z.ZodString;
|
|
305
415
|
timestamp: z.ZodDate;
|
|
416
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
306
417
|
type: z.ZodLiteral<"reasoning">;
|
|
307
418
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
308
419
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -319,6 +430,25 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
319
430
|
id: z.ZodString;
|
|
320
431
|
runId: z.ZodString;
|
|
321
432
|
timestamp: z.ZodDate;
|
|
433
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
434
|
+
type: z.ZodLiteral<"message-delta">;
|
|
435
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
436
|
+
messageId: z.ZodString;
|
|
437
|
+
text: z.ZodString;
|
|
438
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
439
|
+
id: z.ZodString;
|
|
440
|
+
runId: z.ZodString;
|
|
441
|
+
timestamp: z.ZodDate;
|
|
442
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
443
|
+
type: z.ZodLiteral<"reasoning-delta">;
|
|
444
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
445
|
+
reasoningId: z.ZodString;
|
|
446
|
+
text: z.ZodString;
|
|
447
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
448
|
+
id: z.ZodString;
|
|
449
|
+
runId: z.ZodString;
|
|
450
|
+
timestamp: z.ZodDate;
|
|
451
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
322
452
|
type: z.ZodLiteral<"tool-call">;
|
|
323
453
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
324
454
|
model: z.ZodNullable<z.ZodString>;
|
|
@@ -329,6 +459,7 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
329
459
|
id: z.ZodString;
|
|
330
460
|
runId: z.ZodString;
|
|
331
461
|
timestamp: z.ZodDate;
|
|
462
|
+
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
332
463
|
type: z.ZodLiteral<"tool-result">;
|
|
333
464
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
334
465
|
toolCallId: z.ZodString;
|
|
@@ -344,6 +475,43 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
344
475
|
type: z.ZodLiteral<"stderr">;
|
|
345
476
|
sessionId: z.ZodOptional<z.ZodString>;
|
|
346
477
|
text: z.ZodString;
|
|
478
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
479
|
+
id: z.ZodString;
|
|
480
|
+
runId: z.ZodString;
|
|
481
|
+
timestamp: z.ZodDate;
|
|
482
|
+
type: z.ZodLiteral<"rate-limit">;
|
|
483
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
484
|
+
status: z.ZodEnum<{
|
|
485
|
+
allowed: "allowed";
|
|
486
|
+
rejected: "rejected";
|
|
487
|
+
warning: "warning";
|
|
488
|
+
}>;
|
|
489
|
+
limitType: z.ZodOptional<z.ZodString>;
|
|
490
|
+
windowMinutes: z.ZodOptional<z.ZodNumber>;
|
|
491
|
+
utilization: z.ZodOptional<z.ZodNumber>;
|
|
492
|
+
resetsAt: z.ZodOptional<z.ZodDate>;
|
|
493
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
494
|
+
overageStatus: z.ZodOptional<z.ZodEnum<{
|
|
495
|
+
allowed: "allowed";
|
|
496
|
+
rejected: "rejected";
|
|
497
|
+
warning: "warning";
|
|
498
|
+
}>>;
|
|
499
|
+
isUsingOverage: z.ZodOptional<z.ZodBoolean>;
|
|
500
|
+
overageDisabledReason: z.ZodOptional<z.ZodString>;
|
|
501
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
502
|
+
id: z.ZodString;
|
|
503
|
+
runId: z.ZodString;
|
|
504
|
+
timestamp: z.ZodDate;
|
|
505
|
+
type: z.ZodLiteral<"notice">;
|
|
506
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
507
|
+
notice: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
508
|
+
kind: z.ZodLiteral<"mcp-server-failed">;
|
|
509
|
+
server: z.ZodString;
|
|
510
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
511
|
+
kind: z.ZodLiteral<"hook-failed">;
|
|
512
|
+
hook: z.ZodString;
|
|
513
|
+
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
514
|
+
}, z.core.$strip>], "kind">;
|
|
347
515
|
}, z.core.$strip>, z.ZodObject<{
|
|
348
516
|
id: z.ZodString;
|
|
349
517
|
runId: z.ZodString;
|
|
@@ -372,5 +540,4 @@ declare const eventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
372
540
|
* ```
|
|
373
541
|
*/
|
|
374
542
|
type AgentEvent = z.infer<typeof eventSchema>;
|
|
375
|
-
|
|
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 };
|
|
543
|
+
export { McpServerConfig as A, stderrEventSchema as C, ContentPart as D, AgentCapabilities as E, textContentPartSchema as F, agentCapabilitiesSchema as M, contentPartSchema as N, ImageContentPart as O, imageContentPartSchema as P, sessionStartEventSchema as S, toolResultEventSchema as T, noticeEventSchema as _, RateLimitEvent as a, reasoningEventSchema as b, SessionEndEvent as c, ToolCallEvent as d, ToolResultEvent as f, messageEventSchema as g, messageDeltaEventSchema as h, NoticeEvent as i, TextContentPart as j, JsonSchema as k, SessionStartEvent as l, eventSchema as m, MessageDeltaEvent as n, ReasoningDeltaEvent as o, baseEventSchema as p, MessageEvent as r, ReasoningEvent as s, AgentEvent as t, StderrEvent as u, rateLimitEventSchema as v, toolCallEventSchema as w, sessionEndEventSchema as x, reasoningDeltaEventSchema as y };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
//#region src/adapters/claude-code-cli-pty/types.d.ts
|
|
1
|
+
import { t as Container } from "./index-Q5jNyQHD.mjs";
|
|
2
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-D_QP9PC-.mjs";
|
|
3
|
+
import { l as Sandbox } from "./index-CZiWvyn3.mjs";
|
|
4
|
+
import { A as McpServerConfig } from "./events-DmlAPVpd.mjs";
|
|
5
|
+
import { f as ClaudeCodeCliPermissionMode } from "./index-DilMV_1s.mjs";
|
|
7
6
|
/** Same modes as {@link ClaudeCodeCliPermissionMode}; re-exported for convenience. */
|
|
8
7
|
type ClaudeCodeCliPtyPermissionMode = ClaudeCodeCliPermissionMode;
|
|
9
8
|
interface ClaudeCodeCliPtyExitEvent {
|
|
@@ -107,8 +106,5 @@ interface ClaudeCodeCliPtyAgent extends BaseAgent<EnsureDisjoint<ClaudeCodeCliPt
|
|
|
107
106
|
*/
|
|
108
107
|
fork: () => ClaudeCodeCliPtyAgent;
|
|
109
108
|
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/adapters/claude-code-cli-pty/adapter.d.ts
|
|
112
109
|
declare const createClaudeCodeCliPtyAgent: (options?: ClaudeCodeCliPtyAgentOptions) => ClaudeCodeCliPtyAgent;
|
|
113
|
-
//#endregion
|
|
114
110
|
export { ClaudeCodeCliPtyPermissionMode as a, ClaudeCodeCliPtyModule as i, ClaudeCodeCliPtyAgent as n, ClaudeCodeCliPtyProcess as o, ClaudeCodeCliPtyAgentOptions as r, ClaudeCodeCliPtyRunOptions as s, createClaudeCodeCliPtyAgent as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { a as SpawnOptions, t as AgentProcess } from "./types-BetgZysV.mjs";
|
|
2
|
+
declare const spawnProcess: (command: string, args: string[], options?: SpawnOptions) => AgentProcess;
|
|
3
|
+
declare class ProcessStdinError extends Error {
|
|
4
|
+
constructor(cause: unknown);
|
|
5
|
+
}
|
|
6
|
+
export { spawnProcess as n, ProcessStdinError as t };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { i as ProcessSpawner } from "./types-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { i as ProcessSpawner } from "./types-BetgZysV.mjs";
|
|
2
|
+
import { t as Container } from "./index-Q5jNyQHD.mjs";
|
|
3
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-D_QP9PC-.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-CZiWvyn3.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
|
-
//#region src/adapters/opencode-cli/events/schemas.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Permissive raw-event shape for OpenCode CLI: `{ type: string }` plus
|
|
9
8
|
* arbitrary additional fields the CLI may emit.
|
|
@@ -12,8 +11,6 @@ declare const opencodeEventSchema: z.ZodObject<{
|
|
|
12
11
|
type: z.ZodString;
|
|
13
12
|
}, z.core.$loose>;
|
|
14
13
|
type OpencodeEvent = z.infer<typeof opencodeEventSchema>;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/adapters/opencode-cli/types.d.ts
|
|
17
14
|
/** Per-run options for the `opencode-cli` adapter. */
|
|
18
15
|
interface OpencodeCliRunOptions {
|
|
19
16
|
/** Named OpenCode agent profile (e.g. `"coding"`, `"reviewer"`). */
|
|
@@ -60,8 +57,5 @@ type OpencodeCliAgentOptions = ExclusiveExecutionTargetOptions<Container, Sandbo
|
|
|
60
57
|
interface OpencodeCliAgent extends BaseAgent<EnsureDisjoint<OpencodeCliRunOptions>> {
|
|
61
58
|
readonly type: "opencode-cli";
|
|
62
59
|
}
|
|
63
|
-
//#endregion
|
|
64
|
-
//#region src/adapters/opencode-cli/adapter.d.ts
|
|
65
60
|
declare const createOpencodeCliAgent: (options?: OpencodeCliAgentOptions) => OpencodeCliAgent;
|
|
66
|
-
//#endregion
|
|
67
61
|
export { OpencodeEvent as a, OpencodeCliRunOptions as i, OpencodeCliAgent as n, OpencodeCliAgentOptions as r, createOpencodeCliAgent as t };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { i as ProcessSpawner } from "./types-
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import { l as Sandbox } from "./index-
|
|
1
|
+
import { i as ProcessSpawner } from "./types-BetgZysV.mjs";
|
|
2
|
+
import { t as Container } from "./index-Q5jNyQHD.mjs";
|
|
3
|
+
import { f as EnsureDisjoint, l as BaseAgent, p as ExclusiveExecutionTargetOptions, t as AgentEventHandler } from "./types-D_QP9PC-.mjs";
|
|
4
|
+
import { l as Sandbox } from "./index-CZiWvyn3.mjs";
|
|
5
5
|
import { z } from "zod/v4";
|
|
6
|
-
//#region src/adapters/cursor-cli/events/schemas.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Permissive raw-event shape for Cursor CLI: `{ type: string }` plus
|
|
9
8
|
* arbitrary additional fields the CLI may emit.
|
|
@@ -12,8 +11,6 @@ declare const cursorCliEventSchema: z.ZodObject<{
|
|
|
12
11
|
type: z.ZodString;
|
|
13
12
|
}, z.core.$loose>;
|
|
14
13
|
type CursorCliEvent = z.infer<typeof cursorCliEventSchema>;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/adapters/cursor-cli/types.d.ts
|
|
17
14
|
/**
|
|
18
15
|
* Cursor CLI permission mode — the run's approval/planning strategy. Named
|
|
19
16
|
* `permissionMode` for consistency with the other adapters; the value union is
|
|
@@ -73,8 +70,5 @@ type CursorCliAgentOptions = CursorCliRunOptions & ExclusiveExecutionTargetOptio
|
|
|
73
70
|
interface CursorCliAgent extends BaseAgent<EnsureDisjoint<CursorCliRunOptions>> {
|
|
74
71
|
readonly type: "cursor-cli";
|
|
75
72
|
}
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/adapters/cursor-cli/adapter.d.ts
|
|
78
73
|
declare const createCursorCliAgent: (options?: CursorCliAgentOptions) => CursorCliAgent;
|
|
79
|
-
//#endregion
|
|
80
74
|
export { CursorCliRunOptions as a, CursorCliPermissionMode as i, CursorCliAgent as n, CursorCliSandboxMode as o, CursorCliAgentOptions as r, CursorCliEvent as s, createCursorCliAgent as t };
|
|
@@ -1,6 +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-D_QP9PC-.mjs";
|
|
2
2
|
import "@openai/codex-sdk";
|
|
3
|
-
//#region src/adapters/codex-sdk/types.d.ts
|
|
4
3
|
type CodexSdkSandboxMode = "danger-full-access" | "read-only" | "workspace-write";
|
|
5
4
|
type CodexSdkModelReasoningEffort = "high" | "low" | "medium" | "minimal" | "xhigh";
|
|
6
5
|
type CodexSdkWebSearchMode = "cached" | "disabled" | "live";
|
|
@@ -224,8 +223,5 @@ type CodexSdkItem = CodexSdkAgentMessageItem | CodexSdkCommandExecutionItem | Co
|
|
|
224
223
|
* - `"error"` — fatal stream-level error.
|
|
225
224
|
*/
|
|
226
225
|
type CodexSdkEvent = CodexSdkItemCompletedEvent | CodexSdkItemStartedEvent | CodexSdkItemUpdatedEvent | CodexSdkThreadErrorEvent | CodexSdkThreadStartedEvent | CodexSdkTurnCompletedEvent | CodexSdkTurnFailedEvent | CodexSdkTurnStartedEvent;
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/adapters/codex-sdk/adapter.d.ts
|
|
229
226
|
declare const createCodexSdkAgent: (options?: CodexSdkAgentOptions) => CodexSdkAgent;
|
|
230
|
-
//#endregion
|
|
231
227
|
export { CodexSdkItem as a, CodexSdkEvent as i, CodexSdkAgent as n, CodexSdkPermissionMode as o, CodexSdkAgentOptions as r, CodexSdkRunOptions as s, createCodexSdkAgent as t };
|