@langchain/google 0.2.13 → 0.2.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"errors.cjs","names":["baseNs","iife","LangChainError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["import {\n ns as baseNs,\n LangChainError,\n stampRetryable,\n} from \"@langchain/core/errors\";\nimport type { Gemini } from \"../chat_models/types.js\";\nimport { iife } from \"./misc.js\";\n\n// Internal namespace for all Google provider errors\nconst ns = baseNs.sub(\"google\");\n\nconst RETRYABLE_STATUS_CODES = [\n 408, // Request Timeout\n 429, // Too Many Requests\n 500, // Internal Server Error\n 502, // Bad Gateway\n 503, // Service Unavailable\n 504, // Gateway Timeout\n];\n\nfunction isRetryableStatus(statusCode?: number): boolean {\n if (!statusCode) return false;\n return RETRYABLE_STATUS_CODES.includes(statusCode);\n}\n\nasync function readErrorResponseBody(response: Response): Promise<unknown> {\n return iife(async () => {\n try {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return await response.json();\n }\n\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n } catch {\n return null;\n }\n });\n}\n\n/**\n * Base error class for all Google provider errors.\n *\n * All Google-specific error classes extend this class. Use\n * `GoogleError.isInstance(obj)` to check if an object is any\n * Google provider error.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"hello\");\n * } catch (error) {\n * if (GoogleError.isInstance(error)) {\n * console.log(\"Got a Google error:\", error.message);\n * }\n * }\n * ```\n */\nexport class GoogleError extends ns.brand(LangChainError) {\n readonly name: string = \"GoogleError\";\n}\n\n/**\n * Error thrown when there is a configuration issue with the Google provider.\n *\n * This error is thrown when the Google provider encounters invalid configuration\n * parameters or settings that prevent it from functioning correctly.\n *\n * @example\n * ```typescript\n * try {\n * const model = new ChatGoogle({ invalidOption: true });\n * } catch (error) {\n * if (ConfigurationError.isInstance(error)) {\n * console.log(`Configuration error: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class ConfigurationError extends ns.brand(GoogleError, \"configuration\") {\n readonly name = \"ConfigurationError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a PromptBlockedError\n */\ntype PromptBlockedErrorParams = {\n /**\n * The reason why the prompt was blocked (e.g., \"SAFETY\", \"OTHER\", \"UNKNOWN\")\n */\n blockReason: string;\n /**\n * Optional array of safety ratings that contributed to the block decision\n */\n safetyRatings?: Gemini.SafetyRating[];\n /**\n * Optional custom error message. If not provided, a default message will be generated\n */\n message?: string;\n};\n\n/**\n * Error thrown when a prompt is blocked by Google's safety filters.\n *\n * This error is thrown when the Gemini API blocks a prompt due to safety concerns.\n * It contains information about why the prompt was blocked and the safety ratings\n * that triggered the block.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some potentially unsafe prompt\");\n * } catch (error) {\n * if (PromptBlockedError.isInstance(error)) {\n * console.log(`Blocked due to: ${error.blockReason}`);\n * console.log(`Safety ratings:`, error.safetyRatings);\n * }\n * }\n * ```\n */\nexport class PromptBlockedError extends ns.brand(\n GoogleError,\n \"prompt-blocked\"\n) {\n readonly name = \"PromptBlockedError\";\n\n /**\n * The reason why the prompt was blocked.\n *\n * Common values include:\n * - \"SAFETY\" - Blocked due to safety concerns\n * - \"OTHER\" - Blocked for other reasons\n * - \"UNKNOWN\" - Reason is unknown\n *\n * @readonly\n */\n readonly blockReason: string;\n\n /**\n * Optional array of safety ratings that contributed to the block decision.\n *\n * Each rating contains information about different safety categories\n * (e.g., hate speech, sexually explicit content, dangerous content)\n * and their probability levels.\n *\n * @readonly\n */\n readonly safetyRatings?: Gemini.SafetyRating[];\n\n constructor(params: PromptBlockedErrorParams) {\n const message =\n params.message ??\n `Prompt was blocked: ${params.blockReason}.${\n params.safetyRatings && params.safetyRatings.length > 0\n ? ` Safety ratings: ${JSON.stringify(params.safetyRatings)}`\n : \"\"\n }`;\n\n super(message);\n this.blockReason = params.blockReason;\n this.safetyRatings = params.safetyRatings;\n stampRetryable(this, false);\n }\n\n /**\n * Creates a PromptBlockedError from a Gemini API prompt feedback object.\n *\n * This is a convenience factory method for creating errors from the API response\n * when a prompt is blocked. It extracts the relevant information from the\n * promptFeedback object returned by the Gemini API.\n *\n * @param promptFeedback - The prompt feedback object from the Gemini API response\n * @returns A new PromptBlockedError instance with information from the feedback\n *\n * @example\n * ```typescript\n * const response = await geminiApi.generateContent(request);\n * if (response.promptFeedback?.blockReason) {\n * throw PromptBlockedError.fromPromptFeedback(response.promptFeedback);\n * }\n * ```\n */\n static fromPromptFeedback(\n promptFeedback: Gemini.PromptFeedback\n ): PromptBlockedError {\n return new PromptBlockedError({\n blockReason: promptFeedback.blockReason ?? \"UNKNOWN\",\n safetyRatings: promptFeedback.safetyRatings,\n });\n }\n}\n\n/**\n * Parameters for constructing an AuthError\n */\ntype AuthErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for authentication failures when communicating with Google APIs.\n *\n * This error is thrown when authentication with a Google API fails, typically\n * during the OAuth token exchange process or when using service account credentials.\n * It captures detailed information about the failed authentication attempt including\n * the status code, headers, and response body to aid in debugging and error handling.\n *\n * Common authentication failure scenarios include:\n * - Invalid or expired credentials\n * - Incorrect service account configuration\n * - Missing or invalid API keys\n * - Insufficient permissions or scopes\n * - Token exchange failures\n *\n * @example\n * ```typescript\n * try {\n * const token = await getAccessToken(credentials);\n * } catch (error) {\n * if (AuthError.isInstance(error)) {\n * console.error(`Auth failed with status ${error.statusCode}: ${error.message}`);\n * console.error('Response data:', error.data);\n * }\n * }\n * ```\n */\nexport class AuthError extends ns.brand(GoogleError, \"auth\") {\n readonly name = \"AuthError\" as const;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: AuthErrorParams) {\n super(params.message);\n\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, isRetryableStatus(this.statusCode));\n }\n\n /**\n * Creates an AuthError from a failed HTTP response.\n *\n * This is a convenience factory method for creating authentication errors from\n * HTTP responses. It automatically extracts the error message, status code,\n * headers, and response body from the Response object.\n *\n * The method attempts to parse the response body as JSON to extract an\n * `error_description` field if available. If JSON parsing fails or the\n * content type is not JSON, it falls back to reading the response as text.\n * If both fail, the error body will be null.\n *\n * @param response - The failed HTTP Response object from the authentication request\n * @returns A Promise that resolves to a new AuthError instance with information from the response\n *\n * @example\n * ```typescript\n * const response = await fetch(tokenUrl, {\n * method: 'POST',\n * body: authRequestBody\n * });\n *\n * if (!response.ok) {\n * throw await AuthError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<AuthError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error_description ??\n `Authentication failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new AuthError({\n message,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Parameters for constructing a RequestError\n */\ntype RequestErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for HTTP request failures when communicating with Google APIs.\n *\n * This error is thrown when an HTTP request to a Google API endpoint fails.\n * It captures detailed information about the failed request including the URL,\n * status code, headers, and response body to aid in debugging and error handling.\n *\n * The error includes a `isRetryable()` method to determine if the request should\n * be retried based on the HTTP status code (e.g., 429 Too Many Requests, 503 Service Unavailable).\n *\n * @example\n * ```typescript\n * try {\n * const response = await apiClient.fetch(request);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * } catch (error) {\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * // Retry the request\n * }\n * }\n * ```\n */\nexport class RequestError extends ns.brand(GoogleError, \"request\") {\n readonly name = \"RequestError\" as const;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n readonly url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: RequestErrorParams) {\n super(params.message);\n\n this.url = params.url;\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, this.isRetryable());\n }\n\n /**\n * Determines if this error represents a retryable request failure.\n *\n * A request is considered retryable if it failed with a status code that\n * indicates a temporary issue that might succeed on retry. This includes:\n * - 408 (Request Timeout)\n * - 429 (Too Many Requests / Rate Limiting)\n * - 500 (Internal Server Error)\n * - 502 (Bad Gateway)\n * - 503 (Service Unavailable)\n * - 504 (Gateway Timeout)\n *\n * @returns `true` if the request should be retried, `false` otherwise\n *\n * @example\n * ```typescript\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * await sleep(1000);\n * return retry(request);\n * }\n * ```\n */\n isRetryable(): boolean {\n return isRetryableStatus(this.statusCode);\n }\n\n /**\n * Creates a RequestError from a failed HTTP Response object.\n *\n * This is a factory method that extracts all relevant information from a\n * Response object and constructs a RequestError with appropriate details.\n * It attempts to parse the response body as JSON first, falling back to\n * text if that fails, and finally to null if the body cannot be read.\n *\n * The error message is extracted from the response body if available\n * (looking for `message` or `error` fields), otherwise a generic message\n * is constructed using the status code.\n *\n * @param response - The failed HTTP Response object to convert into an error\n * @returns A Promise that resolves to a new RequestError instance\n *\n * @example\n * ```typescript\n * const response = await fetch(url);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<RequestError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error?.message ??\n errorBody?.message ??\n errorBody?.error ??\n `Request failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new RequestError({\n message,\n url: response.url,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Error thrown when the Gemini API returns no candidates in the response.\n *\n * This error is thrown when the API successfully processes a request but returns\n * an empty candidates array. This can occur when:\n * - The prompt was blocked by safety filters (but no explicit block reason was provided)\n * - An internal error occurred during generation\n * - The model was unable to generate a valid response\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some prompt\");\n * } catch (error) {\n * if (NoCandidatesError.isInstance(error)) {\n * console.log(\"No response candidates were generated\");\n * }\n * }\n * ```\n */\nexport class NoCandidatesError extends ns.brand(GoogleError, \"no-candidates\") {\n readonly name = \"NoCandidatesError\";\n\n constructor() {\n super(\n \"No candidates returned from API. This may indicate the prompt was blocked or an error occurred.\"\n );\n }\n}\n\n/**\n * Error thrown when an invalid tool is provided to the tool converter.\n *\n * This error is thrown when a tool cannot be converted to Gemini's function\n * declaration format. Tools must be one of:\n * - LangChain structured tools (with Zod schemas)\n * - OpenAI format tools (with JSON Schema)\n * - Gemini-native function declarations\n * - Gemini-native tools (codeExecution, googleSearchRetrieval)\n *\n * @example\n * ```typescript\n * try {\n * convertToolsToGeminiFunctionDeclarations([invalidTool]);\n * } catch (error) {\n * if (InvalidToolError.isInstance(error)) {\n * console.log(`Invalid tool: ${error.tool}`);\n * console.log(`Expected formats: LangChain tools, OpenAI tools, or Gemini function declarations`);\n * }\n * }\n * ```\n */\nexport class InvalidToolError extends ns.brand(GoogleError, \"invalid-tool\") {\n readonly name = \"InvalidToolError\";\n\n /**\n * The invalid tool that was provided.\n */\n readonly tool: unknown;\n\n constructor(tool: unknown, message?: string) {\n const defaultMessage = `Received invalid tool: ${JSON.stringify(\n tool\n )}. Tools must be LangChain tools, OpenAI tools, or Gemini function declarations.`;\n\n super(message ?? defaultMessage);\n this.tool = tool;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Error thrown when a ToolMessage references a tool call that cannot be found.\n *\n * This error is thrown when a ToolMessage is passed to ChatGoogle but there is no\n * corresponding AIMessage with a matching toolCallId in the conversation history.\n * This typically indicates that:\n * - The tool call ID in the ToolMessage doesn't match any previous tool calls\n * - The AIMessage containing the tool call was not included in the message history\n * - The tool call ID was incorrectly set or modified\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke([\n * new ToolMessage({ content: \"result\", tool_call_id: \"nonexistent-id\" })\n * ]);\n * } catch (error) {\n * if (ToolCallNotFoundError.isInstance(error)) {\n * console.log(`Tool call not found: ${error.toolCallId}`);\n * }\n * }\n * ```\n */\nexport class ToolCallNotFoundError extends ns.brand(\n GoogleError,\n \"tool-call-not-found\"\n) {\n readonly name = \"ToolCallNotFoundError\";\n\n /**\n * The tool call ID that could not be found in the conversation history.\n */\n readonly toolCallId: string;\n\n constructor(toolCallId: string, message?: string) {\n const defaultMessage = `Tool call with ID \"${toolCallId}\" not found in conversation history. Ensure the corresponding AIMessage with this tool call ID is included in the input.`;\n\n super(message ?? defaultMessage);\n this.toolCallId = toolCallId;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a MalformedOutputError\n */\ntype MalformedOutputErrorParams = {\n /**\n * The error message describing what went wrong during parsing\n */\n message: string;\n /**\n * Optional cause of the parsing error (e.g., the original error that occurred)\n */\n cause?: unknown;\n};\n\n/**\n * Error thrown when output parsing fails in structured output methods.\n *\n * This error is thrown when the model's response cannot be parsed according to\n * the expected schema or format. Common causes include:\n * - Invalid message type (not an AIMessage or AIMessageChunk)\n * - Missing or empty content in the response\n * - Malformed JSON that cannot be parsed\n * - Schema validation failures\n *\n * @example\n * ```typescript\n * try {\n * const result = await model.withStructuredOutput(schema).invoke(\"extract data\");\n * } catch (error) {\n * if (MalformedOutputError.isInstance(error)) {\n * console.log(`Failed to parse output: ${error.message}`);\n * if (error.cause) {\n * console.log(`Cause:`, error.cause);\n * }\n * }\n * }\n * ```\n */\nexport class MalformedOutputError extends ns.brand(\n GoogleError,\n \"malformed-output\"\n) {\n readonly name = \"MalformedOutputError\";\n\n /**\n * Optional cause of the parsing error.\n * This may be the original error that occurred during parsing,\n * or additional context about what went wrong.\n */\n readonly cause?: unknown;\n\n constructor(params: MalformedOutputErrorParams) {\n super(params.message);\n this.cause = params.cause;\n }\n}\n\n/**\n * Error thrown when input provided to the Google provider is invalid.\n *\n * This error is thrown when the user provides input that cannot be\n * processed by Gemini, such as:\n * - Union types in tool/function schemas\n * - Null-only types in schemas\n * - Unsupported content block source types\n * - Missing required fields in content blocks\n *\n * @example\n * ```typescript\n * try {\n * const result = schemaToGeminiParameters(unionTypeSchema);\n * } catch (error) {\n * if (InvalidInputError.isInstance(error)) {\n * console.log(`Invalid input: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class InvalidInputError extends ns.brand(GoogleError, \"invalid-input\") {\n readonly name = \"InvalidInputError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n"],"mappings":";;;AASA,MAAM,KAAKA,uBAAAA,GAAO,IAAI,QAAQ;AAE9B,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,YAA8B;CACvD,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,uBAAuB,SAAS,UAAU;AACnD;AAEA,eAAe,sBAAsB,UAAsC;CACzE,OAAOC,aAAAA,KAAK,YAAY;EACtB,IAAI;GAEF,KADoB,SAAS,QAAQ,IAAI,cAAc,KAAK,GAAA,CAC5C,SAAS,kBAAkB,GACzC,OAAO,MAAM,S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GAAG,MAAM,aAAa,eAAe,CAAC,CAAC;CAC5E,OAAgB;CAEhB,YAAY,SAAkB;EAC5B,MAAM,OAAO;EACb,CAAA,GAAA,uBAAA,eAAA,CAAe,MAAM,KAAK;CAC5B;AACF"}
1
+ {"version":3,"file":"errors.cjs","names":["baseNs","iife","LangChainError","ModelRefusalError"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["import {\n ns as baseNs,\n LangChainError,\n ModelRefusalError,\n stampRetryable,\n} from \"@langchain/core/errors\";\nimport type { Gemini } from \"../chat_models/types.js\";\nimport { iife } from \"./misc.js\";\n\n// Internal namespace for all Google provider errors\nconst ns = baseNs.sub(\"google\");\n\nconst RETRYABLE_STATUS_CODES = [\n 408, // Request Timeout\n 429, // Too Many Requests\n 500, // Internal Server Error\n 502, // Bad Gateway\n 503, // Service Unavailable\n 504, // Gateway Timeout\n];\n\nfunction isRetryableStatus(statusCode?: number): boolean {\n if (!statusCode) return false;\n return RETRYABLE_STATUS_CODES.includes(statusCode);\n}\n\nasync function readErrorResponseBody(response: Response): Promise<unknown> {\n return iife(async () => {\n try {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return await response.json();\n }\n\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n } catch {\n return null;\n }\n });\n}\n\n/**\n * Base error class for all Google provider errors.\n *\n * All Google-specific error classes extend this class. Use\n * `GoogleError.isInstance(obj)` to check if an object is any\n * Google provider error.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"hello\");\n * } catch (error) {\n * if (GoogleError.isInstance(error)) {\n * console.log(\"Got a Google error:\", error.message);\n * }\n * }\n * ```\n */\nexport class GoogleError extends ns.brand(LangChainError) {\n readonly name: string = \"GoogleError\";\n}\n\n/**\n * Error thrown when there is a configuration issue with the Google provider.\n *\n * This error is thrown when the Google provider encounters invalid configuration\n * parameters or settings that prevent it from functioning correctly.\n *\n * @example\n * ```typescript\n * try {\n * const model = new ChatGoogle({ invalidOption: true });\n * } catch (error) {\n * if (ConfigurationError.isInstance(error)) {\n * console.log(`Configuration error: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class ConfigurationError extends ns.brand(GoogleError, \"configuration\") {\n readonly name = \"ConfigurationError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a PromptBlockedError\n */\ntype PromptBlockedErrorParams = {\n /**\n * The reason why the prompt was blocked (e.g., \"SAFETY\", \"OTHER\", \"UNKNOWN\")\n */\n blockReason: string;\n /**\n * Optional array of safety ratings that contributed to the block decision\n */\n safetyRatings?: Gemini.SafetyRating[];\n /**\n * Optional custom error message. If not provided, a default message will be generated\n */\n message?: string;\n};\n\n/**\n * Error thrown when a prompt is blocked by Google's safety filters.\n *\n * This error is thrown when the Gemini API blocks a prompt due to safety concerns.\n * It contains information about why the prompt was blocked and the safety ratings\n * that triggered the block.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some potentially unsafe prompt\");\n * } catch (error) {\n * if (PromptBlockedError.isInstance(error)) {\n * console.log(`Blocked due to: ${error.blockReason}`);\n * console.log(`Safety ratings:`, error.safetyRatings);\n * }\n * }\n * ```\n */\nexport class PromptBlockedError extends ns.brand(\n GoogleError,\n \"prompt-blocked\"\n) {\n readonly name = \"PromptBlockedError\";\n\n /**\n * The reason why the prompt was blocked.\n *\n * Common values include:\n * - \"SAFETY\" - Blocked due to safety concerns\n * - \"OTHER\" - Blocked for other reasons\n * - \"UNKNOWN\" - Reason is unknown\n *\n * @readonly\n */\n readonly blockReason: string;\n\n /**\n * Optional array of safety ratings that contributed to the block decision.\n *\n * Each rating contains information about different safety categories\n * (e.g., hate speech, sexually explicit content, dangerous content)\n * and their probability levels.\n *\n * @readonly\n */\n readonly safetyRatings?: Gemini.SafetyRating[];\n\n constructor(params: PromptBlockedErrorParams) {\n const message =\n params.message ??\n `Prompt was blocked: ${params.blockReason}.${\n params.safetyRatings && params.safetyRatings.length > 0\n ? ` Safety ratings: ${JSON.stringify(params.safetyRatings)}`\n : \"\"\n }`;\n\n super(message);\n this.blockReason = params.blockReason;\n this.safetyRatings = params.safetyRatings;\n stampRetryable(this, false);\n }\n\n /**\n * Creates a PromptBlockedError from a Gemini API prompt feedback object.\n *\n * This is a convenience factory method for creating errors from the API response\n * when a prompt is blocked. It extracts the relevant information from the\n * promptFeedback object returned by the Gemini API.\n *\n * @param promptFeedback - The prompt feedback object from the Gemini API response\n * @returns A new PromptBlockedError instance with information from the feedback\n *\n * @example\n * ```typescript\n * const response = await geminiApi.generateContent(request);\n * if (response.promptFeedback?.blockReason) {\n * throw PromptBlockedError.fromPromptFeedback(response.promptFeedback);\n * }\n * ```\n */\n static fromPromptFeedback(\n promptFeedback: Gemini.PromptFeedback\n ): PromptBlockedError {\n return new this({\n blockReason: promptFeedback.blockReason ?? \"UNKNOWN\",\n safetyRatings: promptFeedback.safetyRatings,\n });\n }\n}\n\n/**\n * A {@link PromptBlockedError} for a prompt Gemini refused, such as one blocked\n * for safety.\n *\n * It also matches `ModelRefusalError.isInstance` from `@langchain/core/errors`,\n * so callers can handle it like a refusal from any other provider.\n */\nexport class PromptRefusedError extends baseNs.brand(\n PromptBlockedError,\n \"model-refusal\"\n) {\n // The inherited check only looks for the refusal brand, which every\n // `ModelRefusalError` carries.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static isInstance<T extends abstract new (...args: any[]) => any>(\n this: T,\n obj: unknown\n ): obj is InstanceType<T> {\n return (\n PromptBlockedError.isInstance(obj) && ModelRefusalError.isInstance(obj)\n );\n }\n}\n\n// The Gemini API and Vertex AI spell the unspecified reason differently.\nconst UNSPECIFIED_BLOCK_REASONS = new Set<string>([\n \"BLOCK_REASON_UNSPECIFIED\",\n \"BLOCKED_REASON_UNSPECIFIED\",\n]);\n\n/** Builds the error for a blocked prompt, a refusal unless the reason is unspecified. */\nexport function promptBlockedError(\n promptFeedback: Gemini.GenContent.GenerateContentResponse[\"promptFeedback\"] &\n object\n): PromptBlockedError {\n const ErrorClass = UNSPECIFIED_BLOCK_REASONS.has(\n promptFeedback.blockReason ?? \"\"\n )\n ? PromptBlockedError\n : PromptRefusedError;\n return ErrorClass.fromPromptFeedback(promptFeedback);\n}\n\n/**\n * Parameters for constructing an AuthError\n */\ntype AuthErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for authentication failures when communicating with Google APIs.\n *\n * This error is thrown when authentication with a Google API fails, typically\n * during the OAuth token exchange process or when using service account credentials.\n * It captures detailed information about the failed authentication attempt including\n * the status code, headers, and response body to aid in debugging and error handling.\n *\n * Common authentication failure scenarios include:\n * - Invalid or expired credentials\n * - Incorrect service account configuration\n * - Missing or invalid API keys\n * - Insufficient permissions or scopes\n * - Token exchange failures\n *\n * @example\n * ```typescript\n * try {\n * const token = await getAccessToken(credentials);\n * } catch (error) {\n * if (AuthError.isInstance(error)) {\n * console.error(`Auth failed with status ${error.statusCode}: ${error.message}`);\n * console.error('Response data:', error.data);\n * }\n * }\n * ```\n */\nexport class AuthError extends ns.brand(GoogleError, \"auth\") {\n readonly name = \"AuthError\" as const;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: AuthErrorParams) {\n super(params.message);\n\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, isRetryableStatus(this.statusCode));\n }\n\n /**\n * Creates an AuthError from a failed HTTP response.\n *\n * This is a convenience factory method for creating authentication errors from\n * HTTP responses. It automatically extracts the error message, status code,\n * headers, and response body from the Response object.\n *\n * The method attempts to parse the response body as JSON to extract an\n * `error_description` field if available. If JSON parsing fails or the\n * content type is not JSON, it falls back to reading the response as text.\n * If both fail, the error body will be null.\n *\n * @param response - The failed HTTP Response object from the authentication request\n * @returns A Promise that resolves to a new AuthError instance with information from the response\n *\n * @example\n * ```typescript\n * const response = await fetch(tokenUrl, {\n * method: 'POST',\n * body: authRequestBody\n * });\n *\n * if (!response.ok) {\n * throw await AuthError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<AuthError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error_description ??\n `Authentication failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new AuthError({\n message,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Parameters for constructing a RequestError\n */\ntype RequestErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for HTTP request failures when communicating with Google APIs.\n *\n * This error is thrown when an HTTP request to a Google API endpoint fails.\n * It captures detailed information about the failed request including the URL,\n * status code, headers, and response body to aid in debugging and error handling.\n *\n * The error includes a `isRetryable()` method to determine if the request should\n * be retried based on the HTTP status code (e.g., 429 Too Many Requests, 503 Service Unavailable).\n *\n * @example\n * ```typescript\n * try {\n * const response = await apiClient.fetch(request);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * } catch (error) {\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * // Retry the request\n * }\n * }\n * ```\n */\nexport class RequestError extends ns.brand(GoogleError, \"request\") {\n readonly name = \"RequestError\" as const;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n readonly url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: RequestErrorParams) {\n super(params.message);\n\n this.url = params.url;\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, this.isRetryable());\n }\n\n /**\n * Determines if this error represents a retryable request failure.\n *\n * A request is considered retryable if it failed with a status code that\n * indicates a temporary issue that might succeed on retry. This includes:\n * - 408 (Request Timeout)\n * - 429 (Too Many Requests / Rate Limiting)\n * - 500 (Internal Server Error)\n * - 502 (Bad Gateway)\n * - 503 (Service Unavailable)\n * - 504 (Gateway Timeout)\n *\n * @returns `true` if the request should be retried, `false` otherwise\n *\n * @example\n * ```typescript\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * await sleep(1000);\n * return retry(request);\n * }\n * ```\n */\n isRetryable(): boolean {\n return isRetryableStatus(this.statusCode);\n }\n\n /**\n * Creates a RequestError from a failed HTTP Response object.\n *\n * This is a factory method that extracts all relevant information from a\n * Response object and constructs a RequestError with appropriate details.\n * It attempts to parse the response body as JSON first, falling back to\n * text if that fails, and finally to null if the body cannot be read.\n *\n * The error message is extracted from the response body if available\n * (looking for `message` or `error` fields), otherwise a generic message\n * is constructed using the status code.\n *\n * @param response - The failed HTTP Response object to convert into an error\n * @returns A Promise that resolves to a new RequestError instance\n *\n * @example\n * ```typescript\n * const response = await fetch(url);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<RequestError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error?.message ??\n errorBody?.message ??\n errorBody?.error ??\n `Request failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new RequestError({\n message,\n url: response.url,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Error thrown when the Gemini API returns no candidates in the response.\n *\n * This error is thrown when the API successfully processes a request but returns\n * an empty candidates array. This can occur when:\n * - The prompt was blocked by safety filters (but no explicit block reason was provided)\n * - An internal error occurred during generation\n * - The model was unable to generate a valid response\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some prompt\");\n * } catch (error) {\n * if (NoCandidatesError.isInstance(error)) {\n * console.log(\"No response candidates were generated\");\n * }\n * }\n * ```\n */\nexport class NoCandidatesError extends ns.brand(GoogleError, \"no-candidates\") {\n readonly name = \"NoCandidatesError\";\n\n constructor() {\n super(\n \"No candidates returned from API. This may indicate the prompt was blocked or an error occurred.\"\n );\n }\n}\n\n/**\n * Error thrown when an invalid tool is provided to the tool converter.\n *\n * This error is thrown when a tool cannot be converted to Gemini's function\n * declaration format. Tools must be one of:\n * - LangChain structured tools (with Zod schemas)\n * - OpenAI format tools (with JSON Schema)\n * - Gemini-native function declarations\n * - Gemini-native tools (codeExecution, googleSearchRetrieval)\n *\n * @example\n * ```typescript\n * try {\n * convertToolsToGeminiFunctionDeclarations([invalidTool]);\n * } catch (error) {\n * if (InvalidToolError.isInstance(error)) {\n * console.log(`Invalid tool: ${error.tool}`);\n * console.log(`Expected formats: LangChain tools, OpenAI tools, or Gemini function declarations`);\n * }\n * }\n * ```\n */\nexport class InvalidToolError extends ns.brand(GoogleError, \"invalid-tool\") {\n readonly name = \"InvalidToolError\";\n\n /**\n * The invalid tool that was provided.\n */\n readonly tool: unknown;\n\n constructor(tool: unknown, message?: string) {\n const defaultMessage = `Received invalid tool: ${JSON.stringify(\n tool\n )}. Tools must be LangChain tools, OpenAI tools, or Gemini function declarations.`;\n\n super(message ?? defaultMessage);\n this.tool = tool;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Error thrown when a ToolMessage references a tool call that cannot be found.\n *\n * This error is thrown when a ToolMessage is passed to ChatGoogle but there is no\n * corresponding AIMessage with a matching toolCallId in the conversation history.\n * This typically indicates that:\n * - The tool call ID in the ToolMessage doesn't match any previous tool calls\n * - The AIMessage containing the tool call was not included in the message history\n * - The tool call ID was incorrectly set or modified\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke([\n * new ToolMessage({ content: \"result\", tool_call_id: \"nonexistent-id\" })\n * ]);\n * } catch (error) {\n * if (ToolCallNotFoundError.isInstance(error)) {\n * console.log(`Tool call not found: ${error.toolCallId}`);\n * }\n * }\n * ```\n */\nexport class ToolCallNotFoundError extends ns.brand(\n GoogleError,\n \"tool-call-not-found\"\n) {\n readonly name = \"ToolCallNotFoundError\";\n\n /**\n * The tool call ID that could not be found in the conversation history.\n */\n readonly toolCallId: string;\n\n constructor(toolCallId: string, message?: string) {\n const defaultMessage = `Tool call with ID \"${toolCallId}\" not found in conversation history. Ensure the corresponding AIMessage with this tool call ID is included in the input.`;\n\n super(message ?? defaultMessage);\n this.toolCallId = toolCallId;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a MalformedOutputError\n */\ntype MalformedOutputErrorParams = {\n /**\n * The error message describing what went wrong during parsing\n */\n message: string;\n /**\n * Optional cause of the parsing error (e.g., the original error that occurred)\n */\n cause?: unknown;\n};\n\n/**\n * Error thrown when output parsing fails in structured output methods.\n *\n * This error is thrown when the model's response cannot be parsed according to\n * the expected schema or format. Common causes include:\n * - Invalid message type (not an AIMessage or AIMessageChunk)\n * - Missing or empty content in the response\n * - Malformed JSON that cannot be parsed\n * - Schema validation failures\n *\n * @example\n * ```typescript\n * try {\n * const result = await model.withStructuredOutput(schema).invoke(\"extract data\");\n * } catch (error) {\n * if (MalformedOutputError.isInstance(error)) {\n * console.log(`Failed to parse output: ${error.message}`);\n * if (error.cause) {\n * console.log(`Cause:`, error.cause);\n * }\n * }\n * }\n * ```\n */\nexport class MalformedOutputError extends ns.brand(\n GoogleError,\n \"malformed-output\"\n) {\n readonly name = \"MalformedOutputError\";\n\n /**\n * Optional cause of the parsing error.\n * This may be the original error that occurred during parsing,\n * or additional context about what went wrong.\n */\n readonly cause?: unknown;\n\n constructor(params: MalformedOutputErrorParams) {\n super(params.message);\n this.cause = params.cause;\n }\n}\n\n/**\n * Error thrown when input provided to the Google provider is invalid.\n *\n * This error is thrown when the user provides input that cannot be\n * processed by Gemini, such as:\n * - Union types in tool/function schemas\n * - Null-only types in schemas\n * - Unsupported content block source types\n * - Missing required fields in content blocks\n *\n * @example\n * ```typescript\n * try {\n * const result = schemaToGeminiParameters(unionTypeSchema);\n * } catch (error) {\n * if (InvalidInputError.isInstance(error)) {\n * console.log(`Invalid input: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class InvalidInputError extends ns.brand(GoogleError, \"invalid-input\") {\n readonly name = \"InvalidInputError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n"],"mappings":";;;AAUA,MAAM,KAAKA,uBAAAA,GAAO,IAAI,QAAQ;AAE9B,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,YAA8B;CACvD,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,uBAAuB,SAAS,UAAU;AACnD;AAEA,eAAe,sBAAsB,UAAsC;CACzE,OAAOC,aAAAA,KAAK,YAAY;EACtB,IAAI;GAEF,KADoB,SAAS,QAAQ,IAAI,cAAc,KAAK,GAAA,CAC5C,SAAS,kBAAkB,GACzC,OAAO,MAAM,SAAS,KAAK;GAG7B,MAAM,OAAO,MAAM,SAAS,KAAK;GACjC,IAAI;IACF,OAAO,KAAK,MAAM,IAAI;GACxB,QAAQ;IACN,OAAO;GACT;EACF,QAAQ;GACN,OAAO;EACT;CACF,CAAC;AACH;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,cAAb,cAAiC,GAAG,MAAMC,uBAAAA,cAAc,CAAC,CAAC;CACxD,OAAwB;AAC1B;;;;;;;;;;;;;;;;;;AAmBA,IAAa,qBAAb,cAAwC,GAAG,MAAM,aAAa,eAAe,CAAC,CAAC;CAC7E,OAAgB;CAEhB,YAAY,SAA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C5E,OAAgB;CAEhB,YAAY,SAAkB;EAC5B,MAAM,OAAO;EACb,CAAA,GAAA,uBAAA,eAAA,CAAe,MAAM,KAAK;CAC5B;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { iife } from "./misc.js";
2
- import { LangChainError, ns, stampRetryable } from "@langchain/core/errors";
2
+ import { LangChainError, ModelRefusalError, ns, stampRetryable } from "@langchain/core/errors";
3
3
  // src/utils/errors.ts
4
4
  const ns$1 = ns.sub("google");
5
5
  const RETRYABLE_STATUS_CODES = [
@@ -93,7 +93,7 @@ var ConfigurationError = class extends ns$1.brand(GoogleError, "configuration")
93
93
  * }
94
94
  * ```
95
95
  */
96
- var PromptBlockedError = class PromptBlockedError extends ns$1.brand(GoogleError, "prompt-blocked") {
96
+ var PromptBlockedError = class extends ns$1.brand(GoogleError, "prompt-blocked") {
97
97
  name = "PromptBlockedError";
98
98
  /**
99
99
  * The reason why the prompt was blocked.
@@ -142,13 +142,30 @@ var PromptBlockedError = class PromptBlockedError extends ns$1.brand(GoogleError
142
142
  * ```
143
143
  */
144
144
  static fromPromptFeedback(promptFeedback) {
145
- return new PromptBlockedError({
145
+ return new this({
146
146
  blockReason: promptFeedback.blockReason ?? "UNKNOWN",
147
147
  safetyRatings: promptFeedback.safetyRatings
148
148
  });
149
149
  }
150
150
  };
151
151
  /**
152
+ * A {@link PromptBlockedError} for a prompt Gemini refused, such as one blocked
153
+ * for safety.
154
+ *
155
+ * It also matches `ModelRefusalError.isInstance` from `@langchain/core/errors`,
156
+ * so callers can handle it like a refusal from any other provider.
157
+ */
158
+ var PromptRefusedError = class extends ns.brand(PromptBlockedError, "model-refusal") {
159
+ static isInstance(obj) {
160
+ return PromptBlockedError.isInstance(obj) && ModelRefusalError.isInstance(obj);
161
+ }
162
+ };
163
+ const UNSPECIFIED_BLOCK_REASONS = /* @__PURE__ */ new Set(["BLOCK_REASON_UNSPECIFIED", "BLOCKED_REASON_UNSPECIFIED"]);
164
+ /** Builds the error for a blocked prompt, a refusal unless the reason is unspecified. */
165
+ function promptBlockedError(promptFeedback) {
166
+ return (UNSPECIFIED_BLOCK_REASONS.has(promptFeedback.blockReason ?? "") ? PromptBlockedError : PromptRefusedError).fromPromptFeedback(promptFeedback);
167
+ }
168
+ /**
152
169
  * Error class for authentication failures when communicating with Google APIs.
153
170
  *
154
171
  * This error is thrown when authentication with a Google API fails, typically
@@ -549,6 +566,6 @@ var InvalidInputError = class extends ns$1.brand(GoogleError, "invalid-input") {
549
566
  stampRetryable(this, false);
550
567
  }
551
568
  };
552
- export { AuthError, ConfigurationError, GoogleError, InvalidInputError, InvalidToolError, MalformedOutputError, NoCandidatesError, PromptBlockedError, RequestError, ToolCallNotFoundError };
569
+ export { AuthError, ConfigurationError, GoogleError, InvalidInputError, InvalidToolError, MalformedOutputError, NoCandidatesError, PromptBlockedError, PromptRefusedError, RequestError, ToolCallNotFoundError, promptBlockedError };
553
570
 
554
571
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["ns","baseNs"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["import {\n ns as baseNs,\n LangChainError,\n stampRetryable,\n} from \"@langchain/core/errors\";\nimport type { Gemini } from \"../chat_models/types.js\";\nimport { iife } from \"./misc.js\";\n\n// Internal namespace for all Google provider errors\nconst ns = baseNs.sub(\"google\");\n\nconst RETRYABLE_STATUS_CODES = [\n 408, // Request Timeout\n 429, // Too Many Requests\n 500, // Internal Server Error\n 502, // Bad Gateway\n 503, // Service Unavailable\n 504, // Gateway Timeout\n];\n\nfunction isRetryableStatus(statusCode?: number): boolean {\n if (!statusCode) return false;\n return RETRYABLE_STATUS_CODES.includes(statusCode);\n}\n\nasync function readErrorResponseBody(response: Response): Promise<unknown> {\n return iife(async () => {\n try {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return await response.json();\n }\n\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n } catch {\n return null;\n }\n });\n}\n\n/**\n * Base error class for all Google provider errors.\n *\n * All Google-specific error classes extend this class. Use\n * `GoogleError.isInstance(obj)` to check if an object is any\n * Google provider error.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"hello\");\n * } catch (error) {\n * if (GoogleError.isInstance(error)) {\n * console.log(\"Got a Google error:\", error.message);\n * }\n * }\n * ```\n */\nexport class GoogleError extends ns.brand(LangChainError) {\n readonly name: string = \"GoogleError\";\n}\n\n/**\n * Error thrown when there is a configuration issue with the Google provider.\n *\n * This error is thrown when the Google provider encounters invalid configuration\n * parameters or settings that prevent it from functioning correctly.\n *\n * @example\n * ```typescript\n * try {\n * const model = new ChatGoogle({ invalidOption: true });\n * } catch (error) {\n * if (ConfigurationError.isInstance(error)) {\n * console.log(`Configuration error: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class ConfigurationError extends ns.brand(GoogleError, \"configuration\") {\n readonly name = \"ConfigurationError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a PromptBlockedError\n */\ntype PromptBlockedErrorParams = {\n /**\n * The reason why the prompt was blocked (e.g., \"SAFETY\", \"OTHER\", \"UNKNOWN\")\n */\n blockReason: string;\n /**\n * Optional array of safety ratings that contributed to the block decision\n */\n safetyRatings?: Gemini.SafetyRating[];\n /**\n * Optional custom error message. If not provided, a default message will be generated\n */\n message?: string;\n};\n\n/**\n * Error thrown when a prompt is blocked by Google's safety filters.\n *\n * This error is thrown when the Gemini API blocks a prompt due to safety concerns.\n * It contains information about why the prompt was blocked and the safety ratings\n * that triggered the block.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some potentially unsafe prompt\");\n * } catch (error) {\n * if (PromptBlockedError.isInstance(error)) {\n * console.log(`Blocked due to: ${error.blockReason}`);\n * console.log(`Safety ratings:`, error.safetyRatings);\n * }\n * }\n * ```\n */\nexport class PromptBlockedError extends ns.brand(\n GoogleError,\n \"prompt-blocked\"\n) {\n readonly name = \"PromptBlockedError\";\n\n /**\n * The reason why the prompt was blocked.\n *\n * Common values include:\n * - \"SAFETY\" - Blocked due to safety concerns\n * - \"OTHER\" - Blocked for other reasons\n * - \"UNKNOWN\" - Reason is unknown\n *\n * @readonly\n */\n readonly blockReason: string;\n\n /**\n * Optional array of safety ratings that contributed to the block decision.\n *\n * Each rating contains information about different safety categories\n * (e.g., hate speech, sexually explicit content, dangerous content)\n * and their probability levels.\n *\n * @readonly\n */\n readonly safetyRatings?: Gemini.SafetyRating[];\n\n constructor(params: PromptBlockedErrorParams) {\n const message =\n params.message ??\n `Prompt was blocked: ${params.blockReason}.${\n params.safetyRatings && params.safetyRatings.length > 0\n ? ` Safety ratings: ${JSON.stringify(params.safetyRatings)}`\n : \"\"\n }`;\n\n super(message);\n this.blockReason = params.blockReason;\n this.safetyRatings = params.safetyRatings;\n stampRetryable(this, false);\n }\n\n /**\n * Creates a PromptBlockedError from a Gemini API prompt feedback object.\n *\n * This is a convenience factory method for creating errors from the API response\n * when a prompt is blocked. It extracts the relevant information from the\n * promptFeedback object returned by the Gemini API.\n *\n * @param promptFeedback - The prompt feedback object from the Gemini API response\n * @returns A new PromptBlockedError instance with information from the feedback\n *\n * @example\n * ```typescript\n * const response = await geminiApi.generateContent(request);\n * if (response.promptFeedback?.blockReason) {\n * throw PromptBlockedError.fromPromptFeedback(response.promptFeedback);\n * }\n * ```\n */\n static fromPromptFeedback(\n promptFeedback: Gemini.PromptFeedback\n ): PromptBlockedError {\n return new PromptBlockedError({\n blockReason: promptFeedback.blockReason ?? \"UNKNOWN\",\n safetyRatings: promptFeedback.safetyRatings,\n });\n }\n}\n\n/**\n * Parameters for constructing an AuthError\n */\ntype AuthErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for authentication failures when communicating with Google APIs.\n *\n * This error is thrown when authentication with a Google API fails, typically\n * during the OAuth token exchange process or when using service account credentials.\n * It captures detailed information about the failed authentication attempt including\n * the status code, headers, and response body to aid in debugging and error handling.\n *\n * Common authentication failure scenarios include:\n * - Invalid or expired credentials\n * - Incorrect service account configuration\n * - Missing or invalid API keys\n * - Insufficient permissions or scopes\n * - Token exchange failures\n *\n * @example\n * ```typescript\n * try {\n * const token = await getAccessToken(credentials);\n * } catch (error) {\n * if (AuthError.isInstance(error)) {\n * console.error(`Auth failed with status ${error.statusCode}: ${error.message}`);\n * console.error('Response data:', error.data);\n * }\n * }\n * ```\n */\nexport class AuthError extends ns.brand(GoogleError, \"auth\") {\n readonly name = \"AuthError\" as const;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: AuthErrorParams) {\n super(params.message);\n\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, isRetryableStatus(this.statusCode));\n }\n\n /**\n * Creates an AuthError from a failed HTTP response.\n *\n * This is a convenience factory method for creating authentication errors from\n * HTTP responses. It automatically extracts the error message, status code,\n * headers, and response body from the Response object.\n *\n * The method attempts to parse the response body as JSON to extract an\n * `error_description` field if available. If JSON parsing fails or the\n * content type is not JSON, it falls back to reading the response as text.\n * If both fail, the error body will be null.\n *\n * @param response - The failed HTTP Response object from the authentication request\n * @returns A Promise that resolves to a new AuthError instance with information from the response\n *\n * @example\n * ```typescript\n * const response = await fetch(tokenUrl, {\n * method: 'POST',\n * body: authRequestBody\n * });\n *\n * if (!response.ok) {\n * throw await AuthError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<AuthError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error_description ??\n `Authentication failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new AuthError({\n message,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Parameters for constructing a RequestError\n */\ntype RequestErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for HTTP request failures when communicating with Google APIs.\n *\n * This error is thrown when an HTTP request to a Google API endpoint fails.\n * It captures detailed information about the failed request including the URL,\n * status code, headers, and response body to aid in debugging and error handling.\n *\n * The error includes a `isRetryable()` method to determine if the request should\n * be retried based on the HTTP status code (e.g., 429 Too Many Requests, 503 Service Unavailable).\n *\n * @example\n * ```typescript\n * try {\n * const response = await apiClient.fetch(request);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * } catch (error) {\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * // Retry the request\n * }\n * }\n * ```\n */\nexport class RequestError extends ns.brand(GoogleError, \"request\") {\n readonly name = \"RequestError\" as const;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n readonly url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: RequestErrorParams) {\n super(params.message);\n\n this.url = params.url;\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, this.isRetryable());\n }\n\n /**\n * Determines if this error represents a retryable request failure.\n *\n * A request is considered retryable if it failed with a status code that\n * indicates a temporary issue that might succeed on retry. This includes:\n * - 408 (Request Timeout)\n * - 429 (Too Many Requests / Rate Limiting)\n * - 500 (Internal Server Error)\n * - 502 (Bad Gateway)\n * - 503 (Service Unavailable)\n * - 504 (Gateway Timeout)\n *\n * @returns `true` if the request should be retried, `false` otherwise\n *\n * @example\n * ```typescript\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * await sleep(1000);\n * return retry(request);\n * }\n * ```\n */\n isRetryable(): boolean {\n return isRetryableStatus(this.statusCode);\n }\n\n /**\n * Creates a RequestError from a failed HTTP Response object.\n *\n * This is a factory method that extracts all relevant information from a\n * Response object and constructs a RequestError with appropriate details.\n * It attempts to parse the response body as JSON first, falling back to\n * text if that fails, and finally to null if the body cannot be read.\n *\n * The error message is extracted from the response body if available\n * (looking for `message` or `error` fields), otherwise a generic message\n * is constructed using the status code.\n *\n * @param response - The failed HTTP Response object to convert into an error\n * @returns A Promise that resolves to a new RequestError instance\n *\n * @example\n * ```typescript\n * const response = await fetch(url);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<RequestError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error?.message ??\n errorBody?.message ??\n errorBody?.error ??\n `Request failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new RequestError({\n message,\n url: response.url,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Error thrown when the Gemini API returns no candidates in the response.\n *\n * This error is thrown when the API successfully processes a request but returns\n * an empty candidates array. This can occur when:\n * - The prompt was blocked by safety filters (but no explicit block reason was provided)\n * - An internal error occurred during generation\n * - The model was unable to generate a valid response\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some prompt\");\n * } catch (error) {\n * if (NoCandidatesError.isInstance(error)) {\n * console.log(\"No response candidates were generated\");\n * }\n * }\n * ```\n */\nexport class NoCandidatesError extends ns.brand(GoogleError, \"no-candidates\") {\n readonly name = \"NoCandidatesError\";\n\n constructor() {\n super(\n \"No candidates returned from API. This may indicate the prompt was blocked or an error occurred.\"\n );\n }\n}\n\n/**\n * Error thrown when an invalid tool is provided to the tool converter.\n *\n * This error is thrown when a tool cannot be converted to Gemini's function\n * declaration format. Tools must be one of:\n * - LangChain structured tools (with Zod schemas)\n * - OpenAI format tools (with JSON Schema)\n * - Gemini-native function declarations\n * - Gemini-native tools (codeExecution, googleSearchRetrieval)\n *\n * @example\n * ```typescript\n * try {\n * convertToolsToGeminiFunctionDeclarations([invalidTool]);\n * } catch (error) {\n * if (InvalidToolError.isInstance(error)) {\n * console.log(`Invalid tool: ${error.tool}`);\n * console.log(`Expected formats: LangChain tools, OpenAI tools, or Gemini function declarations`);\n * }\n * }\n * ```\n */\nexport class InvalidToolError extends ns.brand(GoogleError, \"invalid-tool\") {\n readonly name = \"InvalidToolError\";\n\n /**\n * The invalid tool that was provided.\n */\n readonly tool: unknown;\n\n constructor(tool: unknown, message?: string) {\n const defaultMessage = `Received invalid tool: ${JSON.stringify(\n tool\n )}. Tools must be LangChain tools, OpenAI tools, or Gemini function declarations.`;\n\n super(message ?? defaultMessage);\n this.tool = tool;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Error thrown when a ToolMessage references a tool call that cannot be found.\n *\n * This error is thrown when a ToolMessage is passed to ChatGoogle but there is no\n * corresponding AIMessage with a matching toolCallId in the conversation history.\n * This typically indicates that:\n * - The tool call ID in the ToolMessage doesn't match any previous tool calls\n * - The AIMessage containing the tool call was not included in the message history\n * - The tool call ID was incorrectly set or modified\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke([\n * new ToolMessage({ content: \"result\", tool_call_id: \"nonexistent-id\" })\n * ]);\n * } catch (error) {\n * if (ToolCallNotFoundError.isInstance(error)) {\n * console.log(`Tool call not found: ${error.toolCallId}`);\n * }\n * }\n * ```\n */\nexport class ToolCallNotFoundError extends ns.brand(\n GoogleError,\n \"tool-call-not-found\"\n) {\n readonly name = \"ToolCallNotFoundError\";\n\n /**\n * The tool call ID that could not be found in the conversation history.\n */\n readonly toolCallId: string;\n\n constructor(toolCallId: string, message?: string) {\n const defaultMessage = `Tool call with ID \"${toolCallId}\" not found in conversation history. Ensure the corresponding AIMessage with this tool call ID is included in the input.`;\n\n super(message ?? defaultMessage);\n this.toolCallId = toolCallId;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a MalformedOutputError\n */\ntype MalformedOutputErrorParams = {\n /**\n * The error message describing what went wrong during parsing\n */\n message: string;\n /**\n * Optional cause of the parsing error (e.g., the original error that occurred)\n */\n cause?: unknown;\n};\n\n/**\n * Error thrown when output parsing fails in structured output methods.\n *\n * This error is thrown when the model's response cannot be parsed according to\n * the expected schema or format. Common causes include:\n * - Invalid message type (not an AIMessage or AIMessageChunk)\n * - Missing or empty content in the response\n * - Malformed JSON that cannot be parsed\n * - Schema validation failures\n *\n * @example\n * ```typescript\n * try {\n * const result = await model.withStructuredOutput(schema).invoke(\"extract data\");\n * } catch (error) {\n * if (MalformedOutputError.isInstance(error)) {\n * console.log(`Failed to parse output: ${error.message}`);\n * if (error.cause) {\n * console.log(`Cause:`, error.cause);\n * }\n * }\n * }\n * ```\n */\nexport class MalformedOutputError extends ns.brand(\n GoogleError,\n \"malformed-output\"\n) {\n readonly name = \"MalformedOutputError\";\n\n /**\n * Optional cause of the parsing error.\n * This may be the original error that occurred during parsing,\n * or additional context about what went wrong.\n */\n readonly cause?: unknown;\n\n constructor(params: MalformedOutputErrorParams) {\n super(params.message);\n this.cause = params.cause;\n }\n}\n\n/**\n * Error thrown when input provided to the Google provider is invalid.\n *\n * This error is thrown when the user provides input that cannot be\n * processed by Gemini, such as:\n * - Union types in tool/function schemas\n * - Null-only types in schemas\n * - Unsupported content block source types\n * - Missing required fields in content blocks\n *\n * @example\n * ```typescript\n * try {\n * const result = schemaToGeminiParameters(unionTypeSchema);\n * } catch (error) {\n * if (InvalidInputError.isInstance(error)) {\n * console.log(`Invalid input: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class InvalidInputError extends ns.brand(GoogleError, \"invalid-input\") {\n readonly name = \"InvalidInputError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n"],"mappings":";;;AASA,MAAMA,OAAKC,GAAO,IAAI,QAAQ;AAE9B,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,YAA8B;CACvD,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,uBAAuB,SAAS,UAAU;AACnD;AAEA,eAAe,sBAAsB,UAAsC;CACzE,OAAO,KAAK,YAAY;EACtB,IAAI;GAEF,KADoB,SAAS,QAAQ,IAAI,cAAc,KAAK,GAAA,CAC5C,SAAS,kBAAkB,GACzC,OAAO,MAAM,SAAS,KAAK;GAG7B,MAAM,OAAO,MAAM,SAAS,KAAK;GACjC,IAAI;IACF,OAAO,KAAK,MAAM,IAAI;GACxB,QAAQ;IACN,OAAO;GACT;EACF,QAAQ;GACN,OAAO;EACT;CACF,CAAC;AACH;;;;;;;;;;;;;;;;;;;AAoBA,IAAa,cAAb,cAAiCD,KAAG,MAAM,cAAc,CAAC,CAAC;CACxD,OAAwB;AAC1B;;;;;;;;;;;;;;;;;;AAmBA,IAAa,qBAAb,cAAwCA,KAAG,MAAM,aAAa,eAAe,CAAC,CAAC;CAC7E,OAAgB;CAEhB,YAAY,SAAkB;EAC5B,MAAM,OAAO;EACb,eAAe,MAAM,KAAK;CAC5B;AACF;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,qBAAb,MAAa,2BAA2BA,KAAG,MACzC,aACA,gBACF,CAAC,CAAC;CACA,OAAgB;;;;;;;;;;;CAYhB;;;;;;;;;;CAWA;CAEA,YAAY,QAAkC;EAC5C,MAAM,UACJ,OAAO,WACP,uBAAuB,OAAO,YAAY,GACxC,OAAO,iBAAiB,OAAO,cAAc,SAAS,IAClD,oBAAoB,KAAK,UAAU,OAAO,aAAa,MACvD;EAGR,MAAM,OAAO;EACb,KAAK,cAAc,OAAO;E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Aa;EAClB,eAAe,MAAM,KAAK;CAC5B;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,uBAAb,cAA0CA,KAAG,MAC3C,aACA,kBACF,CAAC,CAAC;CACA,OAAgB;;;;;;CAOhB;CAEA,YAAY,QAAoC;EAC9C,MAAM,OAAO,OAAO;EACpB,KAAK,QAAQ,OAAO;CACtB;AACF;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAa,oBAAb,cAAuCA,KAAG,MAAM,aAAa,eAAe,CAAC,CAAC;CAC5E,OAAgB;CAEhB,YAAY,SAAkB;EAC5B,MAAM,OAAO;EACb,eAAe,MAAM,KAAK;CAC5B;AACF"}
1
+ {"version":3,"file":"errors.js","names":["ns","baseNs"],"sources":["../../src/utils/errors.ts"],"sourcesContent":["import {\n ns as baseNs,\n LangChainError,\n ModelRefusalError,\n stampRetryable,\n} from \"@langchain/core/errors\";\nimport type { Gemini } from \"../chat_models/types.js\";\nimport { iife } from \"./misc.js\";\n\n// Internal namespace for all Google provider errors\nconst ns = baseNs.sub(\"google\");\n\nconst RETRYABLE_STATUS_CODES = [\n 408, // Request Timeout\n 429, // Too Many Requests\n 500, // Internal Server Error\n 502, // Bad Gateway\n 503, // Service Unavailable\n 504, // Gateway Timeout\n];\n\nfunction isRetryableStatus(statusCode?: number): boolean {\n if (!statusCode) return false;\n return RETRYABLE_STATUS_CODES.includes(statusCode);\n}\n\nasync function readErrorResponseBody(response: Response): Promise<unknown> {\n return iife(async () => {\n try {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (contentType.includes(\"application/json\")) {\n return await response.json();\n }\n\n const text = await response.text();\n try {\n return JSON.parse(text);\n } catch {\n return text;\n }\n } catch {\n return null;\n }\n });\n}\n\n/**\n * Base error class for all Google provider errors.\n *\n * All Google-specific error classes extend this class. Use\n * `GoogleError.isInstance(obj)` to check if an object is any\n * Google provider error.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"hello\");\n * } catch (error) {\n * if (GoogleError.isInstance(error)) {\n * console.log(\"Got a Google error:\", error.message);\n * }\n * }\n * ```\n */\nexport class GoogleError extends ns.brand(LangChainError) {\n readonly name: string = \"GoogleError\";\n}\n\n/**\n * Error thrown when there is a configuration issue with the Google provider.\n *\n * This error is thrown when the Google provider encounters invalid configuration\n * parameters or settings that prevent it from functioning correctly.\n *\n * @example\n * ```typescript\n * try {\n * const model = new ChatGoogle({ invalidOption: true });\n * } catch (error) {\n * if (ConfigurationError.isInstance(error)) {\n * console.log(`Configuration error: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class ConfigurationError extends ns.brand(GoogleError, \"configuration\") {\n readonly name = \"ConfigurationError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a PromptBlockedError\n */\ntype PromptBlockedErrorParams = {\n /**\n * The reason why the prompt was blocked (e.g., \"SAFETY\", \"OTHER\", \"UNKNOWN\")\n */\n blockReason: string;\n /**\n * Optional array of safety ratings that contributed to the block decision\n */\n safetyRatings?: Gemini.SafetyRating[];\n /**\n * Optional custom error message. If not provided, a default message will be generated\n */\n message?: string;\n};\n\n/**\n * Error thrown when a prompt is blocked by Google's safety filters.\n *\n * This error is thrown when the Gemini API blocks a prompt due to safety concerns.\n * It contains information about why the prompt was blocked and the safety ratings\n * that triggered the block.\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some potentially unsafe prompt\");\n * } catch (error) {\n * if (PromptBlockedError.isInstance(error)) {\n * console.log(`Blocked due to: ${error.blockReason}`);\n * console.log(`Safety ratings:`, error.safetyRatings);\n * }\n * }\n * ```\n */\nexport class PromptBlockedError extends ns.brand(\n GoogleError,\n \"prompt-blocked\"\n) {\n readonly name = \"PromptBlockedError\";\n\n /**\n * The reason why the prompt was blocked.\n *\n * Common values include:\n * - \"SAFETY\" - Blocked due to safety concerns\n * - \"OTHER\" - Blocked for other reasons\n * - \"UNKNOWN\" - Reason is unknown\n *\n * @readonly\n */\n readonly blockReason: string;\n\n /**\n * Optional array of safety ratings that contributed to the block decision.\n *\n * Each rating contains information about different safety categories\n * (e.g., hate speech, sexually explicit content, dangerous content)\n * and their probability levels.\n *\n * @readonly\n */\n readonly safetyRatings?: Gemini.SafetyRating[];\n\n constructor(params: PromptBlockedErrorParams) {\n const message =\n params.message ??\n `Prompt was blocked: ${params.blockReason}.${\n params.safetyRatings && params.safetyRatings.length > 0\n ? ` Safety ratings: ${JSON.stringify(params.safetyRatings)}`\n : \"\"\n }`;\n\n super(message);\n this.blockReason = params.blockReason;\n this.safetyRatings = params.safetyRatings;\n stampRetryable(this, false);\n }\n\n /**\n * Creates a PromptBlockedError from a Gemini API prompt feedback object.\n *\n * This is a convenience factory method for creating errors from the API response\n * when a prompt is blocked. It extracts the relevant information from the\n * promptFeedback object returned by the Gemini API.\n *\n * @param promptFeedback - The prompt feedback object from the Gemini API response\n * @returns A new PromptBlockedError instance with information from the feedback\n *\n * @example\n * ```typescript\n * const response = await geminiApi.generateContent(request);\n * if (response.promptFeedback?.blockReason) {\n * throw PromptBlockedError.fromPromptFeedback(response.promptFeedback);\n * }\n * ```\n */\n static fromPromptFeedback(\n promptFeedback: Gemini.PromptFeedback\n ): PromptBlockedError {\n return new this({\n blockReason: promptFeedback.blockReason ?? \"UNKNOWN\",\n safetyRatings: promptFeedback.safetyRatings,\n });\n }\n}\n\n/**\n * A {@link PromptBlockedError} for a prompt Gemini refused, such as one blocked\n * for safety.\n *\n * It also matches `ModelRefusalError.isInstance` from `@langchain/core/errors`,\n * so callers can handle it like a refusal from any other provider.\n */\nexport class PromptRefusedError extends baseNs.brand(\n PromptBlockedError,\n \"model-refusal\"\n) {\n // The inherited check only looks for the refusal brand, which every\n // `ModelRefusalError` carries.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static isInstance<T extends abstract new (...args: any[]) => any>(\n this: T,\n obj: unknown\n ): obj is InstanceType<T> {\n return (\n PromptBlockedError.isInstance(obj) && ModelRefusalError.isInstance(obj)\n );\n }\n}\n\n// The Gemini API and Vertex AI spell the unspecified reason differently.\nconst UNSPECIFIED_BLOCK_REASONS = new Set<string>([\n \"BLOCK_REASON_UNSPECIFIED\",\n \"BLOCKED_REASON_UNSPECIFIED\",\n]);\n\n/** Builds the error for a blocked prompt, a refusal unless the reason is unspecified. */\nexport function promptBlockedError(\n promptFeedback: Gemini.GenContent.GenerateContentResponse[\"promptFeedback\"] &\n object\n): PromptBlockedError {\n const ErrorClass = UNSPECIFIED_BLOCK_REASONS.has(\n promptFeedback.blockReason ?? \"\"\n )\n ? PromptBlockedError\n : PromptRefusedError;\n return ErrorClass.fromPromptFeedback(promptFeedback);\n}\n\n/**\n * Parameters for constructing an AuthError\n */\ntype AuthErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for authentication failures when communicating with Google APIs.\n *\n * This error is thrown when authentication with a Google API fails, typically\n * during the OAuth token exchange process or when using service account credentials.\n * It captures detailed information about the failed authentication attempt including\n * the status code, headers, and response body to aid in debugging and error handling.\n *\n * Common authentication failure scenarios include:\n * - Invalid or expired credentials\n * - Incorrect service account configuration\n * - Missing or invalid API keys\n * - Insufficient permissions or scopes\n * - Token exchange failures\n *\n * @example\n * ```typescript\n * try {\n * const token = await getAccessToken(credentials);\n * } catch (error) {\n * if (AuthError.isInstance(error)) {\n * console.error(`Auth failed with status ${error.statusCode}: ${error.message}`);\n * console.error('Response data:', error.data);\n * }\n * }\n * ```\n */\nexport class AuthError extends ns.brand(GoogleError, \"auth\") {\n readonly name = \"AuthError\" as const;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: AuthErrorParams) {\n super(params.message);\n\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, isRetryableStatus(this.statusCode));\n }\n\n /**\n * Creates an AuthError from a failed HTTP response.\n *\n * This is a convenience factory method for creating authentication errors from\n * HTTP responses. It automatically extracts the error message, status code,\n * headers, and response body from the Response object.\n *\n * The method attempts to parse the response body as JSON to extract an\n * `error_description` field if available. If JSON parsing fails or the\n * content type is not JSON, it falls back to reading the response as text.\n * If both fail, the error body will be null.\n *\n * @param response - The failed HTTP Response object from the authentication request\n * @returns A Promise that resolves to a new AuthError instance with information from the response\n *\n * @example\n * ```typescript\n * const response = await fetch(tokenUrl, {\n * method: 'POST',\n * body: authRequestBody\n * });\n *\n * if (!response.ok) {\n * throw await AuthError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<AuthError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error_description ??\n `Authentication failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new AuthError({\n message,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Parameters for constructing a RequestError\n */\ntype RequestErrorParams = {\n /**\n * The error message describing what went wrong\n */\n message: string;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n data?: unknown;\n};\n\n/**\n * Error class for HTTP request failures when communicating with Google APIs.\n *\n * This error is thrown when an HTTP request to a Google API endpoint fails.\n * It captures detailed information about the failed request including the URL,\n * status code, headers, and response body to aid in debugging and error handling.\n *\n * The error includes a `isRetryable()` method to determine if the request should\n * be retried based on the HTTP status code (e.g., 429 Too Many Requests, 503 Service Unavailable).\n *\n * @example\n * ```typescript\n * try {\n * const response = await apiClient.fetch(request);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * } catch (error) {\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * // Retry the request\n * }\n * }\n * ```\n */\nexport class RequestError extends ns.brand(GoogleError, \"request\") {\n readonly name = \"RequestError\" as const;\n\n /**\n * The URL of the failed request.\n * This is the full URL that was being accessed when the error occurred.\n */\n readonly url: string;\n\n /**\n * The HTTP status code of the failed response.\n * Common values include 400 (Bad Request), 401 (Unauthorized),\n * 403 (Forbidden), 404 (Not Found), 429 (Too Many Requests),\n * 500 (Internal Server Error), etc.\n */\n readonly statusCode?: number;\n\n /**\n * The HTTP status text of the failed response.\n * This is the human-readable status message that accompanies the status code\n * (e.g., \"Bad Request\", \"Internal Server Error\").\n */\n readonly statusText?: string;\n\n /**\n * The HTTP response headers from the failed request.\n * Stored as a key-value record for easy access to header information.\n */\n readonly headers?: Record<string, string>;\n\n /**\n * The response body data from the failed request.\n * This may be a parsed JSON object, a text string, or null if the body\n * could not be read. Often contains additional error details from the API.\n */\n readonly data?: unknown;\n\n constructor(params: RequestErrorParams) {\n super(params.message);\n\n this.url = params.url;\n this.statusCode = params.statusCode;\n this.statusText = params.statusText;\n this.headers = params.headers;\n this.data = params.data;\n stampRetryable(this, this.isRetryable());\n }\n\n /**\n * Determines if this error represents a retryable request failure.\n *\n * A request is considered retryable if it failed with a status code that\n * indicates a temporary issue that might succeed on retry. This includes:\n * - 408 (Request Timeout)\n * - 429 (Too Many Requests / Rate Limiting)\n * - 500 (Internal Server Error)\n * - 502 (Bad Gateway)\n * - 503 (Service Unavailable)\n * - 504 (Gateway Timeout)\n *\n * @returns `true` if the request should be retried, `false` otherwise\n *\n * @example\n * ```typescript\n * if (RequestError.isInstance(error) && error.isRetryable()) {\n * await sleep(1000);\n * return retry(request);\n * }\n * ```\n */\n isRetryable(): boolean {\n return isRetryableStatus(this.statusCode);\n }\n\n /**\n * Creates a RequestError from a failed HTTP Response object.\n *\n * This is a factory method that extracts all relevant information from a\n * Response object and constructs a RequestError with appropriate details.\n * It attempts to parse the response body as JSON first, falling back to\n * text if that fails, and finally to null if the body cannot be read.\n *\n * The error message is extracted from the response body if available\n * (looking for `message` or `error` fields), otherwise a generic message\n * is constructed using the status code.\n *\n * @param response - The failed HTTP Response object to convert into an error\n * @returns A Promise that resolves to a new RequestError instance\n *\n * @example\n * ```typescript\n * const response = await fetch(url);\n * if (!response.ok) {\n * throw await RequestError.fromResponse(response);\n * }\n * ```\n */\n static async fromResponse(response: Response): Promise<RequestError> {\n const errorBody = await readErrorResponseBody(response);\n\n const message =\n errorBody?.error?.message ??\n errorBody?.message ??\n errorBody?.error ??\n `Request failed with status code ${response.status}`;\n\n const headers = iife(() => {\n const object: Record<string, string> = {};\n response.headers.forEach((value, name) => {\n object[name] = value;\n });\n return object;\n });\n\n return new RequestError({\n message,\n url: response.url,\n statusCode: response.status,\n statusText: response.statusText,\n headers,\n data: errorBody,\n });\n }\n}\n\n/**\n * Error thrown when the Gemini API returns no candidates in the response.\n *\n * This error is thrown when the API successfully processes a request but returns\n * an empty candidates array. This can occur when:\n * - The prompt was blocked by safety filters (but no explicit block reason was provided)\n * - An internal error occurred during generation\n * - The model was unable to generate a valid response\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke(\"some prompt\");\n * } catch (error) {\n * if (NoCandidatesError.isInstance(error)) {\n * console.log(\"No response candidates were generated\");\n * }\n * }\n * ```\n */\nexport class NoCandidatesError extends ns.brand(GoogleError, \"no-candidates\") {\n readonly name = \"NoCandidatesError\";\n\n constructor() {\n super(\n \"No candidates returned from API. This may indicate the prompt was blocked or an error occurred.\"\n );\n }\n}\n\n/**\n * Error thrown when an invalid tool is provided to the tool converter.\n *\n * This error is thrown when a tool cannot be converted to Gemini's function\n * declaration format. Tools must be one of:\n * - LangChain structured tools (with Zod schemas)\n * - OpenAI format tools (with JSON Schema)\n * - Gemini-native function declarations\n * - Gemini-native tools (codeExecution, googleSearchRetrieval)\n *\n * @example\n * ```typescript\n * try {\n * convertToolsToGeminiFunctionDeclarations([invalidTool]);\n * } catch (error) {\n * if (InvalidToolError.isInstance(error)) {\n * console.log(`Invalid tool: ${error.tool}`);\n * console.log(`Expected formats: LangChain tools, OpenAI tools, or Gemini function declarations`);\n * }\n * }\n * ```\n */\nexport class InvalidToolError extends ns.brand(GoogleError, \"invalid-tool\") {\n readonly name = \"InvalidToolError\";\n\n /**\n * The invalid tool that was provided.\n */\n readonly tool: unknown;\n\n constructor(tool: unknown, message?: string) {\n const defaultMessage = `Received invalid tool: ${JSON.stringify(\n tool\n )}. Tools must be LangChain tools, OpenAI tools, or Gemini function declarations.`;\n\n super(message ?? defaultMessage);\n this.tool = tool;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Error thrown when a ToolMessage references a tool call that cannot be found.\n *\n * This error is thrown when a ToolMessage is passed to ChatGoogle but there is no\n * corresponding AIMessage with a matching toolCallId in the conversation history.\n * This typically indicates that:\n * - The tool call ID in the ToolMessage doesn't match any previous tool calls\n * - The AIMessage containing the tool call was not included in the message history\n * - The tool call ID was incorrectly set or modified\n *\n * @example\n * ```typescript\n * try {\n * await model.invoke([\n * new ToolMessage({ content: \"result\", tool_call_id: \"nonexistent-id\" })\n * ]);\n * } catch (error) {\n * if (ToolCallNotFoundError.isInstance(error)) {\n * console.log(`Tool call not found: ${error.toolCallId}`);\n * }\n * }\n * ```\n */\nexport class ToolCallNotFoundError extends ns.brand(\n GoogleError,\n \"tool-call-not-found\"\n) {\n readonly name = \"ToolCallNotFoundError\";\n\n /**\n * The tool call ID that could not be found in the conversation history.\n */\n readonly toolCallId: string;\n\n constructor(toolCallId: string, message?: string) {\n const defaultMessage = `Tool call with ID \"${toolCallId}\" not found in conversation history. Ensure the corresponding AIMessage with this tool call ID is included in the input.`;\n\n super(message ?? defaultMessage);\n this.toolCallId = toolCallId;\n stampRetryable(this, false);\n }\n}\n\n/**\n * Parameters for constructing a MalformedOutputError\n */\ntype MalformedOutputErrorParams = {\n /**\n * The error message describing what went wrong during parsing\n */\n message: string;\n /**\n * Optional cause of the parsing error (e.g., the original error that occurred)\n */\n cause?: unknown;\n};\n\n/**\n * Error thrown when output parsing fails in structured output methods.\n *\n * This error is thrown when the model's response cannot be parsed according to\n * the expected schema or format. Common causes include:\n * - Invalid message type (not an AIMessage or AIMessageChunk)\n * - Missing or empty content in the response\n * - Malformed JSON that cannot be parsed\n * - Schema validation failures\n *\n * @example\n * ```typescript\n * try {\n * const result = await model.withStructuredOutput(schema).invoke(\"extract data\");\n * } catch (error) {\n * if (MalformedOutputError.isInstance(error)) {\n * console.log(`Failed to parse output: ${error.message}`);\n * if (error.cause) {\n * console.log(`Cause:`, error.cause);\n * }\n * }\n * }\n * ```\n */\nexport class MalformedOutputError extends ns.brand(\n GoogleError,\n \"malformed-output\"\n) {\n readonly name = \"MalformedOutputError\";\n\n /**\n * Optional cause of the parsing error.\n * This may be the original error that occurred during parsing,\n * or additional context about what went wrong.\n */\n readonly cause?: unknown;\n\n constructor(params: MalformedOutputErrorParams) {\n super(params.message);\n this.cause = params.cause;\n }\n}\n\n/**\n * Error thrown when input provided to the Google provider is invalid.\n *\n * This error is thrown when the user provides input that cannot be\n * processed by Gemini, such as:\n * - Union types in tool/function schemas\n * - Null-only types in schemas\n * - Unsupported content block source types\n * - Missing required fields in content blocks\n *\n * @example\n * ```typescript\n * try {\n * const result = schemaToGeminiParameters(unionTypeSchema);\n * } catch (error) {\n * if (InvalidInputError.isInstance(error)) {\n * console.log(`Invalid input: ${error.message}`);\n * }\n * }\n * ```\n */\nexport class InvalidInputError extends ns.brand(GoogleError, \"invalid-input\") {\n readonly name = \"InvalidInputError\";\n\n constructor(message?: string) {\n super(message);\n stampRetryable(this, false);\n }\n}\n"],"mappings":";;;AAUA,MAAMA,OAAKC,GAAO,IAAI,QAAQ;AAE9B,MAAM,yBAAyB;CAC7B;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,kBAAkB,YAA8B;CACvD,IAAI,CAAC,YAAY,OAAO;CACxB,OAAO,uBAAuB,SAAS,UAAU;AACnD;AAEA,eAAe,sBAAsB,UAAsC;CACzE,OAAO,KAAK,YAAY;EACtB,IAAI;GAEF,KADoB,SAAS,QAAQ,IAAI,cAAc,KAAK,GAAA,CAC5C,SAAS,kBAAkB,GACzC,OAAO,MAAM,SAAS,KAAK;GAG7B,MAAM,OAAO,MAAM,SAAS,KAAK;GACjC,IAAI;IACF,OAAO,KAAK,MAAM,IAAI;GACxB,QAAQ;IACN,OAAO;GACT;EACF,QAAQ;GACN,OAAO;EACT;CACF,CA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,cAAuCA,KAAG,MAAM,aAAa,eAAe,CAAC,CAAC;CAC5E,OAAgB;CAEhB,YAAY,SAAkB;EAC5B,MAAM,OAAO;EACb,eAAe,MAAM,KAAK;CAC5B;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/google",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Google integrations for LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "jose": "^6.2.14"
20
20
  },
21
21
  "peerDependencies": {
22
- "@langchain/core": "^1.3.5"
22
+ "@langchain/core": "^1.3.7"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@tsconfig/recommended": "^1.0.10",
@@ -30,7 +30,7 @@
30
30
  "vitest": "^5.0.5",
31
31
  "zod": "^3.25.76 || ^4",
32
32
  "zod-to-json-schema": "^3.25.2",
33
- "@langchain/core": "^1.3.5",
33
+ "@langchain/core": "^1.3.7",
34
34
  "@langchain/standard-tests": "0.0.23"
35
35
  },
36
36
  "publishConfig": {