@elizaos/plugin-openrouter 1.3.1 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/dist/browser/index.browser.js +968 -0
- package/dist/browser/index.browser.js.map +20 -0
- package/dist/browser/index.d.ts +2 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.node.cjs +630 -0
- package/dist/cjs/index.node.js.map +19 -0
- package/dist/index.browser.d.ts +2 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.node.d.ts +2 -0
- package/dist/init.d.ts +6 -0
- package/dist/models/image.d.ts +14 -0
- package/dist/models/index.d.ts +3 -0
- package/dist/models/object.d.ts +9 -0
- package/dist/models/text.d.ts +17 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/{index.js → node/index.node.js} +178 -118
- package/dist/node/index.node.js.map +19 -0
- package/dist/providers/index.d.ts +1 -0
- package/dist/providers/openrouter.d.ts +8 -0
- package/dist/types/index.d.ts +60 -0
- package/dist/utils/config.d.ts +57 -0
- package/dist/utils/events.d.ts +6 -0
- package/dist/utils/helpers.d.ts +29 -0
- package/dist/utils/image-storage.d.ts +8 -0
- package/dist/utils/index.d.ts +2 -0
- package/package.json +27 -20
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts", "../../src/init.ts", "../../src/utils/config.ts", "../../src/models/text.ts", "../../src/providers/openrouter.ts", "../../src/utils/events.ts", "../../src/utils/helpers.ts", "../../src/models/object.ts", "../../src/models/image.ts", "../../src/utils/image-storage.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n ModelType,\n type Plugin,\n type IAgentRuntime,\n type GenerateTextParams,\n type ObjectGenerationParams,\n type ImageDescriptionParams,\n type ImageGenerationParams,\n} from \"@elizaos/core\";\nimport type { Tool, ToolChoice } from \"ai\";\nimport { initializeOpenRouter } from \"./init\";\nimport { handleTextSmall, handleTextLarge } from \"./models/text\";\nimport { handleObjectSmall, handleObjectLarge } from \"./models/object\";\nimport { handleImageDescription, handleImageGeneration } from \"./models/image\";\n\n/**\n * Defines the OpenRouter plugin with its name, description, and configuration options.\n * @type {Plugin}\n */\nexport const openrouterPlugin: Plugin = {\n name: \"openrouter\",\n description: \"OpenRouter plugin\",\n config: {\n OPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,\n OPENROUTER_BASE_URL: process.env.OPENROUTER_BASE_URL,\n OPENROUTER_SMALL_MODEL: process.env.OPENROUTER_SMALL_MODEL,\n OPENROUTER_LARGE_MODEL: process.env.OPENROUTER_LARGE_MODEL,\n OPENROUTER_IMAGE_MODEL: process.env.OPENROUTER_IMAGE_MODEL,\n OPENROUTER_IMAGE_GENERATION_MODEL:\n process.env.OPENROUTER_IMAGE_GENERATION_MODEL,\n OPENROUTER_AUTO_CLEANUP_IMAGES: process.env.OPENROUTER_AUTO_CLEANUP_IMAGES,\n SMALL_MODEL: process.env.SMALL_MODEL,\n LARGE_MODEL: process.env.LARGE_MODEL,\n IMAGE_MODEL: process.env.IMAGE_MODEL,\n IMAGE_GENERATION_MODEL: process.env.IMAGE_GENERATION_MODEL,\n },\n async init(config, runtime) {\n // Note: We intentionally don't await here because ElizaOS expects\n // the init method to return quickly. The initializeOpenRouter function\n // only performs synchronous validation and logging, so it's safe to\n // call without await. This prevents blocking the plugin initialization.\n initializeOpenRouter(config, runtime);\n },\n models: {\n [ModelType.TEXT_SMALL]: async (\n runtime: IAgentRuntime,\n params: GenerateTextParams & {\n tools?: Record<string, Tool>;\n toolChoice?: ToolChoice<Record<string, Tool>>;\n },\n ) => {\n return handleTextSmall(runtime, params);\n },\n [ModelType.TEXT_LARGE]: async (\n runtime: IAgentRuntime,\n params: GenerateTextParams & {\n tools?: Record<string, Tool>;\n toolChoice?: ToolChoice<Record<string, Tool>>;\n },\n ) => {\n return handleTextLarge(runtime, params);\n },\n [ModelType.OBJECT_SMALL]: async (\n runtime: IAgentRuntime,\n params: ObjectGenerationParams,\n ) => {\n return handleObjectSmall(runtime, params);\n },\n [ModelType.OBJECT_LARGE]: async (\n runtime: IAgentRuntime,\n params: ObjectGenerationParams,\n ) => {\n return handleObjectLarge(runtime, params);\n },\n [ModelType.IMAGE_DESCRIPTION]: async (\n runtime: IAgentRuntime,\n params: ImageDescriptionParams | string,\n ) => {\n return handleImageDescription(runtime, params);\n },\n [ModelType.IMAGE]: async (\n runtime: IAgentRuntime,\n params: ImageGenerationParams,\n ) => {\n return handleImageGeneration(runtime, params);\n },\n },\n};\n\nexport default openrouterPlugin;\n",
|
|
6
|
+
"import { logger, type IAgentRuntime } from \"@elizaos/core\";\nimport { fetch } from \"undici\";\nimport { getApiKey, getBaseURL } from \"./utils/config\";\n\n/**\n * Initialize and validate OpenRouter configuration\n * Returns the exact same function that works inline\n */\nexport function initializeOpenRouter(_config: any, runtime: IAgentRuntime) {\n // do check in the background\n (async () => {\n try {\n const isBrowser =\n typeof globalThis !== \"undefined\" && (globalThis as any).document;\n // In browser, skip validation entirely to avoid exposing secrets\n if (isBrowser) {\n return;\n }\n if (!getApiKey(runtime)) {\n logger.warn(\n \"OPENROUTER_API_KEY is not set in environment - OpenRouter functionality will be limited\",\n );\n return;\n }\n try {\n const baseURL = getBaseURL(runtime);\n const response = await fetch(`${baseURL}/models`, {\n headers: { Authorization: `Bearer ${getApiKey(runtime)}` },\n });\n if (!response.ok) {\n logger.warn(\n `OpenRouter API key validation failed: ${response.statusText}`,\n );\n logger.warn(\n \"OpenRouter functionality will be limited until a valid API key is provided\",\n );\n } else {\n logger.log(\"OpenRouter API key validated successfully\");\n }\n } catch (fetchError: unknown) {\n const message =\n fetchError instanceof Error ? fetchError.message : String(fetchError);\n logger.warn(`Error validating OpenRouter API key: ${message}`);\n logger.warn(\n \"OpenRouter functionality will be limited until a valid API key is provided\",\n );\n }\n } catch (error: unknown) {\n const message =\n (error as { errors?: Array<{ message: string }> })?.errors\n ?.map((e) => e.message)\n .join(\", \") ||\n (error instanceof Error ? error.message : String(error));\n logger.warn(\n `OpenRouter plugin configuration issue: ${message} - You need to configure the OPENROUTER_API_KEY in your environment variables`,\n );\n }\n })();\n return;\n}\n",
|
|
7
|
+
"import type { IAgentRuntime } from \"@elizaos/core\";\n\n/**\n * Retrieves a configuration setting from the runtime, falling back to environment variables or a default value if not found.\n *\n * @param key - The name of the setting to retrieve.\n * @param defaultValue - The value to return if the setting is not found in the runtime or environment.\n * @returns The resolved setting value, or {@link defaultValue} if not found.\n */\nexport function getSetting(\n runtime: IAgentRuntime,\n key: string,\n defaultValue?: string,\n): string | undefined {\n return runtime.getSetting(key) ?? process.env[key] ?? defaultValue;\n}\n\n/**\n * Retrieves the OpenRouter API base URL from runtime settings, environment variables, or defaults.\n *\n * @returns The resolved base URL for OpenRouter API requests.\n */\nexport function getBaseURL(runtime: IAgentRuntime): string {\n const browserURL = getSetting(runtime, \"OPENROUTER_BROWSER_BASE_URL\");\n if (\n typeof globalThis !== \"undefined\" &&\n (globalThis as any).document &&\n browserURL\n ) {\n return browserURL;\n }\n return (\n getSetting(\n runtime,\n \"OPENROUTER_BASE_URL\",\n \"https://openrouter.ai/api/v1\",\n ) || \"https://openrouter.ai/api/v1\"\n );\n}\n\n/**\n * Helper function to get the API key for OpenRouter\n *\n * @param runtime The runtime context\n * @returns The configured API key\n */\nexport function getApiKey(runtime: IAgentRuntime): string | undefined {\n return getSetting(runtime, \"OPENROUTER_API_KEY\");\n}\n\n/**\n * Helper function to get the small model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured small model name\n */\nexport function getSmallModel(runtime: IAgentRuntime): string {\n return (\n getSetting(runtime, \"OPENROUTER_SMALL_MODEL\") ??\n getSetting(runtime, \"SMALL_MODEL\", \"google/gemini-2.0-flash-001\") ??\n \"google/gemini-2.0-flash-001\"\n );\n}\n\n/**\n * Helper function to get the large model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured large model name\n */\nexport function getLargeModel(runtime: IAgentRuntime): string {\n return (\n getSetting(runtime, \"OPENROUTER_LARGE_MODEL\") ??\n getSetting(runtime, \"LARGE_MODEL\", \"google/gemini-2.5-flash\") ??\n \"google/gemini-2.5-flash\"\n );\n}\n\n/**\n * Helper function to get the image model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured image model name\n */\nexport function getImageModel(runtime: IAgentRuntime): string {\n return (\n getSetting(runtime, \"OPENROUTER_IMAGE_MODEL\") ??\n getSetting(runtime, \"IMAGE_MODEL\", \"x-ai/grok-2-vision-1212\") ??\n \"x-ai/grok-2-vision-1212\"\n );\n}\n\n/**\n * Helper function to get the image generation model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured image generation model name\n */\nexport function getImageGenerationModel(runtime: IAgentRuntime): string {\n return (\n getSetting(runtime, \"OPENROUTER_IMAGE_GENERATION_MODEL\") ??\n getSetting(\n runtime,\n \"IMAGE_GENERATION_MODEL\",\n \"google/gemini-2.5-flash-image-preview\",\n ) ??\n \"google/gemini-2.5-flash-image-preview\"\n );\n}\n\n/**\n * Helper function to check if auto cleanup is enabled for generated images\n *\n * @param runtime The runtime context\n * @returns Whether to auto-cleanup generated images (default: false)\n */\nexport function shouldAutoCleanupImages(runtime: IAgentRuntime): boolean {\n const setting = getSetting(\n runtime,\n \"OPENROUTER_AUTO_CLEANUP_IMAGES\",\n \"false\",\n );\n return setting?.toLowerCase() === \"true\";\n}\n",
|
|
8
|
+
"import type { GenerateTextParams, IAgentRuntime } from \"@elizaos/core\";\nimport { logger, ModelType } from \"@elizaos/core\";\nimport { generateText } from \"ai\";\nimport type { Tool, ToolChoice } from \"ai\";\n\nimport { createOpenRouterProvider } from \"../providers\";\nimport type { ToolCall, ToolResponse, ToolResult } from \"../types\";\nimport { getSmallModel, getLargeModel } from \"../utils/config\";\nimport { emitModelUsageEvent } from \"../utils/events\";\nimport { handleEmptyToolResponse, decodeBase64Fields } from \"../utils/helpers\";\n\n/**\n * Common text generation logic for both small and large models\n */\nasync function generateTextWithModel(\n runtime: IAgentRuntime,\n modelType: typeof ModelType.TEXT_SMALL | typeof ModelType.TEXT_LARGE,\n params: GenerateTextParams & {\n tools?: Record<string, Tool>;\n toolChoice?: ToolChoice<Record<string, Tool>>;\n },\n): Promise<string | ToolResponse> {\n const { prompt, stopSequences = [], tools, toolChoice } = params;\n const temperature = params.temperature ?? 0.7;\n const frequencyPenalty = params.frequencyPenalty ?? 0.7;\n const presencePenalty = params.presencePenalty ?? 0.7;\n // AI SDK v5: prefer maxOutputTokens; keep legacy maxTokens as fallback; default 8192\n const resolvedMaxOutput =\n (params as any).maxOutputTokens ?? (params as any).maxTokens ?? 8192;\n\n const openrouter = createOpenRouterProvider(runtime);\n const modelName =\n modelType === ModelType.TEXT_SMALL\n ? getSmallModel(runtime)\n : getLargeModel(runtime);\n const modelLabel =\n modelType === ModelType.TEXT_SMALL ? \"TEXT_SMALL\" : \"TEXT_LARGE\";\n\n logger.log(\n `[OpenRouter] Generating text with ${modelLabel} model: ${modelName}`,\n );\n\n const generateParams: Parameters<typeof generateText>[0] = {\n model: openrouter.chat(modelName),\n prompt: prompt,\n system: runtime.character.system ?? undefined,\n temperature: temperature,\n frequencyPenalty: frequencyPenalty,\n presencePenalty: presencePenalty,\n stopSequences: stopSequences,\n };\n\n (generateParams as any).maxOutputTokens = resolvedMaxOutput;\n\n // Add tools if provided\n if (tools) {\n (generateParams as any).tools = tools;\n }\n\n // Add toolChoice if provided\n if (toolChoice) {\n (generateParams as any).toolChoice = toolChoice;\n }\n\n // Capture tool results if tools are used\n let capturedToolResults: ToolResult[] = [];\n let capturedToolCalls: ToolCall[] = [];\n\n if (tools) {\n (generateParams as any).onStepFinish = async (stepResult: any) => {\n if (stepResult.toolCalls && stepResult.toolCalls.length > 0) {\n capturedToolCalls = [\n ...capturedToolCalls,\n ...(stepResult.toolCalls as any),\n ];\n }\n if (stepResult.toolResults && stepResult.toolResults.length > 0) {\n const decodedToolResults = (stepResult.toolResults as any[]).map(\n (result: any) => ({\n toolCallId: result.toolCallId,\n result: decodeBase64Fields(result.result),\n }),\n );\n capturedToolResults = [...capturedToolResults, ...decodedToolResults];\n }\n };\n }\n\n const response = await generateText(generateParams);\n\n // Handle cases where tool execution doesn't generate text\n let responseText: string;\n if (\n tools &&\n (!response.text ||\n response.text.trim() === \"\" ||\n response.text === \"Tools executed successfully.\")\n ) {\n responseText = handleEmptyToolResponse(modelLabel);\n } else {\n responseText = response.text;\n }\n\n if (response.usage) {\n emitModelUsageEvent(runtime, modelType, prompt, response.usage);\n }\n\n // If tools were used, return the full response object to access toolCalls and toolResults\n if (\n tools &&\n (capturedToolCalls.length > 0 || capturedToolResults.length > 0)\n ) {\n return {\n text: responseText,\n toolCalls: capturedToolCalls,\n toolResults: capturedToolResults,\n // Include other useful properties\n usage: response.usage,\n finishReason: response.finishReason,\n };\n }\n\n return responseText;\n}\n\n/**\n * TEXT_SMALL model handler\n */\nexport async function handleTextSmall(\n runtime: IAgentRuntime,\n params: GenerateTextParams & {\n tools?: Record<string, Tool>;\n toolChoice?: ToolChoice<Record<string, Tool>>;\n },\n): Promise<string | ToolResponse> {\n return generateTextWithModel(runtime, ModelType.TEXT_SMALL, params);\n}\n\n/**\n * TEXT_LARGE model handler\n */\nexport async function handleTextLarge(\n runtime: IAgentRuntime,\n params: GenerateTextParams & {\n tools?: Record<string, Tool>;\n toolChoice?: ToolChoice<Record<string, Tool>>;\n },\n): Promise<string | ToolResponse> {\n return generateTextWithModel(runtime, ModelType.TEXT_LARGE, params);\n}\n",
|
|
9
|
+
"import { createOpenRouter } from \"@openrouter/ai-sdk-provider\";\nimport { logger, type IAgentRuntime } from \"@elizaos/core\";\nimport { getApiKey, getBaseURL } from \"../utils/config\";\n\n/**\n * Create an OpenRouter provider instance with proper configuration\n *\n * @param runtime The runtime context\n * @returns Configured OpenRouter provider instance\n */\nexport function createOpenRouterProvider(runtime: IAgentRuntime) {\n const apiKey = getApiKey(runtime);\n const isBrowser =\n typeof globalThis !== \"undefined\" && (globalThis as any).document;\n const baseURL = getBaseURL(runtime);\n // In browser, omit apiKey and rely on proxy baseURL\n return createOpenRouter({\n apiKey: isBrowser ? undefined : apiKey,\n baseURL,\n });\n}\n",
|
|
10
|
+
"import {\n EventType,\n type IAgentRuntime,\n type ModelTypeName,\n} from \"@elizaos/core\";\nimport type { LanguageModelUsage } from \"ai\";\n\n/**\n * Emits a model usage event\n */\nexport function emitModelUsageEvent(\n runtime: IAgentRuntime,\n type: ModelTypeName,\n prompt: string,\n usage: LanguageModelUsage,\n) {\n // Never emit the full prompt; truncate to avoid leaking secrets/PII\n const truncatedPrompt =\n typeof prompt === \"string\"\n ? prompt.length > 200\n ? `${prompt.slice(0, 200)}…`\n : prompt\n : \"\";\n // Coalesce optional usage fields to stable numbers\n const inputTokens = Number(usage.inputTokens || 0);\n const outputTokens = Number(usage.outputTokens || 0);\n const totalTokens = Number(\n usage.totalTokens != null ? usage.totalTokens : inputTokens + outputTokens,\n );\n runtime.emitEvent(EventType.MODEL_USED, {\n provider: \"openrouter\",\n type,\n prompt: truncatedPrompt,\n tokens: {\n prompt: inputTokens,\n completion: outputTokens,\n total: totalTokens,\n },\n });\n}\n",
|
|
11
|
+
"import { logger } from \"@elizaos/core\";\nimport { JSONParseError } from \"ai\";\nimport type { GenerateTextResponse, ImageDescriptionResult } from \"../types\";\n\n/**\n * Returns a function to repair JSON text\n */\nexport function getJsonRepairFunction(): (params: {\n text: string;\n error: unknown;\n}) => Promise<string | null> {\n return async ({ text, error }: { text: string; error: unknown }) => {\n try {\n if (error instanceof JSONParseError) {\n const cleanedText = text.replace(/```json\\n|\\n```|```/g, \"\");\n JSON.parse(cleanedText);\n return cleanedText;\n }\n return null;\n } catch (jsonError: unknown) {\n const message =\n jsonError instanceof Error ? jsonError.message : String(jsonError);\n logger.warn(`Failed to repair JSON text: ${message}`);\n return null;\n }\n };\n}\n\n// Re-export for backward compatibility\nexport { emitModelUsageEvent } from \"./events\";\n\n/**\n * Logs response structure for debugging (debug level only)\n */\nexport function logResponseStructure(\n modelType: string,\n response: GenerateTextResponse,\n) {\n // Only log safe, non-sensitive usage fields (avoid raw request bodies)\n const u = (response as any)?.usage;\n const safeUsage =\n u && typeof u === \"object\"\n ? {\n inputTokens: u.inputTokens,\n outputTokens: u.outputTokens,\n totalTokens: u.totalTokens,\n }\n : undefined;\n logger.debug(\n `[${modelType}] Response structure: ${JSON.stringify(\n {\n hasText: !!response.text,\n textLength: response.text?.length || 0,\n hasSteps: !!response.steps,\n stepsCount: response.steps?.length || 0,\n finishReason: response.finishReason,\n usage: safeUsage,\n },\n null,\n 2,\n )}`,\n );\n}\n\n/**\n * Handles cases where tool execution doesn't generate text\n */\nexport function handleEmptyToolResponse(modelType: string): string {\n logger.warn(`[${modelType}] No text generated after tool execution`);\n\n const fallbackText =\n \"I executed the requested action. The tool completed successfully.\";\n logger.warn(`[${modelType}] Using fallback response text`);\n return fallbackText;\n}\n\n/**\n * Parses image description response from text or JSON format\n */\nexport function parseImageDescriptionResponse(\n responseText: string,\n): ImageDescriptionResult {\n // Try to parse as JSON first\n try {\n const jsonResponse = JSON.parse(responseText);\n if (jsonResponse.title && jsonResponse.description) {\n return jsonResponse;\n }\n } catch (e) {\n // If not valid JSON, process as text\n logger.debug(`Parsing as JSON failed, processing as text: ${e}`);\n }\n\n // Extract title and description from text format\n const titleMatch = responseText.match(/title[:\\s]+(.+?)(?:\\n|$)/i);\n const title = titleMatch?.[1]?.trim() || \"Image Analysis\";\n const description = responseText\n .replace(/title[:\\s]+(.+?)(?:\\n|$)/i, \"\")\n .trim();\n\n return { title, description };\n}\n\n/**\n * Handles errors during object generation, including JSON repair attempts\n */\nexport async function handleObjectGenerationError(\n error: unknown,\n): Promise<unknown> {\n if (error instanceof JSONParseError) {\n logger.error(`[generateObject] Failed to parse JSON: ${error.message}`);\n const repairFunction = getJsonRepairFunction();\n const repairedJsonString = await repairFunction({\n text: error.text,\n error,\n });\n\n if (repairedJsonString) {\n try {\n const repairedObject = JSON.parse(repairedJsonString);\n logger.log(\"[generateObject] Successfully repaired JSON.\");\n return repairedObject;\n } catch (repairParseError: unknown) {\n const message =\n repairParseError instanceof Error\n ? repairParseError.message\n : String(repairParseError);\n logger.error(\n `[generateObject] Failed to parse repaired JSON: ${message}`,\n );\n if (repairParseError instanceof Error) throw repairParseError;\n throw Object.assign(new Error(message), { cause: repairParseError });\n }\n } else {\n logger.error(\"[generateObject] JSON repair failed.\");\n throw error;\n }\n } else {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`[generateObject] Unknown error: ${message}`);\n if (error instanceof Error) throw error;\n throw Object.assign(new Error(message), { cause: error });\n }\n}\n\n/**\n * Quick heuristic to detect if a field likely contains base64 data\n */\nfunction isLikelyBase64(key: string, value: string): boolean {\n // Check key name patterns (expanded base64 field names)\n const base64KeyPattern =\n /^(data|content|body|payload|encoded|b64|base64|document)$/i;\n if (!base64KeyPattern.test(key)) return false;\n\n // Basic format checks\n if (value.length < 20 || value.length > 1024 * 1024) return false; // Size limits\n if (value.length % 4 !== 0) return false; // Invalid base64 length\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value)) return false; // Invalid chars\n\n return true;\n}\n\n/**\n * Recursively decodes base64 fields in tool results\n */\nexport function decodeBase64Fields(obj: unknown, depth = 0): unknown {\n // Simple depth protection\n if (depth > 5) return obj;\n if (!obj || typeof obj !== \"object\") return obj;\n if (Array.isArray(obj))\n return obj.map((item) => decodeBase64Fields(item, depth + 1));\n\n const decoded: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n if (typeof value === \"string\" && isLikelyBase64(key, value)) {\n try {\n decoded[key] = Buffer.from(value, \"base64\").toString(\"utf8\");\n logger.debug(\n `[decodeBase64] Decoded field '${key}' (${value.length} chars)`,\n );\n } catch (error) {\n logger.warn(`[decodeBase64] Failed to decode field '${key}': ${error}`);\n decoded[key] = value; // Keep original if decode fails\n }\n } else if (value && typeof value === \"object\") {\n decoded[key] = decodeBase64Fields(value, depth + 1);\n } else {\n decoded[key] = value;\n }\n }\n return decoded;\n}\n",
|
|
12
|
+
"import {\n ModelType,\n logger,\n type IAgentRuntime,\n type ObjectGenerationParams,\n} from \"@elizaos/core\";\nimport { generateObject } from \"ai\";\nimport { createOpenRouterProvider } from \"../providers\";\nimport { getSmallModel, getLargeModel } from \"../utils/config\";\nimport { emitModelUsageEvent } from \"../utils/events\";\nimport {\n getJsonRepairFunction,\n handleObjectGenerationError,\n} from \"../utils/helpers\";\n\n/**\n * Common object generation logic for both small and large models\n */\nasync function generateObjectWithModel(\n runtime: IAgentRuntime,\n modelType: typeof ModelType.OBJECT_SMALL | typeof ModelType.OBJECT_LARGE,\n params: ObjectGenerationParams,\n): Promise<unknown> {\n const openrouter = createOpenRouterProvider(runtime);\n const modelName =\n modelType === ModelType.OBJECT_SMALL\n ? getSmallModel(runtime)\n : getLargeModel(runtime);\n const modelLabel =\n modelType === ModelType.OBJECT_SMALL ? \"OBJECT_SMALL\" : \"OBJECT_LARGE\";\n\n logger.log(`[OpenRouter] Using ${modelLabel} model: ${modelName}`);\n const temperature = params.temperature ?? 0.7;\n\n try {\n const { object, usage } = await generateObject({\n model: openrouter.chat(modelName),\n output: \"no-schema\",\n prompt: params.prompt,\n temperature: temperature,\n experimental_repairText: getJsonRepairFunction(),\n });\n\n if (usage) {\n emitModelUsageEvent(runtime, modelType, params.prompt, usage);\n }\n return object;\n } catch (error: unknown) {\n return handleObjectGenerationError(error);\n }\n}\n\n/**\n * OBJECT_SMALL model handler\n */\nexport async function handleObjectSmall(\n runtime: IAgentRuntime,\n params: ObjectGenerationParams,\n): Promise<unknown> {\n return generateObjectWithModel(runtime, ModelType.OBJECT_SMALL, params);\n}\n\n/**\n * OBJECT_LARGE model handler\n */\nexport async function handleObjectLarge(\n runtime: IAgentRuntime,\n params: ObjectGenerationParams,\n): Promise<unknown> {\n return generateObjectWithModel(runtime, ModelType.OBJECT_LARGE, params);\n}\n",
|
|
13
|
+
"import {\n logger,\n type IAgentRuntime,\n type ImageDescriptionParams,\n type ImageGenerationParams,\n} from \"@elizaos/core\";\nimport { generateText } from \"ai\";\nimport type { OpenRouterImageResponse } from \"../types\";\nimport { createOpenRouterProvider } from \"../providers\";\nimport {\n getApiKey,\n getBaseURL,\n getImageGenerationModel,\n getImageModel,\n shouldAutoCleanupImages,\n} from \"../utils/config\";\nimport { parseImageDescriptionResponse } from \"../utils/helpers\";\nimport { deleteImage, saveBase64Image } from \"../utils/image-storage\";\n\n/**\n * IMAGE_DESCRIPTION model handler\n */\nexport async function handleImageDescription(\n runtime: IAgentRuntime,\n params: ImageDescriptionParams | string,\n): Promise<{ title: string; description: string }> {\n let imageUrl: string;\n let promptText: string | undefined;\n const modelName = getImageModel(runtime);\n logger.log(`[OpenRouter] Using IMAGE_DESCRIPTION model: ${modelName}`);\n const maxOutputTokens = 300;\n\n if (typeof params === \"string\") {\n imageUrl = params;\n promptText =\n \"Please analyze this image and provide a title and detailed description.\";\n } else {\n imageUrl = params.imageUrl;\n promptText =\n params.prompt ||\n \"Please analyze this image and provide a title and detailed description.\";\n }\n\n const openrouter = createOpenRouterProvider(runtime);\n\n const messages = [\n {\n role: \"user\" as const,\n content: [\n { type: \"text\" as const, text: promptText },\n { type: \"image\" as const, image: imageUrl },\n ],\n },\n ];\n\n try {\n const model = openrouter.chat(modelName);\n\n const { text: responseText } = await generateText({\n model: model,\n messages: messages,\n maxOutputTokens: maxOutputTokens,\n });\n\n return parseImageDescriptionResponse(responseText);\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`Error analyzing image: ${message}`);\n return {\n title: \"Failed to analyze image\",\n description: `Error: ${message}`,\n };\n }\n}\n\n/**\n * IMAGE model handler for image generation\n */\nexport async function handleImageGeneration(\n runtime: IAgentRuntime,\n params: ImageGenerationParams,\n): Promise<{ url: string }[]> {\n const modelName = getImageGenerationModel(runtime);\n logger.log(`[OpenRouter] Using IMAGE_GENERATION model: ${modelName}`);\n const apiKey = getApiKey(runtime);\n\n try {\n const baseUrl = getBaseURL(runtime);\n const isBrowser =\n typeof globalThis !== \"undefined\" && (globalThis as any).document;\n const response = await fetch(`${baseUrl}/chat/completions`, {\n method: \"POST\",\n headers: {\n ...(isBrowser ? {} : { Authorization: `Bearer ${apiKey}` }),\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n model: modelName,\n messages: [\n {\n role: \"user\",\n content: params.prompt,\n },\n ],\n modalities: [\"image\", \"text\"],\n }),\n // 60 seconds timeout\n signal: AbortSignal.timeout ? AbortSignal.timeout(60000) : undefined,\n });\n\n if (!response.ok) {\n const errorText = await response.text().catch(() => \"\");\n throw new Error(\n `HTTP ${response.status} ${response.statusText} ${errorText}`,\n );\n }\n\n const result = (await response.json()) as OpenRouterImageResponse;\n\n const images: { url: string; filepath?: string }[] = [];\n const savedPaths: string[] = [];\n\n // Extract images from the response\n if (result.choices?.[0]?.message?.images) {\n for (const [index, image] of result.choices[0].message.images.entries()) {\n const base64Url = image.image_url.url;\n\n // Save image to disk\n const filepath = await saveBase64Image(\n base64Url,\n runtime.agentId,\n index,\n );\n if (filepath) {\n // Return the actual file path for Discord/Telegram compatibility\n logger.log(`[OpenRouter] Returning image with filepath: ${filepath}`);\n images.push({\n url: filepath, // Use actual file path\n });\n savedPaths.push(filepath);\n } else if (!base64Url.startsWith(\"data:\")) {\n // If not base64, return as is (might be a URL)\n images.push({ url: base64Url });\n } else {\n // Failed to save base64 image\n logger.warn(\n `[OpenRouter] Failed to save image ${index + 1}, skipping`,\n );\n }\n }\n }\n\n // Clean up images after a short delay if auto-cleanup is enabled\n if (savedPaths.length > 0 && shouldAutoCleanupImages(runtime)) {\n setTimeout(() => {\n savedPaths.forEach((path) => {\n deleteImage(path);\n });\n }, 30000); // Delete after 30 seconds\n }\n\n if (images.length === 0) {\n throw new Error(\"No images generated in response\");\n }\n\n logger.log(`[OpenRouter] Generated ${images.length} image(s)`);\n return images;\n } catch (error: unknown) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error(`[OpenRouter] Error generating image: ${message}`);\n return [];\n }\n}\n",
|
|
14
|
+
"import { logger, getGeneratedDir } from \"@elizaos/core\";\n\nfunction isBrowser(): boolean {\n return typeof globalThis !== \"undefined\" && (globalThis as any).document;\n}\n\n// Restrict identifiers to a safe subset to prevent path traversal/FS escape\nfunction sanitizeId(id: string): string {\n const src = (id ?? \"\").toString();\n const normalized = src.normalize(\"NFKC\");\n let safe = normalized.replace(/[^a-zA-Z0-9_-]/g, \"_\");\n safe = safe.replace(/_+/g, \"_\");\n safe = safe.slice(0, 64);\n safe = safe.replace(/^_+|_+$/g, \"\");\n return safe || \"agent\";\n}\n\n// Lightweight base64 decoder that avoids Node Buffer and works in browser/Node\nfunction base64ToBytes(base64: string): Uint8Array {\n // Remove padding\n const cleaned = base64.replace(/\\s+/g, \"\");\n const chars =\n \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n const lookup: number[] = new Array(256).fill(-1);\n for (let i = 0; i < chars.length; i++) lookup[chars.charCodeAt(i)] = i;\n\n const len = cleaned.length;\n let pad = 0;\n if (len >= 2 && cleaned[len - 1] === \"=\") pad++;\n if (len >= 2 && cleaned[len - 2] === \"=\") pad++;\n const outLen = ((len * 3) >> 2) - pad;\n const out = new Uint8Array(outLen);\n\n let o = 0;\n for (let i = 0; i < len; i += 4) {\n const c0 = lookup[cleaned.charCodeAt(i)];\n const c1 = lookup[cleaned.charCodeAt(i + 1)];\n const c2 = lookup[cleaned.charCodeAt(i + 2)];\n const c3 = lookup[cleaned.charCodeAt(i + 3)];\n const n = (c0 << 18) | (c1 << 12) | ((c2 & 63) << 6) | (c3 & 63);\n if (o < outLen) out[o++] = (n >> 16) & 255;\n if (o < outLen) out[o++] = (n >> 8) & 255;\n if (o < outLen) out[o++] = n & 255;\n }\n return out;\n}\n\n/**\n * Save base64 image to disk and return the file path\n */\nexport async function saveBase64Image(\n base64Url: string,\n agentId: string,\n index: number = 0,\n): Promise<string | null> {\n if (isBrowser()) {\n return null;\n }\n // Extract base64 data and extension with MIME type validation\n const m = base64Url.match(\n /^data:(image\\/[a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)$/,\n );\n if (!m) return null;\n\n const mime = m[1];\n const base64Data = m[2];\n\n // Whitelist of allowed MIME types mapped to extensions\n const extMap: Record<string, string> = {\n \"image/png\": \"png\",\n \"image/jpeg\": \"jpg\",\n \"image/jpg\": \"jpg\",\n \"image/webp\": \"webp\",\n \"image/gif\": \"gif\",\n \"image/bmp\": \"bmp\",\n \"image/tiff\": \"tiff\",\n };\n\n const extension = extMap[mime];\n if (!extension) return null;\n\n // Use ElizaOS convention: .eliza/data/generated/{agentId}/\n const { join } = await import(\"node:path\");\n const safeAgentId = sanitizeId(agentId);\n const baseDir = join(getGeneratedDir(), safeAgentId);\n\n // Create directory if it doesn't exist\n const { existsSync } = await import(\"node:fs\");\n if (!existsSync(baseDir)) {\n const { mkdir } = await import(\"node:fs/promises\");\n await mkdir(baseDir, { recursive: true });\n }\n\n // Generate filename with timestamp\n const timestamp = Date.now();\n const filename = `image_${timestamp}_${index}.${extension}`;\n const filepath = join(baseDir, filename);\n\n // Save image to disk\n const buffer = base64ToBytes(base64Data);\n const { writeFile } = await import(\"node:fs/promises\");\n await writeFile(filepath, buffer);\n\n logger.info(`[OpenRouter] Saved generated image to ${filepath}`);\n\n // Return only the file path for Discord/Telegram to read\n return filepath;\n}\n\n/**\n * Delete a specific image file\n */\nexport function deleteImage(filepath: string): void {\n if (isBrowser()) {\n return;\n }\n try {\n (async () => {\n const { existsSync, unlinkSync } = await import(\"node:fs\");\n if (existsSync(filepath)) {\n unlinkSync(filepath);\n logger.debug(`[OpenRouter] Deleted image: ${filepath}`);\n }\n })().catch((error) => {\n logger.warn(\n `[OpenRouter] Failed to delete image ${filepath}:`,\n String(error),\n );\n });\n } catch (error) {\n logger.warn(\n `[OpenRouter] Failed to delete image ${filepath}:`,\n String(error),\n );\n }\n}\n"
|
|
15
|
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AA,KAEzC,WAAU,oBAAoB,OAC7B,SACA,WACG;AAAA,MACH,OAAO,uBAAuB,SAAS,MAAM;AAAA;AAAA,KAE9C,WAAU,QAAQ,OACjB,SACA,WACG;AAAA,MACH,OAAO,sBAAsB,SAAS,MAAM;AAAA;AAAA,EAEhD;AACF;AAEA,IAAe;",
|
|
17
|
+
"debugId": "E1E5C3C96B97EF5164756E2164756E21",
|
|
18
|
+
"names": []
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createOpenRouterProvider } from "./openrouter";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Create an OpenRouter provider instance with proper configuration
|
|
4
|
+
*
|
|
5
|
+
* @param runtime The runtime context
|
|
6
|
+
* @returns Configured OpenRouter provider instance
|
|
7
|
+
*/
|
|
8
|
+
export declare function createOpenRouterProvider(runtime: IAgentRuntime): import("@openrouter/ai-sdk-provider").OpenRouterProvider;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { LanguageModelUsage } from "ai";
|
|
2
|
+
export interface OpenRouterConfig {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
baseURL?: string;
|
|
5
|
+
smallModel?: string;
|
|
6
|
+
largeModel?: string;
|
|
7
|
+
imageModel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolCall {
|
|
10
|
+
toolCallId: string;
|
|
11
|
+
toolName: string;
|
|
12
|
+
args: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface ToolResult {
|
|
15
|
+
toolCallId: string;
|
|
16
|
+
result: unknown;
|
|
17
|
+
}
|
|
18
|
+
export interface ToolResponse {
|
|
19
|
+
text: string;
|
|
20
|
+
toolCalls: ToolCall[];
|
|
21
|
+
toolResults: ToolResult[];
|
|
22
|
+
usage?: LanguageModelUsage;
|
|
23
|
+
finishReason?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface GenerateTextResponse {
|
|
26
|
+
text: string;
|
|
27
|
+
steps?: Array<{
|
|
28
|
+
stepType: string;
|
|
29
|
+
text?: string;
|
|
30
|
+
toolCalls?: unknown[];
|
|
31
|
+
toolResults?: unknown[];
|
|
32
|
+
finishReason?: string;
|
|
33
|
+
}>;
|
|
34
|
+
response?: {
|
|
35
|
+
messages?: Array<{
|
|
36
|
+
role: string;
|
|
37
|
+
content?: Array<{
|
|
38
|
+
type: string;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}>;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
finishReason?: string;
|
|
44
|
+
usage?: LanguageModelUsage;
|
|
45
|
+
}
|
|
46
|
+
export interface ImageDescriptionResult {
|
|
47
|
+
title: string;
|
|
48
|
+
description: string;
|
|
49
|
+
}
|
|
50
|
+
export interface OpenRouterImageResponse {
|
|
51
|
+
choices?: Array<{
|
|
52
|
+
message?: {
|
|
53
|
+
images?: Array<{
|
|
54
|
+
image_url: {
|
|
55
|
+
url: string;
|
|
56
|
+
};
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves a configuration setting from the runtime, falling back to environment variables or a default value if not found.
|
|
4
|
+
*
|
|
5
|
+
* @param key - The name of the setting to retrieve.
|
|
6
|
+
* @param defaultValue - The value to return if the setting is not found in the runtime or environment.
|
|
7
|
+
* @returns The resolved setting value, or {@link defaultValue} if not found.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSetting(runtime: IAgentRuntime, key: string, defaultValue?: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves the OpenRouter API base URL from runtime settings, environment variables, or defaults.
|
|
12
|
+
*
|
|
13
|
+
* @returns The resolved base URL for OpenRouter API requests.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBaseURL(runtime: IAgentRuntime): string;
|
|
16
|
+
/**
|
|
17
|
+
* Helper function to get the API key for OpenRouter
|
|
18
|
+
*
|
|
19
|
+
* @param runtime The runtime context
|
|
20
|
+
* @returns The configured API key
|
|
21
|
+
*/
|
|
22
|
+
export declare function getApiKey(runtime: IAgentRuntime): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to get the small model name with fallbacks
|
|
25
|
+
*
|
|
26
|
+
* @param runtime The runtime context
|
|
27
|
+
* @returns The configured small model name
|
|
28
|
+
*/
|
|
29
|
+
export declare function getSmallModel(runtime: IAgentRuntime): string;
|
|
30
|
+
/**
|
|
31
|
+
* Helper function to get the large model name with fallbacks
|
|
32
|
+
*
|
|
33
|
+
* @param runtime The runtime context
|
|
34
|
+
* @returns The configured large model name
|
|
35
|
+
*/
|
|
36
|
+
export declare function getLargeModel(runtime: IAgentRuntime): string;
|
|
37
|
+
/**
|
|
38
|
+
* Helper function to get the image model name with fallbacks
|
|
39
|
+
*
|
|
40
|
+
* @param runtime The runtime context
|
|
41
|
+
* @returns The configured image model name
|
|
42
|
+
*/
|
|
43
|
+
export declare function getImageModel(runtime: IAgentRuntime): string;
|
|
44
|
+
/**
|
|
45
|
+
* Helper function to get the image generation model name with fallbacks
|
|
46
|
+
*
|
|
47
|
+
* @param runtime The runtime context
|
|
48
|
+
* @returns The configured image generation model name
|
|
49
|
+
*/
|
|
50
|
+
export declare function getImageGenerationModel(runtime: IAgentRuntime): string;
|
|
51
|
+
/**
|
|
52
|
+
* Helper function to check if auto cleanup is enabled for generated images
|
|
53
|
+
*
|
|
54
|
+
* @param runtime The runtime context
|
|
55
|
+
* @returns Whether to auto-cleanup generated images (default: false)
|
|
56
|
+
*/
|
|
57
|
+
export declare function shouldAutoCleanupImages(runtime: IAgentRuntime): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type IAgentRuntime, type ModelTypeName } from "@elizaos/core";
|
|
2
|
+
import type { LanguageModelUsage } from "ai";
|
|
3
|
+
/**
|
|
4
|
+
* Emits a model usage event
|
|
5
|
+
*/
|
|
6
|
+
export declare function emitModelUsageEvent(runtime: IAgentRuntime, type: ModelTypeName, prompt: string, usage: LanguageModelUsage): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GenerateTextResponse, ImageDescriptionResult } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function to repair JSON text
|
|
4
|
+
*/
|
|
5
|
+
export declare function getJsonRepairFunction(): (params: {
|
|
6
|
+
text: string;
|
|
7
|
+
error: unknown;
|
|
8
|
+
}) => Promise<string | null>;
|
|
9
|
+
export { emitModelUsageEvent } from "./events";
|
|
10
|
+
/**
|
|
11
|
+
* Logs response structure for debugging (debug level only)
|
|
12
|
+
*/
|
|
13
|
+
export declare function logResponseStructure(modelType: string, response: GenerateTextResponse): void;
|
|
14
|
+
/**
|
|
15
|
+
* Handles cases where tool execution doesn't generate text
|
|
16
|
+
*/
|
|
17
|
+
export declare function handleEmptyToolResponse(modelType: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Parses image description response from text or JSON format
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseImageDescriptionResponse(responseText: string): ImageDescriptionResult;
|
|
22
|
+
/**
|
|
23
|
+
* Handles errors during object generation, including JSON repair attempts
|
|
24
|
+
*/
|
|
25
|
+
export declare function handleObjectGenerationError(error: unknown): Promise<unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Recursively decodes base64 fields in tool results
|
|
28
|
+
*/
|
|
29
|
+
export declare function decodeBase64Fields(obj: unknown, depth?: number): unknown;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Save base64 image to disk and return the file path
|
|
3
|
+
*/
|
|
4
|
+
export declare function saveBase64Image(base64Url: string, agentId: string, index?: number): Promise<string | null>;
|
|
5
|
+
/**
|
|
6
|
+
* Delete a specific image file
|
|
7
|
+
*/
|
|
8
|
+
export declare function deleteImage(filepath: string): void;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elizaos/plugin-openrouter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.10",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"main": "dist/index.
|
|
6
|
-
"module": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"main": "dist/cjs/index.node.cjs",
|
|
6
|
+
"module": "dist/node/index.node.js",
|
|
7
|
+
"types": "dist/node/index.d.ts",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/elizaos-plugins/plugin-openrouter.git"
|
|
@@ -12,34 +12,35 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
"./package.json": "./package.json",
|
|
14
14
|
".": {
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
"types": "./dist/node/index.d.ts",
|
|
16
|
+
"import": "./dist/node/index.node.js",
|
|
17
|
+
"require": "./dist/cjs/index.node.cjs",
|
|
18
|
+
"browser": "./dist/browser/index.browser.js",
|
|
19
|
+
"node": "./dist/node/index.node.js",
|
|
20
|
+
"default": "./dist/node/index.node.js"
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
"files": [
|
|
22
24
|
"dist"
|
|
23
25
|
],
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@ai-sdk/openai": "^
|
|
27
|
+
"@ai-sdk/openai": "^2.0.32",
|
|
26
28
|
"@ai-sdk/ui-utils": "1.2.11",
|
|
27
29
|
"@elizaos/core": "^1.5.10",
|
|
28
|
-
"@openrouter/ai-sdk-provider": "^
|
|
29
|
-
"ai": "^
|
|
30
|
-
"undici": "^7.
|
|
30
|
+
"@openrouter/ai-sdk-provider": "^1.2.0",
|
|
31
|
+
"ai": "^5.0.47",
|
|
32
|
+
"undici": "^7.16.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
|
-
"@types/bun": "^1.
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"dotenv": "^
|
|
36
|
-
"prettier": "3.
|
|
37
|
-
"
|
|
38
|
-
"typescript": "5.8.3"
|
|
35
|
+
"@types/bun": "^1.2.22",
|
|
36
|
+
"@types/node": "^24.5.2",
|
|
37
|
+
"dotenv": "^17.2.2",
|
|
38
|
+
"prettier": "3.6.2",
|
|
39
|
+
"typescript": "5.9.2"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
|
-
"build": "
|
|
42
|
-
"dev": "
|
|
42
|
+
"build": "bun run build.ts",
|
|
43
|
+
"dev": "bun --hot build.ts",
|
|
43
44
|
"lint": "prettier --write ./src",
|
|
44
45
|
"clean": "rm -rf dist .turbo node_modules .turbo-tsconfig.json tsconfig.tsbuildinfo",
|
|
45
46
|
"format": "prettier --write ./src",
|
|
@@ -72,6 +73,12 @@
|
|
|
72
73
|
"default": "https://openrouter.ai/api/v1",
|
|
73
74
|
"sensitive": false
|
|
74
75
|
},
|
|
76
|
+
"OPENROUTER_BROWSER_BASE_URL": {
|
|
77
|
+
"type": "string",
|
|
78
|
+
"description": "Browser-only proxy endpoint base URL for OpenRouter requests (no secrets in the client).",
|
|
79
|
+
"required": false,
|
|
80
|
+
"sensitive": false
|
|
81
|
+
},
|
|
75
82
|
"OPENROUTER_SMALL_MODEL": {
|
|
76
83
|
"type": "string",
|
|
77
84
|
"description": "Overrides the default small language model used for text/object generation.",
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/init.ts","../src/utils/config.ts","../src/models/text.ts","../src/providers/openrouter.ts","../src/utils/events.ts","../src/utils/helpers.ts","../src/models/object.ts","../src/models/image.ts","../src/utils/image-storage.ts"],"sourcesContent":["import {\n\tModelType,\n\ttype Plugin,\n\ttype IAgentRuntime,\n\ttype GenerateTextParams,\n\ttype ObjectGenerationParams,\n\ttype ImageDescriptionParams,\n\ttype ImageGenerationParams,\n} from \"@elizaos/core\";\nimport type { Tool, ToolChoice } from \"ai\";\nimport { initializeOpenRouter } from \"./init\";\nimport { handleTextSmall, handleTextLarge } from \"./models/text\";\nimport { handleObjectSmall, handleObjectLarge } from \"./models/object\";\nimport { handleImageDescription, handleImageGeneration } from \"./models/image\";\n\n/**\n * Defines the OpenRouter plugin with its name, description, and configuration options.\n * @type {Plugin}\n */\nexport const openrouterPlugin: Plugin = {\n\tname: \"openrouter\",\n\tdescription: \"OpenRouter plugin\",\n\tconfig: {\n\t\tOPENROUTER_API_KEY: process.env.OPENROUTER_API_KEY,\n\t\tOPENROUTER_BASE_URL: process.env.OPENROUTER_BASE_URL,\n\t\tOPENROUTER_SMALL_MODEL: process.env.OPENROUTER_SMALL_MODEL,\n\t\tOPENROUTER_LARGE_MODEL: process.env.OPENROUTER_LARGE_MODEL,\n\t\tOPENROUTER_IMAGE_MODEL: process.env.OPENROUTER_IMAGE_MODEL,\n\t\tOPENROUTER_IMAGE_GENERATION_MODEL: process.env.OPENROUTER_IMAGE_GENERATION_MODEL,\n\t\tOPENROUTER_AUTO_CLEANUP_IMAGES: process.env.OPENROUTER_AUTO_CLEANUP_IMAGES,\n\t\tSMALL_MODEL: process.env.SMALL_MODEL,\n\t\tLARGE_MODEL: process.env.LARGE_MODEL,\n\t\tIMAGE_MODEL: process.env.IMAGE_MODEL,\n\t\tIMAGE_GENERATION_MODEL: process.env.IMAGE_GENERATION_MODEL,\n\t},\n\tasync init(config, runtime) {\n\t\t// Note: We intentionally don't await here because ElizaOS expects\n\t\t// the init method to return quickly. The initializeOpenRouter function\n\t\t// only performs synchronous validation and logging, so it's safe to\n\t\t// call without await. This prevents blocking the plugin initialization.\n\t\tinitializeOpenRouter(config, runtime);\n\t},\n\tmodels: {\n\t\t[ModelType.TEXT_SMALL]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: GenerateTextParams & {\n\t\t\t\ttools?: Record<string, Tool>;\n\t\t\t\ttoolChoice?: ToolChoice<Record<string, Tool>>;\n\t\t\t},\n\t\t) => {\n\t\t\treturn handleTextSmall(runtime, params);\n\t\t},\n\t\t[ModelType.TEXT_LARGE]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: GenerateTextParams & {\n\t\t\t\ttools?: Record<string, Tool>;\n\t\t\t\ttoolChoice?: ToolChoice<Record<string, Tool>>;\n\t\t\t},\n\t\t) => {\n\t\t\treturn handleTextLarge(runtime, params);\n\t\t},\n\t\t[ModelType.OBJECT_SMALL]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: ObjectGenerationParams,\n\t\t) => {\n\t\t\treturn handleObjectSmall(runtime, params);\n\t\t},\n\t\t[ModelType.OBJECT_LARGE]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: ObjectGenerationParams,\n\t\t) => {\n\t\t\treturn handleObjectLarge(runtime, params);\n\t\t},\n\t\t[ModelType.IMAGE_DESCRIPTION]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: ImageDescriptionParams | string,\n\t\t) => {\n\t\t\treturn handleImageDescription(runtime, params);\n\t\t},\n\t\t[ModelType.IMAGE]: async (\n\t\t\truntime: IAgentRuntime,\n\t\t\tparams: ImageGenerationParams,\n\t\t) => {\n\t\t\treturn handleImageGeneration(runtime, params);\n\t\t},\n\t},\n};\n\nexport default openrouterPlugin;\n","import { logger, type IAgentRuntime } from \"@elizaos/core\";\nimport { fetch } from \"undici\";\nimport { getApiKey, getBaseURL } from \"./utils/config\";\n\n/**\n * Initialize and validate OpenRouter configuration\n * Returns the exact same function that works inline\n */\nexport function initializeOpenRouter(_config: any, runtime: IAgentRuntime) {\n\t// do check in the background\n\t(async () => {\n\t\ttry {\n\t\t\tif (!getApiKey(runtime)) {\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"OPENROUTER_API_KEY is not set in environment - OpenRouter functionality will be limited\",\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst baseURL = getBaseURL(runtime);\n\t\t\t\tconst response = await fetch(`${baseURL}/models`, {\n\t\t\t\t\theaders: { Authorization: `Bearer ${getApiKey(runtime)}` },\n\t\t\t\t});\n\t\t\t\tif (!response.ok) {\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t`OpenRouter API key validation failed: ${response.statusText}`,\n\t\t\t\t\t);\n\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\"OpenRouter functionality will be limited until a valid API key is provided\",\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.log(\"OpenRouter API key validated successfully\");\n\t\t\t\t}\n\t\t\t} catch (fetchError: unknown) {\n\t\t\t\tconst message =\n\t\t\t\t\tfetchError instanceof Error ? fetchError.message : String(fetchError);\n\t\t\t\tlogger.warn(`Error validating OpenRouter API key: ${message}`);\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"OpenRouter functionality will be limited until a valid API key is provided\",\n\t\t\t\t);\n\t\t\t}\n\t\t} catch (error: unknown) {\n\t\t\tconst message =\n\t\t\t\t(error as { errors?: Array<{ message: string }> })?.errors\n\t\t\t\t\t?.map((e) => e.message)\n\t\t\t\t\t.join(\", \") ||\n\t\t\t\t(error instanceof Error ? error.message : String(error));\n\t\t\tlogger.warn(\n\t\t\t\t`OpenRouter plugin configuration issue: ${message} - You need to configure the OPENROUTER_API_KEY in your environment variables`,\n\t\t\t);\n\t\t}\n\t})();\n\treturn;\n}\n","import type { IAgentRuntime } from \"@elizaos/core\";\n\n/**\n * Retrieves a configuration setting from the runtime, falling back to environment variables or a default value if not found.\n *\n * @param key - The name of the setting to retrieve.\n * @param defaultValue - The value to return if the setting is not found in the runtime or environment.\n * @returns The resolved setting value, or {@link defaultValue} if not found.\n */\nexport function getSetting(\n\truntime: IAgentRuntime,\n\tkey: string,\n\tdefaultValue?: string,\n): string | undefined {\n\treturn runtime.getSetting(key) ?? process.env[key] ?? defaultValue;\n}\n\n/**\n * Retrieves the OpenRouter API base URL from runtime settings, environment variables, or defaults.\n *\n * @returns The resolved base URL for OpenRouter API requests.\n */\nexport function getBaseURL(runtime: IAgentRuntime): string {\n\treturn (\n\t\tgetSetting(\n\t\t\truntime,\n\t\t\t\"OPENROUTER_BASE_URL\",\n\t\t\t\"https://openrouter.ai/api/v1\",\n\t\t) || \"https://openrouter.ai/api/v1\"\n\t);\n}\n\n/**\n * Helper function to get the API key for OpenRouter\n *\n * @param runtime The runtime context\n * @returns The configured API key\n */\nexport function getApiKey(runtime: IAgentRuntime): string | undefined {\n\treturn getSetting(runtime, \"OPENROUTER_API_KEY\");\n}\n\n/**\n * Helper function to get the small model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured small model name\n */\nexport function getSmallModel(runtime: IAgentRuntime): string {\n\treturn (\n\t\tgetSetting(runtime, \"OPENROUTER_SMALL_MODEL\") ??\n\t\tgetSetting(runtime, \"SMALL_MODEL\", \"google/gemini-2.0-flash-001\") ??\n\t\t\"google/gemini-2.0-flash-001\"\n\t);\n}\n\n/**\n * Helper function to get the large model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured large model name\n */\nexport function getLargeModel(runtime: IAgentRuntime): string {\n return (\n getSetting(runtime, \"OPENROUTER_LARGE_MODEL\") ??\n getSetting(\n runtime,\n \"LARGE_MODEL\",\n \"google/gemini-2.5-flash\",\n ) ??\n \"google/gemini-2.5-flash\"\n );\n}\n\n/**\n * Helper function to get the image model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured image model name\n */\nexport function getImageModel(runtime: IAgentRuntime): string {\n\treturn (\n\t\tgetSetting(runtime, \"OPENROUTER_IMAGE_MODEL\") ??\n\t\tgetSetting(runtime, \"IMAGE_MODEL\", \"x-ai/grok-2-vision-1212\") ??\n\t\t\"x-ai/grok-2-vision-1212\"\n\t);\n}\n\n/**\n * Helper function to get the image generation model name with fallbacks\n *\n * @param runtime The runtime context\n * @returns The configured image generation model name\n */\nexport function getImageGenerationModel(runtime: IAgentRuntime): string {\n\treturn (\n\t\tgetSetting(runtime, \"OPENROUTER_IMAGE_GENERATION_MODEL\") ??\n\t\tgetSetting(runtime, \"IMAGE_GENERATION_MODEL\", \"google/gemini-2.5-flash-image-preview\") ??\n\t\t\"google/gemini-2.5-flash-image-preview\"\n\t);\n}\n\n/**\n * Helper function to check if auto cleanup is enabled for generated images\n *\n * @param runtime The runtime context\n * @returns Whether to auto-cleanup generated images (default: false)\n */\nexport function shouldAutoCleanupImages(runtime: IAgentRuntime): boolean {\n\tconst setting = getSetting(runtime, \"OPENROUTER_AUTO_CLEANUP_IMAGES\", \"false\");\n\treturn setting?.toLowerCase() === \"true\";\n}\n","import type { GenerateTextParams, IAgentRuntime } from \"@elizaos/core\";\nimport { logger, ModelType } from \"@elizaos/core\";\nimport { generateText } from \"ai\";\nimport type { Tool, ToolChoice } from \"ai\";\n\nimport { createOpenRouterProvider } from \"../providers\";\nimport type { ToolCall, ToolResponse, ToolResult } from \"../types\";\nimport { getSmallModel, getLargeModel } from \"../utils/config\";\nimport { emitModelUsageEvent } from \"../utils/events\";\nimport { handleEmptyToolResponse, decodeBase64Fields } from \"../utils/helpers\";\n\n/**\n * Common text generation logic for both small and large models\n */\nasync function generateTextWithModel(\n\truntime: IAgentRuntime,\n\tmodelType: typeof ModelType.TEXT_SMALL | typeof ModelType.TEXT_LARGE,\n\tparams: GenerateTextParams & {\n\t\ttools?: Record<string, Tool>;\n\t\ttoolChoice?: ToolChoice<Record<string, Tool>>;\n\t},\n): Promise<string | ToolResponse> {\n\tconst { prompt, stopSequences = [], tools, toolChoice } = params;\n\tconst temperature = params.temperature ?? 0.7;\n\tconst frequencyPenalty = params.frequencyPenalty ?? 0.7;\n\tconst presencePenalty = params.presencePenalty ?? 0.7;\n\tconst maxResponseLength = params.maxTokens ?? 8192;\n\n\tconst openrouter = createOpenRouterProvider(runtime);\n\tconst modelName =\n\t\tmodelType === ModelType.TEXT_SMALL\n\t\t\t? getSmallModel(runtime)\n\t\t\t: getLargeModel(runtime);\n\tconst modelLabel =\n\t\tmodelType === ModelType.TEXT_SMALL ? \"TEXT_SMALL\" : \"TEXT_LARGE\";\n\n\tlogger.log(\n\t\t`[OpenRouter] Generating text with ${modelLabel} model: ${modelName}`,\n\t);\n\n\tconst generateParams: Parameters<typeof generateText>[0] & {\n\t\textra_body?: { provider?: { require_parameters?: boolean } };\n\t} = {\n\t\tmodel: openrouter.chat(modelName),\n\t\tprompt: prompt,\n\t\tsystem: runtime.character.system ?? undefined,\n\t\ttemperature: temperature,\n\t\tmaxTokens: maxResponseLength,\n\t\tfrequencyPenalty: frequencyPenalty,\n\t\tpresencePenalty: presencePenalty,\n\t\tstopSequences: stopSequences,\n\t};\n\n\t// Add tools if provided\n\tif (tools) {\n\t\tgenerateParams.tools = tools;\n\t\tgenerateParams.maxSteps = 10; // Allow tool call + response generation\n\t\t// For OpenRouter: ensure request is only routed to providers that support function calling\n\t\tgenerateParams.extra_body = {\n\t\t\tprovider: {\n\t\t\t\trequire_parameters: true,\n\t\t\t},\n\t\t};\n\t}\n\n\t// Add toolChoice if provided\n\tif (toolChoice) {\n\t\tgenerateParams.toolChoice = toolChoice;\n\t}\n\n\t// Capture tool results if tools are used\n\tlet capturedToolResults: ToolResult[] = [];\n\tlet capturedToolCalls: ToolCall[] = [];\n\n\tif (tools) {\n\t\tgenerateParams.onStepFinish = async (stepResult) => {\n\t\t\tif (stepResult.toolCalls && stepResult.toolCalls.length > 0) {\n\t\t\t\tcapturedToolCalls = [...capturedToolCalls, ...stepResult.toolCalls];\n\t\t\t}\n\t\t\tif (stepResult.toolResults && stepResult.toolResults.length > 0) {\n\t\t\t\t// Decode base64 fields in tool results before capturing them\n\t\t\t\tconst decodedToolResults = stepResult.toolResults.map((result: ToolResult) => ({\n\t\t\t\t\t...result,\n\t\t\t\t\tresult: decodeBase64Fields(result.result),\n\t\t\t\t}));\n\t\t\t\tcapturedToolResults = [...capturedToolResults, ...decodedToolResults];\n\t\t\t}\n\t\t};\n\t}\n\n\tconst response = await generateText(generateParams);\n\n\t// Handle cases where tool execution doesn't generate text\n\tlet responseText: string;\n\tif (\n\t\ttools &&\n\t\t(!response.text ||\n\t\t\tresponse.text.trim() === \"\" ||\n\t\t\tresponse.text === \"Tools executed successfully.\")\n\t) {\n\t\tresponseText = handleEmptyToolResponse(modelLabel);\n\t} else {\n\t\tresponseText = response.text;\n\t}\n\n\tif (response.usage) {\n\t\temitModelUsageEvent(runtime, modelType, prompt, response.usage);\n\t}\n\n\t// If tools were used, return the full response object to access toolCalls and toolResults\n\tif (\n\t\ttools &&\n\t\t(capturedToolCalls.length > 0 || capturedToolResults.length > 0)\n\t) {\n\t\treturn {\n\t\t\ttext: responseText,\n\t\t\ttoolCalls: capturedToolCalls,\n\t\t\ttoolResults: capturedToolResults,\n\t\t\t// Include other useful properties\n\t\t\tusage: response.usage,\n\t\t\tfinishReason: response.finishReason,\n\t\t};\n\t}\n\n\treturn responseText;\n}\n\n/**\n * TEXT_SMALL model handler\n */\nexport async function handleTextSmall(\n\truntime: IAgentRuntime,\n\tparams: GenerateTextParams & {\n\t\ttools?: Record<string, Tool>;\n\t\ttoolChoice?: ToolChoice<Record<string, Tool>>;\n\t},\n): Promise<string | ToolResponse> {\n\treturn generateTextWithModel(runtime, ModelType.TEXT_SMALL, params);\n}\n\n/**\n * TEXT_LARGE model handler\n */\nexport async function handleTextLarge(\n\truntime: IAgentRuntime,\n\tparams: GenerateTextParams & {\n\t\ttools?: Record<string, Tool>;\n\t\ttoolChoice?: ToolChoice<Record<string, Tool>>;\n\t},\n): Promise<string | ToolResponse> {\n\treturn generateTextWithModel(runtime, ModelType.TEXT_LARGE, params);\n}\n","import { createOpenRouter } from \"@openrouter/ai-sdk-provider\";\nimport { logger, type IAgentRuntime } from \"@elizaos/core\";\nimport { getApiKey } from \"../utils/config\";\n\n/**\n * Create an OpenRouter provider instance with proper configuration\n *\n * @param runtime The runtime context\n * @returns Configured OpenRouter provider instance\n */\nexport function createOpenRouterProvider(runtime: IAgentRuntime) {\n\tconst apiKey = getApiKey(runtime);\n\tif (!apiKey) {\n\t\t// This case should ideally be caught in init, but good practice to check\n\t\tlogger.error(\n\t\t\t\"OpenRouter API Key is missing when trying to create provider\",\n\t\t);\n\t\tthrow new Error(\"OpenRouter API Key is missing.\");\n\t}\n\n\t// Note: createOpenRouter doesn't seem to take baseURL directly in the documentation.\n\t// It might pick it up from OPENROUTER_BASE_URL env var automatically,\n\t// or it might not be needed/configurable in the same way as createOpenRouter.\n\t// We'll rely on the apiKey for now.\n\treturn createOpenRouter({\n\t\tapiKey: apiKey,\n\t\t// We might need to handle baseURL differently if required.\n\t\t// The @ai-sdk/provider utils might handle OPENROUTER_BASE_URL env var.\n\t});\n}\n","import {\n\tEventType,\n\ttype IAgentRuntime,\n\ttype ModelTypeName,\n} from \"@elizaos/core\";\nimport type { LanguageModelUsage } from \"ai\";\n\n/**\n * Emits a model usage event\n */\nexport function emitModelUsageEvent(\n\truntime: IAgentRuntime,\n\ttype: ModelTypeName,\n\tprompt: string,\n\tusage: LanguageModelUsage,\n) {\n\truntime.emitEvent(EventType.MODEL_USED, {\n\t\tprovider: \"openrouter\",\n\t\ttype,\n\t\tprompt,\n\t\ttokens: {\n\t\t\tprompt: usage.promptTokens,\n\t\t\tcompletion: usage.completionTokens,\n\t\t\ttotal: usage.totalTokens,\n\t\t},\n\t});\n}\n","import { logger } from \"@elizaos/core\";\nimport { JSONParseError } from \"ai\";\nimport type { GenerateTextResponse, ImageDescriptionResult } from \"../types\";\n\n/**\n * Returns a function to repair JSON text\n */\nexport function getJsonRepairFunction(): (params: {\n\ttext: string;\n\terror: unknown;\n}) => Promise<string | null> {\n\treturn async ({ text, error }: { text: string; error: unknown }) => {\n\t\ttry {\n\t\t\tif (error instanceof JSONParseError) {\n\t\t\t\tconst cleanedText = text.replace(/```json\\n|\\n```|```/g, \"\");\n\t\t\t\tJSON.parse(cleanedText);\n\t\t\t\treturn cleanedText;\n\t\t\t}\n\t\t\treturn null;\n\t\t} catch (jsonError: unknown) {\n\t\t\tconst message =\n\t\t\t\tjsonError instanceof Error ? jsonError.message : String(jsonError);\n\t\t\tlogger.warn(`Failed to repair JSON text: ${message}`);\n\t\t\treturn null;\n\t\t}\n\t};\n}\n\n// Re-export for backward compatibility\nexport { emitModelUsageEvent } from \"./events\";\n\n/**\n * Logs response structure for debugging (debug level only)\n */\nexport function logResponseStructure(\n\tmodelType: string,\n\tresponse: GenerateTextResponse,\n) {\n\tlogger.debug(`[${modelType}] Response structure: ${JSON.stringify({\n\t\thasText: !!response.text,\n\t\ttextLength: response.text?.length || 0,\n\t\thasSteps: !!response.steps,\n\t\tstepsCount: response.steps?.length || 0,\n\t\tfinishReason: response.finishReason,\n\t\tusage: response.usage,\n\t}, null, 2)}`);\n}\n\n/**\n * Handles cases where tool execution doesn't generate text\n */\nexport function handleEmptyToolResponse(modelType: string): string {\n\tlogger.warn(`[${modelType}] No text generated after tool execution`);\n\n\tconst fallbackText =\n\t\t\"I executed the requested action. The tool completed successfully.\";\n\tlogger.warn(`[${modelType}] Using fallback response text`);\n\treturn fallbackText;\n}\n\n/**\n * Parses image description response from text or JSON format\n */\nexport function parseImageDescriptionResponse(\n\tresponseText: string,\n): ImageDescriptionResult {\n\t// Try to parse as JSON first\n\ttry {\n\t\tconst jsonResponse = JSON.parse(responseText);\n\t\tif (jsonResponse.title && jsonResponse.description) {\n\t\t\treturn jsonResponse;\n\t\t}\n\t} catch (e) {\n\t\t// If not valid JSON, process as text\n\t\tlogger.debug(`Parsing as JSON failed, processing as text: ${e}`);\n\t}\n\n\t// Extract title and description from text format\n\tconst titleMatch = responseText.match(/title[:\\s]+(.+?)(?:\\n|$)/i);\n\tconst title = titleMatch?.[1]?.trim() || \"Image Analysis\";\n\tconst description = responseText\n\t\t.replace(/title[:\\s]+(.+?)(?:\\n|$)/i, \"\")\n\t\t.trim();\n\n\treturn { title, description };\n}\n\n/**\n * Handles errors during object generation, including JSON repair attempts\n */\nexport async function handleObjectGenerationError(\n\terror: unknown,\n): Promise<unknown> {\n\tif (error instanceof JSONParseError) {\n\t\tlogger.error(`[generateObject] Failed to parse JSON: ${error.message}`);\n\t\tconst repairFunction = getJsonRepairFunction();\n\t\tconst repairedJsonString = await repairFunction({\n\t\t\ttext: error.text,\n\t\t\terror,\n\t\t});\n\n\t\tif (repairedJsonString) {\n\t\t\ttry {\n\t\t\t\tconst repairedObject = JSON.parse(repairedJsonString);\n\t\t\t\tlogger.log(\"[generateObject] Successfully repaired JSON.\");\n\t\t\t\treturn repairedObject;\n\t\t\t} catch (repairParseError: unknown) {\n\t\t\t\tconst message =\n\t\t\t\t\trepairParseError instanceof Error\n\t\t\t\t\t\t? repairParseError.message\n\t\t\t\t\t\t: String(repairParseError);\n\t\t\t\tlogger.error(\n\t\t\t\t\t`[generateObject] Failed to parse repaired JSON: ${message}`,\n\t\t\t\t);\n\t\t\t\tif (repairParseError instanceof Error) throw repairParseError;\n\t\t\t\tthrow Object.assign(new Error(message), { cause: repairParseError });\n\t\t\t}\n\t\t} else {\n\t\t\tlogger.error(\"[generateObject] JSON repair failed.\");\n\t\t\tthrow error;\n\t\t}\n\t} else {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlogger.error(`[generateObject] Unknown error: ${message}`);\n\t\tif (error instanceof Error) throw error;\n\t\tthrow Object.assign(new Error(message), { cause: error });\n\t}\n}\n\n/**\n * Quick heuristic to detect if a field likely contains base64 data\n */\nfunction isLikelyBase64(key: string, value: string): boolean {\n\t// Check key name patterns (expanded base64 field names)\n\tconst base64KeyPattern = /^(data|content|body|payload|encoded|b64|base64|document)$/i;\n\tif (!base64KeyPattern.test(key)) return false;\n\t\n\t// Basic format checks\n\tif (value.length < 20 || value.length > 1024 * 1024) return false; // Size limits\n\tif (value.length % 4 !== 0) return false; // Invalid base64 length\n\tif (!/^[A-Za-z0-9+/]*={0,2}$/.test(value)) return false; // Invalid chars\n\t\n\treturn true;\n}\n\n/**\n * Recursively decodes base64 fields in tool results\n */\nexport function decodeBase64Fields(obj: unknown, depth = 0): unknown {\n\t// Simple depth protection\n\tif (depth > 5) return obj;\n\tif (!obj || typeof obj !== \"object\") return obj;\n\tif (Array.isArray(obj)) return obj.map(item => decodeBase64Fields(item, depth + 1));\n\t\n\tconst decoded: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(obj)) {\n\t\tif (typeof value === \"string\" && isLikelyBase64(key, value)) {\n\t\t\ttry {\n\t\t\t\tdecoded[key] = Buffer.from(value, \"base64\").toString(\"utf8\");\n\t\t\t\tlogger.debug(`[decodeBase64] Decoded field '${key}' (${value.length} chars)`);\n\t\t\t} catch (error) {\n\t\t\t\tlogger.warn(`[decodeBase64] Failed to decode field '${key}': ${error}`);\n\t\t\t\tdecoded[key] = value; // Keep original if decode fails\n\t\t\t}\n\t\t} else if (value && typeof value === \"object\") {\n\t\t\tdecoded[key] = decodeBase64Fields(value, depth + 1);\n\t\t} else {\n\t\t\tdecoded[key] = value;\n\t\t}\n\t}\n\treturn decoded;\n}\n","import {\n\tModelType,\n\tlogger,\n\ttype IAgentRuntime,\n\ttype ObjectGenerationParams,\n} from \"@elizaos/core\";\nimport { generateObject } from \"ai\";\nimport { createOpenRouterProvider } from \"../providers\";\nimport { getSmallModel, getLargeModel } from \"../utils/config\";\nimport { emitModelUsageEvent } from \"../utils/events\";\nimport {\n\tgetJsonRepairFunction,\n\thandleObjectGenerationError,\n} from \"../utils/helpers\";\n\n/**\n * Common object generation logic for both small and large models\n */\nasync function generateObjectWithModel(\n\truntime: IAgentRuntime,\n\tmodelType: typeof ModelType.OBJECT_SMALL | typeof ModelType.OBJECT_LARGE,\n\tparams: ObjectGenerationParams,\n): Promise<unknown> {\n\tconst openrouter = createOpenRouterProvider(runtime);\n\tconst modelName =\n\t\tmodelType === ModelType.OBJECT_SMALL\n\t\t\t? getSmallModel(runtime)\n\t\t\t: getLargeModel(runtime);\n\tconst modelLabel =\n\t\tmodelType === ModelType.OBJECT_SMALL ? \"OBJECT_SMALL\" : \"OBJECT_LARGE\";\n\n\tlogger.log(`[OpenRouter] Using ${modelLabel} model: ${modelName}`);\n\tconst temperature = params.temperature ?? 0.7;\n\n\ttry {\n\t\tconst { object, usage } = await generateObject({\n\t\t\tmodel: openrouter.chat(modelName),\n\t\t\toutput: \"no-schema\",\n\t\t\tprompt: params.prompt,\n\t\t\ttemperature: temperature,\n\t\t\texperimental_repairText: getJsonRepairFunction(),\n\t\t});\n\n\t\tif (usage) {\n\t\t\temitModelUsageEvent(runtime, modelType, params.prompt, usage);\n\t\t}\n\t\treturn object;\n\t} catch (error: unknown) {\n\t\treturn handleObjectGenerationError(error);\n\t}\n}\n\n/**\n * OBJECT_SMALL model handler\n */\nexport async function handleObjectSmall(\n\truntime: IAgentRuntime,\n\tparams: ObjectGenerationParams,\n): Promise<unknown> {\n\treturn generateObjectWithModel(runtime, ModelType.OBJECT_SMALL, params);\n}\n\n/**\n * OBJECT_LARGE model handler\n */\nexport async function handleObjectLarge(\n\truntime: IAgentRuntime,\n\tparams: ObjectGenerationParams,\n): Promise<unknown> {\n\treturn generateObjectWithModel(runtime, ModelType.OBJECT_LARGE, params);\n}\n","import {\n\tlogger,\n\ttype IAgentRuntime,\n\ttype ImageDescriptionParams,\n\ttype ImageGenerationParams,\n} from \"@elizaos/core\";\nimport { generateText } from \"ai\";\nimport type { OpenRouterImageResponse } from \"../types\";\nimport { createOpenRouterProvider } from \"../providers\";\nimport { getApiKey, getBaseURL, getImageGenerationModel, getImageModel, shouldAutoCleanupImages } from \"../utils/config\";\nimport { parseImageDescriptionResponse } from \"../utils/helpers\";\nimport { deleteImage, saveBase64Image } from \"../utils/image-storage\";\n\n/**\n * IMAGE_DESCRIPTION model handler\n */\nexport async function handleImageDescription(\n\truntime: IAgentRuntime,\n\tparams: ImageDescriptionParams | string,\n): Promise<{ title: string; description: string }> {\n\tlet imageUrl: string;\n\tlet promptText: string | undefined;\n\tconst modelName = getImageModel(runtime);\n\tlogger.log(`[OpenRouter] Using IMAGE_DESCRIPTION model: ${modelName}`);\n\tconst maxTokens = 300;\n\n\tif (typeof params === \"string\") {\n\t\timageUrl = params;\n\t\tpromptText =\n\t\t\t\"Please analyze this image and provide a title and detailed description.\";\n\t} else {\n\t\timageUrl = params.imageUrl;\n\t\tpromptText =\n\t\t\tparams.prompt ||\n\t\t\t\"Please analyze this image and provide a title and detailed description.\";\n\t}\n\n\tconst openrouter = createOpenRouterProvider(runtime);\n\n\tconst messages = [\n\t\t{\n\t\t\trole: \"user\" as const,\n\t\t\tcontent: [\n\t\t\t\t{ type: \"text\" as const, text: promptText },\n\t\t\t\t{ type: \"image\" as const, image: imageUrl },\n\t\t\t],\n\t\t},\n\t];\n\n\ttry {\n\t\tconst model = openrouter.chat(modelName);\n\n\t\tconst { text: responseText } = await generateText({\n\t\t\tmodel: model,\n\t\t\tmessages: messages,\n\t\t\tmaxTokens: maxTokens,\n\t\t});\n\n\t\treturn parseImageDescriptionResponse(responseText);\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlogger.error(`Error analyzing image: ${message}`);\n\t\treturn {\n\t\t\ttitle: \"Failed to analyze image\",\n\t\t\tdescription: `Error: ${message}`,\n\t\t};\n\t}\n}\n\n/**\n * IMAGE model handler for image generation\n */\nexport async function handleImageGeneration(\n\truntime: IAgentRuntime,\n\tparams: ImageGenerationParams,\n): Promise<{ url: string }[]> {\n\tconst modelName = getImageGenerationModel(runtime);\n\tlogger.log(`[OpenRouter] Using IMAGE_GENERATION model: ${modelName}`);\n\tconst apiKey = getApiKey(runtime);\n\n\ttry {\n\t\tif (!apiKey) {\n\t\t\tlogger.error(\"[OpenRouter] OpenRouter API key is missing\");\n\t\t\treturn [];\n\t\t}\n\t\tconst baseUrl = getBaseURL(runtime);\n\t\tconst response = await fetch(`${baseUrl}/chat/completions`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t\t\t'Content-Type': 'application/json',\n\t\t\t},\n\t\t\tbody: JSON.stringify({\n\t\t\t\tmodel: modelName,\n\t\t\t\tmessages: [\n\t\t\t\t\t{\n\t\t\t\t\t\trole: 'user',\n\t\t\t\t\t\tcontent: params.prompt,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tmodalities: ['image', 'text'],\n\t\t\t}),\n\t\t\t// 60 seconds timeout\n\t\t\tsignal: AbortSignal.timeout ? AbortSignal.timeout(60000) : undefined,\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text().catch(() => \"\");\n\t\t\tthrow new Error(`HTTP ${response.status} ${response.statusText} ${errorText}`);\n\t\t}\n\n\t\tconst result = await response.json() as OpenRouterImageResponse;\n\t\t\n\t\tconst images: { url: string; filepath?: string }[] = [];\n\t\tconst savedPaths: string[] = [];\n\n\t\t// Extract images from the response\n\t\tif (result.choices?.[0]?.message?.images) {\n\t\t\tfor (const [index, image] of result.choices[0].message.images.entries()) {\n\t\t\t\tconst base64Url = image.image_url.url;\n\t\t\t\t\n\t\t\t\t// Save image to disk\n\t\t\t\tconst filepath = await saveBase64Image(base64Url, runtime.agentId, index);\n\t\t\t\tif (filepath) {\n\t\t\t\t\t// Return the actual file path for Discord/Telegram compatibility\n\t\t\t\t\tlogger.log(`[OpenRouter] Returning image with filepath: ${filepath}`);\n\t\t\t\t\timages.push({ \n\t\t\t\t\t\turl: filepath // Use actual file path\n\t\t\t\t\t});\n\t\t\t\t\tsavedPaths.push(filepath);\n\t\t\t\t} else if (!base64Url.startsWith('data:')) {\n\t\t\t\t\t// If not base64, return as is (might be a URL)\n\t\t\t\t\timages.push({ url: base64Url });\n\t\t\t\t} else {\n\t\t\t\t\t// Failed to save base64 image\n\t\t\t\t\tlogger.warn(`[OpenRouter] Failed to save image ${index + 1}, skipping`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Clean up images after a short delay if auto-cleanup is enabled\n\t\tif (savedPaths.length > 0 && shouldAutoCleanupImages(runtime)) {\n\t\t\tsetTimeout(() => {\n\t\t\t\tsavedPaths.forEach(path => {\n\t\t\t\t\tdeleteImage(path);\n\t\t\t\t});\n\t\t\t}, 30000); // Delete after 30 seconds\n\t\t}\n\n\t\tif (images.length === 0) {\n\t\t\tthrow new Error(\"No images generated in response\");\n\t\t}\n\n\t\tlogger.log(`[OpenRouter] Generated ${images.length} image(s)`);\n\t\treturn images;\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tlogger.error(`[OpenRouter] Error generating image: ${message}`);\n\t\treturn [];\n\t}\n}\n","import { existsSync, unlinkSync } from \"node:fs\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { logger, getGeneratedDir } from \"@elizaos/core\";\n\n/**\n * Save base64 image to disk and return the file path\n */\nexport async function saveBase64Image(base64Url: string, agentId: string, index: number = 0): Promise<string | null> {\n\t// Extract base64 data and extension with MIME type validation\n\tconst m = base64Url.match(/^data:(image\\/[a-zA-Z0-9.+-]+);base64,([A-Za-z0-9+/=]+)$/);\n\tif (!m) return null;\n\t\n\tconst mime = m[1];\n\tconst base64Data = m[2];\n\t\n\t// Whitelist of allowed MIME types mapped to extensions\n\tconst extMap: Record<string, string> = {\n\t\t\"image/png\": \"png\",\n\t\t\"image/jpeg\": \"jpg\",\n\t\t\"image/jpg\": \"jpg\",\n\t\t\"image/webp\": \"webp\",\n\t\t\"image/gif\": \"gif\",\n\t\t\"image/bmp\": \"bmp\",\n\t\t\"image/tiff\": \"tiff\"\n\t};\n\t\n\tconst extension = extMap[mime];\n\tif (!extension) return null;\n\n\t// Use ElizaOS convention: .eliza/data/generated/{agentId}/\n\tconst baseDir = join(getGeneratedDir(), agentId);\n\t\n\t// Create directory if it doesn't exist\n\tif (!existsSync(baseDir)) {\n\t\tawait mkdir(baseDir, { recursive: true });\n\t}\n\n\t// Generate filename with timestamp\n\tconst timestamp = Date.now();\n\tconst filename = `image_${timestamp}_${index}.${extension}`;\n\tconst filepath = join(baseDir, filename);\n\n\t// Save image to disk\n\tconst buffer = Buffer.from(base64Data, \"base64\");\n\tawait writeFile(filepath, buffer);\n\n\tlogger.info(`[OpenRouter] Saved generated image to ${filepath}`);\n\n\t// Return only the file path for Discord/Telegram to read\n\treturn filepath;\n}\n\n/**\n * Delete a specific image file\n */\nexport function deleteImage(filepath: string): void {\n\ttry {\n\t\tif (existsSync(filepath)) {\n\t\t\tunlinkSync(filepath);\n\t\t\tlogger.debug(`[OpenRouter] Deleted image: ${filepath}`);\n\t\t}\n\t} catch (error) {\n\t\tlogger.warn(`[OpenRouter] Failed to delete image ${filepath}:`, String(error));\n\t}\n}"],"mappings":";AAAA;AAAA,EACC,aAAAA;AAAA,OAOM;;;ACRP,SAAS,cAAkC;AAC3C,SAAS,SAAAC,cAAa;;;ACQf,SAAS,WACf,SACA,KACA,cACqB;AACrB,SAAO,QAAQ,WAAW,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK;AACvD;AAOO,SAAS,WAAW,SAAgC;AAC1D,SACC;AAAA,IACC;AAAA,IACA;AAAA,IACA;AAAA,EACD,KAAK;AAEP;AAQO,SAAS,UAAU,SAA4C;AACrE,SAAO,WAAW,SAAS,oBAAoB;AAChD;AAQO,SAAS,cAAc,SAAgC;AAC7D,SACC,WAAW,SAAS,wBAAwB,KAC5C,WAAW,SAAS,eAAe,6BAA6B,KAChE;AAEF;AAQO,SAAS,cAAc,SAAgC;AAC5D,SACE,WAAW,SAAS,wBAAwB,KAC5C;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,EACF,KACA;AAEJ;AAQO,SAAS,cAAc,SAAgC;AAC7D,SACC,WAAW,SAAS,wBAAwB,KAC5C,WAAW,SAAS,eAAe,yBAAyB,KAC5D;AAEF;AAQO,SAAS,wBAAwB,SAAgC;AACvE,SACC,WAAW,SAAS,mCAAmC,KACvD,WAAW,SAAS,0BAA0B,uCAAuC,KACrF;AAEF;AAQO,SAAS,wBAAwB,SAAiC;AACxE,QAAM,UAAU,WAAW,SAAS,kCAAkC,OAAO;AAC7E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ACzB,SACA,WACI;AACJ,aAAO,kBAAkB,SAAS,MAAM;AAAA,IACzC;AAAA,IACA,CAACA,WAAU,iBAAiB,GAAG,OAC9B,SACA,WACI;AACJ,aAAO,uBAAuB,SAAS,MAAM;AAAA,IAC9C;AAAA,IACA,CAACA,WAAU,KAAK,GAAG,OAClB,SACA,WACI;AACJ,aAAO,sBAAsB,SAAS,MAAM;AAAA,IAC7C;AAAA,EACD;AACD;AAEA,IAAO,gBAAQ;","names":["ModelType","fetch","fetch","logger","logger","logger","logger","logger","logger","ModelType","logger","ModelType","logger","logger","generateText","logger","logger","generateText","ModelType"]}
|