@langchain/core 1.0.6 → 1.1.0

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 (695) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/agents.cjs +1 -0
  3. package/agents.d.cts +1 -0
  4. package/agents.d.ts +1 -0
  5. package/agents.js +1 -0
  6. package/caches.cjs +1 -0
  7. package/caches.d.cts +1 -0
  8. package/caches.d.ts +1 -0
  9. package/caches.js +1 -0
  10. package/callbacks/base.cjs +1 -0
  11. package/callbacks/base.d.cts +1 -0
  12. package/callbacks/base.d.ts +1 -0
  13. package/callbacks/base.js +1 -0
  14. package/callbacks/dispatch/web.cjs +1 -0
  15. package/callbacks/dispatch/web.d.cts +1 -0
  16. package/callbacks/dispatch/web.d.ts +1 -0
  17. package/callbacks/dispatch/web.js +1 -0
  18. package/callbacks/dispatch.cjs +1 -0
  19. package/callbacks/dispatch.d.cts +1 -0
  20. package/callbacks/dispatch.d.ts +1 -0
  21. package/callbacks/dispatch.js +1 -0
  22. package/callbacks/manager.cjs +1 -0
  23. package/callbacks/manager.d.cts +1 -0
  24. package/callbacks/manager.d.ts +1 -0
  25. package/callbacks/manager.js +1 -0
  26. package/callbacks/promises.cjs +1 -0
  27. package/callbacks/promises.d.cts +1 -0
  28. package/callbacks/promises.d.ts +1 -0
  29. package/callbacks/promises.js +1 -0
  30. package/chat_history.cjs +1 -0
  31. package/chat_history.d.cts +1 -0
  32. package/chat_history.d.ts +1 -0
  33. package/chat_history.js +1 -0
  34. package/context.cjs +1 -0
  35. package/context.d.cts +1 -0
  36. package/context.d.ts +1 -0
  37. package/context.js +1 -0
  38. package/dist/caches/{base.cjs → index.cjs} +6 -6
  39. package/dist/caches/index.cjs.map +1 -0
  40. package/dist/caches/{base.d.cts → index.d.cts} +2 -2
  41. package/dist/caches/{base.d.ts → index.d.ts} +2 -2
  42. package/dist/caches/{base.js → index.js} +5 -5
  43. package/dist/caches/index.js.map +1 -0
  44. package/dist/callbacks/dispatch/index.d.ts +1 -0
  45. package/dist/callbacks/dispatch/web.d.ts +1 -0
  46. package/dist/chat_history.d.ts +1 -0
  47. package/dist/language_models/base.cjs +2 -2
  48. package/dist/language_models/base.cjs.map +1 -1
  49. package/dist/language_models/base.d.cts +1 -1
  50. package/dist/language_models/base.d.ts +3 -1
  51. package/dist/language_models/base.js +1 -1
  52. package/dist/language_models/base.js.map +1 -1
  53. package/dist/language_models/chat_models.cjs.map +1 -1
  54. package/dist/language_models/chat_models.d.cts +1 -1
  55. package/dist/language_models/chat_models.d.ts +4 -1
  56. package/dist/language_models/chat_models.js.map +1 -1
  57. package/dist/language_models/llms.cjs.map +1 -1
  58. package/dist/language_models/llms.d.cts +1 -1
  59. package/dist/language_models/llms.d.ts +2 -1
  60. package/dist/language_models/llms.js.map +1 -1
  61. package/dist/load/import_constants.cjs +1 -0
  62. package/dist/load/import_constants.cjs.map +1 -1
  63. package/dist/load/import_constants.js +1 -0
  64. package/dist/load/import_constants.js.map +1 -1
  65. package/dist/load/import_map.cjs +12 -12
  66. package/dist/load/import_map.cjs.map +1 -1
  67. package/dist/load/import_map.js +16 -16
  68. package/dist/load/import_map.js.map +1 -1
  69. package/dist/messages/base.cjs +10 -3
  70. package/dist/messages/base.cjs.map +1 -1
  71. package/dist/messages/base.js +10 -3
  72. package/dist/messages/base.js.map +1 -1
  73. package/dist/messages/message.d.cts +1 -1
  74. package/dist/messages/message.d.ts +1 -1
  75. package/dist/messages/system.cjs +25 -1
  76. package/dist/messages/system.cjs.map +1 -1
  77. package/dist/messages/system.d.cts +6 -0
  78. package/dist/messages/system.d.ts +6 -0
  79. package/dist/messages/system.js +25 -1
  80. package/dist/messages/system.js.map +1 -1
  81. package/dist/messages/transformers.d.cts +2 -1
  82. package/dist/messages/transformers.d.ts +2 -1
  83. package/dist/messages/utils.d.cts +8 -8
  84. package/dist/messages/utils.d.ts +8 -8
  85. package/dist/output_parsers/base.d.ts +3 -0
  86. package/dist/output_parsers/index.cjs +1 -1
  87. package/dist/output_parsers/index.js +1 -1
  88. package/dist/output_parsers/list.d.ts +1 -0
  89. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
  90. package/dist/output_parsers/string.d.ts +1 -0
  91. package/dist/prompts/base.d.ts +1 -0
  92. package/dist/prompts/chat.d.ts +1 -0
  93. package/dist/prompts/few_shot.d.ts +1 -0
  94. package/dist/prompts/image.d.ts +1 -0
  95. package/dist/prompts/prompt.d.ts +1 -0
  96. package/dist/prompts/serde.d.ts +1 -0
  97. package/dist/prompts/structured.d.ts +1 -1
  98. package/dist/prompts/template.d.ts +1 -1
  99. package/dist/retrievers/document_compressors/{base.cjs → index.cjs} +6 -6
  100. package/dist/retrievers/document_compressors/index.cjs.map +1 -0
  101. package/dist/retrievers/document_compressors/{base.d.cts → index.d.cts} +2 -2
  102. package/dist/retrievers/document_compressors/{base.d.ts → index.d.ts} +2 -2
  103. package/dist/retrievers/document_compressors/index.js +17 -0
  104. package/dist/retrievers/document_compressors/index.js.map +1 -0
  105. package/dist/retrievers/index.d.ts +1 -0
  106. package/dist/runnables/base.cjs +2 -2
  107. package/dist/runnables/base.cjs.map +1 -1
  108. package/dist/runnables/base.d.cts +0 -17
  109. package/dist/runnables/base.d.ts +0 -17
  110. package/dist/runnables/base.js +2 -2
  111. package/dist/runnables/base.js.map +1 -1
  112. package/dist/runnables/branch.d.ts +1 -0
  113. package/dist/runnables/history.d.ts +2 -0
  114. package/dist/runnables/index.cjs +4 -1
  115. package/dist/runnables/index.cjs.map +1 -1
  116. package/dist/runnables/index.d.cts +2 -1
  117. package/dist/runnables/index.d.ts +2 -1
  118. package/dist/runnables/index.js +4 -2
  119. package/dist/runnables/index.js.map +1 -1
  120. package/dist/runnables/passthrough.d.ts +1 -0
  121. package/dist/runnables/router.d.ts +1 -0
  122. package/dist/tools/index.cjs +1 -1
  123. package/dist/tools/index.cjs.map +1 -1
  124. package/dist/tools/index.d.ts +2 -0
  125. package/dist/tools/index.js +2 -2
  126. package/dist/tools/index.js.map +1 -1
  127. package/dist/tools/types.d.cts +0 -13
  128. package/dist/tools/types.d.ts +2 -13
  129. package/dist/tracers/event_stream.d.ts +1 -0
  130. package/dist/utils/async_caller.cjs +1 -1
  131. package/dist/utils/async_caller.cjs.map +1 -1
  132. package/dist/utils/async_caller.js +1 -1
  133. package/dist/utils/async_caller.js.map +1 -1
  134. package/dist/utils/fast-json-patch/src/core.d.cts +0 -18
  135. package/dist/utils/fast-json-patch/src/core.d.ts +0 -18
  136. package/dist/utils/json_schema.d.cts +0 -5
  137. package/dist/utils/json_schema.d.ts +1 -5
  138. package/dist/utils/signal.d.cts +13 -0
  139. package/dist/utils/signal.d.ts +13 -0
  140. package/dist/utils/testing/chat_models.d.ts +1 -0
  141. package/dist/utils/testing/message_history.d.ts +1 -0
  142. package/dist/utils/types/index.cjs +2 -0
  143. package/dist/utils/types/index.d.cts +2 -2
  144. package/dist/utils/types/index.d.ts +2 -2
  145. package/dist/utils/types/index.js +3 -2
  146. package/dist/utils/types/zod.cjs +4 -0
  147. package/dist/utils/types/zod.cjs.map +1 -1
  148. package/dist/utils/types/zod.d.cts +3 -2
  149. package/dist/utils/types/zod.d.ts +3 -2
  150. package/dist/utils/types/zod.js +4 -1
  151. package/dist/utils/types/zod.js.map +1 -1
  152. package/dist/utils/zod-to-json-schema/Options.d.ts +3 -0
  153. package/dist/utils/zod-to-json-schema/Refs.d.ts +3 -0
  154. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +1 -0
  155. package/dist/utils/zod-to-json-schema/index.d.ts +37 -0
  156. package/dist/utils/zod-to-json-schema/parseDef.d.ts +3 -0
  157. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +2 -0
  158. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +1 -0
  159. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +1 -0
  160. package/dist/utils/zod-to-json-schema/parsers/branded.d.ts +3 -0
  161. package/dist/utils/zod-to-json-schema/parsers/catch.d.ts +3 -0
  162. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +2 -0
  163. package/dist/utils/zod-to-json-schema/parsers/default.d.ts +3 -0
  164. package/dist/utils/zod-to-json-schema/parsers/effects.d.ts +3 -0
  165. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +1 -0
  166. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +1 -0
  167. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +2 -0
  168. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +1 -0
  169. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +2 -0
  170. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +1 -0
  171. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +1 -0
  172. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +1 -0
  173. package/dist/utils/zod-to-json-schema/parsers/optional.d.ts +3 -0
  174. package/dist/utils/zod-to-json-schema/parsers/pipeline.d.ts +4 -0
  175. package/dist/utils/zod-to-json-schema/parsers/promise.d.ts +3 -0
  176. package/dist/utils/zod-to-json-schema/parsers/readonly.d.ts +3 -0
  177. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +1 -0
  178. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +1 -0
  179. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +1 -0
  180. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +1 -0
  181. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +1 -0
  182. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +2 -1
  183. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +1 -0
  184. package/dist/utils/zod-to-json-schema/selectParser.d.ts +3 -0
  185. package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.ts +3 -0
  186. package/document_loaders/base.cjs +1 -0
  187. package/document_loaders/base.d.cts +1 -0
  188. package/document_loaders/base.d.ts +1 -0
  189. package/document_loaders/base.js +1 -0
  190. package/document_loaders/langsmith.cjs +1 -0
  191. package/document_loaders/langsmith.d.cts +1 -0
  192. package/document_loaders/langsmith.d.ts +1 -0
  193. package/document_loaders/langsmith.js +1 -0
  194. package/documents.cjs +1 -0
  195. package/documents.d.cts +1 -0
  196. package/documents.d.ts +1 -0
  197. package/documents.js +1 -0
  198. package/embeddings.cjs +1 -0
  199. package/embeddings.d.cts +1 -0
  200. package/embeddings.d.ts +1 -0
  201. package/embeddings.js +1 -0
  202. package/example_selectors.cjs +1 -0
  203. package/example_selectors.d.cts +1 -0
  204. package/example_selectors.d.ts +1 -0
  205. package/example_selectors.js +1 -0
  206. package/indexing.cjs +1 -0
  207. package/indexing.d.cts +1 -0
  208. package/indexing.d.ts +1 -0
  209. package/indexing.js +1 -0
  210. package/language_models/base.cjs +1 -0
  211. package/language_models/base.d.cts +1 -0
  212. package/language_models/base.d.ts +1 -0
  213. package/language_models/base.js +1 -0
  214. package/language_models/chat_models.cjs +1 -0
  215. package/language_models/chat_models.d.cts +1 -0
  216. package/language_models/chat_models.d.ts +1 -0
  217. package/language_models/chat_models.js +1 -0
  218. package/language_models/llms.cjs +1 -0
  219. package/language_models/llms.d.cts +1 -0
  220. package/language_models/llms.d.ts +1 -0
  221. package/language_models/llms.js +1 -0
  222. package/language_models/profile.cjs +1 -0
  223. package/language_models/profile.d.cts +1 -0
  224. package/language_models/profile.d.ts +1 -0
  225. package/language_models/profile.js +1 -0
  226. package/load/serializable.cjs +1 -0
  227. package/load/serializable.d.cts +1 -0
  228. package/load/serializable.d.ts +1 -0
  229. package/load/serializable.js +1 -0
  230. package/load.cjs +1 -0
  231. package/load.d.cts +1 -0
  232. package/load.d.ts +1 -0
  233. package/load.js +1 -0
  234. package/memory.cjs +1 -0
  235. package/memory.d.cts +1 -0
  236. package/memory.d.ts +1 -0
  237. package/memory.js +1 -0
  238. package/messages/tool.cjs +1 -0
  239. package/messages/tool.d.cts +1 -0
  240. package/messages/tool.d.ts +1 -0
  241. package/messages/tool.js +1 -0
  242. package/messages.cjs +1 -0
  243. package/messages.d.cts +1 -0
  244. package/messages.d.ts +1 -0
  245. package/messages.js +1 -0
  246. package/output_parsers/openai_functions.cjs +1 -0
  247. package/output_parsers/openai_functions.d.cts +1 -0
  248. package/output_parsers/openai_functions.d.ts +1 -0
  249. package/output_parsers/openai_functions.js +1 -0
  250. package/output_parsers/openai_tools.cjs +1 -0
  251. package/output_parsers/openai_tools.d.cts +1 -0
  252. package/output_parsers/openai_tools.d.ts +1 -0
  253. package/output_parsers/openai_tools.js +1 -0
  254. package/output_parsers.cjs +1 -0
  255. package/output_parsers.d.cts +1 -0
  256. package/output_parsers.d.ts +1 -0
  257. package/output_parsers.js +1 -0
  258. package/outputs.cjs +1 -0
  259. package/outputs.d.cts +1 -0
  260. package/outputs.d.ts +1 -0
  261. package/outputs.js +1 -0
  262. package/package.json +163 -63
  263. package/prompt_values.cjs +1 -0
  264. package/prompt_values.d.cts +1 -0
  265. package/prompt_values.d.ts +1 -0
  266. package/prompt_values.js +1 -0
  267. package/prompts.cjs +1 -0
  268. package/prompts.d.cts +1 -0
  269. package/prompts.d.ts +1 -0
  270. package/prompts.js +1 -0
  271. package/retrievers/document_compressors.cjs +1 -0
  272. package/retrievers/document_compressors.d.cts +1 -0
  273. package/retrievers/document_compressors.d.ts +1 -0
  274. package/retrievers/document_compressors.js +1 -0
  275. package/retrievers.cjs +1 -0
  276. package/retrievers.d.cts +1 -0
  277. package/retrievers.d.ts +1 -0
  278. package/retrievers.js +1 -0
  279. package/runnables/graph.cjs +1 -0
  280. package/runnables/graph.d.cts +1 -0
  281. package/runnables/graph.d.ts +1 -0
  282. package/runnables/graph.js +1 -0
  283. package/runnables.cjs +1 -0
  284. package/runnables.d.cts +1 -0
  285. package/runnables.d.ts +1 -0
  286. package/runnables.js +1 -0
  287. package/singletons.cjs +1 -0
  288. package/singletons.d.cts +1 -0
  289. package/singletons.d.ts +1 -0
  290. package/singletons.js +1 -0
  291. package/stores.cjs +1 -0
  292. package/stores.d.cts +1 -0
  293. package/stores.d.ts +1 -0
  294. package/stores.js +1 -0
  295. package/structured_query.cjs +1 -0
  296. package/structured_query.d.cts +1 -0
  297. package/structured_query.d.ts +1 -0
  298. package/structured_query.js +1 -0
  299. package/tools.cjs +1 -0
  300. package/tools.d.cts +1 -0
  301. package/tools.d.ts +1 -0
  302. package/tools.js +1 -0
  303. package/tracers/base.cjs +1 -0
  304. package/tracers/base.d.cts +1 -0
  305. package/tracers/base.d.ts +1 -0
  306. package/tracers/base.js +1 -0
  307. package/tracers/console.cjs +1 -0
  308. package/tracers/console.d.cts +1 -0
  309. package/tracers/console.d.ts +1 -0
  310. package/tracers/console.js +1 -0
  311. package/tracers/log_stream.cjs +1 -0
  312. package/tracers/log_stream.d.cts +1 -0
  313. package/tracers/log_stream.d.ts +1 -0
  314. package/tracers/log_stream.js +1 -0
  315. package/tracers/run_collector.cjs +1 -0
  316. package/tracers/run_collector.d.cts +1 -0
  317. package/tracers/run_collector.d.ts +1 -0
  318. package/tracers/run_collector.js +1 -0
  319. package/tracers/tracer_langchain.cjs +1 -0
  320. package/tracers/tracer_langchain.d.cts +1 -0
  321. package/tracers/tracer_langchain.d.ts +1 -0
  322. package/tracers/tracer_langchain.js +1 -0
  323. package/types/stream.cjs +1 -0
  324. package/types/stream.d.cts +1 -0
  325. package/types/stream.d.ts +1 -0
  326. package/types/stream.js +1 -0
  327. package/utils/async_caller.cjs +1 -0
  328. package/utils/async_caller.d.cts +1 -0
  329. package/utils/async_caller.d.ts +1 -0
  330. package/utils/async_caller.js +1 -0
  331. package/utils/chunk_array.cjs +1 -0
  332. package/utils/chunk_array.d.cts +1 -0
  333. package/utils/chunk_array.d.ts +1 -0
  334. package/utils/chunk_array.js +1 -0
  335. package/utils/env.cjs +1 -0
  336. package/utils/env.d.cts +1 -0
  337. package/utils/env.d.ts +1 -0
  338. package/utils/env.js +1 -0
  339. package/utils/event_source_parse.cjs +1 -0
  340. package/utils/event_source_parse.d.cts +1 -0
  341. package/utils/event_source_parse.d.ts +1 -0
  342. package/utils/event_source_parse.js +1 -0
  343. package/utils/format.cjs +1 -0
  344. package/utils/format.d.cts +1 -0
  345. package/utils/format.d.ts +1 -0
  346. package/utils/format.js +1 -0
  347. package/utils/function_calling.cjs +1 -0
  348. package/utils/function_calling.d.cts +1 -0
  349. package/utils/function_calling.d.ts +1 -0
  350. package/utils/function_calling.js +1 -0
  351. package/utils/hash.cjs +1 -0
  352. package/utils/hash.d.cts +1 -0
  353. package/utils/hash.d.ts +1 -0
  354. package/utils/hash.js +1 -0
  355. package/utils/json_patch.cjs +1 -0
  356. package/utils/json_patch.d.cts +1 -0
  357. package/utils/json_patch.d.ts +1 -0
  358. package/utils/json_patch.js +1 -0
  359. package/utils/json_schema.cjs +1 -0
  360. package/utils/json_schema.d.cts +1 -0
  361. package/utils/json_schema.d.ts +1 -0
  362. package/utils/json_schema.js +1 -0
  363. package/utils/math.cjs +1 -0
  364. package/utils/math.d.cts +1 -0
  365. package/utils/math.d.ts +1 -0
  366. package/utils/math.js +1 -0
  367. package/utils/stream.cjs +1 -0
  368. package/utils/stream.d.cts +1 -0
  369. package/utils/stream.d.ts +1 -0
  370. package/utils/stream.js +1 -0
  371. package/utils/testing.cjs +1 -0
  372. package/utils/testing.d.cts +1 -0
  373. package/utils/testing.d.ts +1 -0
  374. package/utils/testing.js +1 -0
  375. package/utils/tiktoken.cjs +1 -0
  376. package/utils/tiktoken.d.cts +1 -0
  377. package/utils/tiktoken.d.ts +1 -0
  378. package/utils/tiktoken.js +1 -0
  379. package/utils/types.cjs +1 -0
  380. package/utils/types.d.cts +1 -0
  381. package/utils/types.d.ts +1 -0
  382. package/utils/types.js +1 -0
  383. package/vectorstores.cjs +1 -0
  384. package/vectorstores.d.cts +1 -0
  385. package/vectorstores.d.ts +1 -0
  386. package/vectorstores.js +1 -0
  387. package/dist/agents.d.cts.map +0 -1
  388. package/dist/agents.d.ts.map +0 -1
  389. package/dist/caches/base.cjs.map +0 -1
  390. package/dist/caches/base.d.cts.map +0 -1
  391. package/dist/caches/base.d.ts.map +0 -1
  392. package/dist/caches/base.js.map +0 -1
  393. package/dist/callbacks/base.d.cts.map +0 -1
  394. package/dist/callbacks/base.d.ts.map +0 -1
  395. package/dist/callbacks/dispatch/index.d.cts.map +0 -1
  396. package/dist/callbacks/dispatch/index.d.ts.map +0 -1
  397. package/dist/callbacks/dispatch/web.d.cts.map +0 -1
  398. package/dist/callbacks/dispatch/web.d.ts.map +0 -1
  399. package/dist/callbacks/manager.d.cts.map +0 -1
  400. package/dist/callbacks/manager.d.ts.map +0 -1
  401. package/dist/chat_history.d.cts.map +0 -1
  402. package/dist/chat_history.d.ts.map +0 -1
  403. package/dist/context.d.cts.map +0 -1
  404. package/dist/context.d.ts.map +0 -1
  405. package/dist/document_loaders/base.d.cts.map +0 -1
  406. package/dist/document_loaders/base.d.ts.map +0 -1
  407. package/dist/document_loaders/langsmith.d.cts.map +0 -1
  408. package/dist/document_loaders/langsmith.d.ts.map +0 -1
  409. package/dist/documents/document.d.cts.map +0 -1
  410. package/dist/documents/document.d.ts.map +0 -1
  411. package/dist/documents/transformers.d.cts.map +0 -1
  412. package/dist/documents/transformers.d.ts.map +0 -1
  413. package/dist/embeddings.d.cts.map +0 -1
  414. package/dist/embeddings.d.ts.map +0 -1
  415. package/dist/example_selectors/base.d.cts.map +0 -1
  416. package/dist/example_selectors/base.d.ts.map +0 -1
  417. package/dist/example_selectors/conditional.d.cts.map +0 -1
  418. package/dist/example_selectors/conditional.d.ts.map +0 -1
  419. package/dist/example_selectors/length_based.d.cts.map +0 -1
  420. package/dist/example_selectors/length_based.d.ts.map +0 -1
  421. package/dist/example_selectors/semantic_similarity.d.cts.map +0 -1
  422. package/dist/example_selectors/semantic_similarity.d.ts.map +0 -1
  423. package/dist/indexing/base.d.cts.map +0 -1
  424. package/dist/indexing/base.d.ts.map +0 -1
  425. package/dist/indexing/record_manager.d.cts.map +0 -1
  426. package/dist/indexing/record_manager.d.ts.map +0 -1
  427. package/dist/language_models/base.d.cts.map +0 -1
  428. package/dist/language_models/base.d.ts.map +0 -1
  429. package/dist/language_models/chat_models.d.cts.map +0 -1
  430. package/dist/language_models/chat_models.d.ts.map +0 -1
  431. package/dist/language_models/llms.d.cts.map +0 -1
  432. package/dist/language_models/llms.d.ts.map +0 -1
  433. package/dist/language_models/profile.d.cts.map +0 -1
  434. package/dist/language_models/profile.d.ts.map +0 -1
  435. package/dist/load/import_type.d.cts.map +0 -1
  436. package/dist/load/import_type.d.ts.map +0 -1
  437. package/dist/load/index.d.cts.map +0 -1
  438. package/dist/load/index.d.ts.map +0 -1
  439. package/dist/load/map_keys.d.cts.map +0 -1
  440. package/dist/load/map_keys.d.ts.map +0 -1
  441. package/dist/load/serializable.d.cts.map +0 -1
  442. package/dist/load/serializable.d.ts.map +0 -1
  443. package/dist/memory.d.cts.map +0 -1
  444. package/dist/memory.d.ts.map +0 -1
  445. package/dist/messages/ai.d.cts.map +0 -1
  446. package/dist/messages/ai.d.ts.map +0 -1
  447. package/dist/messages/base.d.cts.map +0 -1
  448. package/dist/messages/base.d.ts.map +0 -1
  449. package/dist/messages/chat.d.cts.map +0 -1
  450. package/dist/messages/chat.d.ts.map +0 -1
  451. package/dist/messages/content/base.d.cts.map +0 -1
  452. package/dist/messages/content/base.d.ts.map +0 -1
  453. package/dist/messages/content/data.d.cts.map +0 -1
  454. package/dist/messages/content/data.d.ts.map +0 -1
  455. package/dist/messages/content/index.d.cts.map +0 -1
  456. package/dist/messages/content/index.d.ts.map +0 -1
  457. package/dist/messages/content/multimodal.d.cts.map +0 -1
  458. package/dist/messages/content/multimodal.d.ts.map +0 -1
  459. package/dist/messages/content/tools.d.cts.map +0 -1
  460. package/dist/messages/content/tools.d.ts.map +0 -1
  461. package/dist/messages/format.d.cts.map +0 -1
  462. package/dist/messages/format.d.ts.map +0 -1
  463. package/dist/messages/function.d.cts.map +0 -1
  464. package/dist/messages/function.d.ts.map +0 -1
  465. package/dist/messages/human.d.cts.map +0 -1
  466. package/dist/messages/human.d.ts.map +0 -1
  467. package/dist/messages/message.d.cts.map +0 -1
  468. package/dist/messages/message.d.ts.map +0 -1
  469. package/dist/messages/metadata.d.cts.map +0 -1
  470. package/dist/messages/metadata.d.ts.map +0 -1
  471. package/dist/messages/modifier.d.cts.map +0 -1
  472. package/dist/messages/modifier.d.ts.map +0 -1
  473. package/dist/messages/system.d.cts.map +0 -1
  474. package/dist/messages/system.d.ts.map +0 -1
  475. package/dist/messages/tool.d.cts.map +0 -1
  476. package/dist/messages/tool.d.ts.map +0 -1
  477. package/dist/messages/transformers.d.cts.map +0 -1
  478. package/dist/messages/transformers.d.ts.map +0 -1
  479. package/dist/messages/utils.d.cts.map +0 -1
  480. package/dist/messages/utils.d.ts.map +0 -1
  481. package/dist/output_parsers/base.d.cts.map +0 -1
  482. package/dist/output_parsers/base.d.ts.map +0 -1
  483. package/dist/output_parsers/bytes.d.cts.map +0 -1
  484. package/dist/output_parsers/bytes.d.ts.map +0 -1
  485. package/dist/output_parsers/json.d.cts.map +0 -1
  486. package/dist/output_parsers/json.d.ts.map +0 -1
  487. package/dist/output_parsers/list.d.cts.map +0 -1
  488. package/dist/output_parsers/list.d.ts.map +0 -1
  489. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +0 -1
  490. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +0 -1
  491. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +0 -1
  492. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +0 -1
  493. package/dist/output_parsers/string.d.cts.map +0 -1
  494. package/dist/output_parsers/string.d.ts.map +0 -1
  495. package/dist/output_parsers/structured.d.cts.map +0 -1
  496. package/dist/output_parsers/structured.d.ts.map +0 -1
  497. package/dist/output_parsers/transform.d.cts.map +0 -1
  498. package/dist/output_parsers/transform.d.ts.map +0 -1
  499. package/dist/output_parsers/xml.d.cts.map +0 -1
  500. package/dist/output_parsers/xml.d.ts.map +0 -1
  501. package/dist/outputs.d.cts.map +0 -1
  502. package/dist/outputs.d.ts.map +0 -1
  503. package/dist/prompt_values.d.cts.map +0 -1
  504. package/dist/prompt_values.d.ts.map +0 -1
  505. package/dist/prompts/base.d.cts.map +0 -1
  506. package/dist/prompts/base.d.ts.map +0 -1
  507. package/dist/prompts/chat.d.cts.map +0 -1
  508. package/dist/prompts/chat.d.ts.map +0 -1
  509. package/dist/prompts/dict.d.cts.map +0 -1
  510. package/dist/prompts/dict.d.ts.map +0 -1
  511. package/dist/prompts/few_shot.d.cts.map +0 -1
  512. package/dist/prompts/few_shot.d.ts.map +0 -1
  513. package/dist/prompts/image.d.cts.map +0 -1
  514. package/dist/prompts/image.d.ts.map +0 -1
  515. package/dist/prompts/pipeline.d.cts.map +0 -1
  516. package/dist/prompts/pipeline.d.ts.map +0 -1
  517. package/dist/prompts/prompt.d.cts.map +0 -1
  518. package/dist/prompts/prompt.d.ts.map +0 -1
  519. package/dist/prompts/serde.d.cts.map +0 -1
  520. package/dist/prompts/serde.d.ts.map +0 -1
  521. package/dist/prompts/string.d.cts.map +0 -1
  522. package/dist/prompts/string.d.ts.map +0 -1
  523. package/dist/prompts/structured.d.cts.map +0 -1
  524. package/dist/prompts/structured.d.ts.map +0 -1
  525. package/dist/prompts/template.d.cts.map +0 -1
  526. package/dist/prompts/template.d.ts.map +0 -1
  527. package/dist/retrievers/document_compressors/base.cjs.map +0 -1
  528. package/dist/retrievers/document_compressors/base.d.cts.map +0 -1
  529. package/dist/retrievers/document_compressors/base.d.ts.map +0 -1
  530. package/dist/retrievers/document_compressors/base.js +0 -17
  531. package/dist/retrievers/document_compressors/base.js.map +0 -1
  532. package/dist/retrievers/index.d.cts.map +0 -1
  533. package/dist/retrievers/index.d.ts.map +0 -1
  534. package/dist/runnables/base.d.cts.map +0 -1
  535. package/dist/runnables/base.d.ts.map +0 -1
  536. package/dist/runnables/branch.d.cts.map +0 -1
  537. package/dist/runnables/branch.d.ts.map +0 -1
  538. package/dist/runnables/config.d.cts.map +0 -1
  539. package/dist/runnables/config.d.ts.map +0 -1
  540. package/dist/runnables/graph.d.cts.map +0 -1
  541. package/dist/runnables/graph.d.ts.map +0 -1
  542. package/dist/runnables/history.d.cts.map +0 -1
  543. package/dist/runnables/history.d.ts.map +0 -1
  544. package/dist/runnables/passthrough.d.cts.map +0 -1
  545. package/dist/runnables/passthrough.d.ts.map +0 -1
  546. package/dist/runnables/router.d.cts.map +0 -1
  547. package/dist/runnables/router.d.ts.map +0 -1
  548. package/dist/runnables/types.d.cts.map +0 -1
  549. package/dist/runnables/types.d.ts.map +0 -1
  550. package/dist/singletons/async_local_storage/context.d.cts.map +0 -1
  551. package/dist/singletons/async_local_storage/context.d.ts.map +0 -1
  552. package/dist/singletons/async_local_storage/globals.d.cts.map +0 -1
  553. package/dist/singletons/async_local_storage/globals.d.ts.map +0 -1
  554. package/dist/singletons/async_local_storage/index.d.cts.map +0 -1
  555. package/dist/singletons/async_local_storage/index.d.ts.map +0 -1
  556. package/dist/singletons/callbacks.d.cts.map +0 -1
  557. package/dist/singletons/callbacks.d.ts.map +0 -1
  558. package/dist/stores.d.cts.map +0 -1
  559. package/dist/stores.d.ts.map +0 -1
  560. package/dist/structured_query/base.d.cts.map +0 -1
  561. package/dist/structured_query/base.d.ts.map +0 -1
  562. package/dist/structured_query/functional.d.cts.map +0 -1
  563. package/dist/structured_query/functional.d.ts.map +0 -1
  564. package/dist/structured_query/ir.d.cts.map +0 -1
  565. package/dist/structured_query/ir.d.ts.map +0 -1
  566. package/dist/structured_query/utils.d.cts.map +0 -1
  567. package/dist/structured_query/utils.d.ts.map +0 -1
  568. package/dist/tools/index.d.cts.map +0 -1
  569. package/dist/tools/index.d.ts.map +0 -1
  570. package/dist/tools/types.d.cts.map +0 -1
  571. package/dist/tools/types.d.ts.map +0 -1
  572. package/dist/tools/utils.d.cts.map +0 -1
  573. package/dist/tools/utils.d.ts.map +0 -1
  574. package/dist/tracers/base.d.cts.map +0 -1
  575. package/dist/tracers/base.d.ts.map +0 -1
  576. package/dist/tracers/console.d.cts.map +0 -1
  577. package/dist/tracers/console.d.ts.map +0 -1
  578. package/dist/tracers/event_stream.d.cts.map +0 -1
  579. package/dist/tracers/event_stream.d.ts.map +0 -1
  580. package/dist/tracers/log_stream.d.cts.map +0 -1
  581. package/dist/tracers/log_stream.d.ts.map +0 -1
  582. package/dist/tracers/run_collector.d.cts.map +0 -1
  583. package/dist/tracers/run_collector.d.ts.map +0 -1
  584. package/dist/tracers/tracer_langchain.d.cts.map +0 -1
  585. package/dist/tracers/tracer_langchain.d.ts.map +0 -1
  586. package/dist/types/_internal.d.cts.map +0 -1
  587. package/dist/types/_internal.d.ts.map +0 -1
  588. package/dist/types/type-utils.d.cts.map +0 -1
  589. package/dist/types/type-utils.d.ts.map +0 -1
  590. package/dist/utils/async_caller.d.cts.map +0 -1
  591. package/dist/utils/async_caller.d.ts.map +0 -1
  592. package/dist/utils/chunk_array.d.cts.map +0 -1
  593. package/dist/utils/chunk_array.d.ts.map +0 -1
  594. package/dist/utils/env.d.cts.map +0 -1
  595. package/dist/utils/env.d.ts.map +0 -1
  596. package/dist/utils/event_source_parse.d.cts.map +0 -1
  597. package/dist/utils/event_source_parse.d.ts.map +0 -1
  598. package/dist/utils/fast-json-patch/src/core.d.cts.map +0 -1
  599. package/dist/utils/fast-json-patch/src/core.d.ts.map +0 -1
  600. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +0 -1
  601. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +0 -1
  602. package/dist/utils/format.d.cts.map +0 -1
  603. package/dist/utils/format.d.ts.map +0 -1
  604. package/dist/utils/function_calling.d.cts.map +0 -1
  605. package/dist/utils/function_calling.d.ts.map +0 -1
  606. package/dist/utils/hash.d.cts.map +0 -1
  607. package/dist/utils/hash.d.ts.map +0 -1
  608. package/dist/utils/js-sha256/hash.d.cts.map +0 -1
  609. package/dist/utils/js-sha256/hash.d.ts.map +0 -1
  610. package/dist/utils/json.d.cts.map +0 -1
  611. package/dist/utils/json.d.ts.map +0 -1
  612. package/dist/utils/json_schema.d.cts.map +0 -1
  613. package/dist/utils/json_schema.d.ts.map +0 -1
  614. package/dist/utils/math.d.cts.map +0 -1
  615. package/dist/utils/math.d.ts.map +0 -1
  616. package/dist/utils/ml-distance/similarities.d.cts.map +0 -1
  617. package/dist/utils/ml-distance/similarities.d.ts.map +0 -1
  618. package/dist/utils/stream.d.cts.map +0 -1
  619. package/dist/utils/stream.d.ts.map +0 -1
  620. package/dist/utils/testing/chat_models.d.cts.map +0 -1
  621. package/dist/utils/testing/chat_models.d.ts.map +0 -1
  622. package/dist/utils/testing/embeddings.d.cts.map +0 -1
  623. package/dist/utils/testing/embeddings.d.ts.map +0 -1
  624. package/dist/utils/testing/llms.d.cts.map +0 -1
  625. package/dist/utils/testing/llms.d.ts.map +0 -1
  626. package/dist/utils/testing/message_history.d.cts.map +0 -1
  627. package/dist/utils/testing/message_history.d.ts.map +0 -1
  628. package/dist/utils/testing/output_parsers.d.cts.map +0 -1
  629. package/dist/utils/testing/output_parsers.d.ts.map +0 -1
  630. package/dist/utils/testing/retrievers.d.cts.map +0 -1
  631. package/dist/utils/testing/retrievers.d.ts.map +0 -1
  632. package/dist/utils/testing/runnables.d.cts.map +0 -1
  633. package/dist/utils/testing/runnables.d.ts.map +0 -1
  634. package/dist/utils/testing/tools.d.cts.map +0 -1
  635. package/dist/utils/testing/tools.d.ts.map +0 -1
  636. package/dist/utils/testing/tracers.d.cts.map +0 -1
  637. package/dist/utils/testing/tracers.d.ts.map +0 -1
  638. package/dist/utils/testing/vectorstores.d.cts.map +0 -1
  639. package/dist/utils/testing/vectorstores.d.ts.map +0 -1
  640. package/dist/utils/tiktoken.d.cts.map +0 -1
  641. package/dist/utils/tiktoken.d.ts.map +0 -1
  642. package/dist/utils/types/index.d.cts.map +0 -1
  643. package/dist/utils/types/index.d.ts.map +0 -1
  644. package/dist/utils/types/zod.d.cts.map +0 -1
  645. package/dist/utils/types/zod.d.ts.map +0 -1
  646. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +0 -1
  647. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +0 -1
  648. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +0 -1
  649. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +0 -1
  650. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +0 -1
  651. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +0 -1
  652. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +0 -1
  653. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +0 -1
  654. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +0 -1
  655. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +0 -1
  656. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +0 -1
  657. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +0 -1
  658. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +0 -1
  659. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +0 -1
  660. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +0 -1
  661. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +0 -1
  662. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +0 -1
  663. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +0 -1
  664. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +0 -1
  665. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +0 -1
  666. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +0 -1
  667. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +0 -1
  668. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +0 -1
  669. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +0 -1
  670. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +0 -1
  671. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +0 -1
  672. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +0 -1
  673. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +0 -1
  674. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +0 -1
  675. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +0 -1
  676. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +0 -1
  677. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +0 -1
  678. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +0 -1
  679. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +0 -1
  680. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +0 -1
  681. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +0 -1
  682. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +0 -1
  683. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +0 -1
  684. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +0 -1
  685. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +0 -1
  686. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +0 -1
  687. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +0 -1
  688. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +0 -1
  689. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +0 -1
  690. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +0 -1
  691. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +0 -1
  692. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +0 -1
  693. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +0 -1
  694. package/dist/vectorstores.d.cts.map +0 -1
  695. package/dist/vectorstores.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"async_caller.cjs","names":["error: any","params: AsyncCallerParams","PQueueMod","callable: T","options: AsyncCallerCallOptions","listener: (() => void) | undefined","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import pRetry from \"p-retry\";\nimport PQueueMod from \"p-queue\";\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 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: this.onFailedAttempt,\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,IAAI,OAAO;AACX,QAAM;CACP;AACF;;;;;;;;;;;;;;AAyCD,IAAa,cAAb,MAAyB;CACvB,AAAU;CAEV,AAAU;CAEV,AAAU;CAEV,AAAQ;CAER,YAAYC,QAA2B;EACrC,KAAK,iBAAiB,OAAO,kBAAkB;EAC/C,KAAK,aAAa,OAAO,cAAc;EACvC,KAAK,kBACH,OAAO,mBAAmB;EAE5B,MAAM,SACJ,aAAaC,kBAAYA,gBAAU,UAAUA;EAE/C,KAAK,QAAQ,IAAI,OAAO,EAAE,aAAa,KAAK,eAAgB;CAC7D;CAGD,KACEC,UACA,GAAG,MAC8B;AACjC,SAAO,KAAK,MAAM,IAChB,2BAEI,MACE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU;AAEjC,OAAI,iBAAiB,MACnB,OAAM;OAEN,OAAM,IAAI,MAAM;EAEnB,EAAC,EACJ;GACE,iBAAiB,KAAK;GACtB,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,OAAOC,mCAAoB,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.cjs","names":["error: any","params: AsyncCallerParams","PQueueMod","callable: T","options: AsyncCallerCallOptions","listener: (() => void) | undefined","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import pRetry from \"p-retry\";\nimport PQueueMod from \"p-queue\";\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 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;C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AAW,MAAM;KACf,OAAOC,mCAAoB,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"}
@@ -58,7 +58,7 @@ var AsyncCaller = class {
58
58
  if (error instanceof Error) throw error;
59
59
  else throw new Error(error);
60
60
  }), {
61
- onFailedAttempt: this.onFailedAttempt,
61
+ onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),
62
62
  retries: this.maxRetries,
63
63
  randomize: true
64
64
  }), { throwOnTimeout: true });
@@ -1 +1 @@
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 pRetry from \"p-retry\";\nimport PQueueMod from \"p-queue\";\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 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: this.onFailedAttempt,\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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AAoB,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 pRetry from \"p-retry\";\nimport PQueueMod from \"p-queue\";\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 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,IAAI,OAAO;AACX,QAAM;CACP;AACF;;;;;;;;;;;;;;AAyCD,IAAa,cAAb,MAAyB;CACvB,AAAU;CAEV,AAAU;CAEV,AAAU;CAEV,AAAQ;CAER,YAAYC,QAA2B;EACrC,KAAK,iBAAiB,OAAO,kBAAkB;EAC/C,KAAK,aAAa,OAAO,cAAc;EACvC,KAAK,kBACH,OAAO,mBAAmB;EAE5B,MAAM,SACJ,aAAa,YAAY,UAAU,UAAU;EAE/C,KAAK,QAAQ,IAAI,OAAO,EAAE,aAAa,KAAK,eAAgB;CAC7D;CAGD,KACEC,UACA,GAAG,MAC8B;AACjC,SAAO,KAAK,MAAM,IAChB,MACE,OACE,MACE,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,UAAU;AAEjC,OAAI,iBAAiB,MACnB,OAAM;OAEN,OAAM,IAAI,MAAM;EAEnB,EAAC,EACJ;GACE,iBAAiB,CAAC,EAAE,OAAO,KAAK,KAAK,kBAAkB,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"}
@@ -42,15 +42,6 @@ interface GetOperation<T> extends BaseOperation {
42
42
  interface PatchResult<T> extends Array<OperationResult<T>> {
43
43
  newDocument: T;
44
44
  }
45
- /**
46
- * Retrieves a value from a JSON document by a JSON pointer.
47
- * Returns the value.
48
- *
49
- * @param document The document to get the value from
50
- * @param pointer an escaped JSON pointer
51
- * @return The retrieved value
52
- */
53
-
54
45
  /**
55
46
  * Apply a full JSON Patch array on a JSON document.
56
47
  * Returns the {newDocument, result} of the patch.
@@ -66,15 +57,6 @@ interface PatchResult<T> extends Array<OperationResult<T>> {
66
57
  * @return An array of `{newDocument, result}` after the patch
67
58
  */
68
59
  declare function applyPatch<T>(document: T, patch: ReadonlyArray<Operation>, validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult<T>;
69
- /**
70
- * Apply a single JSON Patch Operation on a JSON document.
71
- * Returns the updated document.
72
- * Suitable as a reducer.
73
- *
74
- * @param document The document to patch
75
- * @param operation The operation to apply
76
- * @return The updated document
77
- */
78
60
  //#endregion
79
61
  export { Operation, applyPatch };
80
62
  //# sourceMappingURL=core.d.cts.map
@@ -42,15 +42,6 @@ interface GetOperation<T> extends BaseOperation {
42
42
  interface PatchResult<T> extends Array<OperationResult<T>> {
43
43
  newDocument: T;
44
44
  }
45
- /**
46
- * Retrieves a value from a JSON document by a JSON pointer.
47
- * Returns the value.
48
- *
49
- * @param document The document to get the value from
50
- * @param pointer an escaped JSON pointer
51
- * @return The retrieved value
52
- */
53
-
54
45
  /**
55
46
  * Apply a full JSON Patch array on a JSON document.
56
47
  * Returns the {newDocument, result} of the patch.
@@ -66,15 +57,6 @@ interface PatchResult<T> extends Array<OperationResult<T>> {
66
57
  * @return An array of `{newDocument, result}` after the patch
67
58
  */
68
59
  declare function applyPatch<T>(document: T, patch: ReadonlyArray<Operation>, validateOperation?: boolean | Validator<T>, mutateDocument?: boolean, banPrototypeModifications?: boolean): PatchResult<T>;
69
- /**
70
- * Apply a single JSON Patch Operation on a JSON document.
71
- * Returns the updated document.
72
- * Suitable as a reducer.
73
- *
74
- * @param document The document to patch
75
- * @param operation The operation to apply
76
- * @return The updated document
77
- */
78
60
  //#endregion
79
61
  export { Operation, applyPatch };
80
62
  //# sourceMappingURL=core.d.ts.map
@@ -22,11 +22,6 @@ declare function toJsonSchema(schema: InteropZodType | JsonSchema7Type): JsonSch
22
22
  * @returns `true` if the schema validates only strings, `false` otherwise.
23
23
  */
24
24
  declare function validatesOnlyStrings(schema: unknown): boolean;
25
- // Re-export of the types used throughout langchain for json schema serialization.
26
- // The plan is to eventually nix zod-to-json-schema altogether in place for
27
- // zod v4 / a more standardized way of serializing validated inputs, so its re-exported
28
- // here to remove the dependency on zod-to-json-schema in downstream packages until
29
- // a determination is made.
30
25
  //#endregion
31
26
  export { type JsonSchema7Type as JSONSchema, type JsonSchema7ArrayType, type JsonSchema7NullableType, type JsonSchema7NumberType, type JsonSchema7ObjectType, type JsonSchema7StringType, type JsonSchema7Type, Validator, deepCompareStrict, toJsonSchema, validatesOnlyStrings };
32
27
  //# sourceMappingURL=json_schema.d.cts.map
@@ -5,6 +5,7 @@ import { JsonSchema7StringType } from "./zod-to-json-schema/parsers/string.js";
5
5
  import { JsonSchema7NullableType } from "./zod-to-json-schema/parsers/nullable.js";
6
6
  import { JsonSchema7ObjectType } from "./zod-to-json-schema/parsers/object.js";
7
7
  import { JsonSchema7Type } from "./zod-to-json-schema/parseTypes.js";
8
+ import "./zod-to-json-schema/index.js";
8
9
  import { Validator, deepCompareStrict } from "@cfworker/json-schema";
9
10
 
10
11
  //#region src/utils/json_schema.d.ts
@@ -22,11 +23,6 @@ declare function toJsonSchema(schema: InteropZodType | JsonSchema7Type): JsonSch
22
23
  * @returns `true` if the schema validates only strings, `false` otherwise.
23
24
  */
24
25
  declare function validatesOnlyStrings(schema: unknown): boolean;
25
- // Re-export of the types used throughout langchain for json schema serialization.
26
- // The plan is to eventually nix zod-to-json-schema altogether in place for
27
- // zod v4 / a more standardized way of serializing validated inputs, so its re-exported
28
- // here to remove the dependency on zod-to-json-schema in downstream packages until
29
- // a determination is made.
30
26
  //#endregion
31
27
  export { type JsonSchema7Type as JSONSchema, type JsonSchema7ArrayType, type JsonSchema7NullableType, type JsonSchema7NumberType, type JsonSchema7ObjectType, type JsonSchema7StringType, type JsonSchema7Type, Validator, deepCompareStrict, toJsonSchema, validatesOnlyStrings };
32
28
  //# sourceMappingURL=json_schema.d.ts.map
@@ -0,0 +1,13 @@
1
+ //#region src/utils/signal.d.ts
2
+ /**
3
+ * Race a promise with an abort signal. If the signal is aborted, the promise will
4
+ * be rejected with the error from the signal. If the promise is rejected, the signal will be aborted.
5
+ *
6
+ * @param promise - The promise to race.
7
+ * @param signal - The abort signal.
8
+ * @returns The result of the promise.
9
+ */
10
+ declare function raceWithSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
11
+ //#endregion
12
+ export { raceWithSignal };
13
+ //# sourceMappingURL=signal.d.cts.map
@@ -0,0 +1,13 @@
1
+ //#region src/utils/signal.d.ts
2
+ /**
3
+ * Race a promise with an abort signal. If the signal is aborted, the promise will
4
+ * be rejected with the error from the signal. If the promise is rejected, the signal will be aborted.
5
+ *
6
+ * @param promise - The promise to race.
7
+ * @param signal - The abort signal.
8
+ * @returns The result of the promise.
9
+ */
10
+ declare function raceWithSignal<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
11
+ //#endregion
12
+ export { raceWithSignal };
13
+ //# sourceMappingURL=signal.d.ts.map
@@ -6,6 +6,7 @@ import { InteropZodType } from "../types/zod.js";
6
6
  import { CallbackManagerForLLMRun } from "../../callbacks/manager.js";
7
7
  import { Runnable } from "../../runnables/base.js";
8
8
  import { BaseLanguageModelInput, StructuredOutputMethodOptions, StructuredOutputMethodParams } from "../../language_models/base.js";
9
+ import "../../messages/index.js";
9
10
  import { StructuredTool } from "../../tools/index.js";
10
11
  import { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams } from "../../language_models/chat_models.js";
11
12
  import { BaseLLMParams } from "../../language_models/llms.js";
@@ -1,5 +1,6 @@
1
1
  import { BaseMessage } from "../../messages/base.js";
2
2
  import { BaseTracer, Run } from "../../tracers/base.js";
3
+ import "../../messages/index.js";
3
4
  import { BaseChatMessageHistory, BaseListChatMessageHistory } from "../../chat_history.js";
4
5
 
5
6
  //#region src/utils/testing/message_history.d.ts
@@ -17,6 +17,7 @@ require_rolldown_runtime.__export(types_exports, {
17
17
  interopZodObjectPassthrough: () => require_zod.interopZodObjectPassthrough,
18
18
  interopZodObjectStrict: () => require_zod.interopZodObjectStrict,
19
19
  interopZodTransformInputSchema: () => require_zod.interopZodTransformInputSchema,
20
+ isInteropZodError: () => require_zod.isInteropZodError,
20
21
  isInteropZodLiteral: () => require_zod.isInteropZodLiteral,
21
22
  isInteropZodObject: () => require_zod.isInteropZodObject,
22
23
  isInteropZodSchema: () => require_zod.isInteropZodSchema,
@@ -46,6 +47,7 @@ exports.interopZodObjectPartial = require_zod.interopZodObjectPartial;
46
47
  exports.interopZodObjectPassthrough = require_zod.interopZodObjectPassthrough;
47
48
  exports.interopZodObjectStrict = require_zod.interopZodObjectStrict;
48
49
  exports.interopZodTransformInputSchema = require_zod.interopZodTransformInputSchema;
50
+ exports.isInteropZodError = require_zod.isInteropZodError;
49
51
  exports.isInteropZodLiteral = require_zod.isInteropZodLiteral;
50
52
  exports.isInteropZodObject = require_zod.isInteropZodObject;
51
53
  exports.isInteropZodSchema = require_zod.isInteropZodSchema;
@@ -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, 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, 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";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
 
@@ -12,5 +12,5 @@ type PartialValues<K extends string = string> = Record<K, string | (() => Promis
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  type ChainValues = Record<string, any>;
14
14
  //#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, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
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 };
16
16
  //# 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, 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, 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";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
 
@@ -12,5 +12,5 @@ type PartialValues<K extends string = string> = Record<K, string | (() => Promis
12
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
13
  type ChainValues = Record<string, any>;
14
14
  //#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, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
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 };
16
16
  //# 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, 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, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
3
3
 
4
4
  //#region src/utils/types/index.ts
5
5
  var types_exports = {};
@@ -17,6 +17,7 @@ __export(types_exports, {
17
17
  interopZodObjectPassthrough: () => interopZodObjectPassthrough,
18
18
  interopZodObjectStrict: () => interopZodObjectStrict,
19
19
  interopZodTransformInputSchema: () => interopZodTransformInputSchema,
20
+ isInteropZodError: () => isInteropZodError,
20
21
  isInteropZodLiteral: () => isInteropZodLiteral,
21
22
  isInteropZodObject: () => isInteropZodObject,
22
23
  isInteropZodSchema: () => isInteropZodSchema,
@@ -33,5 +34,5 @@ __export(types_exports, {
33
34
  });
34
35
 
35
36
  //#endregion
36
- export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4, types_exports };
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 };
37
38
  //# sourceMappingURL=index.js.map
@@ -476,6 +476,9 @@ function interopZodObjectMakeFieldsOptional(schema, predicate) {
476
476
  }
477
477
  throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
478
478
  }
479
+ function isInteropZodError(e) {
480
+ return e instanceof Error && (e.constructor.name === "ZodError" || e.constructor.name === "$ZodError");
481
+ }
479
482
 
480
483
  //#endregion
481
484
  exports.extendInteropZodObject = extendInteropZodObject;
@@ -491,6 +494,7 @@ exports.interopZodObjectPartial = interopZodObjectPartial;
491
494
  exports.interopZodObjectPassthrough = interopZodObjectPassthrough;
492
495
  exports.interopZodObjectStrict = interopZodObjectStrict;
493
496
  exports.interopZodTransformInputSchema = interopZodTransformInputSchema;
497
+ exports.isInteropZodError = isInteropZodError;
494
498
  exports.isInteropZodLiteral = isInteropZodLiteral;
495
499
  exports.isInteropZodObject = isInteropZodObject;
496
500
  exports.isInteropZodSchema = isInteropZodSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"zod.cjs","names":["schema: unknown","schema: z3.ZodType<RunOutput> | Record<string, unknown>","input: unknown","obj: unknown","schema: InteropZodType<T>","schema: InteropZodType<unknown> | Record<string, unknown>","globalRegistry","schema: T","extension: InteropZodObjectShape","util","$ZodOptional","outputShape: Mutable<z4.$ZodShape>","meta","$ZodNever","$ZodUnknown","schema: InteropZodType","recursive: boolean","cache: WeakMap<InteropZodType, InteropZodType>","outputSchema: InteropZodType","predicate: (key: string, value: InteropZodType) => boolean","modifiedShape: Record<string, z3.ZodTypeAny>"],"sources":["../../../src/utils/types/zod.ts"],"sourcesContent":["import type * as z3 from \"zod/v3\";\nimport type * as z4 from \"zod/v4/core\";\nimport {\n parse,\n parseAsync,\n globalRegistry,\n util,\n clone,\n _unknown,\n _never,\n $ZodUnknown,\n $ZodNever,\n $ZodOptional,\n} from \"zod/v4/core\";\n\nexport type ZodStringV3 = z3.ZodString;\n\nexport type ZodStringV4 = z4.$ZodType<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ZodObjectV3 = z3.ZodObject<any, any, any, any>;\n\nexport type ZodObjectV4 = z4.$ZodObject;\n\nexport type ZodDefaultV3<T extends z3.ZodTypeAny> = z3.ZodDefault<T>;\nexport type ZodDefaultV4<T extends z4.SomeType> = z4.$ZodDefault<T>;\nexport type ZodOptionalV3<T extends z3.ZodTypeAny> = z3.ZodOptional<T>;\nexport type ZodOptionalV4<T extends z4.SomeType> = z4.$ZodOptional<T>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type InteropZodType<Output = any, Input = Output> =\n | z3.ZodType<Output, z3.ZodTypeDef, Input>\n | z4.$ZodType<Output, Input>;\n\nexport type InteropZodObject = ZodObjectV3 | ZodObjectV4;\nexport type InteropZodDefault<T = InteropZodObjectShape> =\n T extends z3.ZodTypeAny\n ? ZodDefaultV3<T>\n : T extends z4.SomeType\n ? ZodDefaultV4<T>\n : never;\nexport type InteropZodOptional<T = InteropZodObjectShape> =\n T extends z3.ZodTypeAny\n ? ZodOptionalV3<T>\n : T extends z4.SomeType\n ? ZodOptionalV4<T>\n : never;\n\nexport type InteropZodObjectShape<\n T extends InteropZodObject = InteropZodObject\n> = T extends z3.ZodObject<infer Shape>\n ? { [K in keyof Shape]: Shape[K] }\n : T extends z4.$ZodObject<infer Shape>\n ? { [K in keyof Shape]: Shape[K] }\n : never;\n\nexport type InteropZodIssue = z3.ZodIssue | z4.$ZodIssue;\n\n// Simplified type inference to avoid circular dependencies\nexport type InferInteropZodInput<T> = T extends z3.ZodType<\n unknown,\n z3.ZodTypeDef,\n infer Input\n>\n ? Input\n : T extends z4.$ZodType<unknown, infer Input>\n ? Input\n : T extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\nexport type InferInteropZodOutput<T> = T extends z3.ZodType<\n infer Output,\n z3.ZodTypeDef,\n unknown\n>\n ? Output\n : T extends z4.$ZodType<infer Output, unknown>\n ? Output\n : T extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nexport function isZodSchemaV4(\n schema: unknown\n): schema is z4.$ZodType<unknown, unknown> {\n if (typeof schema !== \"object\" || schema === null) {\n return false;\n }\n\n const obj = schema as Record<string, unknown>;\n if (!(\"_zod\" in obj)) {\n return false;\n }\n\n const zod = obj._zod;\n return (\n typeof zod === \"object\" &&\n zod !== null &&\n \"def\" in (zod as Record<string, unknown>)\n );\n}\n\nexport function isZodSchemaV3(\n schema: unknown\n): schema is z3.ZodType<unknown, z3.ZodTypeDef, unknown> {\n if (typeof schema !== \"object\" || schema === null) {\n return false;\n }\n\n const obj = schema as Record<string, unknown>;\n if (!(\"_def\" in obj) || \"_zod\" in obj) {\n return false;\n }\n\n const def = obj._def;\n return (\n typeof def === \"object\" &&\n def != null &&\n \"typeName\" in (def as Record<string, unknown>)\n );\n}\n\n/** Backward compatible isZodSchema for Zod 3 */\nexport function isZodSchema<\n RunOutput extends Record<string, unknown> = Record<string, unknown>\n>(\n schema: z3.ZodType<RunOutput> | Record<string, unknown>\n): schema is z3.ZodType<RunOutput> {\n if (isZodSchemaV4(schema)) {\n console.warn(\n \"[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior.\"\n );\n }\n return isZodSchemaV3(schema);\n}\n\n/**\n * Given either a Zod schema, or plain object, determine if the input is a Zod schema.\n *\n * @param {unknown} input\n * @returns {boolean} Whether or not the provided input is a Zod schema.\n */\nexport function isInteropZodSchema(input: unknown): input is InteropZodType {\n if (!input) {\n return false;\n }\n if (typeof input !== \"object\") {\n return false;\n }\n if (Array.isArray(input)) {\n return false;\n }\n if (\n isZodSchemaV4(input) ||\n isZodSchemaV3(input as z3.ZodType<Record<string, unknown>>)\n ) {\n return true;\n }\n return false;\n}\n\nexport type InteropZodLiteral = z3.ZodLiteral<unknown> | z4.$ZodLiteral;\n\nexport function isZodLiteralV3(obj: unknown): obj is z3.ZodLiteral<unknown> {\n // Zod v3 literal schemas have _def.typeName === \"ZodLiteral\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_def\" in obj &&\n typeof obj._def === \"object\" &&\n obj._def !== null &&\n \"typeName\" in obj._def &&\n obj._def.typeName === \"ZodLiteral\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodLiteralV4(obj: unknown): obj is z4.$ZodLiteral {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 literal schemas have _zod.def.type === \"literal\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"literal\"\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Determines if the provided value is an InteropZodLiteral (Zod v3 or v4 literal schema).\n *\n * @param obj The value to check.\n * @returns {boolean} True if the value is a Zod v3 or v4 literal schema, false otherwise.\n */\nexport function isInteropZodLiteral(obj: unknown): obj is InteropZodLiteral {\n if (isZodLiteralV3(obj)) return true;\n if (isZodLiteralV4(obj)) return true;\n return false;\n}\n\ntype InteropZodSafeParseResult<T> = z3.SafeParseReturnType<T, T>;\n\n/**\n * Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns a safe parse result.\n * This function handles both Zod v3 and v4 schemas, returning a result object indicating success or failure.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {Promise<InteropZodSafeParseResult<T>>} A promise that resolves to a safe parse result object.\n * @throws {Error} If the schema is not a recognized Zod v3 or v4 schema.\n */\nexport async function interopSafeParseAsync<T>(\n schema: InteropZodType<T>,\n input: unknown\n): Promise<InteropZodSafeParseResult<T>> {\n if (isZodSchemaV4(schema)) {\n try {\n const data = await parseAsync(schema, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as z3.ZodError<T>,\n };\n }\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return await schema.safeParseAsync(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns the parsed value.\n * Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {Promise<T>} A promise that resolves to the parsed value.\n * @throws {Error} If parsing fails or the schema is not a recognized Zod v3 or v4 schema.\n */\nexport async function interopParseAsync<T>(\n schema: InteropZodType<T>,\n input: unknown\n): Promise<T> {\n if (isZodSchemaV4(schema)) {\n return await parseAsync(schema, input);\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return await schema.parseAsync(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Safely parses the input using the provided Zod schema (v3 or v4) and returns a result object\n * indicating success or failure. This function is compatible with both Zod v3 and v4 schemas.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {InteropZodSafeParseResult<T>} An object with either the parsed data (on success)\n * or the error (on failure).\n * @throws {Error} If the schema is not a recognized Zod v3 or v4 schema.\n */\nexport function interopSafeParse<T>(\n schema: InteropZodType<T>,\n input: unknown\n): InteropZodSafeParseResult<T> {\n if (isZodSchemaV4(schema)) {\n try {\n const data = parse(schema, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as z3.ZodError<T>,\n };\n }\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.safeParse(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Parses the input using the provided Zod schema (v3 or v4) and returns the parsed value.\n * Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {T} The parsed value.\n * @throws {Error} If parsing fails or the schema is not a recognized Zod v3 or v4 schema.\n */\nexport function interopParse<T>(schema: InteropZodType<T>, input: unknown): T {\n if (isZodSchemaV4(schema)) {\n return parse(schema, input);\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.parse(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Retrieves the description from a schema definition (v3, v4, or plain object), if available.\n *\n * @param {unknown} schema - The schema to extract the description from.\n * @returns {string | undefined} The description of the schema, or undefined if not present.\n */\nexport function getSchemaDescription(\n schema: InteropZodType<unknown> | Record<string, unknown>\n): string | undefined {\n if (isZodSchemaV4(schema)) {\n return globalRegistry.get(schema)?.description;\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.description as string | undefined;\n }\n if (\"description\" in schema && typeof schema.description === \"string\") {\n return schema.description;\n }\n return undefined;\n}\n\n/**\n * Determines if the provided Zod schema is \"shapeless\".\n * A shapeless schema is one that does not define any object shape,\n * such as ZodString, ZodNumber, ZodBoolean, ZodAny, etc.\n * For ZodObject, it must have no shape keys to be considered shapeless.\n * ZodRecord schemas are considered shapeless since they define dynamic\n * key-value mappings without fixed keys.\n *\n * @param schema The Zod schema to check.\n * @returns {boolean} True if the schema is shapeless, false otherwise.\n */\nexport function isShapelessZodSchema(schema: unknown): boolean {\n if (!isInteropZodSchema(schema)) {\n return false;\n }\n\n // Check for v3 schemas\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n // @ts-expect-error - zod v3 types are not compatible with zod v4 types\n const def = schema._def as { typeName?: string };\n\n // ZodObject is only shaped if it has actual shape keys\n if (def.typeName === \"ZodObject\") {\n const obj = schema as { shape?: Record<string, unknown> };\n return !obj.shape || Object.keys(obj.shape).length === 0;\n }\n\n // ZodRecord is shapeless (dynamic key-value mapping)\n if (def.typeName === \"ZodRecord\") {\n return true;\n }\n }\n\n // Check for v4 schemas\n if (isZodSchemaV4(schema)) {\n const def = schema._zod.def;\n\n // Object type is only shaped if it has actual shape keys\n if (def.type === \"object\") {\n const obj = schema as { shape?: Record<string, unknown> };\n return !obj.shape || Object.keys(obj.shape).length === 0;\n }\n\n // Record type is shapeless (dynamic key-value mapping)\n if (def.type === \"record\") {\n return true;\n }\n }\n\n // For other schemas, check if they have a `shape` property\n // If they don't have shape, they're likely shapeless\n if (typeof schema === \"object\" && schema !== null && !(\"shape\" in schema)) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Determines if the provided Zod schema should be treated as a simple string schema\n * that maps to DynamicTool. This aligns with the type-level constraint of\n * InteropZodType<string | undefined> which only matches basic string schemas.\n * If the provided schema is just z.string(), we can make the determination that\n * the tool is just a generic string tool that doesn't require any input validation.\n *\n * This function only returns true for basic ZodString schemas, including:\n * - Basic string schemas (z.string())\n * - String schemas with validations (z.string().min(1), z.string().email(), etc.)\n *\n * This function returns false for everything else, including:\n * - String schemas with defaults (z.string().default(\"value\"))\n * - Branded string schemas (z.string().brand<\"UserId\">())\n * - String schemas with catch operations (z.string().catch(\"default\"))\n * - Optional/nullable string schemas (z.string().optional())\n * - Transformed schemas (z.string().transform() or z.object().transform())\n * - Object or record schemas, even if they're empty\n * - Any other schema type\n *\n * @param schema The Zod schema to check.\n * @returns {boolean} True if the schema is a basic ZodString, false otherwise.\n */\nexport function isSimpleStringZodSchema(\n schema: unknown\n): schema is InteropZodType<string | undefined> {\n if (!isInteropZodSchema(schema)) {\n return false;\n }\n\n // For v3 schemas\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n // @ts-expect-error - zod v3 types are not compatible with zod v4 types\n const def = schema._def as { typeName?: string };\n\n // Only accept basic ZodString\n return def.typeName === \"ZodString\";\n }\n\n // For v4 schemas\n if (isZodSchemaV4(schema)) {\n const def = schema._zod.def;\n\n // Only accept basic string type\n return def.type === \"string\";\n }\n\n return false;\n}\n\nexport function isZodObjectV3(obj: unknown): obj is ZodObjectV3 {\n // Zod v3 object schemas have _def.typeName === \"ZodObject\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_def\" in obj &&\n typeof obj._def === \"object\" &&\n obj._def !== null &&\n \"typeName\" in obj._def &&\n obj._def.typeName === \"ZodObject\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodObjectV4(obj: unknown): obj is z4.$ZodObject {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 object schemas have _zod.def.type === \"object\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"object\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodArrayV4(obj: unknown): obj is z4.$ZodArray {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 array schemas have _zod.def.type === \"array\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"array\"\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).\n *\n * @param obj The value to check.\n * @returns {boolean} True if the value is a Zod v3 or v4 object schema, false otherwise.\n */\nexport function isInteropZodObject(obj: unknown): obj is InteropZodObject {\n if (isZodObjectV3(obj)) return true;\n if (isZodObjectV4(obj)) return true;\n return false;\n}\n\n/**\n * Retrieves the shape (fields) of a Zod object schema, supporting both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @returns {InteropZodObjectShape<T>} The shape of the object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function getInteropZodObjectShape<T extends InteropZodObject>(\n schema: T\n): InteropZodObjectShape<T> {\n if (isZodSchemaV3(schema)) {\n return schema.shape;\n }\n if (isZodSchemaV4(schema)) {\n return schema._zod.def.shape as InteropZodObjectShape<T>;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Extends a Zod object schema with additional fields, supporting both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {InteropZodObjectShape} extension - The fields to add to the schema.\n * @returns {InteropZodObject} The extended Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function extendInteropZodObject<T extends InteropZodObject>(\n schema: T,\n extension: InteropZodObjectShape\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n return schema.extend(extension as z3.ZodRawShape);\n }\n if (isZodSchemaV4(schema)) {\n return util.extend(schema, extension);\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a partial version of a Zod object schema, making all fields optional.\n * Supports both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @returns {InteropZodObject} The partial Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectPartial<T extends InteropZodObject>(\n schema: T\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n // z3: .partial() exists and works as expected\n return schema.partial();\n }\n if (isZodSchemaV4(schema)) {\n // z4: util.partial exists and works as expected\n return util.partial($ZodOptional, schema, undefined);\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a strict version of a Zod object schema, disallowing unknown keys.\n * Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies strictness\n * recursively to all nested object schemas and arrays of object schemas.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {boolean} [recursive=false] - Whether to apply strictness recursively to nested objects/arrays.\n * @returns {InteropZodObject} The strict Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectStrict<T extends InteropZodObject>(\n schema: T,\n recursive = false\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema.strict();\n }\n if (isZodObjectV4(schema)) {\n const outputShape: Mutable<z4.$ZodShape> = schema._zod.def.shape;\n if (recursive) {\n for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {\n // If the shape key is a v4 object schema, we need to make it strict\n if (isZodObjectV4(keySchema)) {\n const outputSchema = interopZodObjectStrict(keySchema, recursive);\n outputShape[key] = outputSchema as ZodObjectV4;\n }\n // If the shape key is a v4 array schema, we need to make the element\n // schema strict if it's an object schema\n else if (isZodArrayV4(keySchema)) {\n let elementSchema = keySchema._zod.def.element;\n if (isZodObjectV4(elementSchema)) {\n elementSchema = interopZodObjectStrict(\n elementSchema,\n recursive\n ) as ZodObjectV4;\n }\n outputShape[key] = clone(keySchema, {\n ...keySchema._zod.def,\n element: elementSchema,\n });\n }\n // Otherwise, just use the keySchema\n else {\n outputShape[key] = keySchema;\n }\n // Assign meta fields to the keySchema\n const meta = globalRegistry.get(keySchema);\n if (meta) globalRegistry.add(outputShape[key], meta);\n }\n }\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _never($ZodNever),\n });\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a passthrough version of a Zod object schema, allowing unknown keys.\n * Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies passthrough\n * recursively to all nested object schemas and arrays of object schemas.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {boolean} [recursive=false] - Whether to apply passthrough recursively to nested objects/arrays.\n * @returns {InteropZodObject} The passthrough Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectPassthrough<T extends InteropZodObject>(\n schema: T,\n recursive = false\n): InteropZodObject {\n if (isZodObjectV3(schema)) {\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema.passthrough();\n }\n if (isZodObjectV4(schema)) {\n const outputShape: Mutable<z4.$ZodShape> = schema._zod.def.shape;\n if (recursive) {\n for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {\n // If the shape key is a v4 object schema, we need to make it passthrough\n if (isZodObjectV4(keySchema)) {\n const outputSchema = interopZodObjectPassthrough(\n keySchema,\n recursive\n );\n outputShape[key] = outputSchema as ZodObjectV4;\n }\n // If the shape key is a v4 array schema, we need to make the element\n // schema passthrough if it's an object schema\n else if (isZodArrayV4(keySchema)) {\n let elementSchema = keySchema._zod.def.element;\n if (isZodObjectV4(elementSchema)) {\n elementSchema = interopZodObjectPassthrough(\n elementSchema,\n recursive\n ) as ZodObjectV4;\n }\n outputShape[key] = clone(keySchema, {\n ...keySchema._zod.def,\n element: elementSchema,\n });\n }\n // Otherwise, just use the keySchema\n else {\n outputShape[key] = keySchema;\n }\n // Assign meta fields to the keySchema\n const meta = globalRegistry.get(keySchema);\n if (meta) globalRegistry.add(outputShape[key], meta);\n }\n }\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _unknown($ZodUnknown),\n });\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a getter function for the default value of a Zod schema, if one is defined.\n * Supports both Zod v3 and v4 schemas. If the schema has a default value,\n * the returned function will return that value when called. If no default is defined,\n * returns undefined.\n *\n * @template T - The type of the Zod schema.\n * @param {T} schema - The Zod schema instance (either v3 or v4).\n * @returns {(() => InferInteropZodOutput<T>) | undefined} A function that returns the default value, or undefined if no default is set.\n */\nexport function getInteropZodDefaultGetter<T extends InteropZodType>(\n schema: T\n): (() => InferInteropZodOutput<T>) | undefined {\n if (isZodSchemaV3(schema)) {\n try {\n const defaultValue = schema.parse(undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n if (isZodSchemaV4(schema)) {\n try {\n const defaultValue = parse(schema, undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction isZodTransformV3(\n schema: InteropZodType\n): schema is z3.ZodEffects<z3.ZodTypeAny> {\n return (\n isZodSchemaV3(schema) &&\n \"typeName\" in schema._def &&\n schema._def.typeName === \"ZodEffects\"\n );\n}\n\nfunction isZodTransformV4(schema: InteropZodType): schema is z4.$ZodPipe {\n return isZodSchemaV4(schema) && schema._zod.def.type === \"pipe\";\n}\n\nfunction interopZodTransformInputSchemaImpl(\n schema: InteropZodType,\n recursive: boolean,\n cache: WeakMap<InteropZodType, InteropZodType>\n): InteropZodType {\n const cached = cache.get(schema);\n if (cached !== undefined) {\n return cached;\n }\n\n // Zod v3: ._def.schema is the input schema for ZodEffects (transform)\n if (isZodSchemaV3(schema)) {\n if (isZodTransformV3(schema)) {\n return interopZodTransformInputSchemaImpl(\n schema._def.schema,\n recursive,\n cache\n );\n }\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema;\n }\n\n // Zod v4: _def.type is the input schema for ZodEffects (transform)\n if (isZodSchemaV4(schema)) {\n let outputSchema: InteropZodType = schema;\n if (isZodTransformV4(schema)) {\n outputSchema = interopZodTransformInputSchemaImpl(\n schema._zod.def.in,\n recursive,\n cache\n );\n }\n if (recursive) {\n // Handle nested object schemas\n if (isZodObjectV4(outputSchema)) {\n const outputShape: Mutable<z4.$ZodShape> = outputSchema._zod.def.shape;\n for (const [key, keySchema] of Object.entries(\n outputSchema._zod.def.shape\n )) {\n outputShape[key] = interopZodTransformInputSchemaImpl(\n keySchema,\n recursive,\n cache\n ) as z4.$ZodType;\n }\n outputSchema = clone<ZodObjectV4>(outputSchema, {\n ...outputSchema._zod.def,\n shape: outputShape,\n });\n }\n // Handle nested array schemas\n else if (isZodArrayV4(outputSchema)) {\n const elementSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.element,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodArray>(outputSchema, {\n ...outputSchema._zod.def,\n element: elementSchema as z4.$ZodType,\n });\n }\n }\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(outputSchema as z4.$ZodType, meta);\n cache.set(schema, outputSchema);\n return outputSchema;\n }\n\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Returns the input type of a Zod transform schema, for both v3 and v4.\n * If the schema is not a transform, returns undefined. If `recursive` is true,\n * recursively processes nested object schemas and arrays of object schemas.\n *\n * @param schema - The Zod schema instance (v3 or v4)\n * @param {boolean} [recursive=false] - Whether to recursively process nested objects/arrays.\n * @returns The input Zod schema of the transform, or undefined if not a transform\n */\nexport function interopZodTransformInputSchema(\n schema: InteropZodType,\n recursive = false\n): InteropZodType {\n const cache = new WeakMap<InteropZodType, InteropZodType>();\n return interopZodTransformInputSchemaImpl(schema, recursive, cache);\n}\n\n/**\n * Creates a modified version of a Zod object schema where fields matching a predicate are made optional.\n * Supports both Zod v3 and v4 schemas and preserves the original schema version.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {(key: string, value: InteropZodType) => boolean} predicate - Function to determine which fields should be optional.\n * @returns {InteropZodObject} The modified Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectMakeFieldsOptional<T extends InteropZodObject>(\n schema: T,\n predicate: (key: string, value: InteropZodType) => boolean\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n const shape = getInteropZodObjectShape(schema);\n const modifiedShape: Record<string, z3.ZodTypeAny> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value)) {\n // Make this field optional using v3 methods\n modifiedShape[key] = (value as z3.ZodTypeAny).optional();\n } else {\n // Keep field as-is\n modifiedShape[key] = value;\n }\n }\n\n // Use v3's extend method to create a new schema with the modified shape\n return schema.extend(modifiedShape as z3.ZodRawShape);\n }\n\n if (isZodSchemaV4(schema)) {\n const shape = getInteropZodObjectShape(schema);\n const outputShape: Mutable<z4.$ZodShape> = { ...schema._zod.def.shape };\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value)) {\n // Make this field optional using v4 methods\n outputShape[key] = new $ZodOptional({\n type: \"optional\" as const,\n innerType: value as z4.$ZodType,\n });\n }\n // Otherwise keep the field as-is (already in outputShape)\n }\n\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n });\n\n // Preserve metadata\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n\n return modifiedSchema;\n }\n\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n"],"mappings":";;;;AAuFA,SAAgB,cACdA,QACyC;AACzC,KAAI,OAAO,WAAW,YAAY,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QAAQ,yBAAyB,OAAO;EAC9C,MAAMT,cAAqC,EAAE,GAAG,OAAO,KAAK,IAAI,MAAO;AAEvE,OAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,KAAK,MAAM,EAEvB,YAAY,OAAO,IAAID,yBAAa;GAClC,MAAM;GACN,WAAW;EACZ;EAKL,MAAM,wCAAoC,QAAQ;GAChD,GAAG,OAAO,KAAK;GACf,OAAO;EACR,EAAC;EAGF,MAAM,OAAOJ,2BAAe,IAAI,OAAO;AACvC,MAAI,MAAMA,2BAAe,IAAI,gBAAgB,KAAK;AAElD,SAAO;CACR;AAED,OAAM,IAAI,MACR;AAEH"}
1
+ {"version":3,"file":"zod.cjs","names":["schema: unknown","schema: z3.ZodType<RunOutput> | Record<string, unknown>","input: unknown","obj: unknown","schema: InteropZodType<T>","schema: InteropZodType<unknown> | Record<string, unknown>","globalRegistry","schema: T","extension: InteropZodObjectShape","util","$ZodOptional","outputShape: Mutable<z4.$ZodShape>","meta","$ZodNever","$ZodUnknown","schema: InteropZodType","recursive: boolean","cache: WeakMap<InteropZodType, InteropZodType>","outputSchema: InteropZodType","predicate: (key: string, value: InteropZodType) => boolean","modifiedShape: Record<string, z3.ZodTypeAny>","e: unknown"],"sources":["../../../src/utils/types/zod.ts"],"sourcesContent":["import type * as z3 from \"zod/v3\";\nimport type * as z4 from \"zod/v4/core\";\nimport {\n parse,\n parseAsync,\n globalRegistry,\n util,\n clone,\n _unknown,\n _never,\n $ZodUnknown,\n $ZodNever,\n $ZodOptional,\n} from \"zod/v4/core\";\n\nexport type ZodStringV3 = z3.ZodString;\n\nexport type ZodStringV4 = z4.$ZodType<string, unknown>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ZodObjectV3 = z3.ZodObject<any, any, any, any>;\n\nexport type ZodObjectV4 = z4.$ZodObject;\n\nexport type ZodDefaultV3<T extends z3.ZodTypeAny> = z3.ZodDefault<T>;\nexport type ZodDefaultV4<T extends z4.SomeType> = z4.$ZodDefault<T>;\nexport type ZodOptionalV3<T extends z3.ZodTypeAny> = z3.ZodOptional<T>;\nexport type ZodOptionalV4<T extends z4.SomeType> = z4.$ZodOptional<T>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type InteropZodType<Output = any, Input = Output> =\n | z3.ZodType<Output, z3.ZodTypeDef, Input>\n | z4.$ZodType<Output, Input>;\n\nexport type InteropZodObject = ZodObjectV3 | ZodObjectV4;\nexport type InteropZodDefault<T = InteropZodObjectShape> =\n T extends z3.ZodTypeAny\n ? ZodDefaultV3<T>\n : T extends z4.SomeType\n ? ZodDefaultV4<T>\n : never;\nexport type InteropZodOptional<T = InteropZodObjectShape> =\n T extends z3.ZodTypeAny\n ? ZodOptionalV3<T>\n : T extends z4.SomeType\n ? ZodOptionalV4<T>\n : never;\n\nexport type InteropZodObjectShape<\n T extends InteropZodObject = InteropZodObject\n> = T extends z3.ZodObject<infer Shape>\n ? { [K in keyof Shape]: Shape[K] }\n : T extends z4.$ZodObject<infer Shape>\n ? { [K in keyof Shape]: Shape[K] }\n : never;\n\nexport type InteropZodIssue = z3.ZodIssue | z4.$ZodIssue;\n\n// Simplified type inference to avoid circular dependencies\nexport type InferInteropZodInput<T> = T extends z3.ZodType<\n unknown,\n z3.ZodTypeDef,\n infer Input\n>\n ? Input\n : T extends z4.$ZodType<unknown, infer Input>\n ? Input\n : T extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\nexport type InferInteropZodOutput<T> = T extends z3.ZodType<\n infer Output,\n z3.ZodTypeDef,\n unknown\n>\n ? Output\n : T extends z4.$ZodType<infer Output, unknown>\n ? Output\n : T extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nexport function isZodSchemaV4(\n schema: unknown\n): schema is z4.$ZodType<unknown, unknown> {\n if (typeof schema !== \"object\" || schema === null) {\n return false;\n }\n\n const obj = schema as Record<string, unknown>;\n if (!(\"_zod\" in obj)) {\n return false;\n }\n\n const zod = obj._zod;\n return (\n typeof zod === \"object\" &&\n zod !== null &&\n \"def\" in (zod as Record<string, unknown>)\n );\n}\n\nexport function isZodSchemaV3(\n schema: unknown\n): schema is z3.ZodType<unknown, z3.ZodTypeDef, unknown> {\n if (typeof schema !== \"object\" || schema === null) {\n return false;\n }\n\n const obj = schema as Record<string, unknown>;\n if (!(\"_def\" in obj) || \"_zod\" in obj) {\n return false;\n }\n\n const def = obj._def;\n return (\n typeof def === \"object\" &&\n def != null &&\n \"typeName\" in (def as Record<string, unknown>)\n );\n}\n\n/** Backward compatible isZodSchema for Zod 3 */\nexport function isZodSchema<\n RunOutput extends Record<string, unknown> = Record<string, unknown>\n>(\n schema: z3.ZodType<RunOutput> | Record<string, unknown>\n): schema is z3.ZodType<RunOutput> {\n if (isZodSchemaV4(schema)) {\n console.warn(\n \"[WARNING] Attempting to use Zod 4 schema in a context where Zod 3 schema is expected. This may cause unexpected behavior.\"\n );\n }\n return isZodSchemaV3(schema);\n}\n\n/**\n * Given either a Zod schema, or plain object, determine if the input is a Zod schema.\n *\n * @param {unknown} input\n * @returns {boolean} Whether or not the provided input is a Zod schema.\n */\nexport function isInteropZodSchema(input: unknown): input is InteropZodType {\n if (!input) {\n return false;\n }\n if (typeof input !== \"object\") {\n return false;\n }\n if (Array.isArray(input)) {\n return false;\n }\n if (\n isZodSchemaV4(input) ||\n isZodSchemaV3(input as z3.ZodType<Record<string, unknown>>)\n ) {\n return true;\n }\n return false;\n}\n\nexport type InteropZodLiteral = z3.ZodLiteral<unknown> | z4.$ZodLiteral;\n\nexport function isZodLiteralV3(obj: unknown): obj is z3.ZodLiteral<unknown> {\n // Zod v3 literal schemas have _def.typeName === \"ZodLiteral\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_def\" in obj &&\n typeof obj._def === \"object\" &&\n obj._def !== null &&\n \"typeName\" in obj._def &&\n obj._def.typeName === \"ZodLiteral\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodLiteralV4(obj: unknown): obj is z4.$ZodLiteral {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 literal schemas have _zod.def.type === \"literal\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"literal\"\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Determines if the provided value is an InteropZodLiteral (Zod v3 or v4 literal schema).\n *\n * @param obj The value to check.\n * @returns {boolean} True if the value is a Zod v3 or v4 literal schema, false otherwise.\n */\nexport function isInteropZodLiteral(obj: unknown): obj is InteropZodLiteral {\n if (isZodLiteralV3(obj)) return true;\n if (isZodLiteralV4(obj)) return true;\n return false;\n}\n\ntype InteropZodSafeParseResult<T> = z3.SafeParseReturnType<T, T>;\n\n/**\n * Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns a safe parse result.\n * This function handles both Zod v3 and v4 schemas, returning a result object indicating success or failure.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {Promise<InteropZodSafeParseResult<T>>} A promise that resolves to a safe parse result object.\n * @throws {Error} If the schema is not a recognized Zod v3 or v4 schema.\n */\nexport async function interopSafeParseAsync<T>(\n schema: InteropZodType<T>,\n input: unknown\n): Promise<InteropZodSafeParseResult<T>> {\n if (isZodSchemaV4(schema)) {\n try {\n const data = await parseAsync(schema, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as z3.ZodError<T>,\n };\n }\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return await schema.safeParseAsync(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns the parsed value.\n * Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {Promise<T>} A promise that resolves to the parsed value.\n * @throws {Error} If parsing fails or the schema is not a recognized Zod v3 or v4 schema.\n */\nexport async function interopParseAsync<T>(\n schema: InteropZodType<T>,\n input: unknown\n): Promise<T> {\n if (isZodSchemaV4(schema)) {\n return await parseAsync(schema, input);\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return await schema.parseAsync(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Safely parses the input using the provided Zod schema (v3 or v4) and returns a result object\n * indicating success or failure. This function is compatible with both Zod v3 and v4 schemas.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {InteropZodSafeParseResult<T>} An object with either the parsed data (on success)\n * or the error (on failure).\n * @throws {Error} If the schema is not a recognized Zod v3 or v4 schema.\n */\nexport function interopSafeParse<T>(\n schema: InteropZodType<T>,\n input: unknown\n): InteropZodSafeParseResult<T> {\n if (isZodSchemaV4(schema)) {\n try {\n const data = parse(schema, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as z3.ZodError<T>,\n };\n }\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.safeParse(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Parses the input using the provided Zod schema (v3 or v4) and returns the parsed value.\n * Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.\n *\n * @template T - The expected output type of the schema.\n * @param {InteropZodType<T>} schema - The Zod schema (v3 or v4) to use for parsing.\n * @param {unknown} input - The input value to parse.\n * @returns {T} The parsed value.\n * @throws {Error} If parsing fails or the schema is not a recognized Zod v3 or v4 schema.\n */\nexport function interopParse<T>(schema: InteropZodType<T>, input: unknown): T {\n if (isZodSchemaV4(schema)) {\n return parse(schema, input);\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.parse(input);\n }\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Retrieves the description from a schema definition (v3, v4, or plain object), if available.\n *\n * @param {unknown} schema - The schema to extract the description from.\n * @returns {string | undefined} The description of the schema, or undefined if not present.\n */\nexport function getSchemaDescription(\n schema: InteropZodType<unknown> | Record<string, unknown>\n): string | undefined {\n if (isZodSchemaV4(schema)) {\n return globalRegistry.get(schema)?.description;\n }\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n return schema.description as string | undefined;\n }\n if (\"description\" in schema && typeof schema.description === \"string\") {\n return schema.description;\n }\n return undefined;\n}\n\n/**\n * Determines if the provided Zod schema is \"shapeless\".\n * A shapeless schema is one that does not define any object shape,\n * such as ZodString, ZodNumber, ZodBoolean, ZodAny, etc.\n * For ZodObject, it must have no shape keys to be considered shapeless.\n * ZodRecord schemas are considered shapeless since they define dynamic\n * key-value mappings without fixed keys.\n *\n * @param schema The Zod schema to check.\n * @returns {boolean} True if the schema is shapeless, false otherwise.\n */\nexport function isShapelessZodSchema(schema: unknown): boolean {\n if (!isInteropZodSchema(schema)) {\n return false;\n }\n\n // Check for v3 schemas\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n // @ts-expect-error - zod v3 types are not compatible with zod v4 types\n const def = schema._def as { typeName?: string };\n\n // ZodObject is only shaped if it has actual shape keys\n if (def.typeName === \"ZodObject\") {\n const obj = schema as { shape?: Record<string, unknown> };\n return !obj.shape || Object.keys(obj.shape).length === 0;\n }\n\n // ZodRecord is shapeless (dynamic key-value mapping)\n if (def.typeName === \"ZodRecord\") {\n return true;\n }\n }\n\n // Check for v4 schemas\n if (isZodSchemaV4(schema)) {\n const def = schema._zod.def;\n\n // Object type is only shaped if it has actual shape keys\n if (def.type === \"object\") {\n const obj = schema as { shape?: Record<string, unknown> };\n return !obj.shape || Object.keys(obj.shape).length === 0;\n }\n\n // Record type is shapeless (dynamic key-value mapping)\n if (def.type === \"record\") {\n return true;\n }\n }\n\n // For other schemas, check if they have a `shape` property\n // If they don't have shape, they're likely shapeless\n if (typeof schema === \"object\" && schema !== null && !(\"shape\" in schema)) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Determines if the provided Zod schema should be treated as a simple string schema\n * that maps to DynamicTool. This aligns with the type-level constraint of\n * InteropZodType<string | undefined> which only matches basic string schemas.\n * If the provided schema is just z.string(), we can make the determination that\n * the tool is just a generic string tool that doesn't require any input validation.\n *\n * This function only returns true for basic ZodString schemas, including:\n * - Basic string schemas (z.string())\n * - String schemas with validations (z.string().min(1), z.string().email(), etc.)\n *\n * This function returns false for everything else, including:\n * - String schemas with defaults (z.string().default(\"value\"))\n * - Branded string schemas (z.string().brand<\"UserId\">())\n * - String schemas with catch operations (z.string().catch(\"default\"))\n * - Optional/nullable string schemas (z.string().optional())\n * - Transformed schemas (z.string().transform() or z.object().transform())\n * - Object or record schemas, even if they're empty\n * - Any other schema type\n *\n * @param schema The Zod schema to check.\n * @returns {boolean} True if the schema is a basic ZodString, false otherwise.\n */\nexport function isSimpleStringZodSchema(\n schema: unknown\n): schema is InteropZodType<string | undefined> {\n if (!isInteropZodSchema(schema)) {\n return false;\n }\n\n // For v3 schemas\n if (isZodSchemaV3(schema as z3.ZodType<Record<string, unknown>>)) {\n // @ts-expect-error - zod v3 types are not compatible with zod v4 types\n const def = schema._def as { typeName?: string };\n\n // Only accept basic ZodString\n return def.typeName === \"ZodString\";\n }\n\n // For v4 schemas\n if (isZodSchemaV4(schema)) {\n const def = schema._zod.def;\n\n // Only accept basic string type\n return def.type === \"string\";\n }\n\n return false;\n}\n\nexport function isZodObjectV3(obj: unknown): obj is ZodObjectV3 {\n // Zod v3 object schemas have _def.typeName === \"ZodObject\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_def\" in obj &&\n typeof obj._def === \"object\" &&\n obj._def !== null &&\n \"typeName\" in obj._def &&\n obj._def.typeName === \"ZodObject\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodObjectV4(obj: unknown): obj is z4.$ZodObject {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 object schemas have _zod.def.type === \"object\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"object\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodArrayV4(obj: unknown): obj is z4.$ZodArray {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 array schemas have _zod.def.type === \"array\"\n if (\n typeof obj === \"object\" &&\n obj !== null &&\n \"_zod\" in obj &&\n typeof obj._zod === \"object\" &&\n obj._zod !== null &&\n \"def\" in obj._zod &&\n typeof obj._zod.def === \"object\" &&\n obj._zod.def !== null &&\n \"type\" in obj._zod.def &&\n obj._zod.def.type === \"array\"\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).\n *\n * @param obj The value to check.\n * @returns {boolean} True if the value is a Zod v3 or v4 object schema, false otherwise.\n */\nexport function isInteropZodObject(obj: unknown): obj is InteropZodObject {\n if (isZodObjectV3(obj)) return true;\n if (isZodObjectV4(obj)) return true;\n return false;\n}\n\n/**\n * Retrieves the shape (fields) of a Zod object schema, supporting both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @returns {InteropZodObjectShape<T>} The shape of the object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function getInteropZodObjectShape<T extends InteropZodObject>(\n schema: T\n): InteropZodObjectShape<T> {\n if (isZodSchemaV3(schema)) {\n return schema.shape;\n }\n if (isZodSchemaV4(schema)) {\n return schema._zod.def.shape as InteropZodObjectShape<T>;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Extends a Zod object schema with additional fields, supporting both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {InteropZodObjectShape} extension - The fields to add to the schema.\n * @returns {InteropZodObject} The extended Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function extendInteropZodObject<T extends InteropZodObject>(\n schema: T,\n extension: InteropZodObjectShape\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n return schema.extend(extension as z3.ZodRawShape);\n }\n if (isZodSchemaV4(schema)) {\n return util.extend(schema, extension);\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a partial version of a Zod object schema, making all fields optional.\n * Supports both Zod v3 and v4.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @returns {InteropZodObject} The partial Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectPartial<T extends InteropZodObject>(\n schema: T\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n // z3: .partial() exists and works as expected\n return schema.partial();\n }\n if (isZodSchemaV4(schema)) {\n // z4: util.partial exists and works as expected\n return util.partial($ZodOptional, schema, undefined);\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a strict version of a Zod object schema, disallowing unknown keys.\n * Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies strictness\n * recursively to all nested object schemas and arrays of object schemas.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {boolean} [recursive=false] - Whether to apply strictness recursively to nested objects/arrays.\n * @returns {InteropZodObject} The strict Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectStrict<T extends InteropZodObject>(\n schema: T,\n recursive = false\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema.strict();\n }\n if (isZodObjectV4(schema)) {\n const outputShape: Mutable<z4.$ZodShape> = schema._zod.def.shape;\n if (recursive) {\n for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {\n // If the shape key is a v4 object schema, we need to make it strict\n if (isZodObjectV4(keySchema)) {\n const outputSchema = interopZodObjectStrict(keySchema, recursive);\n outputShape[key] = outputSchema as ZodObjectV4;\n }\n // If the shape key is a v4 array schema, we need to make the element\n // schema strict if it's an object schema\n else if (isZodArrayV4(keySchema)) {\n let elementSchema = keySchema._zod.def.element;\n if (isZodObjectV4(elementSchema)) {\n elementSchema = interopZodObjectStrict(\n elementSchema,\n recursive\n ) as ZodObjectV4;\n }\n outputShape[key] = clone(keySchema, {\n ...keySchema._zod.def,\n element: elementSchema,\n });\n }\n // Otherwise, just use the keySchema\n else {\n outputShape[key] = keySchema;\n }\n // Assign meta fields to the keySchema\n const meta = globalRegistry.get(keySchema);\n if (meta) globalRegistry.add(outputShape[key], meta);\n }\n }\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _never($ZodNever),\n });\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a passthrough version of a Zod object schema, allowing unknown keys.\n * Supports both Zod v3 and v4 object schemas. If `recursive` is true, applies passthrough\n * recursively to all nested object schemas and arrays of object schemas.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {boolean} [recursive=false] - Whether to apply passthrough recursively to nested objects/arrays.\n * @returns {InteropZodObject} The passthrough Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectPassthrough<T extends InteropZodObject>(\n schema: T,\n recursive = false\n): InteropZodObject {\n if (isZodObjectV3(schema)) {\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema.passthrough();\n }\n if (isZodObjectV4(schema)) {\n const outputShape: Mutable<z4.$ZodShape> = schema._zod.def.shape;\n if (recursive) {\n for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {\n // If the shape key is a v4 object schema, we need to make it passthrough\n if (isZodObjectV4(keySchema)) {\n const outputSchema = interopZodObjectPassthrough(\n keySchema,\n recursive\n );\n outputShape[key] = outputSchema as ZodObjectV4;\n }\n // If the shape key is a v4 array schema, we need to make the element\n // schema passthrough if it's an object schema\n else if (isZodArrayV4(keySchema)) {\n let elementSchema = keySchema._zod.def.element;\n if (isZodObjectV4(elementSchema)) {\n elementSchema = interopZodObjectPassthrough(\n elementSchema,\n recursive\n ) as ZodObjectV4;\n }\n outputShape[key] = clone(keySchema, {\n ...keySchema._zod.def,\n element: elementSchema,\n });\n }\n // Otherwise, just use the keySchema\n else {\n outputShape[key] = keySchema;\n }\n // Assign meta fields to the keySchema\n const meta = globalRegistry.get(keySchema);\n if (meta) globalRegistry.add(outputShape[key], meta);\n }\n }\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _unknown($ZodUnknown),\n });\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema;\n }\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\n/**\n * Returns a getter function for the default value of a Zod schema, if one is defined.\n * Supports both Zod v3 and v4 schemas. If the schema has a default value,\n * the returned function will return that value when called. If no default is defined,\n * returns undefined.\n *\n * @template T - The type of the Zod schema.\n * @param {T} schema - The Zod schema instance (either v3 or v4).\n * @returns {(() => InferInteropZodOutput<T>) | undefined} A function that returns the default value, or undefined if no default is set.\n */\nexport function getInteropZodDefaultGetter<T extends InteropZodType>(\n schema: T\n): (() => InferInteropZodOutput<T>) | undefined {\n if (isZodSchemaV3(schema)) {\n try {\n const defaultValue = schema.parse(undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n if (isZodSchemaV4(schema)) {\n try {\n const defaultValue = parse(schema, undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction isZodTransformV3(\n schema: InteropZodType\n): schema is z3.ZodEffects<z3.ZodTypeAny> {\n return (\n isZodSchemaV3(schema) &&\n \"typeName\" in schema._def &&\n schema._def.typeName === \"ZodEffects\"\n );\n}\n\nfunction isZodTransformV4(schema: InteropZodType): schema is z4.$ZodPipe {\n return isZodSchemaV4(schema) && schema._zod.def.type === \"pipe\";\n}\n\nfunction interopZodTransformInputSchemaImpl(\n schema: InteropZodType,\n recursive: boolean,\n cache: WeakMap<InteropZodType, InteropZodType>\n): InteropZodType {\n const cached = cache.get(schema);\n if (cached !== undefined) {\n return cached;\n }\n\n // Zod v3: ._def.schema is the input schema for ZodEffects (transform)\n if (isZodSchemaV3(schema)) {\n if (isZodTransformV3(schema)) {\n return interopZodTransformInputSchemaImpl(\n schema._def.schema,\n recursive,\n cache\n );\n }\n // TODO: v3 schemas aren't recursively handled here\n // (currently not necessary since zodToJsonSchema handles this)\n return schema;\n }\n\n // Zod v4: _def.type is the input schema for ZodEffects (transform)\n if (isZodSchemaV4(schema)) {\n let outputSchema: InteropZodType = schema;\n if (isZodTransformV4(schema)) {\n outputSchema = interopZodTransformInputSchemaImpl(\n schema._zod.def.in,\n recursive,\n cache\n );\n }\n if (recursive) {\n // Handle nested object schemas\n if (isZodObjectV4(outputSchema)) {\n const outputShape: Mutable<z4.$ZodShape> = outputSchema._zod.def.shape;\n for (const [key, keySchema] of Object.entries(\n outputSchema._zod.def.shape\n )) {\n outputShape[key] = interopZodTransformInputSchemaImpl(\n keySchema,\n recursive,\n cache\n ) as z4.$ZodType;\n }\n outputSchema = clone<ZodObjectV4>(outputSchema, {\n ...outputSchema._zod.def,\n shape: outputShape,\n });\n }\n // Handle nested array schemas\n else if (isZodArrayV4(outputSchema)) {\n const elementSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.element,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodArray>(outputSchema, {\n ...outputSchema._zod.def,\n element: elementSchema as z4.$ZodType,\n });\n }\n }\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(outputSchema as z4.$ZodType, meta);\n cache.set(schema, outputSchema);\n return outputSchema;\n }\n\n throw new Error(\"Schema must be an instance of z3.ZodType or z4.$ZodType\");\n}\n\n/**\n * Returns the input type of a Zod transform schema, for both v3 and v4.\n * If the schema is not a transform, returns undefined. If `recursive` is true,\n * recursively processes nested object schemas and arrays of object schemas.\n *\n * @param schema - The Zod schema instance (v3 or v4)\n * @param {boolean} [recursive=false] - Whether to recursively process nested objects/arrays.\n * @returns The input Zod schema of the transform, or undefined if not a transform\n */\nexport function interopZodTransformInputSchema(\n schema: InteropZodType,\n recursive = false\n): InteropZodType {\n const cache = new WeakMap<InteropZodType, InteropZodType>();\n return interopZodTransformInputSchemaImpl(schema, recursive, cache);\n}\n\n/**\n * Creates a modified version of a Zod object schema where fields matching a predicate are made optional.\n * Supports both Zod v3 and v4 schemas and preserves the original schema version.\n *\n * @template T - The type of the Zod object schema.\n * @param {T} schema - The Zod object schema instance (either v3 or v4).\n * @param {(key: string, value: InteropZodType) => boolean} predicate - Function to determine which fields should be optional.\n * @returns {InteropZodObject} The modified Zod object schema.\n * @throws {Error} If the schema is not a Zod v3 or v4 object.\n */\nexport function interopZodObjectMakeFieldsOptional<T extends InteropZodObject>(\n schema: T,\n predicate: (key: string, value: InteropZodType) => boolean\n): InteropZodObject {\n if (isZodSchemaV3(schema)) {\n const shape = getInteropZodObjectShape(schema);\n const modifiedShape: Record<string, z3.ZodTypeAny> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value)) {\n // Make this field optional using v3 methods\n modifiedShape[key] = (value as z3.ZodTypeAny).optional();\n } else {\n // Keep field as-is\n modifiedShape[key] = value;\n }\n }\n\n // Use v3's extend method to create a new schema with the modified shape\n return schema.extend(modifiedShape as z3.ZodRawShape);\n }\n\n if (isZodSchemaV4(schema)) {\n const shape = getInteropZodObjectShape(schema);\n const outputShape: Mutable<z4.$ZodShape> = { ...schema._zod.def.shape };\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value)) {\n // Make this field optional using v4 methods\n outputShape[key] = new $ZodOptional({\n type: \"optional\" as const,\n innerType: value as z4.$ZodType,\n });\n }\n // Otherwise keep the field as-is (already in outputShape)\n }\n\n const modifiedSchema = clone<ZodObjectV4>(schema, {\n ...schema._zod.def,\n shape: outputShape,\n });\n\n // Preserve metadata\n const meta = globalRegistry.get(schema);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n\n return modifiedSchema;\n }\n\n throw new Error(\n \"Schema must be an instance of z3.ZodObject or z4.$ZodObject\"\n );\n}\n\nexport function isInteropZodError(e: unknown) {\n return (\n // eslint-disable-next-line no-instanceof/no-instanceof\n e instanceof Error &&\n (e.constructor.name === \"ZodError\" || e.constructor.name === \"$ZodError\")\n );\n}\n"],"mappings":";;;;AAuFA,SAAgB,cACdA,QACyC;AACzC,KAAI,OAAO,WAAW,YAAY,WAAW,KAC3C,QAAO;CAGT,MAAM,MAAM;AACZ,KAAI,EAAE,UAAU,KACd,QAAO;CAGT,MAAM,MAAM,IAAI;AAChB,QACE,OAAO,QAAQ,YACf,QAAQ,QACR,SAAU;AAEb;AAED,SAAgB,cACdA,QACuD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,EAEvB,YAAY,OAAO,IAAID,yBAAa;GAClC,MAAM;GACN,WAAW;EACZ;EAKL,MAAM,wCAAoC,QAAQ;GAChD,GAAG,OAAO,KAAK;GACf,OAAO;EACR,EAAC;EAGF,MAAM,OAAOJ,2BAAe,IAAI,OAAO;AACvC,MAAI,MAAMA,2BAAe,IAAI,gBAAgB,KAAK;AAElD,SAAO;CACR;AAED,OAAM,IAAI,MACR;AAEH;AAED,SAAgB,kBAAkBe,GAAY;AAC5C,QAEE,aAAa,UACZ,EAAE,YAAY,SAAS,cAAc,EAAE,YAAY,SAAS;AAEhE"}
@@ -12,7 +12,7 @@ type ZodDefaultV4<T extends z4.SomeType> = z4.$ZodDefault<T>;
12
12
  type ZodOptionalV3<T extends z3.ZodTypeAny> = z3.ZodOptional<T>;
13
13
  type ZodOptionalV4<T extends z4.SomeType> = z4.$ZodOptional<T>;
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- type InteropZodType<Output = any, Input = Output> = z3.ZodType<Output, z3.ZodTypeDef, Input> | z4.$ZodType<Output, Input>;
15
+ type InteropZodType<Output$1 = any, Input$1 = Output$1> = z3.ZodType<Output$1, z3.ZodTypeDef, Input$1> | z4.$ZodType<Output$1, Input$1>;
16
16
  type InteropZodObject = ZodObjectV3 | ZodObjectV4;
17
17
  type InteropZodDefault<T = InteropZodObjectShape> = T extends z3.ZodTypeAny ? ZodDefaultV3<T> : T extends z4.SomeType ? ZodDefaultV4<T> : never;
18
18
  type InteropZodOptional<T = InteropZodObjectShape> = T extends z3.ZodTypeAny ? ZodOptionalV3<T> : T extends z4.SomeType ? ZodOptionalV4<T> : never;
@@ -235,6 +235,7 @@ declare function interopZodTransformInputSchema(schema: InteropZodType, recursiv
235
235
  * @throws {Error} If the schema is not a Zod v3 or v4 object.
236
236
  */
237
237
  declare function interopZodObjectMakeFieldsOptional<T extends InteropZodObject>(schema: T, predicate: (key: string, value: InteropZodType) => boolean): InteropZodObject;
238
+ declare function isInteropZodError(e: unknown): boolean;
238
239
  //#endregion
239
- export { 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, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
240
+ export { 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 };
240
241
  //# sourceMappingURL=zod.d.cts.map
@@ -12,7 +12,7 @@ type ZodDefaultV4<T extends z4.SomeType> = z4.$ZodDefault<T>;
12
12
  type ZodOptionalV3<T extends z3.ZodTypeAny> = z3.ZodOptional<T>;
13
13
  type ZodOptionalV4<T extends z4.SomeType> = z4.$ZodOptional<T>;
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- type InteropZodType<Output = any, Input = Output> = z3.ZodType<Output, z3.ZodTypeDef, Input> | z4.$ZodType<Output, Input>;
15
+ type InteropZodType<Output$1 = any, Input$1 = Output$1> = z3.ZodType<Output$1, z3.ZodTypeDef, Input$1> | z4.$ZodType<Output$1, Input$1>;
16
16
  type InteropZodObject = ZodObjectV3 | ZodObjectV4;
17
17
  type InteropZodDefault<T = InteropZodObjectShape> = T extends z3.ZodTypeAny ? ZodDefaultV3<T> : T extends z4.SomeType ? ZodDefaultV4<T> : never;
18
18
  type InteropZodOptional<T = InteropZodObjectShape> = T extends z3.ZodTypeAny ? ZodOptionalV3<T> : T extends z4.SomeType ? ZodOptionalV4<T> : never;
@@ -235,6 +235,7 @@ declare function interopZodTransformInputSchema(schema: InteropZodType, recursiv
235
235
  * @throws {Error} If the schema is not a Zod v3 or v4 object.
236
236
  */
237
237
  declare function interopZodObjectMakeFieldsOptional<T extends InteropZodObject>(schema: T, predicate: (key: string, value: InteropZodType) => boolean): InteropZodObject;
238
+ declare function isInteropZodError(e: unknown): boolean;
238
239
  //#endregion
239
- export { 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, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
240
+ export { 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 };
240
241
  //# sourceMappingURL=zod.d.ts.map
@@ -475,7 +475,10 @@ function interopZodObjectMakeFieldsOptional(schema, predicate) {
475
475
  }
476
476
  throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
477
477
  }
478
+ function isInteropZodError(e) {
479
+ return e instanceof Error && (e.constructor.name === "ZodError" || e.constructor.name === "$ZodError");
480
+ }
478
481
 
479
482
  //#endregion
480
- export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
483
+ 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 };
481
484
  //# sourceMappingURL=zod.js.map