@@ -10,7 +10,6 @@ import {
10
10
Client ,
11
11
defaultValues ,
12
12
Dm ,
13
- sdkVersions ,
14
13
type Consent ,
15
14
type Conversation ,
16
15
type DecodedMessage ,
@@ -201,30 +200,7 @@ export class WorkerClient extends Worker {
201
200
env ,
202
201
) ;
203
202
204
- // Extract SDK version from name if it exists (e.g., ivi-100 would use v100)
205
- const nameParts = this . name . split ( "-" ) ;
206
- const versionSuffix =
207
- nameParts . length > 1 ? nameParts [ nameParts . length - 1 ] : null ;
208
-
209
- // Determine which SDK version to use
210
- let clientClass : typeof Client ;
211
- if (
212
- versionSuffix &&
213
- / ^ \d + $ / . test ( versionSuffix ) &&
214
- `v${ versionSuffix } ` in sdkVersions
215
- ) {
216
- const version = `v${ versionSuffix } ` as keyof typeof sdkVersions ;
217
- console . log (
218
- `[${ this . nameId } ] Using SDK version ${ version } for worker ${ this . name } ` ,
219
- ) ;
220
- clientClass = sdkVersions [ version ] . Client as typeof Client ;
221
- } else {
222
- // Default to latest version (v104)
223
- clientClass = sdkVersions . v104 . Client ;
224
- }
225
-
226
- // Create the client with the appropriate version
227
- this . client = await clientClass . create ( signer , encryptionKey , {
203
+ this . client = await Client . create ( signer , encryptionKey , {
228
204
dbPath,
229
205
env,
230
206
loggingLevel : process . env . LOGGING_LEVEL as LogLevel ,
@@ -342,18 +318,12 @@ export class WorkerClient extends Worker {
342
318
*/
343
319
private shouldGenerateGptResponse ( message : DecodedMessage ) : boolean {
344
320
if ( ! this . gptEnabled ) return false ;
345
-
346
- // Get the conversation
347
321
const conversation = this . client . conversations . getConversationById (
348
322
message . conversationId ,
349
323
) ;
350
-
351
324
// Get the base name without installation ID
352
325
const baseName = this . name . split ( "-" ) [ 0 ] . toLowerCase ( ) ;
353
-
354
- // Check if it's a DM - need to handle different SDK versions
355
- const isDm = this . isDmConversation ( conversation ) ;
356
-
326
+ const isDm = conversation instanceof Dm ;
357
327
return ( ( message ?. contentType ?. typeId === "text" &&
358
328
message . content . includes ( baseName ) &&
359
329
! message . content . includes ( "/" ) &&
@@ -363,26 +333,6 @@ export class WorkerClient extends Worker {
363
333
isDm ) as boolean ;
364
334
}
365
335
366
- // Add a helper method to check if a conversation is a DM across SDK versions
367
- private isDmConversation ( conversation : any ) : boolean {
368
- // Extract version suffix if it exists
369
- const nameParts = this . name . split ( "-" ) ;
370
- const versionSuffix =
371
- nameParts . length > 1 ? nameParts [ nameParts . length - 1 ] : null ;
372
-
373
- if (
374
- versionSuffix &&
375
- / ^ \d + $ / . test ( versionSuffix ) &&
376
- `v${ versionSuffix } ` in sdkVersions
377
- ) {
378
- const version = `v${ versionSuffix } ` as keyof typeof sdkVersions ;
379
- return conversation instanceof sdkVersions [ version ] . Dm ;
380
- }
381
-
382
- // Default to latest version
383
- return conversation instanceof sdkVersions . v104 . Dm ;
384
- }
385
-
386
336
/**
387
337
* Handle generating and sending GPT responses
388
338
*/
0 commit comments