@@ -30,13 +30,13 @@ function structuredOf<T>(result: { structuredContent?: unknown }): T {
3030
3131function createToolContext (
3232 browser : Browser ,
33- executionDir : string ,
33+ workingDir : string ,
3434 resourcesDir ?: string ,
3535) : ToolContext {
3636 return {
3737 browser,
3838 directories : {
39- executionDir ,
39+ workingDir ,
4040 resourcesDir,
4141 } ,
4242 }
@@ -50,10 +50,8 @@ function createBrowserStub(methods: Record<string, unknown>): Browser {
5050}
5151
5252describe ( 'page action tools' , ( ) => {
53- it ( 'save_pdf resolves relative paths against the execution directory by default' , async ( ) => {
54- const executionDir = await mkdtemp (
55- join ( tmpdir ( ) , 'browseros-page-actions-' ) ,
56- )
53+ it ( 'save_pdf resolves relative paths against the working directory by default' , async ( ) => {
54+ const workingDir = await mkdtemp ( join ( tmpdir ( ) , 'browseros-page-actions-' ) )
5755 const browser = createBrowserStub ( {
5856 printToPDF : async ( ) => ( {
5957 data : Buffer . from ( 'pdf-data' ) . toString ( 'base64' ) ,
@@ -64,26 +62,24 @@ describe('page action tools', () => {
6462 const result = await executeTool (
6563 save_pdf ,
6664 { page : 1 , path : 'report.pdf' } ,
67- createToolContext ( browser , executionDir ) ,
65+ createToolContext ( browser , workingDir ) ,
6866 AbortSignal . timeout ( 1_000 ) ,
6967 )
7068
7169 assert . ok ( ! result . isError , textOf ( result ) )
72- const outputPath = join ( executionDir , 'report.pdf' )
70+ const outputPath = join ( workingDir , 'report.pdf' )
7371 assert . strictEqual (
7472 structuredOf < { path : string } > ( result ) . path ,
7573 outputPath ,
7674 )
77- assert . ok ( existsSync ( outputPath ) , 'PDF file should exist in executionDir ' )
75+ assert . ok ( existsSync ( outputPath ) , 'PDF file should exist in workingDir ' )
7876 } finally {
79- await rm ( executionDir , { recursive : true , force : true } )
77+ await rm ( workingDir , { recursive : true , force : true } )
8078 }
8179 } )
8280
8381 it ( 'save_screenshot still honors an explicit cwd override' , async ( ) => {
84- const executionDir = await mkdtemp (
85- join ( tmpdir ( ) , 'browseros-page-actions-' ) ,
86- )
82+ const workingDir = await mkdtemp ( join ( tmpdir ( ) , 'browseros-page-actions-' ) )
8783 const overrideDir = await mkdtemp ( join ( tmpdir ( ) , 'browseros-page-actions-' ) )
8884 const browser = createBrowserStub ( {
8985 screenshot : async ( ) => ( {
@@ -95,7 +91,7 @@ describe('page action tools', () => {
9591 const result = await executeTool (
9692 save_screenshot ,
9793 { page : 1 , path : 'capture.png' , cwd : overrideDir } ,
98- createToolContext ( browser , executionDir ) ,
94+ createToolContext ( browser , workingDir ) ,
9995 AbortSignal . timeout ( 1_000 ) ,
10096 )
10197
@@ -110,18 +106,18 @@ describe('page action tools', () => {
110106 'Screenshot should exist in overrideDir' ,
111107 )
112108 assert . ok (
113- ! existsSync ( join ( executionDir , 'capture.png' ) ) ,
114- 'Execution directory should not be used when cwd is provided' ,
109+ ! existsSync ( join ( workingDir , 'capture.png' ) ) ,
110+ 'Working directory should not be used when cwd is provided' ,
115111 )
116112 } finally {
117- await rm ( executionDir , { recursive : true , force : true } )
113+ await rm ( workingDir , { recursive : true , force : true } )
118114 await rm ( overrideDir , { recursive : true , force : true } )
119115 }
120116 } )
121117
122- it ( 'download_file resolves relative directories against the execution directory by default' , async ( ) => {
118+ it ( 'download_file resolves relative directories against the working directory by default' , async ( ) => {
123119 const baseDir = await mkdtemp ( join ( tmpdir ( ) , 'browseros-page-actions-' ) )
124- const executionDir = join ( baseDir , 'execution ' )
120+ const workingDir = join ( baseDir , 'working ' )
125121 let stagingDir : string | undefined
126122 const browser = createBrowserStub ( {
127123 downloadViaClick : async (
@@ -143,23 +139,23 @@ describe('page action tools', () => {
143139 const result = await executeTool (
144140 download_file ,
145141 { page : 1 , element : 7 , path : '.' } ,
146- createToolContext ( browser , executionDir ) ,
142+ createToolContext ( browser , workingDir ) ,
147143 AbortSignal . timeout ( 1_000 ) ,
148144 )
149145
150146 assert . ok ( ! result . isError , textOf ( result ) )
151- const outputPath = join ( executionDir , 'download.txt' )
147+ const outputPath = join ( workingDir , 'download.txt' )
152148 const structured = structuredOf < {
153149 directory : string
154150 destinationPath : string
155151 } > ( result )
156- assert . strictEqual ( structured . directory , executionDir )
152+ assert . strictEqual ( structured . directory , workingDir )
157153 assert . strictEqual ( structured . destinationPath , outputPath )
158- assert . ok ( existsSync ( outputPath ) , 'Download should land in executionDir ' )
154+ assert . ok ( existsSync ( outputPath ) , 'Download should land in workingDir ' )
159155 assert . ok ( stagingDir , 'Download should use a staging directory' )
160156 assert . ok (
161- stagingDir . startsWith ( join ( executionDir , 'browseros-dl-' ) ) ,
162- 'Staging directory should be created inside executionDir ' ,
157+ stagingDir . startsWith ( join ( workingDir , 'browseros-dl-' ) ) ,
158+ 'Staging directory should be created inside workingDir ' ,
163159 )
164160 assert . ok (
165161 ! existsSync ( stagingDir ) ,
0 commit comments