1414 */
1515
1616import * as fs from 'fs/promises' ;
17- import * as path from 'path' ;
1817
1918import {
2019 CodeInterpreterSandbox ,
2120 CodeLanguage ,
22- Sandbox ,
2321 SandboxClient ,
2422 Template ,
25- TemplateType ,
23+ TemplateType
2624} from '../src/index' ;
2725import { logger } from '../src/utils/log' ;
2826
@@ -39,7 +37,7 @@ const client = new SandboxClient();
3937async function listTemplates ( ) : Promise < void > {
4038 log ( '枚举模板列表 / Listing templates' ) ;
4139
42- const templates = await client . listAllTemplates ( ) ;
40+ const templates = await client . listTemplates ( ) ;
4341 log ( `共有 ${ templates . length } 个模板 / Total ${ templates . length } templates:` ) ;
4442
4543 for ( const template of templates ) {
@@ -76,10 +74,12 @@ async function codeInterpreterExample(): Promise<void> {
7674 // 创建模板 / Create template
7775 log ( '\n--- 创建模板 / Creating template ---' ) ;
7876 const template = await Template . create ( {
79- templateName,
80- templateType : TemplateType . CODE_INTERPRETER ,
81- description : 'Test template from Node.js SDK' ,
82- sandboxIdleTimeoutInSeconds : 600 ,
77+ input : {
78+ templateName,
79+ templateType : TemplateType . CODE_INTERPRETER ,
80+ description : 'Test template from Node.js SDK' ,
81+ sandboxIdleTimeoutInSeconds : 600 ,
82+ }
8383 } ) ;
8484
8585 log ( `✓ 创建模板成功 / Template created: ${ template . templateName } ` ) ;
@@ -158,9 +158,9 @@ async function codeInterpreterExample(): Promise<void> {
158158 } ) ;
159159 log ( `✓ 上传文件成功 / File uploaded successfully` ) ;
160160
161- const filestat = await sandbox . fileSystem . stat (
162- '/home/user/test-move/test_file.txt'
163- ) ;
161+ const filestat = await sandbox . fileSystem . stat ( {
162+ path : '/home/user/test-move/test_file.txt'
163+ } ) ;
164164 log ( `✓ 上传文件详情 / Uploaded file stat:` , filestat ) ;
165165
166166 const downloadPath = './downloaded_test_file.txt' ;
@@ -187,7 +187,7 @@ async function codeInterpreterExample(): Promise<void> {
187187 } ) ;
188188 log ( `✓ 写入文件成功 / File written successfully` ) ;
189189
190- const readResult = await sandbox . file . read ( '/home/user/test/test.txt' ) ;
190+ const readResult = await sandbox . file . read ( { path : '/home/user/test/test.txt' } ) ;
191191 log ( `✓ 读取文件结果 / File read result:` , readResult ) ;
192192
193193 // 测试文件移动 / File move test
@@ -198,19 +198,19 @@ async function codeInterpreterExample(): Promise<void> {
198198 } ) ;
199199 log ( `✓ 移动文件成功 / File moved successfully` ) ;
200200
201- const movedContent = await sandbox . file . read (
202- '/home/user/test-move/test2.txt'
203- ) ;
201+ const movedContent = await sandbox . file . read ( {
202+ path : '/home/user/test-move/test2.txt'
203+ } ) ;
204204 log ( `✓ 读取移动后的文件 / Read moved file:` , movedContent ) ;
205205
206206 // 测试文件详情 / File stat test
207207 log ( '\n--- 测试文件详情 / Testing file stat ---' ) ;
208- const dirStat = await sandbox . fileSystem . stat ( '/home/user/test-move' ) ;
208+ const dirStat = await sandbox . fileSystem . stat ( { path : '/home/user/test-move' } ) ;
209209 log ( `✓ 文件详情 / File stat:` , dirStat ) ;
210210
211211 // 测试删除文件 / Delete test
212212 log ( '\n--- 测试删除文件 / Testing file deletion ---' ) ;
213- await sandbox . fileSystem . remove ( '/home/user/test-move' ) ;
213+ await sandbox . fileSystem . remove ( { path : '/home/user/test-move' } ) ;
214214 log ( `✓ 删除文件夹成功 / Directory deleted successfully` ) ;
215215
216216 // 测试进程操作 / Process operations
@@ -221,7 +221,7 @@ async function codeInterpreterExample(): Promise<void> {
221221 const cmdResult = await sandbox . process . cmd ( { command : 'ls' , cwd : '/' } ) ;
222222 log ( `✓ 进程执行结果 / Process execution result:` , cmdResult ) ;
223223
224- const processDetails = await sandbox . process . get ( '1' ) ;
224+ const processDetails = await sandbox . process . get ( { pid : '1' } ) ;
225225 log ( `✓ 进程详情 / Process details:` , processDetails ) ;
226226
227227 // 清理上下文
0 commit comments