99 type AuthenticateRequest ,
1010 type AuthenticateResponse ,
1111 type CancelNotification ,
12+ type FileSystemCapability ,
1213 type ForkSessionRequest ,
1314 type ForkSessionResponse ,
1415 type InitializeRequest ,
@@ -38,6 +39,7 @@ import { MessageBus, DirectTransport } from '../../messageBus';
3839import { NodeBridge } from '../../nodeBridge' ;
3940import type { ACPContextCreateOpts } from './types' ;
4041import { ACPSession } from './session' ;
42+ import { createACPPlugin } from './plugin' ;
4143
4244const debug = createDebug ( 'neovate:acp:agent' ) ;
4345
@@ -63,6 +65,7 @@ export class NeovateACPAgent implements Agent {
6365 private context ?: Context ;
6466 private defaultCwd : string ;
6567 private contextCreateOpts : ACPContextCreateOpts ;
68+ private clientFsCapabilities ?: FileSystemCapability ; // FileSystemCapability from client
6669
6770 constructor (
6871 connection : AgentSideConnection ,
@@ -80,33 +83,45 @@ export class NeovateACPAgent implements Agent {
8083 log ( 'Initializing ACP agent' ) ;
8184 debug ( 'Initialize params: %O' , params ) ;
8285
86+ // Check client capabilities for file system support
87+ if ( params . clientCapabilities ?. fs ) {
88+ log (
89+ 'Client supports file system capabilities:' ,
90+ params . clientCapabilities . fs ,
91+ ) ;
92+ this . clientFsCapabilities = params . clientCapabilities . fs ;
93+ }
94+ // Create context with ACP plugin if file system is supported
95+ log ( 'Creating Neovate context' ) ;
96+ const plugins = [ ...( this . contextCreateOpts . plugins || [ ] ) ] ;
97+
98+ // Add ACP file system plugin if capabilities are available
99+ if ( this . clientFsCapabilities ) {
100+ log ( 'Adding ACP file system plugin' ) ;
101+ const acpPlugin = createACPPlugin ( {
102+ connection : this . connection ,
103+ } ) ;
104+ plugins . push ( acpPlugin ) ;
105+ }
106+
83107 // Create MessageBus for event-driven architecture
84108 log ( 'Creating NodeBridge and MessageBus' ) ;
85109 const nodeBridge = new NodeBridge ( {
86- contextCreateOpts : this . contextCreateOpts ,
110+ contextCreateOpts : {
111+ ...this . contextCreateOpts ,
112+ cwd : this . defaultCwd ,
113+ plugins,
114+ } ,
87115 } ) ;
88116
89117 const [ clientTransport , nodeTransport ] = DirectTransport . createPair ( ) ;
90118 const messageBus = new MessageBus ( ) ;
91119 messageBus . setTransport ( clientTransport ) ;
92120 nodeBridge . messageBus . setTransport ( nodeTransport ) ;
93121
94- // Auto-approve all tool calls in ACP mode
95- messageBus . registerHandler ( 'toolApproval' , async ( ) => {
96- return { approved : true } ;
97- } ) ;
98-
99122 this . messageBus = messageBus ;
100123 this . nodeBridge = nodeBridge ;
101124
102- // Create context
103- log ( 'Creating Neovate context' ) ;
104- this . context = await Context . create ( {
105- ...this . contextCreateOpts ,
106- cwd : this . contextCreateOpts . cwd || this . defaultCwd ,
107- messageBus : this . messageBus ,
108- } ) ;
109-
110125 log ( 'Agent initialized successfully' ) ;
111126 return {
112127 protocolVersion : PROTOCOL_VERSION , // ACP protocol version (will be proper type after SDK install)
@@ -184,6 +199,7 @@ export class NeovateACPAgent implements Agent {
184199 sessionId ,
185200 this . messageBus ,
186201 this . connection ,
202+ this . clientFsCapabilities , // Pass fs capabilities
187203 ) ;
188204
189205 this . sessions . set ( sessionId , acpSession ) ;
0 commit comments