diff --git a/sec-gemini-ts/src/session.ts b/sec-gemini-ts/src/session.ts index 4747fc7..0eb63d4 100644 --- a/sec-gemini-ts/src/session.ts +++ b/sec-gemini-ts/src/session.ts @@ -286,8 +286,8 @@ export class InteractiveSession { } = options; // --- Validation --- - if (ttl <= MIN_TTL_SECONDS) { - throw new Error(`TTL must be greater than ${MIN_TTL_SECONDS} seconds.`); + if (ttl < MIN_TTL_SECONDS) { + throw new Error(`TTL must be at least ${MIN_TTL_SECONDS} seconds.`); } if (!model || !model.model_string) { throw new Error('Valid ModelInfoInput object is required for registration.'); @@ -499,8 +499,8 @@ export class InteractiveSession { // Apply TTL update logic if (ttl > 0) { - if (ttl <= MIN_TTL_SECONDS) { - throw new Error(`TTL must be greater than ${MIN_TTL_SECONDS} seconds`); + if (ttl < MIN_TTL_SECONDS) { + throw new Error(`TTL must be at least ${MIN_TTL_SECONDS} seconds`); } updatePayload.ttl = ttl; } diff --git a/sec-gemini-ts/tests/session.test.ts b/sec-gemini-ts/tests/session.test.ts index 008c79e..0709cf8 100644 --- a/sec-gemini-ts/tests/session.test.ts +++ b/sec-gemini-ts/tests/session.test.ts @@ -134,6 +134,20 @@ describe('Session', () => { jest.clearAllTimers(); openedUrl = ''; }); + test('should throw error when TTL is below minimum', async () => { + const registerPromise = session.register({ + ttl: 299, + model: model, + }); + await expect(registerPromise).rejects.toThrow('TTL must be at least 300 seconds.'); + }); + test('should register session when TTL is exactly 300', async () => { + const registerPromise = session.register({ + ttl: 300, + model: model, + }); + await expect(registerPromise).resolves.not.toThrow(); + }); test('should throw error when registering session', async () => { // Throw error during post request to register session. registerSession.mockImplementationOnce(() => {