@@ -377,111 +377,6 @@ describe("AntigravityAdapterV2 workspace changes", () => {
377377 ) ;
378378} ) ;
379379
380- describe ( "AntigravityAdapterV2 client file system under restrictive policies" , ( ) => {
381- it . effect ( "serves in-workspace reads and writes and still refuses outside paths" , ( ) =>
382- Effect . gen ( function * ( ) {
383- const childProcessSpawner = yield * ChildProcessSpawner . ChildProcessSpawner ;
384- const fileSystem = yield * FileSystem . FileSystem ;
385- const path = yield * Path . Path ;
386- const crypto = yield * Crypto . Crypto ;
387- const mockAgentPath = yield * path . fromFileUrl (
388- new URL ( "../../../scripts/acp-mock-agent.ts" , import . meta. url ) ,
389- ) ;
390- type RuntimeService = AcpSessionRuntime . AcpSessionRuntime [ "Service" ] ;
391- const policies = [
392- {
393- name : "read-only sandbox" ,
394- policy : {
395- runtimeMode : "full-access" ,
396- approvalPolicy : "never" ,
397- sandboxPolicy : { type : "readOnly" } ,
398- } ,
399- } ,
400- { name : "approval-required" , policy : { runtimeMode : "approval-required" } } ,
401- ] as const ;
402- for ( const { name, policy } of policies ) {
403- let readTextFile : Parameters < RuntimeService [ "handleReadTextFile" ] > [ 0 ] | undefined ;
404- let writeTextFile : Parameters < RuntimeService [ "handleWriteTextFile" ] > [ 0 ] | undefined ;
405- const instanceId = ProviderInstanceId . make ( `antigravity-restrictive-${ policy . runtimeMode } ` ) ;
406- const adapter = yield * makeAntigravityAdapterV2 ( {
407- instanceId,
408- selfInvocation : yield * resolveSelfInvocation ( ) ,
409- makeRuntime : ( input ) =>
410- makeAntigravityAcpRuntime ( {
411- ...input ,
412- childProcessSpawner,
413- spawn : {
414- command : process . execPath ,
415- args : [ mockAgentPath ] ,
416- cwd : input . cwd ,
417- env : { T3_ACP_ANTIGRAVITY : "1" } ,
418- } ,
419- } ) . pipe (
420- Effect . provideService ( Crypto . Crypto , crypto ) ,
421- Effect . map ( ( runtime ) : RuntimeService => ( {
422- ...runtime ,
423- handleReadTextFile : ( handler ) =>
424- Effect . sync ( ( ) => {
425- readTextFile = handler ;
426- } ) . pipe ( Effect . andThen ( runtime . handleReadTextFile ( handler ) ) ) ,
427- handleWriteTextFile : ( handler ) =>
428- Effect . sync ( ( ) => {
429- writeTextFile = handler ;
430- } ) . pipe ( Effect . andThen ( runtime . handleWriteTextFile ( handler ) ) ) ,
431- } ) ) ,
432- ) ,
433- withProcess : ( _stop , task ) => task ,
434- defaultModel : Effect . succeed ( undefined ) ,
435- } ) ;
436- const workspace = yield * fileSystem . makeTempDirectoryScoped ( {
437- prefix : "t3-ag-restrictive-" ,
438- } ) ;
439- const outside = yield * fileSystem . makeTempDirectoryScoped ( {
440- prefix : "t3-ag-restrictive-outside-" ,
441- } ) ;
442- yield * fileSystem . writeFileString ( path . join ( workspace , "existing.ts" ) , "existing" ) ;
443- const threadId = ThreadId . make ( `thread-antigravity-restrictive-${ policy . runtimeMode } ` ) ;
444- const runtimePolicy = ProviderAdapter . ProviderAdapterV2RuntimePolicy . make ( {
445- ...policy ,
446- interactionMode : "default" ,
447- cwd : workspace ,
448- } ) ;
449- const modelSelection = { instanceId, model : "gemini-test-low" } as const ;
450- const session = yield * adapter . openSession ( {
451- threadId,
452- providerSessionId : ProviderSessionId . make (
453- `provider-session-antigravity-restrictive-${ policy . runtimeMode } ` ,
454- ) ,
455- modelSelection,
456- runtimePolicy,
457- } ) ;
458- yield * session . ensureThread ( { threadId, modelSelection, runtimePolicy } ) ;
459- if ( readTextFile === undefined || writeTextFile === undefined ) {
460- return yield * Effect . die ( "Antigravity sessions must serve client file requests" ) ;
461- }
462- const context = ( method : string ) => ( { requestId : `test-${ method } ` , method } ) ;
463- const read = yield * readTextFile (
464- { sessionId : "mock-session-1" , path : path . join ( workspace , "existing.ts" ) } ,
465- context ( "fs/read_text_file" ) ,
466- ) ;
467- assert . equal ( read . content , "existing" , name ) ;
468- const written = path . join ( workspace , "src" , "edited.ts" ) ;
469- yield * writeTextFile (
470- { sessionId : "mock-session-1" , path : written , content : "edited" } ,
471- context ( "fs/write_text_file" ) ,
472- ) ;
473- assert . equal ( yield * fileSystem . readFileString ( written ) , "edited" , name ) ;
474- const outsideWrite = yield * writeTextFile (
475- { sessionId : "mock-session-1" , path : path . join ( outside , "x.ts" ) , content : "x" } ,
476- context ( "fs/write_text_file" ) ,
477- ) . pipe ( Effect . exit ) ;
478- assert . isTrue ( Exit . isFailure ( outsideWrite ) , name ) ;
479- assert . isFalse ( yield * fileSystem . exists ( path . join ( outside , "x.ts" ) ) , name ) ;
480- }
481- } ) . pipe ( Effect . provide ( layerSession ) , Effect . scoped ) ,
482- ) ;
483- } ) ;
484-
485380describe ( "AntigravityAdapterV2 html_render pages" , ( ) => {
486381 it . effect ( "shows the page html_render published when the agent reports only a summary" , ( ) =>
487382 Effect . gen ( function * ( ) {
0 commit comments