@langchain/core 1.1.2 → 1.1.3

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.
Files changed (227) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/agents.d.cts +0 -2
  3. package/dist/agents.d.ts +0 -2
  4. package/dist/callbacks/base.d.cts +22 -60
  5. package/dist/callbacks/base.d.ts +22 -60
  6. package/dist/callbacks/dispatch/index.d.cts +1 -3
  7. package/dist/callbacks/dispatch/index.d.ts +1 -3
  8. package/dist/callbacks/dispatch/web.d.cts +1 -3
  9. package/dist/callbacks/dispatch/web.d.ts +1 -3
  10. package/dist/callbacks/manager.d.cts +2 -12
  11. package/dist/callbacks/manager.d.ts +2 -12
  12. package/dist/chat_history.cjs +1 -1
  13. package/dist/chat_history.d.cts +0 -1
  14. package/dist/chat_history.d.ts +0 -1
  15. package/dist/chat_history.js +1 -1
  16. package/dist/document_loaders/langsmith.d.cts +0 -3
  17. package/dist/document_loaders/langsmith.d.ts +0 -3
  18. package/dist/documents/document.d.cts +3 -12
  19. package/dist/documents/document.d.ts +3 -12
  20. package/dist/example_selectors/length_based.d.cts +1 -1
  21. package/dist/example_selectors/length_based.d.ts +1 -1
  22. package/dist/indexing/base.d.cts +0 -1
  23. package/dist/indexing/base.d.ts +0 -1
  24. package/dist/indexing/record_manager.d.cts +0 -1
  25. package/dist/indexing/record_manager.d.ts +0 -1
  26. package/dist/language_models/base.d.cts +8 -38
  27. package/dist/language_models/base.d.ts +8 -38
  28. package/dist/language_models/chat_models.cjs +1 -1
  29. package/dist/language_models/chat_models.d.cts +6 -33
  30. package/dist/language_models/chat_models.d.ts +6 -33
  31. package/dist/language_models/chat_models.js +1 -1
  32. package/dist/language_models/llms.d.cts +0 -6
  33. package/dist/language_models/llms.d.ts +0 -6
  34. package/dist/load/import_type.d.cts +0 -1
  35. package/dist/load/import_type.d.ts +0 -1
  36. package/dist/load/map_keys.cjs +4 -5
  37. package/dist/load/map_keys.cjs.map +1 -1
  38. package/dist/load/map_keys.d.cts +0 -1
  39. package/dist/load/map_keys.d.ts +0 -1
  40. package/dist/load/map_keys.js +3 -3
  41. package/dist/load/map_keys.js.map +1 -1
  42. package/dist/load/serializable.d.cts +0 -1
  43. package/dist/load/serializable.d.ts +0 -1
  44. package/dist/memory.d.cts +0 -3
  45. package/dist/memory.d.ts +0 -3
  46. package/dist/messages/ai.cjs +6 -48
  47. package/dist/messages/ai.cjs.map +1 -1
  48. package/dist/messages/ai.js +6 -48
  49. package/dist/messages/ai.js.map +1 -1
  50. package/dist/messages/base.cjs +3 -2
  51. package/dist/messages/base.cjs.map +1 -1
  52. package/dist/messages/base.d.cts +1 -13
  53. package/dist/messages/base.d.ts +1 -13
  54. package/dist/messages/base.js +3 -2
  55. package/dist/messages/base.js.map +1 -1
  56. package/dist/messages/content/data.d.cts +2 -7
  57. package/dist/messages/content/data.d.ts +2 -7
  58. package/dist/messages/content/index.d.cts +1 -4
  59. package/dist/messages/content/index.d.ts +1 -4
  60. package/dist/messages/content/multimodal.d.cts +0 -1
  61. package/dist/messages/content/multimodal.d.ts +0 -1
  62. package/dist/messages/content/tools.d.cts +0 -1
  63. package/dist/messages/content/tools.d.ts +0 -1
  64. package/dist/messages/index.cjs +4 -2
  65. package/dist/messages/index.d.cts +2 -2
  66. package/dist/messages/index.d.ts +2 -2
  67. package/dist/messages/index.js +5 -4
  68. package/dist/messages/tool.d.cts +2 -9
  69. package/dist/messages/tool.d.ts +2 -9
  70. package/dist/messages/transformers.cjs +2 -2
  71. package/dist/messages/transformers.d.cts +0 -3
  72. package/dist/messages/transformers.d.ts +0 -3
  73. package/dist/messages/transformers.js +2 -2
  74. package/dist/messages/utils.cjs +77 -4
  75. package/dist/messages/utils.cjs.map +1 -1
  76. package/dist/messages/utils.d.cts +35 -7
  77. package/dist/messages/utils.d.ts +35 -7
  78. package/dist/messages/utils.js +77 -5
  79. package/dist/messages/utils.js.map +1 -1
  80. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs +169 -0
  81. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.cjs.map +1 -0
  82. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js +168 -0
  83. package/dist/node_modules/.pnpm/ansi-styles@6.2.3/node_modules/ansi-styles/index.js.map +1 -0
  84. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs +122 -0
  85. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.cjs.map +1 -0
  86. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js +121 -0
  87. package/dist/node_modules/.pnpm/camelcase@9.0.0/node_modules/camelcase/index.js.map +1 -0
  88. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs +18 -0
  89. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.cjs.map +1 -0
  90. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js +17 -0
  91. package/dist/node_modules/.pnpm/decamelize@6.0.1/node_modules/decamelize/index.js.map +1 -0
  92. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs +27 -0
  93. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.cjs.map +1 -0
  94. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js +26 -0
  95. package/dist/node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js.map +1 -0
  96. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs +141 -0
  97. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.cjs.map +1 -0
  98. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js +141 -0
  99. package/dist/node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js.map +1 -0
  100. package/dist/output_parsers/json.d.cts +1 -5
  101. package/dist/output_parsers/json.d.ts +1 -5
  102. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +2 -6
  103. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +2 -6
  104. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -34
  105. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -34
  106. package/dist/output_parsers/transform.d.cts +0 -1
  107. package/dist/output_parsers/transform.d.ts +0 -1
  108. package/dist/outputs.d.cts +0 -6
  109. package/dist/outputs.d.ts +0 -6
  110. package/dist/prompts/base.d.cts +2 -10
  111. package/dist/prompts/base.d.ts +2 -10
  112. package/dist/prompts/chat.cjs +2 -2
  113. package/dist/prompts/chat.d.cts +13 -51
  114. package/dist/prompts/chat.d.ts +13 -51
  115. package/dist/prompts/chat.js +2 -2
  116. package/dist/prompts/few_shot.d.cts +1 -5
  117. package/dist/prompts/few_shot.d.ts +1 -5
  118. package/dist/prompts/image.d.cts +2 -10
  119. package/dist/prompts/image.d.ts +2 -10
  120. package/dist/prompts/prompt.d.cts +4 -15
  121. package/dist/prompts/prompt.d.ts +4 -16
  122. package/dist/prompts/serde.d.cts +0 -1
  123. package/dist/prompts/serde.d.ts +0 -1
  124. package/dist/prompts/string.d.cts +1 -5
  125. package/dist/prompts/string.d.ts +1 -5
  126. package/dist/prompts/structured.d.cts +3 -16
  127. package/dist/prompts/structured.d.ts +3 -16
  128. package/dist/retrievers/document_compressors/index.d.cts +0 -1
  129. package/dist/retrievers/document_compressors/index.d.ts +0 -1
  130. package/dist/retrievers/index.d.cts +2 -6
  131. package/dist/retrievers/index.d.ts +2 -6
  132. package/dist/runnables/base.cjs +7 -7
  133. package/dist/runnables/base.cjs.map +1 -1
  134. package/dist/runnables/base.d.cts +12 -64
  135. package/dist/runnables/base.d.ts +12 -64
  136. package/dist/runnables/base.js +1 -1
  137. package/dist/runnables/branch.d.cts +0 -2
  138. package/dist/runnables/branch.d.ts +0 -2
  139. package/dist/runnables/config.d.cts +0 -1
  140. package/dist/runnables/config.d.ts +0 -1
  141. package/dist/runnables/graph.d.cts +1 -5
  142. package/dist/runnables/graph.d.ts +1 -5
  143. package/dist/runnables/graph_mermaid.cjs +2 -1
  144. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  145. package/dist/runnables/graph_mermaid.js +3 -1
  146. package/dist/runnables/graph_mermaid.js.map +1 -1
  147. package/dist/runnables/history.cjs +1 -1
  148. package/dist/runnables/history.d.cts +4 -12
  149. package/dist/runnables/history.d.ts +4 -12
  150. package/dist/runnables/history.js +1 -1
  151. package/dist/runnables/passthrough.d.cts +0 -2
  152. package/dist/runnables/passthrough.d.ts +0 -2
  153. package/dist/runnables/router.d.cts +0 -1
  154. package/dist/runnables/router.d.ts +0 -1
  155. package/dist/runnables/types.d.cts +2 -9
  156. package/dist/runnables/types.d.ts +2 -9
  157. package/dist/runnables/utils.cjs +5 -0
  158. package/dist/runnables/utils.cjs.map +1 -1
  159. package/dist/runnables/utils.js +5 -1
  160. package/dist/runnables/utils.js.map +1 -1
  161. package/dist/singletons/async_local_storage/context.d.cts +0 -2
  162. package/dist/singletons/async_local_storage/context.d.ts +0 -2
  163. package/dist/singletons/async_local_storage/globals.d.cts +0 -1
  164. package/dist/singletons/async_local_storage/globals.d.ts +0 -1
  165. package/dist/singletons/callbacks.cjs.map +1 -1
  166. package/dist/singletons/callbacks.js.map +1 -1
  167. package/dist/stores.d.cts +0 -1
  168. package/dist/stores.d.ts +0 -1
  169. package/dist/structured_query/utils.d.cts +1 -4
  170. package/dist/structured_query/utils.d.ts +1 -4
  171. package/dist/tools/index.d.cts +1 -6
  172. package/dist/tools/index.d.ts +1 -6
  173. package/dist/tools/types.d.cts +3 -13
  174. package/dist/tools/types.d.ts +3 -13
  175. package/dist/tracers/base.d.cts +1 -20
  176. package/dist/tracers/base.d.ts +1 -20
  177. package/dist/tracers/console.cjs +3 -3
  178. package/dist/tracers/console.cjs.map +1 -1
  179. package/dist/tracers/console.d.cts +0 -2
  180. package/dist/tracers/console.d.ts +0 -2
  181. package/dist/tracers/console.js +3 -3
  182. package/dist/tracers/console.js.map +1 -1
  183. package/dist/tracers/event_stream.d.cts +0 -4
  184. package/dist/tracers/event_stream.d.ts +0 -4
  185. package/dist/tracers/log_stream.d.cts +0 -6
  186. package/dist/tracers/log_stream.d.ts +0 -6
  187. package/dist/types/_internal.d.cts +0 -3
  188. package/dist/types/_internal.d.ts +0 -3
  189. package/dist/types/type-utils.d.cts +0 -2
  190. package/dist/types/type-utils.d.ts +0 -2
  191. package/dist/utils/async_caller.cjs +2 -7
  192. package/dist/utils/async_caller.cjs.map +1 -1
  193. package/dist/utils/async_caller.d.cts +0 -3
  194. package/dist/utils/async_caller.d.ts +0 -3
  195. package/dist/utils/async_caller.js +1 -6
  196. package/dist/utils/async_caller.js.map +1 -1
  197. package/dist/utils/env.d.cts +0 -4
  198. package/dist/utils/env.d.ts +0 -4
  199. package/dist/utils/event_source_parse.d.cts +1 -4
  200. package/dist/utils/event_source_parse.d.ts +1 -4
  201. package/dist/utils/function_calling.d.cts +1 -3
  202. package/dist/utils/function_calling.d.ts +1 -3
  203. package/dist/utils/json.d.cts +0 -1
  204. package/dist/utils/json.d.ts +0 -1
  205. package/dist/utils/stream.d.cts +1 -13
  206. package/dist/utils/stream.d.ts +1 -13
  207. package/dist/utils/testing/chat_models.d.cts +3 -11
  208. package/dist/utils/testing/chat_models.d.ts +3 -11
  209. package/dist/utils/testing/message_history.cjs +1 -1
  210. package/dist/utils/testing/message_history.js +1 -1
  211. package/dist/utils/testing/retrievers.d.cts +1 -3
  212. package/dist/utils/testing/retrievers.d.ts +1 -3
  213. package/dist/utils/testing/vectorstores.d.cts +0 -1
  214. package/dist/utils/testing/vectorstores.d.ts +0 -1
  215. package/dist/utils/types/index.cjs +4 -0
  216. package/dist/utils/types/index.d.cts +2 -4
  217. package/dist/utils/types/index.d.ts +2 -4
  218. package/dist/utils/types/index.js +4 -2
  219. package/dist/utils/types/zod.cjs +24 -0
  220. package/dist/utils/types/zod.cjs.map +1 -1
  221. package/dist/utils/types/zod.d.cts +4 -4
  222. package/dist/utils/types/zod.d.ts +4 -4
  223. package/dist/utils/types/zod.js +23 -1
  224. package/dist/utils/types/zod.js.map +1 -1
  225. package/dist/vectorstores.d.cts +5 -17
  226. package/dist/vectorstores.d.ts +5 -17
  227. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"async_caller.cjs","names":["pRetryModule: typeof import(\"p-retry\") | null","error: any","params: AsyncCallerParams","PQueueMod","callable: T","options: AsyncCallerCallOptions","listener: (() => void) | undefined","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\n\n// p-retry is ESM-only, so we use dynamic import for CJS compatibility.\n// The module is cached after first import, so subsequent calls are essentially free.\n// This approach is recommended by the p-retry author for async contexts:\n// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\nlet pRetryModule: typeof import(\"p-retry\") | null = null;\n\nasync function getPRetry() {\n if (!pRetryModule) {\n pRetryModule = await import(\"p-retry\");\n }\n return pRetryModule.default;\n}\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst defaultFailedAttemptHandler = (error: any) => {\n if (\n error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\") ||\n error.name === \"AbortError\"\n ) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.code === \"ECONNABORTED\") {\n throw error;\n }\n const status =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (error as any)?.response?.status ?? (error as any)?.status;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.error?.code === \"insufficient_quota\") {\n const err = new Error(error?.message);\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n const pRetry = await getPRetry();\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener);\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;;AAQA,IAAIA,eAAgD;AAEpD,eAAe,YAAY;AACzB,KAAI,CAAC,cACH,eAAe,MAAM,OAAO;AAE9B,QAAO,aAAa;AACrB;AAED,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAGD,MAAM,8BAA8B,CAACC,UAAe;AAClD,KACE,MAAM,QAAQ,WAAW,SAAS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AC;IAC5C;IACD,QAAQ,QAAQ,iBAAiB,SAAS,SAAS;GACpD,EACF,EAAC,CAAC,QAAQ,MAAM;AACf,QAAI,QAAQ,UAAU,UACpB,QAAQ,OAAO,oBAAoB,SAAS,SAAS;GAExD,EAAC;EACH;AACD,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;CAC1C;CAED,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,KAAK,MACf,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE;CACF;AACF"}
1
+ {"version":3,"file":"async_caller.cjs","names":["error: any","params: AsyncCallerParams","PQueueMod","callable: T","pRetry","options: AsyncCallerCallOptions","listener: (() => void) | undefined","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\nimport pRetry from \"p-retry\";\n\nimport { getAbortSignalError } from \"./signal.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst defaultFailedAttemptHandler = (error: any) => {\n if (\n error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\") ||\n error.name === \"AbortError\"\n ) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.code === \"ECONNABORTED\") {\n throw error;\n }\n const status =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (error as any)?.response?.status ?? (error as any)?.status;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.error?.code === \"insufficient_quota\") {\n const err = new Error(error?.message);\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener);\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAGD,MAAM,8BAA8B,CAACA,UAAe;AAClD,KACE,MAAM,QAAQ,WAAW,SAAS,IAClC,MAAM,QAAQ,WAAW,aAAa,IACtC,MAAM,SAAS,aAEf,OAAM;AAGR,KAAK,OAAe,SAAS,eAC3B,OAAM;CAER,MAAM,SAEH,OAAe,UAAU,UAAW,OAAe;AACtD,KAAI,UAAU,gBAAgB,SAAS,CAAC,OAAO,CAC7C,OAAM;AAGR,KAAK,OAAe,OAAO,SAAS,sBAAsB;EACxD,MAAM,MAAM,IAAI,MAAM,OAAO;EAC7B,IAA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AAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE;CACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  //#region src/utils/async_caller.d.ts
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
2
  type FailedAttemptHandler = (error: any) => any;
4
3
  interface AsyncCallerParams {
5
4
  /**
@@ -41,9 +40,7 @@ declare class AsyncCaller {
41
40
  protected onFailedAttempt: AsyncCallerParams["onFailedAttempt"];
42
41
  private queue;
43
42
  constructor(params: AsyncCallerParams);
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
43
  call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
44
  callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
48
45
  fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch>;
49
46
  }
@@ -1,5 +1,4 @@
1
1
  //#region src/utils/async_caller.d.ts
2
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
2
  type FailedAttemptHandler = (error: any) => any;
4
3
  interface AsyncCallerParams {
5
4
  /**
@@ -41,9 +40,7 @@ declare class AsyncCaller {
41
40
  protected onFailedAttempt: AsyncCallerParams["onFailedAttempt"];
42
41
  private queue;
43
42
  constructor(params: AsyncCallerParams);
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
43
  call<A extends any[], T extends (...args: A) => Promise<any>>(callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
44
  callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T>): Promise<Awaited<ReturnType<T>>>;
48
45
  fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch>;
49
46
  }
@@ -1,15 +1,11 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.js";
2
+ import { pRetry } from "../node_modules/.pnpm/p-retry@7.1.0/node_modules/p-retry/index.js";
2
3
  import { getAbortSignalError } from "./signal.js";
3
4
  import PQueueMod from "p-queue";
4
5
 
5
6
  //#region src/utils/async_caller.ts
6
7
  var async_caller_exports = {};
7
8
  __export(async_caller_exports, { AsyncCaller: () => AsyncCaller });
8
- let pRetryModule = null;
9
- async function getPRetry() {
10
- if (!pRetryModule) pRetryModule = await import("p-retry");
11
- return pRetryModule.default;
12
- }
13
9
  const STATUS_NO_RETRY = [
14
10
  400,
15
11
  401,
@@ -58,7 +54,6 @@ var AsyncCaller = class {
58
54
  this.queue = new PQueue({ concurrency: this.maxConcurrency });
59
55
  }
60
56
  async call(callable, ...args) {
61
- const pRetry = await getPRetry();
62
57
  return this.queue.add(() => pRetry(() => callable(...args).catch((error) => {
63
58
  if (error instanceof Error) throw error;
64
59
  else throw new Error(error);
@@ -1 +1 @@
1
- {"version":3,"file":"async_caller.js","names":["pRetryModule: typeof import(\"p-retry\") | null","error: any","params: AsyncCallerParams","callable: T","options: AsyncCallerCallOptions","listener: (() => void) | undefined"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\n\n// p-retry is ESM-only, so we use dynamic import for CJS compatibility.\n// The module is cached after first import, so subsequent calls are essentially free.\n// This approach is recommended by the p-retry author for async contexts:\n// https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\nlet pRetryModule: typeof import(\"p-retry\") | null = null;\n\nasync function getPRetry() {\n if (!pRetryModule) {\n pRetryModule = await import(\"p-retry\");\n }\n return pRetryModule.default;\n}\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst defaultFailedAttemptHandler = (error: any) => {\n if (\n error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\") ||\n error.name === \"AbortError\"\n ) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.code === \"ECONNABORTED\") {\n throw error;\n }\n const status =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (error as any)?.response?.status ?? (error as any)?.status;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.error?.code === \"insufficient_quota\") {\n const err = new Error(error?.message);\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n const pRetry = await getPRetry();\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener);\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch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AAkB,MAAM;GAC7D,SAAS,KAAK;GACd,WAAW;EAGZ,EACF,EACH,EAAE,gBAAgB,KAAM,EACzB;CACF;CAGD,gBACEC,SACAD,UACA,GAAG,MAC8B;AAGjC,MAAI,QAAQ,QAAQ;GAClB,IAAIE;AACJ,UAAO,QAAQ,KAAK,CAClB,KAAK,KAAW,UAAU,GAAG,KAAK,EAClC,IAAI,QAAe,CAAC,GAAG,WAAW;IAChC,WAAW,MAAM;KACf,OAAO,oBAAoB,QAAQ,OAAO,CAAC;IAC5C;IACD,QAAQ,QAAQ,iBAAiB,SAAS,SAAS;GACpD,EACF,EAAC,CAAC,QAAQ,MAAM;AACf,QAAI,QAAQ,UAAU,UACpB,QAAQ,OAAO,oBAAoB,SAAS,SAAS;GAExD,EAAC;EACH;AACD,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;CAC1C;CAED,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,KAAK,MACf,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE;CACF;AACF"}
1
+ {"version":3,"file":"async_caller.js","names":["error: any","params: AsyncCallerParams","callable: T","options: AsyncCallerCallOptions","listener: (() => void) | undefined"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\nimport pRetry from \"p-retry\";\n\nimport { getAbortSignalError } from \"./signal.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst defaultFailedAttemptHandler = (error: any) => {\n if (\n error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\") ||\n error.name === \"AbortError\"\n ) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.code === \"ECONNABORTED\") {\n throw error;\n }\n const status =\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (error as any)?.response?.status ?? (error as any)?.status;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if ((error as any)?.error?.code === \"insufficient_quota\") {\n const err = new Error(error?.message);\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: typeof import(\"p-queue\")[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener);\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAGD,MAAM,8BAA8B,CAACA,UAAe;AAClD,KACE,MAAM,QAAQ,WAA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iBAAiB,SAAS,SAAS;GACpD,EACF,EAAC,CAAC,QAAQ,MAAM;AACf,QAAI,QAAQ,UAAU,UACpB,QAAQ,OAAO,oBAAoB,SAAS,SAAS;GAExD,EAAC;EACH;AACD,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;CAC1C;CAED,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,KAAK,MACf,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE;CACF;AACF"}
@@ -1,5 +1,4 @@
1
1
  //#region src/utils/env.d.ts
2
- // Inlined from https://github.com/flexdinesh/browser-or-node
3
2
  declare global {
4
3
  const Deno: {
5
4
  version: {
@@ -13,10 +12,7 @@ declare global {
13
12
  declare const isBrowser: () => boolean;
14
13
  declare const isWebWorker: () => boolean;
15
14
  declare const isJsDom: () => boolean;
16
- // Supabase Edge Function provides a `Deno` global object
17
- // without `version` property
18
15
  declare const isDeno: () => boolean;
19
- // Mark not-as-node if in Supabase Edge Function
20
16
  declare const isNode: () => boolean;
21
17
  declare const getEnv: () => string;
22
18
  type RuntimeEnvironment = {
@@ -1,5 +1,4 @@
1
1
  //#region src/utils/env.d.ts
2
- // Inlined from https://github.com/flexdinesh/browser-or-node
3
2
  declare global {
4
3
  const Deno: {
5
4
  version: {
@@ -13,10 +12,7 @@ declare global {
13
12
  declare const isBrowser: () => boolean;
14
13
  declare const isWebWorker: () => boolean;
15
14
  declare const isJsDom: () => boolean;
16
- // Supabase Edge Function provides a `Deno` global object
17
- // without `version` property
18
15
  declare const isDeno: () => boolean;
19
- // Mark not-as-node if in Supabase Edge Function
20
16
  declare const isNode: () => boolean;
21
17
  declare const getEnv: () => string;
22
18
  type RuntimeEnvironment = {
@@ -1,7 +1,6 @@
1
1
  import { IterableReadableStream } from "./stream.cjs";
2
2
 
3
3
  //#region src/utils/event_source_parse.d.ts
4
-
5
4
  declare const EventStreamContentType = "text/event-stream";
6
5
  /**
7
6
  * Represents a message sent in an event stream
@@ -23,9 +22,7 @@ interface EventSourceMessage {
23
22
  * @param onChunk A function that will be called on each new byte chunk in the stream.
24
23
  * @returns {Promise<void>} A promise that will be resolved when the stream closes.
25
24
  */
26
- declare function getBytes(
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- stream: ReadableStream<Uint8Array> | AsyncIterable<any>, onChunk: (arr: Uint8Array, flush?: boolean) => void): Promise<void>;
25
+ declare function getBytes(stream: ReadableStream<Uint8Array> | AsyncIterable<any>, onChunk: (arr: Uint8Array, flush?: boolean) => void): Promise<void>;
29
26
  /**
30
27
  * Parses arbitary byte chunks into EventSource line buffers.
31
28
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -1,7 +1,6 @@
1
1
  import { IterableReadableStream } from "./stream.js";
2
2
 
3
3
  //#region src/utils/event_source_parse.d.ts
4
-
5
4
  declare const EventStreamContentType = "text/event-stream";
6
5
  /**
7
6
  * Represents a message sent in an event stream
@@ -23,9 +22,7 @@ interface EventSourceMessage {
23
22
  * @param onChunk A function that will be called on each new byte chunk in the stream.
24
23
  * @returns {Promise<void>} A promise that will be resolved when the stream closes.
25
24
  */
26
- declare function getBytes(
27
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
- stream: ReadableStream<Uint8Array> | AsyncIterable<any>, onChunk: (arr: Uint8Array, flush?: boolean) => void): Promise<void>;
25
+ declare function getBytes(stream: ReadableStream<Uint8Array> | AsyncIterable<any>, onChunk: (arr: Uint8Array, flush?: boolean) => void): Promise<void>;
29
26
  /**
30
27
  * Parses arbitary byte chunks into EventSource line buffers.
31
28
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -29,9 +29,7 @@ declare function convertToOpenAIFunction(tool: StructuredToolInterface | Runnabl
29
29
  * @param {StructuredToolInterface | Record<string, any> | RunnableToolLike} tool The tool to convert to an OpenAI tool.
30
30
  * @returns {ToolDefinition} The inputted tool in OpenAI tool format.
31
31
  */
32
- declare function convertToOpenAITool(
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- tool: StructuredToolInterface | Record<string, any> | RunnableToolLike, fields?: {
32
+ declare function convertToOpenAITool(tool: StructuredToolInterface | Record<string, any> | RunnableToolLike, fields?: {
35
33
  /**
36
34
  * If `true`, model output is guaranteed to exactly match the JSON Schema
37
35
  * provided in the function definition.
@@ -29,9 +29,7 @@ declare function convertToOpenAIFunction(tool: StructuredToolInterface | Runnabl
29
29
  * @param {StructuredToolInterface | Record<string, any> | RunnableToolLike} tool The tool to convert to an OpenAI tool.
30
30
  * @returns {ToolDefinition} The inputted tool in OpenAI tool format.
31
31
  */
32
- declare function convertToOpenAITool(
33
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
- tool: StructuredToolInterface | Record<string, any> | RunnableToolLike, fields?: {
32
+ declare function convertToOpenAITool(tool: StructuredToolInterface | Record<string, any> | RunnableToolLike, fields?: {
35
33
  /**
36
34
  * If `true`, model output is guaranteed to exactly match the JSON Schema
37
35
  * provided in the function definition.
@@ -1,6 +1,5 @@
1
1
  //#region src/utils/json.d.ts
2
2
  declare function parseJsonMarkdown(s: string, parser?: typeof parsePartialJson): any;
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  declare function parsePartialJson(s: string): any | null;
5
4
  //#endregion
6
5
  export { parseJsonMarkdown, parsePartialJson };
@@ -1,6 +1,5 @@
1
1
  //#region src/utils/json.d.ts
2
2
  declare function parseJsonMarkdown(s: string, parser?: typeof parsePartialJson): any;
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
3
  declare function parsePartialJson(s: string): any | null;
5
4
  //#endregion
6
5
  export { parseJsonMarkdown, parsePartialJson };
@@ -1,29 +1,19 @@
1
1
  import { IterableReadableStreamInterface } from "../types/_internal.cjs";
2
2
 
3
3
  //#region src/utils/stream.d.ts
4
-
5
- /*
6
- * Support async iterator syntax for ReadableStreams in all environments.
7
- * Source: https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
8
- */
9
4
  declare class IterableReadableStream<T> extends ReadableStream<T> implements IterableReadableStreamInterface<T> {
10
5
  reader: ReadableStreamDefaultReader<T>;
11
6
  ensureReader(): void;
12
7
  next(): Promise<IteratorResult<T>>;
13
8
  return(): Promise<IteratorResult<T>>;
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
9
  throw(e: any): Promise<IteratorResult<T>>;
16
10
  [Symbol.asyncIterator](): this;
17
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
- // @ts-ignore Not present in Node 18 types, required in latest Node 22
19
11
  [Symbol.asyncDispose](): Promise<void>;
20
12
  static fromReadableStream<T>(stream: ReadableStream<T>): IterableReadableStream<T>;
21
13
  static fromAsyncGenerator<T>(generator: AsyncGenerator<T>): IterableReadableStream<T>;
22
14
  }
23
15
  declare function atee<T>(iter: AsyncGenerator<T>, length?: number): AsyncGenerator<T>[];
24
- declare function concat<
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- T extends Array<any> | string | number | Record<string, any> | any>(first: T, second: T): T;
16
+ declare function concat<T extends Array<any> | string | number | Record<string, any> | any>(first: T, second: T): T;
27
17
  declare class AsyncGeneratorWithSetup<S = unknown, T = unknown, TReturn = unknown, TNext = unknown> implements AsyncGenerator<T, TReturn, TNext> {
28
18
  private generator;
29
19
  setup: Promise<S>;
@@ -41,8 +31,6 @@ declare class AsyncGeneratorWithSetup<S = unknown, T = unknown, TReturn = unknow
41
31
  return(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T>>;
42
32
  throw(e: Error): Promise<IteratorResult<T>>;
43
33
  [Symbol.asyncIterator](): this;
44
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
- // @ts-ignore Not present in Node 18 types, required in latest Node 22
46
34
  [Symbol.asyncDispose](): Promise<void>;
47
35
  }
48
36
  declare function pipeGeneratorWithSetup<S, A extends unknown[], T, TReturn, TNext, U, UReturn, UNext>(to: (g: AsyncGenerator<T, TReturn, TNext>, s: S, ...args: A) => AsyncGenerator<U, UReturn, UNext>, generator: AsyncGenerator<T, TReturn, TNext>, startSetup: () => Promise<S>, signal: AbortSignal | undefined, ...args: A): Promise<{
@@ -1,29 +1,19 @@
1
1
  import { IterableReadableStreamInterface } from "../types/_internal.js";
2
2
 
3
3
  //#region src/utils/stream.d.ts
4
-
5
- /*
6
- * Support async iterator syntax for ReadableStreams in all environments.
7
- * Source: https://github.com/MattiasBuelens/web-streams-polyfill/pull/122#issuecomment-1627354490
8
- */
9
4
  declare class IterableReadableStream<T> extends ReadableStream<T> implements IterableReadableStreamInterface<T> {
10
5
  reader: ReadableStreamDefaultReader<T>;
11
6
  ensureReader(): void;
12
7
  next(): Promise<IteratorResult<T>>;
13
8
  return(): Promise<IteratorResult<T>>;
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
9
  throw(e: any): Promise<IteratorResult<T>>;
16
10
  [Symbol.asyncIterator](): this;
17
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
- // @ts-ignore Not present in Node 18 types, required in latest Node 22
19
11
  [Symbol.asyncDispose](): Promise<void>;
20
12
  static fromReadableStream<T>(stream: ReadableStream<T>): IterableReadableStream<T>;
21
13
  static fromAsyncGenerator<T>(generator: AsyncGenerator<T>): IterableReadableStream<T>;
22
14
  }
23
15
  declare function atee<T>(iter: AsyncGenerator<T>, length?: number): AsyncGenerator<T>[];
24
- declare function concat<
25
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
- T extends Array<any> | string | number | Record<string, any> | any>(first: T, second: T): T;
16
+ declare function concat<T extends Array<any> | string | number | Record<string, any> | any>(first: T, second: T): T;
27
17
  declare class AsyncGeneratorWithSetup<S = unknown, T = unknown, TReturn = unknown, TNext = unknown> implements AsyncGenerator<T, TReturn, TNext> {
28
18
  private generator;
29
19
  setup: Promise<S>;
@@ -41,8 +31,6 @@ declare class AsyncGeneratorWithSetup<S = unknown, T = unknown, TReturn = unknow
41
31
  return(value?: TReturn | PromiseLike<TReturn>): Promise<IteratorResult<T>>;
42
32
  throw(e: Error): Promise<IteratorResult<T>>;
43
33
  [Symbol.asyncIterator](): this;
44
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
45
- // @ts-ignore Not present in Node 18 types, required in latest Node 22
46
34
  [Symbol.asyncDispose](): Promise<void>;
47
35
  }
48
36
  declare function pipeGeneratorWithSetup<S, A extends unknown[], T, TReturn, TNext, U, UReturn, UNext>(to: (g: AsyncGenerator<T, TReturn, TNext>, s: S, ...args: A) => AsyncGenerator<U, UReturn, UNext>, generator: AsyncGenerator<T, TReturn, TNext>, startSetup: () => Promise<S>, signal: AbortSignal | undefined, ...args: A): Promise<{
@@ -15,7 +15,7 @@ import { BaseLLMParams } from "../../language_models/llms.cjs";
15
15
  interface ToolSpec {
16
16
  name: string;
17
17
  description?: string;
18
- schema: InteropZodType | Record<string, unknown>; // Either a Zod schema *or* a plain JSON-Schema object
18
+ schema: InteropZodType | Record<string, unknown>;
19
19
  }
20
20
  /**
21
21
  * Interface specific to the Fake Streaming Chat model.
@@ -115,16 +115,8 @@ declare class FakeListChatModel extends BaseChatModel<FakeListChatModelCallOptio
115
115
  _createResponseChunk(text: string): ChatGenerationChunk;
116
116
  _currentResponse(): string;
117
117
  _incrementResponse(): void;
118
- withStructuredOutput<
119
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
- RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, false> | InteropZodType<RunOutput>
121
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
122
- | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
123
- withStructuredOutput<
124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
- RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, true> | InteropZodType<RunOutput>
126
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
- | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
118
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, false> | InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
119
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, true> | InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
128
120
  raw: BaseMessage;
129
121
  parsed: RunOutput;
130
122
  }>;
@@ -16,7 +16,7 @@ import { BaseLLMParams } from "../../language_models/llms.js";
16
16
  interface ToolSpec {
17
17
  name: string;
18
18
  description?: string;
19
- schema: InteropZodType | Record<string, unknown>; // Either a Zod schema *or* a plain JSON-Schema object
19
+ schema: InteropZodType | Record<string, unknown>;
20
20
  }
21
21
  /**
22
22
  * Interface specific to the Fake Streaming Chat model.
@@ -116,16 +116,8 @@ declare class FakeListChatModel extends BaseChatModel<FakeListChatModelCallOptio
116
116
  _createResponseChunk(text: string): ChatGenerationChunk;
117
117
  _currentResponse(): string;
118
118
  _incrementResponse(): void;
119
- withStructuredOutput<
120
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
121
- RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, false> | InteropZodType<RunOutput>
122
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
123
- | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
124
- withStructuredOutput<
125
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
126
- RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, true> | InteropZodType<RunOutput>
127
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
- | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
119
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, false> | InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
120
+ withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(_params: StructuredOutputMethodParams<RunOutput, true> | InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
129
121
  raw: BaseMessage;
130
122
  parsed: RunOutput;
131
123
  }>;
@@ -1,5 +1,5 @@
1
- const require_ai = require('../../messages/ai.cjs');
2
1
  const require_human = require('../../messages/human.cjs');
2
+ const require_ai = require('../../messages/ai.cjs');
3
3
  const require_tracers_base = require('../../tracers/base.cjs');
4
4
  require('../../messages/index.cjs');
5
5
  const require_chat_history = require('../../chat_history.cjs');
@@ -1,5 +1,5 @@
1
- import { AIMessage } from "../../messages/ai.js";
2
1
  import { HumanMessage } from "../../messages/human.js";
2
+ import { AIMessage } from "../../messages/ai.js";
3
3
  import { BaseTracer } from "../../tracers/base.js";
4
4
  import "../../messages/index.js";
5
5
  import { BaseChatMessageHistory, BaseListChatMessageHistory } from "../../chat_history.js";
@@ -8,9 +8,7 @@ declare class FakeRetriever extends BaseRetriever {
8
8
  constructor(fields?: {
9
9
  output: Document[];
10
10
  });
11
- _getRelevantDocuments(_query: string
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- ): Promise<Document<Record<string, any>>[]>;
11
+ _getRelevantDocuments(_query: string): Promise<Document<Record<string, any>>[]>;
14
12
  }
15
13
  //#endregion
16
14
  export { FakeRetriever };
@@ -8,9 +8,7 @@ declare class FakeRetriever extends BaseRetriever {
8
8
  constructor(fields?: {
9
9
  output: Document[];
10
10
  });
11
- _getRelevantDocuments(_query: string
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- ): Promise<Document<Record<string, any>>[]>;
11
+ _getRelevantDocuments(_query: string): Promise<Document<Record<string, any>>[]>;
14
12
  }
15
13
  //#endregion
16
14
  export { FakeRetriever };
@@ -13,7 +13,6 @@ import { cosine } from "../ml-distance/similarities.cjs";
13
13
  interface MemoryVector {
14
14
  content: string;
15
15
  embedding: number[];
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
16
  metadata: Record<string, any>;
18
17
  }
19
18
  /**
@@ -13,7 +13,6 @@ import { cosine } from "../ml-distance/similarities.js";
13
13
  interface MemoryVector {
14
14
  content: string;
15
15
  embedding: number[];
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
16
  metadata: Record<string, any>;
18
17
  }
19
18
  /**
@@ -26,8 +26,10 @@ require_rolldown_runtime.__export(types_exports, {
26
26
  isZodArrayV4: () => require_zod.isZodArrayV4,
27
27
  isZodLiteralV3: () => require_zod.isZodLiteralV3,
28
28
  isZodLiteralV4: () => require_zod.isZodLiteralV4,
29
+ isZodNullableV4: () => require_zod.isZodNullableV4,
29
30
  isZodObjectV3: () => require_zod.isZodObjectV3,
30
31
  isZodObjectV4: () => require_zod.isZodObjectV4,
32
+ isZodOptionalV4: () => require_zod.isZodOptionalV4,
31
33
  isZodSchema: () => require_zod.isZodSchema,
32
34
  isZodSchemaV3: () => require_zod.isZodSchemaV3,
33
35
  isZodSchemaV4: () => require_zod.isZodSchemaV4
@@ -56,8 +58,10 @@ exports.isSimpleStringZodSchema = require_zod.isSimpleStringZodSchema;
56
58
  exports.isZodArrayV4 = require_zod.isZodArrayV4;
57
59
  exports.isZodLiteralV3 = require_zod.isZodLiteralV3;
58
60
  exports.isZodLiteralV4 = require_zod.isZodLiteralV4;
61
+ exports.isZodNullableV4 = require_zod.isZodNullableV4;
59
62
  exports.isZodObjectV3 = require_zod.isZodObjectV3;
60
63
  exports.isZodObjectV4 = require_zod.isZodObjectV4;
64
+ exports.isZodOptionalV4 = require_zod.isZodOptionalV4;
61
65
  exports.isZodSchema = require_zod.isZodSchema;
62
66
  exports.isZodSchemaV3 = require_zod.isZodSchemaV3;
63
67
  exports.isZodSchemaV4 = require_zod.isZodSchemaV4;
@@ -1,4 +1,4 @@
1
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
1
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
 
@@ -6,11 +6,9 @@ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, Interop
6
6
  * Represents a string value with autocompleted, but not required, suggestions.
7
7
  */
8
8
  type StringWithAutocomplete<T> = T | (string & Record<never, never>);
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
9
  type InputValues<K extends string = string> = Record<K, any>;
11
10
  type PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
11
  type ChainValues = Record<string, any>;
14
12
  //#endregion
15
- export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
13
+ export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
16
14
  //# sourceMappingURL=index.d.cts.map
@@ -1,4 +1,4 @@
1
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
1
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
 
@@ -6,11 +6,9 @@ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, Interop
6
6
  * Represents a string value with autocompleted, but not required, suggestions.
7
7
  */
8
8
  type StringWithAutocomplete<T> = T | (string & Record<never, never>);
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
9
  type InputValues<K extends string = string> = Record<K, any>;
11
10
  type PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
11
  type ChainValues = Record<string, any>;
14
12
  //#endregion
15
- export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
13
+ export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
16
14
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { __export } from "../../_virtual/rolldown_runtime.js";
2
- import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
2
+ import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
3
3
 
4
4
  //#region src/utils/types/index.ts
5
5
  var types_exports = {};
@@ -26,13 +26,15 @@ __export(types_exports, {
26
26
  isZodArrayV4: () => isZodArrayV4,
27
27
  isZodLiteralV3: () => isZodLiteralV3,
28
28
  isZodLiteralV4: () => isZodLiteralV4,
29
+ isZodNullableV4: () => isZodNullableV4,
29
30
  isZodObjectV3: () => isZodObjectV3,
30
31
  isZodObjectV4: () => isZodObjectV4,
32
+ isZodOptionalV4: () => isZodOptionalV4,
31
33
  isZodSchema: () => isZodSchema,
32
34
  isZodSchemaV3: () => isZodSchemaV3,
33
35
  isZodSchemaV4: () => isZodSchemaV4
34
36
  });
35
37
 
36
38
  //#endregion
37
- export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4, types_exports };
39
+ export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4, types_exports };
38
40
  //# sourceMappingURL=index.js.map
@@ -230,6 +230,16 @@ function isZodArrayV4(obj) {
230
230
  if (typeof obj === "object" && obj !== null && "_zod" in obj && typeof obj._zod === "object" && obj._zod !== null && "def" in obj._zod && typeof obj._zod.def === "object" && obj._zod.def !== null && "type" in obj._zod.def && obj._zod.def.type === "array") return true;
231
231
  return false;
232
232
  }
233
+ function isZodOptionalV4(obj) {
234
+ if (!isZodSchemaV4(obj)) return false;
235
+ if (typeof obj === "object" && obj !== null && "_zod" in obj && typeof obj._zod === "object" && obj._zod !== null && "def" in obj._zod && typeof obj._zod.def === "object" && obj._zod.def !== null && "type" in obj._zod.def && obj._zod.def.type === "optional") return true;
236
+ return false;
237
+ }
238
+ function isZodNullableV4(obj) {
239
+ if (!isZodSchemaV4(obj)) return false;
240
+ if (typeof obj === "object" && obj !== null && "_zod" in obj && typeof obj._zod === "object" && obj._zod !== null && "def" in obj._zod && typeof obj._zod.def === "object" && obj._zod.def !== null && "type" in obj._zod.def && obj._zod.def.type === "nullable") return true;
241
+ return false;
242
+ }
233
243
  /**
234
244
  * Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).
235
245
  *
@@ -419,6 +429,18 @@ function interopZodTransformInputSchemaImpl(schema, recursive, cache) {
419
429
  ...outputSchema._zod.def,
420
430
  element: elementSchema
421
431
  });
432
+ } else if (isZodOptionalV4(outputSchema)) {
433
+ const innerSchema = interopZodTransformInputSchemaImpl(outputSchema._zod.def.innerType, recursive, cache);
434
+ outputSchema = (0, zod_v4_core.clone)(outputSchema, {
435
+ ...outputSchema._zod.def,
436
+ innerType: innerSchema
437
+ });
438
+ } else if (isZodNullableV4(outputSchema)) {
439
+ const innerSchema = interopZodTransformInputSchemaImpl(outputSchema._zod.def.innerType, recursive, cache);
440
+ outputSchema = (0, zod_v4_core.clone)(outputSchema, {
441
+ ...outputSchema._zod.def,
442
+ innerType: innerSchema
443
+ });
422
444
  }
423
445
  }
424
446
  const meta = zod_v4_core.globalRegistry.get(schema);
@@ -503,8 +525,10 @@ exports.isSimpleStringZodSchema = isSimpleStringZodSchema;
503
525
  exports.isZodArrayV4 = isZodArrayV4;
504
526
  exports.isZodLiteralV3 = isZodLiteralV3;
505
527
  exports.isZodLiteralV4 = isZodLiteralV4;
528
+ exports.isZodNullableV4 = isZodNullableV4;
506
529
  exports.isZodObjectV3 = isZodObjectV3;
507
530
  exports.isZodObjectV4 = isZodObjectV4;
531
+ exports.isZodOptionalV4 = isZodOptionalV4;
508
532
  exports.isZodSchema = isZodSchema;
509
533
  exports.isZodSchemaV3 = isZodSchemaV3;
510
534
  exports.isZodSchemaV4 = isZodSchemaV4;