{"version":3,"sources":["/home/mkabumattar/work/withrawi/rawi/dist/chunk-23ZSXDYA.cjs","../src/core/providers/google.provider.ts"],"names":["googleModelIds","googleModels","name","googleProvider","streamWithGoogle","credentials","prompt","settings","apiKey","baseURL","createGoogleGenerativeAI","result","streamText","error"],"mappings":"AAAA;AACA,wDAAwC,wCCAD,wBAEA,IAoBjCA,CAAAA,CAAiB,CACrB,kBAAA,CACA,yBAAA,CACA,sBAAA,CACA,sBAAA,CACA,qBAAA,CACA,4BAAA,CACA,yBAAA,CACA,gBAAA,CACA,uBAAA,CACA,oBAAA,CACA,oBAAA,CACA,kBAAA,CACA,sBAAA,CACA,2BAAA,CACA,uBAAA,CACA,0BAAA,CACA,qCAAA,CACA,sBAAA,CACA,gBAAA,CACA,kBAAA,CACA,uBAAA,CACA,0BAAA,CACA,gCAAA,CACA,iBAAA,CACA,gBAAA,CACA,gBACF,CAAA,CAEaC,CAAAA,aAA4BD,CAAAA,CAAe,GAAA,CAAKE,CAAAA,EAAAA,CAAU,CACrE,IAAA,CAAAA,CAAAA,CACA,WAAA,CAAaA,CACf,CAAA,CAAE,CAAA,CAEWC,CAAAA,aAAiB,CAC5B,IAAA,CAAM,QAAA,CACN,WAAA,CAAa,2BAAA,CACb,MAAA,CAAQF,CACV,CAAA,CAEaG,CAAAA,aAAmB,KAAA,CAC9BC,CAAAA,CACAC,CAAAA,CAAAA,EAC+B,CAC/B,GAAI,CACF,IAAMC,CAAAA,CAAWF,CAAAA,CAAY,gBAAA,CAEvBG,CAAAA,iBAASD,CAAAA,2BAAU,QAAA,EAAUF,CAAAA,CAAY,MAAA,CAE/C,EAAA,CAAI,CAACG,CAAAA,CACH,MAAM,IAAI,KAAA,CAAM,gCAAgC,CAAA,CAGlD,IAAMC,CAAAA,iBACJF,CAAAA,6BAAU,SAAA,EAAW,kDAAA,CAEjBJ,CAAAA,CAA6CO,8CAAAA,CAE/C,MAAA,CAAQF,CAAAA,CACR,OAAA,CAASC,CACX,CACF,CAAA,CAEME,CAAAA,CAASC,4BAAAA,CACb,KAAA,CAAOT,CAAAA,CAAeE,CAAAA,CAAY,KAAK,CAAA,CACvC,MAAA,CAAAC,CAAAA,CACA,WAAA,CAAaD,CAAAA,CAAY,WAAA,EAAe,EAAA,CACxC,eAAA,CAAiBA,CAAAA,CAAY,SAAA,EAAa,IAC5C,CAAC,CAAA,CAED,MAAO,CACL,UAAA,CAAYM,CAAAA,CAAO,UAAA,CACnB,YAAA,CAAcA,CAAAA,CAAO,IACvB,CACF,CAAA,KAAA,CAASE,CAAAA,CAAO,CACd,MAAM,IAAI,KAAA,CACR,CAAA,uCAAA,EACEA,EAAAA,WAAiB,KAAA,CAAQA,CAAAA,CAAM,OAAA,CAAU,MAAA,CAAOA,CAAK,CACvD,CAAA,CAAA;ADnGozC","file":"/home/mkabumattar/work/withrawi/rawi/dist/chunk-23ZSXDYA.cjs","sourcesContent":[null,"import type {GoogleGenerativeAIProvider, google} from '@ai-sdk/google';\nimport {createGoogleGenerativeAI} from '@ai-sdk/google';\nimport type {ModelMessage} from 'ai';\nimport {generateText, streamText} from 'ai';\nimport {parseCommandFromResponse} from '../exec/parser.js';\nimport type {\n  GoogleSettings,\n  LooseToStrict,\n  ModelInfo,\n  RawiCredentials,\n  StreamingResponse,\n} from '../shared/index.js';\nimport type {\n  ChatCredentials,\n  ChatProvider,\n  ChatStreamOptions,\n  ExecGenerationOptions,\n  ExecGenerationResult,\n} from './types.js';\n\ntype LooseGoogleModelId = Parameters<typeof google>[0];\nexport type GoogleModelId = LooseToStrict<LooseGoogleModelId>;\n\nconst googleModelIds = [\n  'gemini-1.5-flash',\n  'gemini-1.5-flash-latest',\n  'gemini-1.5-flash-001',\n  'gemini-1.5-flash-002',\n  'gemini-1.5-flash-8b',\n  'gemini-1.5-flash-8b-latest',\n  'gemini-1.5-flash-8b-001',\n  'gemini-1.5-pro',\n  'gemini-1.5-pro-latest',\n  'gemini-1.5-pro-001',\n  'gemini-1.5-pro-002',\n  'gemini-2.0-flash',\n  'gemini-2.0-flash-001',\n  'gemini-2.0-flash-live-001',\n  'gemini-2.0-flash-lite',\n  'gemini-2.0-pro-exp-02-05',\n  'gemini-2.0-flash-thinking-exp-01-21',\n  'gemini-2.0-flash-exp',\n  'gemini-2.5-pro',\n  'gemini-2.5-flash',\n  'gemini-2.5-flash-lite',\n  'gemini-2.5-pro-exp-03-25',\n  'gemini-2.5-flash-preview-04-17',\n  'gemini-exp-1206',\n  'gemma-3-12b-it',\n  'gemma-3-27b-it',\n] as const;\n\nexport const googleModels: ModelInfo[] = googleModelIds.map((name) => ({\n  name,\n  displayName: name,\n}));\n\nexport const googleProvider = {\n  name: 'google' as const,\n  displayName: '🔴 Google (Gemini)',\n  models: googleModels,\n};\n\nexport const streamWithGoogle = async (\n  credentials: RawiCredentials,\n  prompt: string,\n): Promise<StreamingResponse> => {\n  try {\n    const settings = credentials.providerSettings as GoogleSettings | undefined;\n\n    const apiKey = settings?.apiKey || credentials.apiKey;\n\n    if (!apiKey) {\n      throw new Error('API key is required for Google');\n    }\n\n    const baseURL =\n      settings?.baseURL || 'https://generativelanguage.googleapis.com/v1beta';\n\n    const googleProvider: GoogleGenerativeAIProvider = createGoogleGenerativeAI(\n      {\n        apiKey: apiKey,\n        baseURL: baseURL,\n      },\n    );\n\n    const result = streamText({\n      model: googleProvider(credentials.model),\n      prompt,\n      temperature: credentials.temperature || 0.7,\n      maxOutputTokens: credentials.maxTokens || 2048,\n    });\n\n    return {\n      textStream: result.textStream,\n      fullResponse: result.text,\n    };\n  } catch (error) {\n    throw new Error(\n      `Error calling Google AI streaming API: ${\n        error instanceof Error ? error.message : String(error)\n      }`,\n    );\n  }\n};\n\nexport const googleChatProvider: ChatProvider = {\n  name: 'google',\n  displayName: '🔴 Google (Gemini)',\n\n  async streamChat(\n    credentials: ChatCredentials,\n    messages: ModelMessage[],\n    options: ChatStreamOptions = {},\n  ): Promise<AsyncIterable<string>> {\n    const settings = credentials.providerSettings || {};\n    const apiKey = settings.apiKey || credentials.apiKey;\n\n    if (!apiKey) {\n      throw new Error('API key is required for Google');\n    }\n\n    const googleProvider = createGoogleGenerativeAI({\n      apiKey: apiKey,\n    });\n\n    const result = streamText({\n      model: googleProvider(credentials.model),\n      messages,\n      temperature: credentials.temperature || options.temperature || 0.7,\n      maxOutputTokens: credentials.maxTokens || options.maxTokens || 2048,\n    });\n\n    return result.textStream;\n  },\n};\n\nexport const generateWithGoogle = async (\n  options: ExecGenerationOptions,\n): Promise<ExecGenerationResult> => {\n  const startTime = Date.now();\n\n  try {\n    const googleSettings = options.credentials\n      .providerSettings as GoogleSettings;\n\n    const googleProvider = createGoogleGenerativeAI({\n      apiKey: options.credentials.apiKey,\n      baseURL: googleSettings?.baseURL,\n    });\n\n    const result = await generateText({\n      model: googleProvider(options.credentials.model),\n      system: options.systemPrompt,\n      prompt: options.userPrompt,\n    });\n\n    const generationTime = Date.now() - startTime;\n\n    const command = parseCommandFromResponse(result.text);\n\n    return {\n      command,\n      generationTime,\n    };\n  } catch (error) {\n    throw new Error(`Google exec generation failed: ${error}`);\n  }\n};\n"]}