Skip to content

Commit cc382c0

Browse files
committed
refactor(sandbox): rename sandboxIdleTimeoutSeconds to sandboxIdleTimeoutInSeconds
Update parameter name across all sandbox classes and test files to use more consistent naming convention with 'inSeconds' suffix 将所有沙箱类和测试文件中的参数名从 sandboxIdleTimeoutSeconds 更新为更一致的命名约定 sandboxIdleTimeoutInSeconds Change-Id: I980240f5aece6c4cdfa83ab9699dd818315060d6 Signed-off-by: OhYee <oyohyee@oyohyee.com>
1 parent 91f37f5 commit cc382c0

14 files changed

Lines changed: 105 additions & 59 deletions

src/sandbox/aio-sandbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ export class AioSandbox extends Sandbox {
304304
static async createFromTemplate(
305305
templateName: string,
306306
options?: {
307-
sandboxIdleTimeoutSeconds?: number;
307+
sandboxIdleTimeoutInSeconds?: number;
308308
nasConfig?: NASConfig;
309309
ossMountConfig?: OSSMountConfig;
310310
polarFsConfig?: PolarFsConfig;
@@ -314,7 +314,7 @@ export class AioSandbox extends Sandbox {
314314
const sandbox = await Sandbox.create(
315315
{
316316
templateName,
317-
sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
317+
sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
318318
nasConfig: options?.nasConfig,
319319
ossMountConfig: options?.ossMountConfig,
320320
polarFsConfig: options?.polarFsConfig,

src/sandbox/api/sandbox-data.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export class SandboxDataAPI {
405405
*/
406406
createSandbox = async (params: {
407407
templateName: string;
408-
sandboxIdleTimeoutSeconds?: number;
408+
sandboxIdleTimeoutInSeconds?: number;
409409
nasConfig?: Record<string, any>;
410410
ossMountConfig?: Record<string, any>;
411411
polarFsConfig?: Record<string, any>;
@@ -419,7 +419,7 @@ export class SandboxDataAPI {
419419
// Build request data / 构建请求数据
420420
const data: Record<string, any> = {
421421
templateName: params.templateName,
422-
sandboxIdleTimeoutSeconds: params.sandboxIdleTimeoutSeconds || 600,
422+
sandboxIdleTimeoutInSeconds: params.sandboxIdleTimeoutInSeconds || 600,
423423
};
424424

425425
// Add optional parameters / 添加可选参数

src/sandbox/browser-sandbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class BrowserSandbox extends Sandbox {
3131
static async createFromTemplate(
3232
templateName: string,
3333
options?: {
34-
sandboxIdleTimeoutSeconds?: number;
34+
sandboxIdleTimeoutInSeconds?: number;
3535
nasConfig?: NASConfig;
3636
ossMountConfig?: OSSMountConfig;
3737
polarFsConfig?: PolarFsConfig;
@@ -41,7 +41,7 @@ export class BrowserSandbox extends Sandbox {
4141
const sandbox = await Sandbox.create(
4242
{
4343
templateName,
44-
sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
44+
sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
4545
nasConfig: options?.nasConfig,
4646
ossMountConfig: options?.ossMountConfig,
4747
polarFsConfig: options?.polarFsConfig,

src/sandbox/client.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ export class SandboxClient {
5959
const result = await this.controlApi.createTemplate({
6060
input: new $AgentRun.CreateTemplateInput({
6161
...finalInput,
62-
networkConfiguration: finalInput.networkConfiguration
63-
? new $AgentRun.NetworkConfiguration({
62+
networkConfiguration:
63+
finalInput.networkConfiguration ?
64+
new $AgentRun.NetworkConfiguration({
6465
...finalInput.networkConfiguration,
6566
})
6667
: undefined,
@@ -117,8 +118,9 @@ export class SandboxClient {
117118
templateName: name,
118119
input: new $AgentRun.UpdateTemplateInput({
119120
...input,
120-
networkConfiguration: input.networkConfiguration
121-
? new $AgentRun.NetworkConfiguration({
121+
networkConfiguration:
122+
input.networkConfiguration ?
123+
new $AgentRun.NetworkConfiguration({
122124
...input.networkConfiguration,
123125
})
124126
: undefined,
@@ -190,6 +192,7 @@ export class SandboxClient {
190192
const cfg = Config.withConfigs(this.config, config);
191193

192194
try {
195+
console.log({ input });
193196
const result = await this.controlApi.createSandbox({
194197
input: new $AgentRun.CreateSandboxInput({
195198
...input,
@@ -212,7 +215,7 @@ export class SandboxClient {
212215
createCodeInterpreterSandbox = async (params: {
213216
templateName: string;
214217
options?: {
215-
sandboxIdleTimeoutSeconds?: number;
218+
sandboxIdleTimeoutInSeconds?: number;
216219
nasConfig?: NASConfig;
217220
ossMountConfig?: OSSMountConfig;
218221
polarFsConfig?: PolarFsConfig;
@@ -223,7 +226,7 @@ export class SandboxClient {
223226
return CodeInterpreterSandbox.createFromTemplate(
224227
templateName,
225228
options,
226-
config ?? this.config
229+
config ?? this.config,
227230
);
228231
};
229232

@@ -234,7 +237,7 @@ export class SandboxClient {
234237
createBrowserSandbox = async (params: {
235238
templateName: string;
236239
options?: {
237-
sandboxIdleTimeoutSeconds?: number;
240+
sandboxIdleTimeoutInSeconds?: number;
238241
nasConfig?: NASConfig;
239242
ossMountConfig?: OSSMountConfig;
240243
polarFsConfig?: PolarFsConfig;
@@ -245,7 +248,7 @@ export class SandboxClient {
245248
return BrowserSandbox.createFromTemplate(
246249
templateName,
247250
options,
248-
config ?? this.config
251+
config ?? this.config,
249252
);
250253
};
251254

@@ -360,12 +363,12 @@ export class SandboxClient {
360363
config: cfg,
361364
});
362365
return (result.sandboxes || []).map((item: $AgentRun.Sandbox) =>
363-
Sandbox.fromInnerObject(item, cfg)
366+
Sandbox.fromInnerObject(item, cfg),
364367
);
365368
};
366369

367370
private prepareTemplateCreateInput(
368-
input: TemplateCreateInput
371+
input: TemplateCreateInput,
369372
): TemplateCreateInput {
370373
const defaults = this.getTemplateDefaults(input.templateType);
371374
const finalInput = { ...defaults, ...input };
@@ -381,7 +384,7 @@ export class SandboxClient {
381384
}
382385

383386
private getTemplateDefaults(
384-
templateType: TemplateType
387+
templateType: TemplateType,
385388
): Partial<TemplateCreateInput> {
386389
const base = {
387390
cpu: 2,
@@ -409,7 +412,7 @@ export class SandboxClient {
409412
input.diskSize !== 10240
410413
) {
411414
throw new Error(
412-
`When templateType is BROWSER or AIO, diskSize must be 10240, got ${input.diskSize}`
415+
`When templateType is BROWSER or AIO, diskSize must be 10240, got ${input.diskSize}`,
413416
);
414417
}
415418

@@ -419,7 +422,7 @@ export class SandboxClient {
419422
input.networkConfiguration?.networkMode === TemplateNetworkMode.PRIVATE
420423
) {
421424
throw new Error(
422-
`When templateType is CODE_INTERPRETER or AIO, networkMode cannot be PRIVATE`
425+
`When templateType is CODE_INTERPRETER or AIO, networkMode cannot be PRIVATE`,
423426
);
424427
}
425428
}

src/sandbox/code-interpreter-sandbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export class CodeInterpreterSandbox extends Sandbox {
302302
static async createFromTemplate(
303303
templateName: string,
304304
options?: {
305-
sandboxIdleTimeoutSeconds?: number;
305+
sandboxIdleTimeoutInSeconds?: number;
306306
nasConfig?: NASConfig;
307307
ossMountConfig?: OSSMountConfig;
308308
polarFsConfig?: PolarFsConfig;
@@ -312,7 +312,7 @@ export class CodeInterpreterSandbox extends Sandbox {
312312
const sandbox = await Sandbox.create(
313313
{
314314
templateName,
315-
sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
315+
sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
316316
nasConfig: options?.nasConfig,
317317
ossMountConfig: options?.ossMountConfig,
318318
polarFsConfig: options?.polarFsConfig,

src/sandbox/custom-sandbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class CustomSandbox extends Sandbox {
3030
static async createFromTemplate(
3131
templateName: string,
3232
options?: {
33-
sandboxIdleTimeoutSeconds?: number;
33+
sandboxIdleTimeoutInSeconds?: number;
3434
nasConfig?: NASConfig;
3535
ossMountConfig?: OSSMountConfig;
3636
polarFsConfig?: PolarFsConfig;
@@ -40,7 +40,7 @@ export class CustomSandbox extends Sandbox {
4040
const sandbox = await Sandbox.create(
4141
{
4242
templateName,
43-
sandboxIdleTimeoutSeconds: options?.sandboxIdleTimeoutSeconds,
43+
sandboxIdleTimeoutInSeconds: options?.sandboxIdleTimeoutInSeconds,
4444
nasConfig: options?.nasConfig,
4545
ossMountConfig: options?.ossMountConfig,
4646
polarFsConfig: options?.polarFsConfig,

src/sandbox/model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ export interface SandboxCreateInput {
354354
/**
355355
* 沙箱空闲超时时间(秒) / Sandbox Idle Timeout (seconds)
356356
*/
357-
sandboxIdleTimeoutSeconds?: number;
357+
sandboxIdleTimeoutInSeconds?: number;
358358
/**
359359
* 沙箱 ID(可选,用户可指定) / Sandbox ID (optional, user can specify)
360360
*/
@@ -503,7 +503,7 @@ export interface SandboxData {
503503
/**
504504
* 沙箱空闲超时时间(秒) / Sandbox Idle Timeout (seconds)
505505
*/
506-
sandboxIdleTimeoutSeconds?: number;
506+
sandboxIdleTimeoutInSeconds?: number;
507507
/**
508508
* 沙箱结束时间 / Sandbox End Time
509509
*/

src/sandbox/sandbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Sandbox extends ResourceBase implements SandboxData {
6060
/**
6161
* 沙箱空闲超时时间(秒) / Sandbox Idle Timeout (seconds)
6262
*/
63-
sandboxIdleTimeoutSeconds?: number;
63+
sandboxIdleTimeoutInSeconds?: number;
6464
/**
6565
* 沙箱结束时间 / Sandbox End Time
6666
*/
@@ -105,7 +105,7 @@ export class Sandbox extends ResourceBase implements SandboxData {
105105
stateReason: obj.stateReason,
106106
createdAt: obj.createdAt,
107107
lastUpdatedAt: obj.lastUpdatedAt,
108-
sandboxIdleTimeoutSeconds: obj.sandboxIdleTimeoutSeconds,
108+
sandboxIdleTimeoutInSeconds: obj.sandboxIdleTimeoutInSeconds,
109109
// New fields / 新增字段
110110
endedAt: obj.endedAt,
111111
metadata: obj.metadata,

tests/e2e/sandbox/browser-sandbox.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Browser Sandbox E2E Tests', () => {
8787
// 注意: BrowserSandbox.createFromTemplate 方法需要先创建模板
8888
sandbox = await BrowserSandbox.createFromTemplate(
8989
templateName,
90-
{ sandboxIdleTimeoutSeconds: 600 }
90+
{ sandboxIdleTimeoutInSeconds: 600 }
9191
);
9292

9393
// 等待 Sandbox 就绪

tests/e2e/sandbox/code-interpreter-sandbox.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('Sandbox Code Interpreter E2E Tests', () => {
8989
// 注意: CodeInterpreterSandbox.createFromTemplate 方法需要先创建模板
9090
sandbox = await CodeInterpreterSandbox.createFromTemplate(
9191
templateName,
92-
{ sandboxIdleTimeoutSeconds: 600 }
92+
{ sandboxIdleTimeoutInSeconds: 600 }
9393
);
9494

9595
// 等待 Sandbox 就绪

0 commit comments

Comments
 (0)