acp-chat 0.2.7 → 0.2.9
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 +14 -0
- package/dist/acp-client.d.ts +12 -0
- package/dist/cli.js +4 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# acp-chat
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/acp-chat)
|
|
4
|
+
[](https://github.com/stdiobus)
|
|
5
|
+
[](https://modelcontextprotocol.io)
|
|
6
|
+
[](https://agentclientprotocol.com)
|
|
7
|
+
[](https://www.jsonrpc.org/specification)
|
|
8
|
+
[](https://nodejs.org)
|
|
9
|
+
[](https://www.typescriptlang.org)
|
|
10
|
+
[](https://esbuild.github.io)
|
|
11
|
+
[](https://github.com/morozow/acp-chat)
|
|
12
|
+
[](https://github.com/morozow/acp-chat)
|
|
13
|
+
[](https://www.npmjs.com/package/acp-chat)
|
|
14
|
+
[](https://github.com/morozow/acp-chat/blob/main/LICENSE)
|
|
15
|
+
[](https://www.npmjs.com/package/acp-chat)
|
|
16
|
+
|
|
3
17
|
Agent-to-agent dialogue over TCP/Unix socket using the ACP protocol.
|
|
4
18
|
|
|
5
19
|

|
package/dist/acp-client.d.ts
CHANGED
|
@@ -78,6 +78,16 @@ export interface ACPClient extends EventEmitter {
|
|
|
78
78
|
sessionCancel(sessionId: string): void;
|
|
79
79
|
readonly requestTracker: RequestTracker;
|
|
80
80
|
}
|
|
81
|
+
export interface PermissionRequest {
|
|
82
|
+
id: string | number;
|
|
83
|
+
method: string;
|
|
84
|
+
params?: Record<string, unknown>;
|
|
85
|
+
}
|
|
86
|
+
export type PermissionHandler = (request: PermissionRequest) => PermissionResponse | Promise<PermissionResponse>;
|
|
87
|
+
export interface PermissionResponse {
|
|
88
|
+
approved: boolean;
|
|
89
|
+
option?: string;
|
|
90
|
+
}
|
|
81
91
|
export interface ACPClientOptions {
|
|
82
92
|
agentId: string;
|
|
83
93
|
requestTimeoutMs?: number;
|
|
@@ -87,5 +97,7 @@ export interface ACPClientOptions {
|
|
|
87
97
|
version?: string;
|
|
88
98
|
};
|
|
89
99
|
clientSessionId?: string;
|
|
100
|
+
/** Handler for incoming permission requests. Defaults to auto-approve. */
|
|
101
|
+
permissionHandler?: PermissionHandler;
|
|
90
102
|
}
|
|
91
103
|
export declare function createACPClient(ndjsonClient: NDJSONClient, opts: ACPClientOptions): ACPClient;
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`
|
|
5
|
-
`)
|
|
6
|
-
`),console.error(`STOP=${o.stopReason} UPDATES=${o.updates.length}`)}finally{await c.close()}}z().catch(n=>{console.error("ERROR:",n.message),process.exit(1)});
|
|
2
|
+
import{EventEmitter as H}from"node:events";import*as k from"node:net";function b(o){let e=JSON.stringify(o);if(e===void 0)throw new TypeError("Value is not JSON-serializable");return e+`
|
|
3
|
+
`}function A(o){return JSON.parse(o)}var I={CAPACITY_EXCEEDED:-32e3,REQUEST_TIMEOUT:-32001,DISCONNECTED:-32004},C=class extends Error{code;data;constructor(e,t,i){super(t),this.name="ACPError",this.code=e,this.data=i}},v=class extends C{constructor(e="Capacity exceeded",t){super(I.CAPACITY_EXCEEDED,e,t),this.name="CapacityExceededError"}},S=class extends C{constructor(e="Request timeout",t){super(I.REQUEST_TIMEOUT,e,t),this.name="RequestTimeoutError"}},P=class extends C{constructor(e="Disconnected",t){super(I.DISCONNECTED,e,t),this.name="DisconnectedError"}};var T=class extends H{opts;socket=null;state="disconnected";reconnectAttempt=0;reconnectTimer=null;lineBuffer="";closedByUser=!1;constructor(e){super(),this.opts=e}connect(){return this.state==="connected"||this.state==="connecting"?Promise.resolve():this.state==="closed"?Promise.reject(new Error("Client has been closed")):(this.closedByUser=!1,this.reconnectAttempt=0,this.createConnection())}send(e){if(this.state!=="connected"||!this.socket)throw new P("Cannot send: not connected to stdio Bus");this.socket.write(b(e))}close(){this.closedByUser=!0,this.clearReconnectTimer();let e=this.state;return this.state="closed",e==="closed"||e==="disconnected"?Promise.resolve():new Promise(t=>{if(this.socket){let i=this.socket;if(this.socket=null,i.destroyed){t();return}i.once("close",()=>t()),i.destroy()}else t()})}isConnected(){return this.state==="connected"}getState(){return this.state}createConnection(){return new Promise((e,t)=>{this.state=this.reconnectAttempt===0?"connecting":"reconnecting",this.lineBuffer="";let i=this.buildConnectOptions(),p=k.createConnection(i);this.socket=p;let u=()=>{d(),this.state="connected",this.reconnectAttempt=0,this.wireSocketEvents(p),e()},r=l=>{d(),this.reconnectAttempt===0&&this.state==="connecting"&&(this.state="disconnected",t(l))},d=()=>{p.removeListener("connect",u),p.removeListener("error",r)};p.once("connect",u),p.once("error",r)})}buildConnectOptions(){if(this.opts.connectionType==="unix")return{path:this.opts.address};let e=this.opts.address.lastIndexOf(":");if(e===-1)throw new Error(`Invalid TCP address: expected "host:port", got "${this.opts.address}"`);let t=this.opts.address.slice(0,e),i=parseInt(this.opts.address.slice(e+1),10);if(isNaN(i))throw new Error(`Invalid TCP port in address "${this.opts.address}"`);return{host:t,port:i}}wireSocketEvents(e){e.on("data",t=>this.handleData(t.toString("utf-8"))),e.on("error",t=>this.emit("error",t)),e.on("close",()=>{this.closedByUser||this.state==="closed"||(this.state="disconnected",this.emit("disconnect"),this.scheduleReconnect())})}handleData(e){this.lineBuffer+=e;let t;for(;(t=this.lineBuffer.indexOf(`
|
|
4
|
+
`))!==-1;){let i=this.lineBuffer.slice(0,t);if(this.lineBuffer=this.lineBuffer.slice(t+1),i.length!==0)try{this.emit("message",A(i))}catch(p){this.emit("framingError",i,p instanceof Error?p:new Error(String(p)))}}}scheduleReconnect(){if(this.closedByUser||this.state==="closed")return;if(this.reconnectAttempt>=this.opts.maxReconnectAttempts){this.state="disconnected",this.emit("disconnect");return}this.state="reconnecting";let e=this.reconnectAttempt++,t=Math.random()*this.opts.baseReconnectDelayMs,i=Math.min(this.opts.baseReconnectDelayMs*Math.pow(2,e)+t,this.opts.maxReconnectDelayMs);this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.emit("reconnect",this.reconnectAttempt),this.attemptReconnect()},i)}attemptReconnect(){if(this.closedByUser||this.state==="closed")return;this.lineBuffer="";let e=k.createConnection(this.buildConnectOptions());this.socket=e,e.once("connect",()=>{e.removeAllListeners("error"),this.state="connected",this.reconnectAttempt=0,this.wireSocketEvents(e)}),e.once("error",()=>{e.destroy(),this.scheduleReconnect()})}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}};var L={maxPending:4096,defaultTimeoutMs:3e4},y=1e3;function D(o){let e={...L,...o};e.defaultTimeoutMs<y&&(e.defaultTimeoutMs=y);let t=new Map;function i(r,d){if(t.size>=e.maxPending)return Promise.reject(new v(`Maximum pending requests (${e.maxPending}) exceeded`));let l=d??e.defaultTimeoutMs;return l<y&&(l=y),new Promise((w,g)=>{let E=setTimeout(()=>{t.delete(r),g(new S(`Request ${String(r)} timed out after ${l}ms`,{id:r,timeoutMs:l}))},l);E.unref&&E.unref(),t.set(r,{id:r,registeredAt:Date.now(),timeoutMs:l,timeoutHandle:E,resolve:w,reject:g})})}function p(r){let d=t.get(r.id);return d?(clearTimeout(d.timeoutHandle),t.delete(r.id),d.resolve(r),!0):!1}function u(r){for(let[,d]of t)clearTimeout(d.timeoutHandle),d.reject(r);t.clear()}return{register:i,resolve:p,cancelAll:u,pendingCount:()=>t.size,hasPending:r=>t.has(r)}}import{EventEmitter as V}from"node:events";function U(o,e){let{agentId:t,requestTimeoutMs:i=12e4,clientInfo:p,permissionHandler:u}=e,r=new V,d=D({defaultTimeoutMs:i}),l=1,w=e.clientSessionId??`client-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,g=new Map,M=u??(()=>({approved:!0,option:"approved-execpolicy-amendment"}));function _(s,n){o.send({jsonrpc:"2.0",id:s,result:n})}function O(s,n,c){o.send({jsonrpc:"2.0",id:s,error:{code:n,message:c}})}async function q(s,n,c){if(n==="session/request_permission")try{let a=await M({id:s,method:n,params:c});_(s,{permission:a.approved?"granted":"denied",option:a.option??(a.approved?"approved-execpolicy-amendment":"denied")})}catch(a){let m=a instanceof Error?a.message:String(a);O(s,-32e3,`Permission handler error: ${m}`)}else r.emit("incomingRequest",s,n,c)||O(s,-32601,`Method not supported by client: ${n}`)}o.on("message",s=>{let n=s;if(!(!n||n.jsonrpc!=="2.0")){if("id"in n&&("result"in n||"error"in n)){d.resolve(n);return}if("id"in n&&"method"in n&&!("result"in n)&&!("error"in n)){let c=n.id,a=n.method,m=n.params;q(c,a,m).catch(h=>{r.emit("error",h)});return}if("method"in n&&!("id"in n)){let c=n.method,a=n.params;if(c==="session/update"&&a){let m=a.sessionId,h=a.update,R=g.get(m);R&&R.push(h),r.emit("update",m,h)}r.emit("notification",c,a)}}});function x(s,n){let c=l++,a={jsonrpc:"2.0",id:c,method:s,agentId:t,sessionId:w,params:n},m=d.register(c);return o.send(a),m}async function J(){let s=await x("initialize",{protocolVersion:1,clientCapabilities:{},clientInfo:p??{name:"acp-chat",version:"1.0.0"}});if(s.error)throw new Error(`initialize: [${s.error.code}] ${s.error.message}`);return s.result}async function $(s){let n={cwd:process.cwd(),mcpServers:[]};s?.length&&(n.configOptions=s);let c=await x("session/new",n);if(c.error)throw new Error(`session/new: [${c.error.code}] ${c.error.message}`);return{...c.result,clientSessionId:w}}async function B(s,n,c="user"){g.set(s,[]);let a=await x("session/prompt",{sessionId:s,prompt:[{type:"text",role:c,text:n}]});await new Promise(f=>setTimeout(f,200));let m=g.get(s)??[];if(g.delete(s),a.error)throw new Error(`session/prompt: [${a.error.code}] ${a.error.message}`);let h=a.result,R=[];for(let f of m)if(f.sessionUpdate==="agent_message_chunk"&&f.content?.text&&R.push(f.content.text),f.sessionUpdate==="tool_call_update"&&f.content)for(let N of f.content)N.content?.text&&R.push(N.content.text);return{stopReason:h.stopReason,updates:m,text:R.join("")}}async function j(s,n){let c=await x("session/configure",{sessionId:s,options:n});if(c.error)throw new Error(`session/configure: [${c.error.code}] ${c.error.message}`)}function z(s){o.send({jsonrpc:"2.0",method:"session/cancel",params:{sessionId:s},agentId:t,sessionId:w})}return Object.assign(r,{initialize:J,sessionNew:$,sessionPrompt:B,sessionConfigure:j,sessionCancel:z,requestTracker:d})}var G=process.env.ACP_BUS_ADDRESS??"127.0.0.1:9800",Q=process.env.ACP_AGENT_ID??"codex-acp";async function X(){let o=process.argv.slice(2),e,t,i;o[0]==="new"?(o.length<2&&(console.error('Usage: acp-chat new "<message>"'),process.exit(1)),i=o[1]):(o.length<3&&(console.error('Usage: acp-chat <clientSessionId> <sessionId> "<message>"'),process.exit(1)),e=o[0],t=o[1],i=o[2]);let p=new T({address:G,connectionType:"tcp",maxReconnectAttempts:3,baseReconnectDelayMs:500,maxReconnectDelayMs:5e3});try{await p.connect();let u=U(p,{agentId:Q,requestTimeoutMs:300*1e3,clientInfo:{name:"acp-chat-cli",version:"1.0.0"},clientSessionId:e});if(u.on("update",(d,l)=>{l.sessionUpdate==="agent_message_chunk"&&process.stdout.write(l.content.text)}),await u.initialize(),t)console.error(`CLIENT_SESSION_ID=${e}`),console.error(`SESSION_ID=${t} (continued)`);else{let d=await u.sessionNew();t=d.sessionId,console.error(`CLIENT_SESSION_ID=${d.clientSessionId}`),console.error(`SESSION_ID=${t}`)}let r=await u.sessionPrompt(t,i);process.stdout.write(`
|
|
5
|
+
`),console.error(`STOP=${r.stopReason} UPDATES=${r.updates.length}`)}finally{await p.close()}}X().catch(o=>{console.error("ERROR:",o.message),process.exit(1)});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { NDJSONClient, type NDJSONClientOptions, type NDJSONClientEvents } from './ndjson-client.js';
|
|
2
|
-
export { createACPClient, type ACPClient, type ACPClientOptions, type SessionUpdate, type SessionNewResult, type PromptResult, type InitializeResult, type ConfigOption, type AgentMessageChunk, type PlanUpdate, type ToolCallUpdate, type ToolCallStatusUpdate } from './acp-client.js';
|
|
2
|
+
export { createACPClient, type ACPClient, type ACPClientOptions, type SessionUpdate, type SessionNewResult, type PromptResult, type InitializeResult, type ConfigOption, type AgentMessageChunk, type PlanUpdate, type ToolCallUpdate, type ToolCallStatusUpdate, type PermissionRequest, type PermissionHandler, type PermissionResponse } from './acp-client.js';
|
|
3
3
|
export { createRequestTracker, type RequestTracker, type RequestTrackerOptions } from './request-tracker.js';
|
|
4
4
|
export { DisconnectedError, CapacityExceededError, RequestTimeoutError, ACPError, ErrorCodes } from './errors.js';
|
|
5
5
|
export type { JsonRpcId, JsonRpcResponse, JsonRpcError, ConnectionState } from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{EventEmitter as
|
|
2
|
-
`}function
|
|
3
|
-
`))!==-1;){let
|
|
1
|
+
import{EventEmitter as B}from"node:events";import*as S from"node:net";function A(a){let e=JSON.stringify(a);if(e===void 0)throw new TypeError("Value is not JSON-serializable");return e+`
|
|
2
|
+
`}function U(a){return JSON.parse(a)}var T={CAPACITY_EXCEEDED:-32e3,REQUEST_TIMEOUT:-32001,DISCONNECTED:-32004},C=class extends Error{code;data;constructor(e,t,c){super(t),this.name="ACPError",this.code=e,this.data=c}},w=class extends C{constructor(e="Capacity exceeded",t){super(T.CAPACITY_EXCEEDED,e,t),this.name="CapacityExceededError"}},x=class extends C{constructor(e="Request timeout",t){super(T.REQUEST_TIMEOUT,e,t),this.name="RequestTimeoutError"}},P=class extends C{constructor(e="Disconnected",t){super(T.DISCONNECTED,e,t),this.name="DisconnectedError"}};var O=class extends B{opts;socket=null;state="disconnected";reconnectAttempt=0;reconnectTimer=null;lineBuffer="";closedByUser=!1;constructor(e){super(),this.opts=e}connect(){return this.state==="connected"||this.state==="connecting"?Promise.resolve():this.state==="closed"?Promise.reject(new Error("Client has been closed")):(this.closedByUser=!1,this.reconnectAttempt=0,this.createConnection())}send(e){if(this.state!=="connected"||!this.socket)throw new P("Cannot send: not connected to stdio Bus");this.socket.write(A(e))}close(){this.closedByUser=!0,this.clearReconnectTimer();let e=this.state;return this.state="closed",e==="closed"||e==="disconnected"?Promise.resolve():new Promise(t=>{if(this.socket){let c=this.socket;if(this.socket=null,c.destroyed){t();return}c.once("close",()=>t()),c.destroy()}else t()})}isConnected(){return this.state==="connected"}getState(){return this.state}createConnection(){return new Promise((e,t)=>{this.state=this.reconnectAttempt===0?"connecting":"reconnecting",this.lineBuffer="";let c=this.buildConnectOptions(),d=S.createConnection(c);this.socket=d;let g=()=>{p(),this.state="connected",this.reconnectAttempt=0,this.wireSocketEvents(d),e()},r=l=>{p(),this.reconnectAttempt===0&&this.state==="connecting"&&(this.state="disconnected",t(l))},p=()=>{d.removeListener("connect",g),d.removeListener("error",r)};d.once("connect",g),d.once("error",r)})}buildConnectOptions(){if(this.opts.connectionType==="unix")return{path:this.opts.address};let e=this.opts.address.lastIndexOf(":");if(e===-1)throw new Error(`Invalid TCP address: expected "host:port", got "${this.opts.address}"`);let t=this.opts.address.slice(0,e),c=parseInt(this.opts.address.slice(e+1),10);if(isNaN(c))throw new Error(`Invalid TCP port in address "${this.opts.address}"`);return{host:t,port:c}}wireSocketEvents(e){e.on("data",t=>this.handleData(t.toString("utf-8"))),e.on("error",t=>this.emit("error",t)),e.on("close",()=>{this.closedByUser||this.state==="closed"||(this.state="disconnected",this.emit("disconnect"),this.scheduleReconnect())})}handleData(e){this.lineBuffer+=e;let t;for(;(t=this.lineBuffer.indexOf(`
|
|
3
|
+
`))!==-1;){let c=this.lineBuffer.slice(0,t);if(this.lineBuffer=this.lineBuffer.slice(t+1),c.length!==0)try{this.emit("message",U(c))}catch(d){this.emit("framingError",c,d instanceof Error?d:new Error(String(d)))}}}scheduleReconnect(){if(this.closedByUser||this.state==="closed")return;if(this.reconnectAttempt>=this.opts.maxReconnectAttempts){this.state="disconnected",this.emit("disconnect");return}this.state="reconnecting";let e=this.reconnectAttempt++,t=Math.random()*this.opts.baseReconnectDelayMs,c=Math.min(this.opts.baseReconnectDelayMs*Math.pow(2,e)+t,this.opts.maxReconnectDelayMs);this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.emit("reconnect",this.reconnectAttempt),this.attemptReconnect()},c)}attemptReconnect(){if(this.closedByUser||this.state==="closed")return;this.lineBuffer="";let e=S.createConnection(this.buildConnectOptions());this.socket=e,e.once("connect",()=>{e.removeAllListeners("error"),this.state="connected",this.reconnectAttempt=0,this.wireSocketEvents(e)}),e.once("error",()=>{e.destroy(),this.scheduleReconnect()})}clearReconnectTimer(){this.reconnectTimer!==null&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}};var H={maxPending:4096,defaultTimeoutMs:3e4},k=1e3;function I(a){let e={...H,...a};e.defaultTimeoutMs<k&&(e.defaultTimeoutMs=k);let t=new Map;function c(r,p){if(t.size>=e.maxPending)return Promise.reject(new w(`Maximum pending requests (${e.maxPending}) exceeded`));let l=p??e.defaultTimeoutMs;return l<k&&(l=k),new Promise((y,f)=>{let E=setTimeout(()=>{t.delete(r),f(new x(`Request ${String(r)} timed out after ${l}ms`,{id:r,timeoutMs:l}))},l);E.unref&&E.unref(),t.set(r,{id:r,registeredAt:Date.now(),timeoutMs:l,timeoutHandle:E,resolve:y,reject:f})})}function d(r){let p=t.get(r.id);return p?(clearTimeout(p.timeoutHandle),t.delete(r.id),p.resolve(r),!0):!1}function g(r){for(let[,p]of t)clearTimeout(p.timeoutHandle),p.reject(r);t.clear()}return{register:c,resolve:d,cancelAll:g,pendingCount:()=>t.size,hasPending:r=>t.has(r)}}import{EventEmitter as L}from"node:events";function V(a,e){let{agentId:t,requestTimeoutMs:c=12e4,clientInfo:d,permissionHandler:g}=e,r=new L,p=I({defaultTimeoutMs:c}),l=1,y=e.clientSessionId??`client-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,f=new Map,M=g??(()=>({approved:!0,option:"approved-execpolicy-amendment"}));function q(s,n){a.send({jsonrpc:"2.0",id:s,result:n})}function N(s,n,o){a.send({jsonrpc:"2.0",id:s,error:{code:n,message:o}})}async function D(s,n,o){if(n==="session/request_permission")try{let i=await M({id:s,method:n,params:o});q(s,{permission:i.approved?"granted":"denied",option:i.option??(i.approved?"approved-execpolicy-amendment":"denied")})}catch(i){let u=i instanceof Error?i.message:String(i);N(s,-32e3,`Permission handler error: ${u}`)}else r.emit("incomingRequest",s,n,o)||N(s,-32601,`Method not supported by client: ${n}`)}a.on("message",s=>{let n=s;if(!(!n||n.jsonrpc!=="2.0")){if("id"in n&&("result"in n||"error"in n)){p.resolve(n);return}if("id"in n&&"method"in n&&!("result"in n)&&!("error"in n)){let o=n.id,i=n.method,u=n.params;D(o,i,u).catch(h=>{r.emit("error",h)});return}if("method"in n&&!("id"in n)){let o=n.method,i=n.params;if(o==="session/update"&&i){let u=i.sessionId,h=i.update,R=f.get(u);R&&R.push(h),r.emit("update",u,h)}r.emit("notification",o,i)}}});function v(s,n){let o=l++,i={jsonrpc:"2.0",id:o,method:s,agentId:t,sessionId:y,params:n},u=p.register(o);return a.send(i),u}async function J(){let s=await v("initialize",{protocolVersion:1,clientCapabilities:{},clientInfo:d??{name:"acp-chat",version:"1.0.0"}});if(s.error)throw new Error(`initialize: [${s.error.code}] ${s.error.message}`);return s.result}async function _(s){let n={cwd:process.cwd(),mcpServers:[]};s?.length&&(n.configOptions=s);let o=await v("session/new",n);if(o.error)throw new Error(`session/new: [${o.error.code}] ${o.error.message}`);return{...o.result,clientSessionId:y}}async function j(s,n,o="user"){f.set(s,[]);let i=await v("session/prompt",{sessionId:s,prompt:[{type:"text",role:o,text:n}]});await new Promise(m=>setTimeout(m,200));let u=f.get(s)??[];if(f.delete(s),i.error)throw new Error(`session/prompt: [${i.error.code}] ${i.error.message}`);let h=i.result,R=[];for(let m of u)if(m.sessionUpdate==="agent_message_chunk"&&m.content?.text&&R.push(m.content.text),m.sessionUpdate==="tool_call_update"&&m.content)for(let b of m.content)b.content?.text&&R.push(b.content.text);return{stopReason:h.stopReason,updates:u,text:R.join("")}}async function $(s,n){let o=await v("session/configure",{sessionId:s,options:n});if(o.error)throw new Error(`session/configure: [${o.error.code}] ${o.error.message}`)}function z(s){a.send({jsonrpc:"2.0",method:"session/cancel",params:{sessionId:s},agentId:t,sessionId:y})}return Object.assign(r,{initialize:J,sessionNew:_,sessionPrompt:j,sessionConfigure:$,sessionCancel:z,requestTracker:p})}export{C as ACPError,w as CapacityExceededError,P as DisconnectedError,T as ErrorCodes,O as NDJSONClient,x as RequestTimeoutError,V as createACPClient,I as createRequestTracker};
|