@@ -127,7 +127,7 @@ const layerSession = Layer.mergeAll(
127127) ;
128128
129129describe ( "AntigravityAdapterV2 client file system" , ( ) => {
130- it . effect ( "confines agent file requests to the workspace under full access " , ( ) =>
130+ it . effect ( "serves confined reads and leaves edits to the agent's diff tools " , ( ) =>
131131 Effect . gen ( function * ( ) {
132132 const childProcessSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
133133 const fileSystem = yield * FileSystem . FileSystem ;
@@ -140,6 +140,8 @@ describe("AntigravityAdapterV2 client file system", () => {
140140 // effect-acp keeps the last handler registered per method; so does this.
141141 let readTextFile : Parameters < RuntimeService [ "handleReadTextFile" ] > [ 0 ] | undefined ;
142142 let writeTextFile : Parameters < RuntimeService [ "handleWriteTextFile" ] > [ 0 ] | undefined ;
143+ const logs = yield * fileSystem . makeTempDirectoryScoped ( { prefix : "t3-antigravity-log-" } ) ;
144+ const requestLog = path . join ( logs , "requests.ndjson" ) ;
143145 const crypto = yield * Crypto . Crypto ;
144146 const instanceId = ProviderInstanceId . make ( "antigravity-containment-test" ) ;
145147 const adapter = yield * makeAntigravityAdapterV2 ( {
@@ -153,7 +155,7 @@ describe("AntigravityAdapterV2 client file system", () => {
153155 command : process . execPath ,
154156 args : [ mockAgentPath ] ,
155157 cwd : input . cwd ,
156- env : { T3_ACP_ANTIGRAVITY : "1" } ,
158+ env : { T3_ACP_ANTIGRAVITY : "1" , T3_ACP_REQUEST_LOG_PATH : requestLog } ,
157159 } ,
158160 } ) . pipe (
159161 Effect . provideService ( Crypto . Crypto , crypto ) ,
@@ -198,17 +200,31 @@ describe("AntigravityAdapterV2 client file system", () => {
198200 runtimePolicy,
199201 } ) ;
200202 yield * session . ensureThread ( { threadId, modelSelection, runtimePolicy } ) ;
201- if ( readTextFile === undefined || writeTextFile === undefined ) {
202- return yield * Effect . die ( "Antigravity sessions must serve client file requests" ) ;
203+ const initialize = ( yield * fileSystem . readFileString ( requestLog ) )
204+ . trim ( )
205+ . split ( "\n" )
206+ . map (
207+ ( line ) =>
208+ JSON . parse ( line ) as {
209+ method ?: string ;
210+ params ?: { clientCapabilities ?: { fs ?: unknown } ; clientInfo ?: { name ?: string } } ;
211+ } ,
212+ )
213+ . find ( ( request ) => request . method === "initialize" ) ;
214+ assert . deepEqual ( initialize ?. params ?. clientCapabilities ?. fs , {
215+ readTextFile : true ,
216+ writeTextFile : false ,
217+ } ) ;
218+ assert . equal ( initialize ?. params ?. clientInfo ?. name , "zed" ) ;
219+ assert . isUndefined ( writeTextFile ) ;
220+ if ( readTextFile === undefined ) {
221+ return yield * Effect . die ( "Antigravity sessions must serve client file reads" ) ;
203222 }
204223 const context = ( method : string ) => ( { requestId : `test-${ method } ` , method } ) ;
205224
206225 const insidePath = path . join ( workspace , "src" , "inside.ts" ) ;
207- yield * writeTextFile (
208- { sessionId : "mock-session-1" , path : insidePath , content : "inside" } ,
209- context ( "fs/write_text_file" ) ,
210- ) ;
211- assert . equal ( yield * fileSystem . readFileString ( insidePath ) , "inside" ) ;
226+ yield * fileSystem . makeDirectory ( path . dirname ( insidePath ) , { recursive : true } ) ;
227+ yield * fileSystem . writeFileString ( insidePath , "inside" ) ;
212228 const pasted = yield * readTextFile (
213229 { sessionId : "mock-session-1" , path : attachment } ,
214230 context ( "fs/read_text_file" ) ,
@@ -220,59 +236,13 @@ describe("AntigravityAdapterV2 client file system", () => {
220236 context ( "fs/read_text_file" ) ,
221237 ) . pipe ( Effect . exit ) ;
222238 assert . isTrue ( Exit . isFailure ( outsideRead ) ) ;
223- const outsideWrite = yield * writeTextFile (
224- { sessionId : "mock-session-1" , path : path . join ( outside , "planted.txt" ) , content : "x" } ,
225- context ( "fs/write_text_file" ) ,
226- ) . pipe ( Effect . exit ) ;
227- assert . isTrue ( Exit . isFailure ( outsideWrite ) ) ;
228- assert . isFalse ( yield * fileSystem . exists ( path . join ( outside , "planted.txt" ) ) ) ;
229-
230239 const linkPath = path . join ( workspace , "linked-secret.txt" ) ;
231240 yield * fileSystem . symlink ( outsideFile , linkPath ) ;
232241 const linkedRead = yield * readTextFile (
233242 { sessionId : "mock-session-1" , path : linkPath } ,
234243 context ( "fs/read_text_file" ) ,
235244 ) . pipe ( Effect . exit ) ;
236245 assert . isTrue ( Exit . isFailure ( linkedRead ) , "a read through an escaping symlink is denied" ) ;
237- const linkedWrite = yield * writeTextFile (
238- { sessionId : "mock-session-1" , path : linkPath , content : "overwritten" } ,
239- context ( "fs/write_text_file" ) ,
240- ) . pipe ( Effect . exit ) ;
241- assert . isTrue ( Exit . isFailure ( linkedWrite ) , "a write through an escaping symlink is denied" ) ;
242- assert . equal ( yield * fileSystem . readFileString ( outsideFile ) , "secret" ) ;
243- const plantedTarget = path . join ( outside , "created-through-link.txt" ) ;
244- const danglingLink = path . join ( workspace , "dangling.txt" ) ;
245- yield * fileSystem . symlink ( plantedTarget , danglingLink ) ;
246- const danglingWrite = yield * writeTextFile (
247- { sessionId : "mock-session-1" , path : danglingLink , content : "planted" } ,
248- context ( "fs/write_text_file" ) ,
249- ) . pipe ( Effect . exit ) ;
250- assert . isTrue ( Exit . isFailure ( danglingWrite ) , "a write through a dangling symlink is denied" ) ;
251- assert . isFalse ( yield * fileSystem . exists ( plantedTarget ) ) ;
252- yield * fileSystem . symlink ( outside , path . join ( workspace , "linked-dir" ) ) ;
253- const linkedDirWrite = yield * writeTextFile (
254- {
255- sessionId : "mock-session-1" ,
256- path : path . join ( workspace , "linked-dir" , "new.txt" ) ,
257- content : "planted" ,
258- } ,
259- context ( "fs/write_text_file" ) ,
260- ) . pipe ( Effect . exit ) ;
261- assert . isTrue ( Exit . isFailure ( linkedDirWrite ) , "a write under an escaping directory link" ) ;
262- assert . isFalse ( yield * fileSystem . exists ( path . join ( outside , "new.txt" ) ) ) ;
263- const nestedLinkedDirWrite = yield * writeTextFile (
264- {
265- sessionId : "mock-session-1" ,
266- path : path . join ( workspace , "linked-dir" , "a" , "b" , "file.txt" ) ,
267- content : "planted" ,
268- } ,
269- context ( "fs/write_text_file" ) ,
270- ) . pipe ( Effect . exit ) ;
271- assert . isTrue (
272- Exit . isFailure ( nestedLinkedDirWrite ) ,
273- "a write to missing directories under an escaping directory link" ,
274- ) ;
275- assert . isFalse ( yield * fileSystem . exists ( path . join ( outside , "a" ) ) ) ;
276246 const insideLink = path . join ( workspace , "inside-link.ts" ) ;
277247 yield * fileSystem . symlink ( insidePath , insideLink ) ;
278248 const viaInsideLink = yield * readTextFile (
0 commit comments