@langchain/core 1.2.0-dev-1775763803878 → 1.2.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.
- package/CHANGELOG.md +120 -0
- package/README.md +1 -1
- package/agents.cjs +1 -0
- package/agents.d.cts +1 -0
- package/agents.d.ts +1 -0
- package/agents.js +1 -0
- package/caches.cjs +1 -0
- package/caches.d.cts +1 -0
- package/caches.d.ts +1 -0
- package/caches.js +1 -0
- package/callbacks/base.cjs +1 -0
- package/callbacks/base.d.cts +1 -0
- package/callbacks/base.d.ts +1 -0
- package/callbacks/base.js +1 -0
- package/callbacks/dispatch/web.cjs +1 -0
- package/callbacks/dispatch/web.d.cts +1 -0
- package/callbacks/dispatch/web.d.ts +1 -0
- package/callbacks/dispatch/web.js +1 -0
- package/callbacks/dispatch.cjs +1 -0
- package/callbacks/dispatch.d.cts +1 -0
- package/callbacks/dispatch.d.ts +1 -0
- package/callbacks/dispatch.js +1 -0
- package/callbacks/manager.cjs +1 -0
- package/callbacks/manager.d.cts +1 -0
- package/callbacks/manager.d.ts +1 -0
- package/callbacks/manager.js +1 -0
- package/callbacks/promises.cjs +1 -0
- package/callbacks/promises.d.cts +1 -0
- package/callbacks/promises.d.ts +1 -0
- package/callbacks/promises.js +1 -0
- package/chat_history.cjs +1 -0
- package/chat_history.d.cts +1 -0
- package/chat_history.d.ts +1 -0
- package/chat_history.js +1 -0
- package/context.cjs +1 -0
- package/context.d.cts +1 -0
- package/context.d.ts +1 -0
- package/context.js +1 -0
- package/dist/callbacks/base.cjs +7 -3
- package/dist/callbacks/base.cjs.map +1 -1
- package/dist/callbacks/base.d.cts +20 -1
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/callbacks/base.d.ts +20 -1
- package/dist/callbacks/base.d.ts.map +1 -1
- package/dist/callbacks/base.js +7 -3
- package/dist/callbacks/base.js.map +1 -1
- package/dist/callbacks/dispatch/index.cjs.map +1 -1
- package/dist/callbacks/dispatch/index.js.map +1 -1
- package/dist/callbacks/manager.cjs +29 -7
- package/dist/callbacks/manager.cjs.map +1 -1
- package/dist/callbacks/manager.d.cts +4 -0
- package/dist/callbacks/manager.d.cts.map +1 -1
- package/dist/callbacks/manager.d.ts +4 -0
- package/dist/callbacks/manager.d.ts.map +1 -1
- package/dist/callbacks/manager.js +23 -1
- package/dist/callbacks/manager.js.map +1 -1
- package/dist/example_selectors/conditional.cjs.map +1 -1
- package/dist/example_selectors/conditional.js.map +1 -1
- package/dist/example_selectors/length_based.cjs.map +1 -1
- package/dist/example_selectors/length_based.js.map +1 -1
- package/dist/example_selectors/semantic_similarity.cjs.map +1 -1
- package/dist/example_selectors/semantic_similarity.js.map +1 -1
- package/dist/indexing/base.cjs +3 -4
- package/dist/indexing/base.cjs.map +1 -1
- package/dist/indexing/base.js +1 -1
- package/dist/indexing/base.js.map +1 -1
- package/dist/language_models/base.cjs +9 -1
- package/dist/language_models/base.cjs.map +1 -1
- package/dist/language_models/base.d.cts +5 -0
- package/dist/language_models/base.d.cts.map +1 -1
- package/dist/language_models/base.d.ts +5 -0
- package/dist/language_models/base.d.ts.map +1 -1
- package/dist/language_models/base.js +9 -1
- package/dist/language_models/base.js.map +1 -1
- package/dist/language_models/chat_models.cjs +71 -33
- package/dist/language_models/chat_models.cjs.map +1 -1
- package/dist/language_models/chat_models.d.cts +74 -3
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts +74 -3
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/language_models/chat_models.js +72 -34
- package/dist/language_models/chat_models.js.map +1 -1
- package/dist/language_models/compat.cjs +255 -78
- package/dist/language_models/compat.cjs.map +1 -1
- package/dist/language_models/compat.d.cts +3 -17
- package/dist/language_models/compat.d.cts.map +1 -1
- package/dist/language_models/compat.d.ts +3 -17
- package/dist/language_models/compat.d.ts.map +1 -1
- package/dist/language_models/compat.js +256 -78
- package/dist/language_models/compat.js.map +1 -1
- package/dist/language_models/event.cjs.map +1 -1
- package/dist/language_models/event.d.cts +82 -90
- package/dist/language_models/event.d.cts.map +1 -1
- package/dist/language_models/event.d.ts +82 -90
- package/dist/language_models/event.d.ts.map +1 -1
- package/dist/language_models/event.js.map +1 -1
- package/dist/language_models/llms.cjs +18 -6
- package/dist/language_models/llms.cjs.map +1 -1
- package/dist/language_models/llms.d.cts.map +1 -1
- package/dist/language_models/llms.d.ts.map +1 -1
- package/dist/language_models/llms.js +18 -6
- package/dist/language_models/llms.js.map +1 -1
- package/dist/language_models/openai_completions_stream.cjs +308 -0
- package/dist/language_models/openai_completions_stream.cjs.map +1 -0
- package/dist/language_models/openai_completions_stream.d.cts +75 -0
- package/dist/language_models/openai_completions_stream.d.cts.map +1 -0
- package/dist/language_models/openai_completions_stream.d.ts +75 -0
- package/dist/language_models/openai_completions_stream.d.ts.map +1 -0
- package/dist/language_models/openai_completions_stream.js +301 -0
- package/dist/language_models/openai_completions_stream.js.map +1 -0
- package/dist/language_models/stream.cjs +216 -86
- package/dist/language_models/stream.cjs.map +1 -1
- package/dist/language_models/stream.d.cts +5 -28
- package/dist/language_models/stream.d.cts.map +1 -1
- package/dist/language_models/stream.d.ts +5 -28
- package/dist/language_models/stream.d.ts.map +1 -1
- package/dist/language_models/stream.js +216 -86
- package/dist/language_models/stream.js.map +1 -1
- package/dist/load/import_map.cjs +4 -0
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +4 -0
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/index.cjs +19 -0
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.d.cts +4 -0
- package/dist/load/index.d.cts.map +1 -1
- package/dist/load/index.d.ts +4 -0
- package/dist/load/index.d.ts.map +1 -1
- package/dist/load/index.js +19 -0
- package/dist/load/index.js.map +1 -1
- package/dist/load/map_keys.cjs +13 -7
- package/dist/load/map_keys.cjs.map +1 -1
- package/dist/load/map_keys.d.cts.map +1 -1
- package/dist/load/map_keys.d.ts.map +1 -1
- package/dist/load/map_keys.js +11 -2
- package/dist/load/map_keys.js.map +1 -1
- package/dist/memory.cjs.map +1 -1
- package/dist/memory.js.map +1 -1
- package/dist/messages/ai.cjs +12 -9
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.d.cts.map +1 -1
- package/dist/messages/ai.d.ts.map +1 -1
- package/dist/messages/ai.js +12 -9
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +10 -0
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +9 -0
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +9 -0
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +10 -0
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/anthropic.cjs.map +1 -1
- package/dist/messages/block_translators/anthropic.js.map +1 -1
- package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -1
- package/dist/messages/block_translators/bedrock_converse.js.map +1 -1
- package/dist/messages/block_translators/google.cjs.map +1 -1
- package/dist/messages/block_translators/google.js.map +1 -1
- package/dist/messages/block_translators/google_vertexai.cjs.map +1 -1
- package/dist/messages/block_translators/google_vertexai.js.map +1 -1
- package/dist/messages/block_translators/index.cjs +2 -0
- package/dist/messages/block_translators/index.cjs.map +1 -1
- package/dist/messages/block_translators/index.js +2 -0
- package/dist/messages/block_translators/index.js.map +1 -1
- package/dist/messages/block_translators/openai.cjs.map +1 -1
- package/dist/messages/block_translators/openai.js.map +1 -1
- package/dist/messages/block_translators/openrouter.cjs +101 -0
- package/dist/messages/block_translators/openrouter.cjs.map +1 -0
- package/dist/messages/block_translators/openrouter.js +101 -0
- package/dist/messages/block_translators/openrouter.js.map +1 -0
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/modifier.cjs +6 -0
- package/dist/messages/modifier.cjs.map +1 -1
- package/dist/messages/modifier.d.cts +9 -4
- package/dist/messages/modifier.d.cts.map +1 -1
- package/dist/messages/modifier.d.ts +9 -4
- package/dist/messages/modifier.d.ts.map +1 -1
- package/dist/messages/modifier.js +6 -0
- package/dist/messages/modifier.js.map +1 -1
- package/dist/messages/transformers.cjs.map +1 -1
- package/dist/messages/transformers.js.map +1 -1
- package/dist/messages/utils.cjs +16 -2
- package/dist/messages/utils.cjs.map +1 -1
- package/dist/messages/utils.d.cts +9 -1
- package/dist/messages/utils.d.cts.map +1 -1
- package/dist/messages/utils.d.ts +9 -1
- package/dist/messages/utils.d.ts.map +1 -1
- package/dist/messages/utils.js +16 -2
- package/dist/messages/utils.js.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -1
- package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
- package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
- package/dist/output_parsers/standard_schema.cjs +3 -0
- package/dist/output_parsers/standard_schema.cjs.map +1 -1
- package/dist/output_parsers/standard_schema.d.cts +2 -0
- package/dist/output_parsers/standard_schema.d.cts.map +1 -1
- package/dist/output_parsers/standard_schema.d.ts +2 -0
- package/dist/output_parsers/standard_schema.d.ts.map +1 -1
- package/dist/output_parsers/standard_schema.js +3 -0
- package/dist/output_parsers/standard_schema.js.map +1 -1
- package/dist/output_parsers/structured.cjs +3 -0
- package/dist/output_parsers/structured.cjs.map +1 -1
- package/dist/output_parsers/structured.d.cts +2 -0
- package/dist/output_parsers/structured.d.cts.map +1 -1
- package/dist/output_parsers/structured.d.ts +2 -0
- package/dist/output_parsers/structured.d.ts.map +1 -1
- package/dist/output_parsers/structured.js +3 -0
- package/dist/output_parsers/structured.js.map +1 -1
- package/dist/output_parsers/xml.cjs.map +1 -1
- package/dist/output_parsers/xml.js.map +1 -1
- package/dist/prompts/base.cjs.map +1 -1
- package/dist/prompts/base.js.map +1 -1
- package/dist/prompts/chat.cjs.map +1 -1
- package/dist/prompts/chat.js.map +1 -1
- package/dist/prompts/few_shot.cjs.map +1 -1
- package/dist/prompts/few_shot.js.map +1 -1
- package/dist/prompts/image.cjs.map +1 -1
- package/dist/prompts/image.js.map +1 -1
- package/dist/prompts/prompt.cjs +1 -1
- package/dist/prompts/prompt.cjs.map +1 -1
- package/dist/prompts/prompt.d.cts +1 -1
- package/dist/prompts/prompt.d.ts +1 -1
- package/dist/prompts/prompt.js +1 -1
- package/dist/prompts/prompt.js.map +1 -1
- package/dist/prompts/string.cjs.map +1 -1
- package/dist/prompts/string.js.map +1 -1
- package/dist/prompts/template.cjs +1 -1
- package/dist/prompts/template.cjs.map +1 -1
- package/dist/prompts/template.js.map +1 -1
- package/dist/retrievers/index.cjs.map +1 -1
- package/dist/retrievers/index.js.map +1 -1
- package/dist/runnables/base.cjs +5 -2
- package/dist/runnables/base.cjs.map +1 -1
- package/dist/runnables/base.d.cts +43 -0
- package/dist/runnables/base.d.cts.map +1 -1
- package/dist/runnables/base.d.ts +43 -0
- package/dist/runnables/base.d.ts.map +1 -1
- package/dist/runnables/base.js +4 -1
- package/dist/runnables/base.js.map +1 -1
- package/dist/runnables/branch.cjs.map +1 -1
- package/dist/runnables/branch.js.map +1 -1
- package/dist/runnables/config.cjs +16 -8
- package/dist/runnables/config.cjs.map +1 -1
- package/dist/runnables/config.d.cts.map +1 -1
- package/dist/runnables/config.d.ts.map +1 -1
- package/dist/runnables/config.js +16 -8
- package/dist/runnables/config.js.map +1 -1
- package/dist/runnables/graph.cjs +6 -6
- package/dist/runnables/graph.cjs.map +1 -1
- package/dist/runnables/graph.js +1 -1
- package/dist/runnables/graph.js.map +1 -1
- package/dist/runnables/graph_mermaid.cjs.map +1 -1
- package/dist/runnables/graph_mermaid.js.map +1 -1
- package/dist/runnables/history.cjs +3 -0
- package/dist/runnables/history.cjs.map +1 -1
- package/dist/runnables/history.d.cts +3 -0
- package/dist/runnables/history.d.cts.map +1 -1
- package/dist/runnables/history.d.ts +3 -0
- package/dist/runnables/history.d.ts.map +1 -1
- package/dist/runnables/history.js +3 -0
- package/dist/runnables/history.js.map +1 -1
- package/dist/runnables/router.cjs.map +1 -1
- package/dist/runnables/router.js.map +1 -1
- package/dist/runnables/utils.cjs.map +1 -1
- package/dist/runnables/utils.js.map +1 -1
- package/dist/singletons/async_local_storage/context.cjs.map +1 -1
- package/dist/singletons/async_local_storage/context.js.map +1 -1
- package/dist/singletons/async_local_storage/index.cjs.map +1 -1
- package/dist/singletons/async_local_storage/index.js.map +1 -1
- package/dist/singletons/callbacks.cjs +1 -1
- package/dist/testing/fake_model_builder.cjs +10 -9
- package/dist/testing/fake_model_builder.cjs.map +1 -1
- package/dist/testing/fake_model_builder.d.cts +1 -2
- package/dist/testing/fake_model_builder.d.cts.map +1 -1
- package/dist/testing/fake_model_builder.d.ts +1 -2
- package/dist/testing/fake_model_builder.d.ts.map +1 -1
- package/dist/testing/fake_model_builder.js +10 -9
- package/dist/testing/fake_model_builder.js.map +1 -1
- package/dist/testing/index.cjs +16 -0
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +3 -1
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.js +10 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/matchers.cjs +3 -1
- package/dist/testing/matchers.cjs.map +1 -1
- package/dist/testing/matchers.d.cts +8 -4
- package/dist/testing/matchers.d.cts.map +1 -1
- package/dist/testing/matchers.d.ts +8 -4
- package/dist/testing/matchers.d.ts.map +1 -1
- package/dist/testing/matchers.js +3 -1
- package/dist/testing/matchers.js.map +1 -1
- package/dist/tracers/console.cjs +30 -4
- package/dist/tracers/console.cjs.map +1 -1
- package/dist/tracers/console.d.cts.map +1 -1
- package/dist/tracers/console.d.ts.map +1 -1
- package/dist/tracers/console.js +28 -1
- package/dist/tracers/console.js.map +1 -1
- package/dist/tracers/event_stream.cjs.map +1 -1
- package/dist/tracers/event_stream.js.map +1 -1
- package/dist/tracers/tracer_langchain.cjs +70 -2
- package/dist/tracers/tracer_langchain.cjs.map +1 -1
- package/dist/tracers/tracer_langchain.d.cts +26 -1
- package/dist/tracers/tracer_langchain.d.cts.map +1 -1
- package/dist/tracers/tracer_langchain.d.ts +26 -1
- package/dist/tracers/tracer_langchain.d.ts.map +1 -1
- package/dist/tracers/tracer_langchain.js +70 -3
- package/dist/tracers/tracer_langchain.js.map +1 -1
- package/dist/utils/async_caller.cjs +3 -2
- package/dist/utils/async_caller.cjs.map +1 -1
- package/dist/utils/async_caller.js +2 -1
- package/dist/utils/async_caller.js.map +1 -1
- package/dist/utils/callbacks.cjs.map +1 -1
- package/dist/utils/callbacks.js.map +1 -1
- package/dist/utils/context.cjs.map +1 -1
- package/dist/utils/context.js.map +1 -1
- package/dist/utils/env.cjs.map +1 -1
- package/dist/utils/env.d.cts.map +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/utils/env.js.map +1 -1
- package/dist/utils/event_source_parse.cjs +5 -12
- package/dist/utils/event_source_parse.cjs.map +1 -1
- package/dist/utils/event_source_parse.js +5 -12
- package/dist/utils/event_source_parse.js.map +1 -1
- package/dist/utils/fast-json-patch/src/core.cjs.map +1 -1
- package/dist/utils/fast-json-patch/src/core.js.map +1 -1
- package/dist/utils/json_schema.cjs.map +1 -1
- package/dist/utils/json_schema.js.map +1 -1
- package/dist/utils/sax-js/sax.cjs.map +1 -1
- package/dist/utils/sax-js/sax.js.map +1 -1
- package/dist/utils/ssrf.cjs.map +1 -1
- package/dist/utils/ssrf.js.map +1 -1
- package/dist/utils/stream.d.cts +2 -2
- package/dist/utils/stream.d.cts.map +1 -1
- package/dist/utils/stream.d.ts +2 -2
- package/dist/utils/stream.d.ts.map +1 -1
- package/dist/utils/testing/chat_models.cjs.map +1 -1
- package/dist/utils/testing/chat_models.js.map +1 -1
- package/dist/utils/testing/embeddings.cjs.map +1 -1
- package/dist/utils/testing/embeddings.js.map +1 -1
- package/dist/utils/testing/index.cjs +17 -1
- package/dist/utils/testing/index.cjs.map +1 -1
- package/dist/utils/testing/index.d.cts +3 -1
- package/dist/utils/testing/index.d.ts +3 -1
- package/dist/utils/testing/index.js +11 -2
- package/dist/utils/testing/index.js.map +1 -1
- package/dist/utils/testing/openai_stream_fixtures.cjs +160 -0
- package/dist/utils/testing/openai_stream_fixtures.cjs.map +1 -0
- package/dist/utils/testing/openai_stream_fixtures.d.cts +12 -0
- package/dist/utils/testing/openai_stream_fixtures.d.cts.map +1 -0
- package/dist/utils/testing/openai_stream_fixtures.d.ts +12 -0
- package/dist/utils/testing/openai_stream_fixtures.d.ts.map +1 -0
- package/dist/utils/testing/openai_stream_fixtures.js +155 -0
- package/dist/utils/testing/openai_stream_fixtures.js.map +1 -0
- package/dist/utils/testing/stream.cjs +136 -0
- package/dist/utils/testing/stream.cjs.map +1 -0
- package/dist/utils/testing/stream.d.cts +96 -0
- package/dist/utils/testing/stream.d.cts.map +1 -0
- package/dist/utils/testing/stream.d.ts +96 -0
- package/dist/utils/testing/stream.d.ts.map +1 -0
- package/dist/utils/testing/stream.js +136 -0
- package/dist/utils/testing/stream.js.map +1 -0
- package/dist/utils/testing/vectorstores.cjs.map +1 -1
- package/dist/utils/testing/vectorstores.js.map +1 -1
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.js.map +1 -1
- package/dist/utils/uuid/index.cjs +58 -0
- package/dist/utils/uuid/index.cjs.map +1 -0
- package/dist/utils/uuid/index.d.cts +26 -0
- package/dist/utils/uuid/index.d.cts.map +1 -0
- package/dist/utils/uuid/index.d.ts +26 -0
- package/dist/utils/uuid/index.d.ts.map +1 -0
- package/dist/utils/uuid/index.js +41 -0
- package/dist/utils/uuid/index.js.map +1 -0
- package/dist/utils/uuid/max.cjs +6 -0
- package/dist/utils/uuid/max.cjs.map +1 -0
- package/dist/utils/uuid/max.js +6 -0
- package/dist/utils/uuid/max.js.map +1 -0
- package/dist/utils/uuid/nil.cjs +6 -0
- package/dist/utils/uuid/nil.cjs.map +1 -0
- package/dist/utils/uuid/nil.js +6 -0
- package/dist/utils/uuid/nil.js.map +1 -0
- package/dist/utils/uuid/parse.cjs +11 -0
- package/dist/utils/uuid/parse.cjs.map +1 -0
- package/dist/utils/uuid/parse.d.cts +7 -0
- package/dist/utils/uuid/parse.d.cts.map +1 -0
- package/dist/utils/uuid/parse.d.ts +7 -0
- package/dist/utils/uuid/parse.d.ts.map +1 -0
- package/dist/utils/uuid/parse.js +11 -0
- package/dist/utils/uuid/parse.js.map +1 -0
- package/dist/utils/uuid/regex.cjs +6 -0
- package/dist/utils/uuid/regex.cjs.map +1 -0
- package/dist/utils/uuid/regex.js +6 -0
- package/dist/utils/uuid/regex.js.map +1 -0
- package/dist/utils/uuid/rng.cjs +9 -0
- package/dist/utils/uuid/rng.cjs.map +1 -0
- package/dist/utils/uuid/rng.js +9 -0
- package/dist/utils/uuid/rng.js.map +1 -0
- package/dist/utils/uuid/sha1.cjs +71 -0
- package/dist/utils/uuid/sha1.cjs.map +1 -0
- package/dist/utils/uuid/sha1.js +71 -0
- package/dist/utils/uuid/sha1.js.map +1 -0
- package/dist/utils/uuid/stringify.cjs +21 -0
- package/dist/utils/uuid/stringify.cjs.map +1 -0
- package/dist/utils/uuid/stringify.d.cts +5 -0
- package/dist/utils/uuid/stringify.d.cts.map +1 -0
- package/dist/utils/uuid/stringify.d.ts +5 -0
- package/dist/utils/uuid/stringify.d.ts.map +1 -0
- package/dist/utils/uuid/stringify.js +20 -0
- package/dist/utils/uuid/stringify.js.map +1 -0
- package/dist/utils/uuid/types.d.cts +26 -0
- package/dist/utils/uuid/types.d.cts.map +1 -0
- package/dist/utils/uuid/types.d.ts +26 -0
- package/dist/utils/uuid/types.d.ts.map +1 -0
- package/dist/utils/uuid/v1.cjs +69 -0
- package/dist/utils/uuid/v1.cjs.map +1 -0
- package/dist/utils/uuid/v1.d.cts +8 -0
- package/dist/utils/uuid/v1.d.cts.map +1 -0
- package/dist/utils/uuid/v1.d.ts +8 -0
- package/dist/utils/uuid/v1.d.ts.map +1 -0
- package/dist/utils/uuid/v1.js +69 -0
- package/dist/utils/uuid/v1.js.map +1 -0
- package/dist/utils/uuid/v1ToV6.cjs +14 -0
- package/dist/utils/uuid/v1ToV6.cjs.map +1 -0
- package/dist/utils/uuid/v1ToV6.js +14 -0
- package/dist/utils/uuid/v1ToV6.js.map +1 -0
- package/dist/utils/uuid/v35.cjs +36 -0
- package/dist/utils/uuid/v35.cjs.map +1 -0
- package/dist/utils/uuid/v35.js +34 -0
- package/dist/utils/uuid/v35.js.map +1 -0
- package/dist/utils/uuid/v4.cjs +25 -0
- package/dist/utils/uuid/v4.cjs.map +1 -0
- package/dist/utils/uuid/v4.d.cts +8 -0
- package/dist/utils/uuid/v4.d.cts.map +1 -0
- package/dist/utils/uuid/v4.d.ts +8 -0
- package/dist/utils/uuid/v4.d.ts.map +1 -0
- package/dist/utils/uuid/v4.js +25 -0
- package/dist/utils/uuid/v4.js.map +1 -0
- package/dist/utils/uuid/v5.cjs +12 -0
- package/dist/utils/uuid/v5.cjs.map +1 -0
- package/dist/utils/uuid/v5.d.cts +14 -0
- package/dist/utils/uuid/v5.d.cts.map +1 -0
- package/dist/utils/uuid/v5.d.ts +14 -0
- package/dist/utils/uuid/v5.d.ts.map +1 -0
- package/dist/utils/uuid/v5.js +12 -0
- package/dist/utils/uuid/v5.js.map +1 -0
- package/dist/utils/uuid/v6.cjs +23 -0
- package/dist/utils/uuid/v6.cjs.map +1 -0
- package/dist/utils/uuid/v6.d.cts +8 -0
- package/dist/utils/uuid/v6.d.cts.map +1 -0
- package/dist/utils/uuid/v6.d.ts +8 -0
- package/dist/utils/uuid/v6.d.ts.map +1 -0
- package/dist/utils/uuid/v6.js +23 -0
- package/dist/utils/uuid/v6.js.map +1 -0
- package/dist/utils/uuid/v7.cjs +57 -0
- package/dist/utils/uuid/v7.cjs.map +1 -0
- package/dist/utils/uuid/v7.d.cts +8 -0
- package/dist/utils/uuid/v7.d.cts.map +1 -0
- package/dist/utils/uuid/v7.d.ts +8 -0
- package/dist/utils/uuid/v7.d.ts.map +1 -0
- package/dist/utils/uuid/v7.js +57 -0
- package/dist/utils/uuid/v7.js.map +1 -0
- package/dist/utils/uuid/validate.cjs +9 -0
- package/dist/utils/uuid/validate.cjs.map +1 -0
- package/dist/utils/uuid/validate.d.cts +5 -0
- package/dist/utils/uuid/validate.d.cts.map +1 -0
- package/dist/utils/uuid/validate.d.ts +5 -0
- package/dist/utils/uuid/validate.d.ts.map +1 -0
- package/dist/utils/uuid/validate.js +9 -0
- package/dist/utils/uuid/validate.js.map +1 -0
- package/dist/utils/uuid/version.cjs +10 -0
- package/dist/utils/uuid/version.cjs.map +1 -0
- package/dist/utils/uuid/version.d.cts +5 -0
- package/dist/utils/uuid/version.d.cts.map +1 -0
- package/dist/utils/uuid/version.d.ts +5 -0
- package/dist/utils/uuid/version.d.ts.map +1 -0
- package/dist/utils/uuid/version.js +10 -0
- package/dist/utils/uuid/version.js.map +1 -0
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/string.cjs +26 -0
- package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -1
- package/dist/utils/zod-to-json-schema/parsers/string.js +26 -0
- package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -1
- package/dist/vectorstores.cjs.map +1 -1
- package/dist/vectorstores.js.map +1 -1
- package/document_loaders/base.cjs +1 -0
- package/document_loaders/base.d.cts +1 -0
- package/document_loaders/base.d.ts +1 -0
- package/document_loaders/base.js +1 -0
- package/document_loaders/langsmith.cjs +1 -0
- package/document_loaders/langsmith.d.cts +1 -0
- package/document_loaders/langsmith.d.ts +1 -0
- package/document_loaders/langsmith.js +1 -0
- package/documents.cjs +1 -0
- package/documents.d.cts +1 -0
- package/documents.d.ts +1 -0
- package/documents.js +1 -0
- package/embeddings.cjs +1 -0
- package/embeddings.d.cts +1 -0
- package/embeddings.d.ts +1 -0
- package/embeddings.js +1 -0
- package/errors.cjs +1 -0
- package/errors.d.cts +1 -0
- package/errors.d.ts +1 -0
- package/errors.js +1 -0
- package/example_selectors.cjs +1 -0
- package/example_selectors.d.cts +1 -0
- package/example_selectors.d.ts +1 -0
- package/example_selectors.js +1 -0
- package/indexing.cjs +1 -0
- package/indexing.d.cts +1 -0
- package/indexing.d.ts +1 -0
- package/indexing.js +1 -0
- package/language_models/base.cjs +1 -0
- package/language_models/base.d.cts +1 -0
- package/language_models/base.d.ts +1 -0
- package/language_models/base.js +1 -0
- package/language_models/chat_models.cjs +1 -0
- package/language_models/chat_models.d.cts +1 -0
- package/language_models/chat_models.d.ts +1 -0
- package/language_models/chat_models.js +1 -0
- package/language_models/compat.cjs +1 -0
- package/language_models/compat.d.cts +1 -0
- package/language_models/compat.d.ts +1 -0
- package/language_models/compat.js +1 -0
- package/language_models/event.cjs +1 -0
- package/language_models/event.d.cts +1 -0
- package/language_models/event.d.ts +1 -0
- package/language_models/event.js +1 -0
- package/language_models/llms.cjs +1 -0
- package/language_models/llms.d.cts +1 -0
- package/language_models/llms.d.ts +1 -0
- package/language_models/llms.js +1 -0
- package/language_models/openai_completions_stream.cjs +1 -0
- package/language_models/openai_completions_stream.d.cts +1 -0
- package/language_models/openai_completions_stream.d.ts +1 -0
- package/language_models/openai_completions_stream.js +1 -0
- package/language_models/profile.cjs +1 -0
- package/language_models/profile.d.cts +1 -0
- package/language_models/profile.d.ts +1 -0
- package/language_models/profile.js +1 -0
- package/language_models/stream.cjs +1 -0
- package/language_models/stream.d.cts +1 -0
- package/language_models/stream.d.ts +1 -0
- package/language_models/stream.js +1 -0
- package/language_models/structured_output.cjs +1 -0
- package/language_models/structured_output.d.cts +1 -0
- package/language_models/structured_output.d.ts +1 -0
- package/language_models/structured_output.js +1 -0
- package/load/serializable.cjs +1 -0
- package/load/serializable.d.cts +1 -0
- package/load/serializable.d.ts +1 -0
- package/load/serializable.js +1 -0
- package/load.cjs +1 -0
- package/load.d.cts +1 -0
- package/load.d.ts +1 -0
- package/load.js +1 -0
- package/memory.cjs +1 -0
- package/memory.d.cts +1 -0
- package/memory.d.ts +1 -0
- package/memory.js +1 -0
- package/messages/tool.cjs +1 -0
- package/messages/tool.d.cts +1 -0
- package/messages/tool.d.ts +1 -0
- package/messages/tool.js +1 -0
- package/messages.cjs +1 -0
- package/messages.d.cts +1 -0
- package/messages.d.ts +1 -0
- package/messages.js +1 -0
- package/output_parsers/openai_functions.cjs +1 -0
- package/output_parsers/openai_functions.d.cts +1 -0
- package/output_parsers/openai_functions.d.ts +1 -0
- package/output_parsers/openai_functions.js +1 -0
- package/output_parsers/openai_tools.cjs +1 -0
- package/output_parsers/openai_tools.d.cts +1 -0
- package/output_parsers/openai_tools.d.ts +1 -0
- package/output_parsers/openai_tools.js +1 -0
- package/output_parsers.cjs +1 -0
- package/output_parsers.d.cts +1 -0
- package/output_parsers.d.ts +1 -0
- package/output_parsers.js +1 -0
- package/outputs.cjs +1 -0
- package/outputs.d.cts +1 -0
- package/outputs.d.ts +1 -0
- package/outputs.js +1 -0
- package/package.json +34 -14
- package/prompt_values.cjs +1 -0
- package/prompt_values.d.cts +1 -0
- package/prompt_values.d.ts +1 -0
- package/prompt_values.js +1 -0
- package/prompts.cjs +1 -0
- package/prompts.d.cts +1 -0
- package/prompts.d.ts +1 -0
- package/prompts.js +1 -0
- package/retrievers/document_compressors.cjs +1 -0
- package/retrievers/document_compressors.d.cts +1 -0
- package/retrievers/document_compressors.d.ts +1 -0
- package/retrievers/document_compressors.js +1 -0
- package/retrievers.cjs +1 -0
- package/retrievers.d.cts +1 -0
- package/retrievers.d.ts +1 -0
- package/retrievers.js +1 -0
- package/runnables/graph.cjs +1 -0
- package/runnables/graph.d.cts +1 -0
- package/runnables/graph.d.ts +1 -0
- package/runnables/graph.js +1 -0
- package/runnables.cjs +1 -0
- package/runnables.d.cts +1 -0
- package/runnables.d.ts +1 -0
- package/runnables.js +1 -0
- package/singletons.cjs +1 -0
- package/singletons.d.cts +1 -0
- package/singletons.d.ts +1 -0
- package/singletons.js +1 -0
- package/stores.cjs +1 -0
- package/stores.d.cts +1 -0
- package/stores.d.ts +1 -0
- package/stores.js +1 -0
- package/structured_query.cjs +1 -0
- package/structured_query.d.cts +1 -0
- package/structured_query.d.ts +1 -0
- package/structured_query.js +1 -0
- package/testing.cjs +1 -0
- package/testing.d.cts +1 -0
- package/testing.d.ts +1 -0
- package/testing.js +1 -0
- package/tools.cjs +1 -0
- package/tools.d.cts +1 -0
- package/tools.d.ts +1 -0
- package/tools.js +1 -0
- package/tracers/base.cjs +1 -0
- package/tracers/base.d.cts +1 -0
- package/tracers/base.d.ts +1 -0
- package/tracers/base.js +1 -0
- package/tracers/console.cjs +1 -0
- package/tracers/console.d.cts +1 -0
- package/tracers/console.d.ts +1 -0
- package/tracers/console.js +1 -0
- package/tracers/log_stream.cjs +1 -0
- package/tracers/log_stream.d.cts +1 -0
- package/tracers/log_stream.d.ts +1 -0
- package/tracers/log_stream.js +1 -0
- package/tracers/run_collector.cjs +1 -0
- package/tracers/run_collector.d.cts +1 -0
- package/tracers/run_collector.d.ts +1 -0
- package/tracers/run_collector.js +1 -0
- package/tracers/tracer_langchain.cjs +1 -0
- package/tracers/tracer_langchain.d.cts +1 -0
- package/tracers/tracer_langchain.d.ts +1 -0
- package/tracers/tracer_langchain.js +1 -0
- package/types/stream.cjs +1 -0
- package/types/stream.d.cts +1 -0
- package/types/stream.d.ts +1 -0
- package/types/stream.js +1 -0
- package/utils/async_caller.cjs +1 -0
- package/utils/async_caller.d.cts +1 -0
- package/utils/async_caller.d.ts +1 -0
- package/utils/async_caller.js +1 -0
- package/utils/chunk_array.cjs +1 -0
- package/utils/chunk_array.d.cts +1 -0
- package/utils/chunk_array.d.ts +1 -0
- package/utils/chunk_array.js +1 -0
- package/utils/context.cjs +1 -0
- package/utils/context.d.cts +1 -0
- package/utils/context.d.ts +1 -0
- package/utils/context.js +1 -0
- package/utils/env.cjs +1 -0
- package/utils/env.d.cts +1 -0
- package/utils/env.d.ts +1 -0
- package/utils/env.js +1 -0
- package/utils/event_source_parse.cjs +1 -0
- package/utils/event_source_parse.d.cts +1 -0
- package/utils/event_source_parse.d.ts +1 -0
- package/utils/event_source_parse.js +1 -0
- package/utils/format.cjs +1 -0
- package/utils/format.d.cts +1 -0
- package/utils/format.d.ts +1 -0
- package/utils/format.js +1 -0
- package/utils/function_calling.cjs +1 -0
- package/utils/function_calling.d.cts +1 -0
- package/utils/function_calling.d.ts +1 -0
- package/utils/function_calling.js +1 -0
- package/utils/hash.cjs +1 -0
- package/utils/hash.d.cts +1 -0
- package/utils/hash.d.ts +1 -0
- package/utils/hash.js +1 -0
- package/utils/json_patch.cjs +1 -0
- package/utils/json_patch.d.cts +1 -0
- package/utils/json_patch.d.ts +1 -0
- package/utils/json_patch.js +1 -0
- package/utils/json_schema.cjs +1 -0
- package/utils/json_schema.d.cts +1 -0
- package/utils/json_schema.d.ts +1 -0
- package/utils/json_schema.js +1 -0
- package/utils/math.cjs +1 -0
- package/utils/math.d.cts +1 -0
- package/utils/math.d.ts +1 -0
- package/utils/math.js +1 -0
- package/utils/ssrf.cjs +1 -0
- package/utils/ssrf.d.cts +1 -0
- package/utils/ssrf.d.ts +1 -0
- package/utils/ssrf.js +1 -0
- package/utils/standard_schema.cjs +1 -0
- package/utils/standard_schema.d.cts +1 -0
- package/utils/standard_schema.d.ts +1 -0
- package/utils/standard_schema.js +1 -0
- package/utils/stream.cjs +1 -0
- package/utils/stream.d.cts +1 -0
- package/utils/stream.d.ts +1 -0
- package/utils/stream.js +1 -0
- package/utils/testing.cjs +1 -0
- package/utils/testing.d.cts +1 -0
- package/utils/testing.d.ts +1 -0
- package/utils/testing.js +1 -0
- package/utils/tiktoken.cjs +1 -0
- package/utils/tiktoken.d.cts +1 -0
- package/utils/tiktoken.d.ts +1 -0
- package/utils/tiktoken.js +1 -0
- package/utils/types.cjs +1 -0
- package/utils/types.d.cts +1 -0
- package/utils/types.d.ts +1 -0
- package/utils/types.js +1 -0
- package/utils/uuid.cjs +1 -0
- package/utils/uuid.d.cts +1 -0
- package/utils/uuid.d.ts +1 -0
- package/utils/uuid.js +1 -0
- package/vectorstores.cjs +1 -0
- package/vectorstores.d.cts +1 -0
- package/vectorstores.d.ts +1 -0
- package/vectorstores.js +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","names":[],"sources":["../../../src/utils/testing/stream.ts"],"sourcesContent":["import type { AIMessage } from \"../../messages/index.js\";\nimport type { UsageMetadata } from \"../../messages/metadata.js\";\nimport { ChatModelStream } from \"../../language_models/stream.js\";\n\n/**\n * The `this` context that Vitest provides to custom matchers via `expect.extend`.\n * @see https://vitest.dev/guide/extending-matchers.html\n */\ninterface ExpectExtendThis {\n isNot?: boolean;\n equals(a: unknown, b: unknown): boolean;\n utils: {\n matcherHint(\n name: string,\n received?: string,\n expected?: string,\n options?: { isNot?: boolean }\n ): string;\n printReceived(value: unknown): string;\n printExpected(value: unknown): string;\n };\n}\n\ninterface ExpectationResult {\n pass: boolean;\n message: () => string;\n actual?: unknown;\n expected?: unknown;\n}\n\nfunction isChatModelStream(received: unknown): received is ChatModelStream {\n if (received == null || typeof received !== \"object\") {\n return false;\n }\n const stream = received as ChatModelStream;\n return (\n typeof stream.text !== \"undefined\" &&\n typeof stream.toolCalls !== \"undefined\" &&\n typeof stream.reasoning !== \"undefined\" &&\n typeof stream.usage !== \"undefined\" &&\n typeof stream.output !== \"undefined\" &&\n typeof stream[Symbol.asyncIterator] === \"function\"\n );\n}\n\nfunction matchesPartialObject(\n actual: Record<string, unknown> | undefined,\n expected: Record<string, unknown>,\n equals: ExpectExtendThis[\"equals\"]\n): boolean {\n if (actual == null) {\n return false;\n }\n return Object.entries(expected).every(([key, value]) =>\n equals(actual[key], value)\n );\n}\n\nfunction matchesStreamUsage(\n actual: UsageMetadata | undefined,\n expected: StreamUsageExpectation,\n equals: ExpectExtendThis[\"equals\"]\n): boolean {\n if (actual == null) {\n return false;\n }\n return matchesPartialObject(\n actual as Record<string, unknown>,\n expected as Record<string, unknown>,\n equals\n );\n}\n\nfunction getOutputText(message: AIMessage): string | undefined {\n const content = message.content as Array<{ type: string; text?: string }>;\n return content.find((block) => block.type === \"text\")?.text;\n}\n\nfunction matchesStreamOutput(\n message: AIMessage,\n expected: StreamOutputExpectation,\n equals: ExpectExtendThis[\"equals\"]\n): boolean {\n if (expected.id !== undefined && message.id !== expected.id) {\n return false;\n }\n if (expected.text !== undefined && getOutputText(message) !== expected.text) {\n return false;\n }\n if (expected.toolCalls !== undefined) {\n const calls = message.tool_calls ?? [];\n if (calls.length !== expected.toolCalls.length) {\n return false;\n }\n for (let i = 0; i < expected.toolCalls.length; i++) {\n const call = calls[i];\n const exp = expected.toolCalls[i]!;\n if (call?.name !== exp.name || !equals(call.args, exp.args)) {\n return false;\n }\n }\n }\n if (\n expected.usage !== undefined &&\n !matchesStreamUsage(message.usage_metadata, expected.usage, equals)\n ) {\n return false;\n }\n if (\n expected.responseMetadata !== undefined &&\n !matchesPartialObject(\n message.response_metadata as Record<string, unknown>,\n expected.responseMetadata,\n equals\n )\n ) {\n return false;\n }\n return true;\n}\n\nfunction invalidStreamResult(\n received: unknown,\n matcherName: string,\n utils: ExpectExtendThis[\"utils\"]\n): ExpectationResult {\n return {\n pass: false,\n message: () =>\n `${utils.matcherHint(matcherName)}\\n\\n` +\n `Expected: ChatModelStream (return value of model.streamEvents(\"Hello\"))\\n` +\n `Received: ${utils.printReceived(received)}`,\n actual: received,\n expected: \"ChatModelStream\",\n };\n}\n\nfunction applyNot(pass: boolean, isNot?: boolean): boolean {\n return isNot ? !pass : pass;\n}\n\nexport async function toHaveStreamText(\n this: ExpectExtendThis,\n received: unknown,\n expected: string\n): Promise<ExpectationResult> {\n const { isNot, utils } = this;\n const matcherName = \"toHaveStreamText\";\n\n if (!isChatModelStream(received)) {\n return invalidStreamResult(received, matcherName, utils);\n }\n\n const actual = await received.text;\n const pass = applyNot(actual === expected, isNot);\n\n return {\n pass,\n message: () =>\n `${utils.matcherHint(matcherName, undefined, undefined, { isNot })}\\n\\n` +\n `Expected stream text: ${isNot ? \"not \" : \"\"}${utils.printExpected(expected)}\\n` +\n `Received stream text: ${utils.printReceived(actual)}`,\n actual,\n expected,\n };\n}\n\nexport async function toHaveStreamReasoning(\n this: ExpectExtendThis,\n received: unknown,\n expected: string\n): Promise<ExpectationResult> {\n const { isNot, utils } = this;\n const matcherName = \"toHaveStreamReasoning\";\n\n if (!isChatModelStream(received)) {\n return invalidStreamResult(received, matcherName, utils);\n }\n\n const actual = await received.reasoning;\n const pass = applyNot(actual === expected, isNot);\n\n return {\n pass,\n message: () =>\n `${utils.matcherHint(matcherName, undefined, undefined, { isNot })}\\n\\n` +\n `Expected stream reasoning: ${isNot ? \"not \" : \"\"}${utils.printExpected(expected)}\\n` +\n `Received stream reasoning: ${utils.printReceived(actual)}`,\n actual,\n expected,\n };\n}\n\nexport type StreamToolCallExpectation = {\n name: string;\n args: Record<string, unknown>;\n};\n\nexport type StreamUsageExpectation = {\n input_tokens?: number;\n output_tokens?: number;\n total_tokens?: number;\n input_token_details?: Record<string, unknown>;\n output_token_details?: Record<string, unknown>;\n};\n\nexport type StreamOutputExpectation = {\n id?: string;\n text?: string;\n toolCalls?: StreamToolCallExpectation[];\n usage?: StreamUsageExpectation;\n responseMetadata?: Record<string, unknown>;\n};\n\nexport async function toHaveStreamToolCalls(\n this: ExpectExtendThis,\n received: unknown,\n expected: StreamToolCallExpectation[]\n): Promise<ExpectationResult> {\n const { isNot, utils } = this;\n const matcherName = \"toHaveStreamToolCalls\";\n\n if (!isChatModelStream(received)) {\n return invalidStreamResult(received, matcherName, utils);\n }\n\n const actual = await received.toolCalls;\n\n let pass =\n actual.length === expected.length &&\n expected.every((exp, i) => {\n const call = actual[i];\n return call?.name === exp.name && this.equals(call.args, exp.args);\n });\n pass = applyNot(pass, isNot);\n\n return {\n pass,\n message: () =>\n `${utils.matcherHint(matcherName, undefined, undefined, { isNot })}\\n\\n` +\n `Expected stream tool calls: ${utils.printExpected(expected)}\\n` +\n `Received stream tool calls: ${utils.printReceived(\n actual.map((tc) => ({ name: tc.name, args: tc.args }))\n )}`,\n actual: actual.map((tc) => ({ name: tc.name, args: tc.args })),\n expected,\n };\n}\n\nexport async function toHaveStreamUsage(\n this: ExpectExtendThis,\n received: unknown,\n expected: StreamUsageExpectation\n): Promise<ExpectationResult> {\n const { isNot, utils } = this;\n const matcherName = \"toHaveStreamUsage\";\n\n if (!isChatModelStream(received)) {\n return invalidStreamResult(received, matcherName, utils);\n }\n\n const actual = await received.usage;\n const pass = applyNot(\n matchesStreamUsage(actual, expected, this.equals),\n isNot\n );\n\n return {\n pass,\n message: () =>\n `${utils.matcherHint(matcherName, undefined, undefined, { isNot })}\\n\\n` +\n `Expected stream usage: ${utils.printExpected(expected)}\\n` +\n `Received stream usage: ${utils.printReceived(actual)}`,\n actual,\n expected,\n };\n}\n\nexport async function toHaveStreamOutput(\n this: ExpectExtendThis,\n received: unknown,\n expected: StreamOutputExpectation\n): Promise<ExpectationResult> {\n const { isNot, utils } = this;\n const matcherName = \"toHaveStreamOutput\";\n\n if (!isChatModelStream(received)) {\n return invalidStreamResult(received, matcherName, utils);\n }\n\n const message = await received.output;\n const pass = applyNot(\n matchesStreamOutput(message, expected, this.equals),\n isNot\n );\n\n return {\n pass,\n message: () =>\n `${utils.matcherHint(matcherName, undefined, undefined, { isNot })}\\n\\n` +\n `Expected stream output: ${utils.printExpected(expected)}\\n` +\n `Received stream output: ${utils.printReceived({\n id: message.id,\n text: getOutputText(message),\n tool_calls: message.tool_calls?.map((tc) => ({\n name: tc.name,\n args: tc.args,\n })),\n usage_metadata: message.usage_metadata,\n response_metadata: message.response_metadata,\n })}`,\n actual: message,\n expected,\n };\n}\n\n/** Stream matchers for `expect.extend()`. */\nexport const streamMatchers = {\n toHaveStreamText,\n toHaveStreamReasoning,\n toHaveStreamToolCalls,\n toHaveStreamUsage,\n toHaveStreamOutput,\n};\n\n/**\n * Custom assertion helpers for values returned by `BaseChatModel.streamEvents()`.\n *\n * These matchers consume the stream lazily through the corresponding\n * `ChatModelStream` promise-backed properties.\n *\n * @typeParam R - The assertion return type provided by the test framework.\n */\nexport interface StreamMatchers<R = unknown> {\n /**\n * Asserts that the stream resolves to the expected concatenated text.\n *\n * @param expected - The exact text expected from `ChatModelStream.text`.\n */\n toHaveStreamText(expected: string): R;\n\n /**\n * Asserts that the stream resolves to the expected concatenated reasoning text.\n *\n * @param expected - The exact reasoning text expected from `ChatModelStream.reasoning`.\n */\n toHaveStreamReasoning(expected: string): R;\n\n /**\n * Asserts that the stream resolves to the expected ordered tool calls.\n *\n * @param expected - Tool call names and arguments expected from `ChatModelStream.toolCalls`.\n */\n toHaveStreamToolCalls(expected: StreamToolCallExpectation[]): R;\n\n /**\n * Asserts that the stream resolves to usage metadata matching the expected fields.\n *\n * @param expected - A partial usage metadata object expected from `ChatModelStream.usage`.\n */\n toHaveStreamUsage(expected: StreamUsageExpectation): R;\n\n /**\n * Asserts that the final streamed output message matches the expected fields.\n *\n * @param expected - A partial output expectation checked against `ChatModelStream.output`.\n */\n toHaveStreamOutput(expected: StreamOutputExpectation): R;\n}\n"],"mappings":";AA8BA,SAAS,kBAAkB,UAAgD;AACzE,KAAI,YAAY,QAAQ,OAAO,aAAa,SAC1C,QAAO;CAET,MAAM,SAAS;AACf,QACE,OAAO,OAAO,SAAS,eACvB,OAAO,OAAO,cAAc,eAC5B,OAAO,OAAO,cAAc,eAC5B,OAAO,OAAO,UAAU,eACxB,OAAO,OAAO,WAAW,eACzB,OAAO,OAAO,OAAO,mBAAmB;;AAI5C,SAAS,qBACP,QACA,UACA,QACS;AACT,KAAI,UAAU,KACZ,QAAO;AAET,QAAO,OAAO,QAA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CAAC;EACJ,QAAQ;EACR;EACD;;;AAIH,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectorstores.cjs","names":["VectorStore","cosine","Document"],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwBA,qBAAAA,YAAY;CAG/C,gBAAgC,EAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;;CAGT,YACE,YACA,EAAE,YAAY,GAAG,SAA8B,EAAE,EACjD;AACA,QAAM,YAAY,KAAK;AAEvB,OAAK,aAAa,cAAcC,qBAAAA;;;;;;;;;CAUlC,MAAM,aAAa,WAAsC;EACvD,MAAM,QAAQ,UAAU,KAAK,EAAE,kBAAkB,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;;;;;;;;;;CAWH,MAAM,WAAW,SAAqB,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,KAAK,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;GAC1B,EAAE;AAEH,OAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;;;;;;;;;;;;CAa/D,MAAM,gCACJ,OACA,GACA,QAC+B;EAC/B,MAAM,kBAAkB,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;AAOT,UAAO,
|
|
1
|
+
{"version":3,"file":"vectorstores.cjs","names":["VectorStore","cosine","Document"],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwBA,qBAAAA,YAAY;CAG/C,gBAAgC,EAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;;CAGT,YACE,YACA,EAAE,YAAY,GAAG,SAA8B,EAAE,EACjD;AACA,QAAM,YAAY,KAAK;AAEvB,OAAK,aAAa,cAAcC,qBAAAA;;;;;;;;;CAUlC,MAAM,aAAa,WAAsC;EACvD,MAAM,QAAQ,UAAU,KAAK,EAAE,kBAAkB,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;;;;;;;;;;CAWH,MAAM,WAAW,SAAqB,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,KAAK,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;GAC1B,EAAE;AAEH,OAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;;;;;;;;;;;;CAa/D,MAAM,gCACJ,OACA,GACA,QAC+B;EAC/B,MAAM,kBAAkB,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;AAOT,UAAO,OAAO,IAJEC,iBAAAA,SAAS;IACvB,UAAU,aAAa;IACvB,aAAa,aAAa;IAC3B,CACgB,CAAC;;EAEpB,MAAM,wBAAwB,KAAK,cAAc,OAAO,eAAe;AAiBvE,SAhBiB,sBACd,KAAK,QAAQ,WAAW;GACvB,YAAY,KAAK,WAAW,OAAO,OAAO,UAAU;GACpD;GACD,EAAE,CACF,MAAM,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,KAAK,EAAG,CACtD,MAAM,GAAG,EAEiC,CAAC,KAAK,WAAW,CAC5D,IAAIA,iBAAAA,SAAS;GACX,UAAU,sBAAsB,OAAO,OAAO;GAC9C,aAAa,sBAAsB,OAAO,OAAO;GAClD,CAAC,EACF,OAAO,WACR,CAEY;;;;;;;;;;;;CAaf,aAAa,UACX,OACA,WACA,YACA,UAC0B;EAC1B,MAAM,OAAmB,EAAE;AAC3B,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG,UAAU,KAAK;GAC3D,MAAM,SAAS,IAAIA,iBAAAA,SAAS;IAC1B,aAAa,MAAM;IACnB;IACD,CAAC;AACF,QAAK,KAAK,OAAO;;AAEnB,SAAO,gBAAgB,cAAc,MAAM,YAAY,SAAS;;;;;;;;;;CAWlE,aAAa,cACX,MACA,YACA,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY,SAAS;AAC/C,QAAM,SAAS,aAAa,KAAK;AACjC,SAAO;;;;;;;;;;CAWT,aAAa,kBACX,YACA,UAC0B;AAE1B,SAAO,IADc,KAAK,YAAY,SACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectorstores.js","names":[],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAG/C,gBAAgC,EAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;;CAGT,YACE,YACA,EAAE,YAAY,GAAG,SAA8B,EAAE,EACjD;AACA,QAAM,YAAY,KAAK;AAEvB,OAAK,aAAa,cAAc;;;;;;;;;CAUlC,MAAM,aAAa,WAAsC;EACvD,MAAM,QAAQ,UAAU,KAAK,EAAE,kBAAkB,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;;;;;;;;;;CAWH,MAAM,WAAW,SAAqB,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,KAAK,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;GAC1B,EAAE;AAEH,OAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;;;;;;;;;;;;CAa/D,MAAM,gCACJ,OACA,GACA,QAC+B;EAC/B,MAAM,kBAAkB,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;AAOT,UAAO,
|
|
1
|
+
{"version":3,"file":"vectorstores.js","names":[],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAG/C,gBAAgC,EAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;;CAGT,YACE,YACA,EAAE,YAAY,GAAG,SAA8B,EAAE,EACjD;AACA,QAAM,YAAY,KAAK;AAEvB,OAAK,aAAa,cAAc;;;;;;;;;CAUlC,MAAM,aAAa,WAAsC;EACvD,MAAM,QAAQ,UAAU,KAAK,EAAE,kBAAkB,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;;;;;;;;;;CAWH,MAAM,WAAW,SAAqB,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,KAAK,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;GAC1B,EAAE;AAEH,OAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;;;;;;;;;;;;CAa/D,MAAM,gCACJ,OACA,GACA,QAC+B;EAC/B,MAAM,kBAAkB,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;AAOT,UAAO,OAAO,IAJE,SAAS;IACvB,UAAU,aAAa;IACvB,aAAa,aAAa;IAC3B,CACgB,CAAC;;EAEpB,MAAM,wBAAwB,KAAK,cAAc,OAAO,eAAe;AAiBvE,SAhBiB,sBACd,KAAK,QAAQ,WAAW;GACvB,YAAY,KAAK,WAAW,OAAO,OAAO,UAAU;GACpD;GACD,EAAE,CACF,MAAM,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,KAAK,EAAG,CACtD,MAAM,GAAG,EAEiC,CAAC,KAAK,WAAW,CAC5D,IAAI,SAAS;GACX,UAAU,sBAAsB,OAAO,OAAO;GAC9C,aAAa,sBAAsB,OAAO,OAAO;GAClD,CAAC,EACF,OAAO,WACR,CAEY;;;;;;;;;;;;CAaf,aAAa,UACX,OACA,WACA,YACA,UAC0B;EAC1B,MAAM,OAAmB,EAAE;AAC3B,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG,UAAU,KAAK;GAC3D,MAAM,SAAS,IAAI,SAAS;IAC1B,aAAa,MAAM;IACnB;IACD,CAAC;AACF,QAAK,KAAK,OAAO;;AAEnB,SAAO,gBAAgB,cAAc,MAAM,YAAY,SAAS;;;;;;;;;;CAWlE,aAAa,cACX,MACA,YACA,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY,SAAS;AAC/C,QAAM,SAAS,aAAa,KAAK;AACjC,SAAO;;;;;;;;;;CAWT,aAAa,kBACX,YACA,UAC0B;AAE1B,SAAO,IADc,KAAK,YAAY,SACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.cjs","names":["globalRegistry","util","$ZodOptional","$ZodNever","$ZodUnknown"],"sources":["../../../src/utils/types/zod.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\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\n// Internal-only type import – used for casts inside function bodies.\n// Never appears in exported type signatures, so it won't leak into\n// downstream .d.ts files or trigger cross-version structural comparisons.\nimport type * as z4 from \"zod/v4/core\";\n\nimport { SerializableSchema } from \"../standard_schema.js\";\n\n// @langchain/core's public API exposes types like `InteropZodType` (a union\n// of Zod v3 and v4 schema types) in function signatures, class properties,\n// and generic constraints. When those types were defined in terms of the\n// *real* Zod type imports (`z3.ZodType`, `z4.$ZodType`), they worked fine as\n// long as every package in the workspace resolved the exact same Zod version.\n//\n// In practice that assumption breaks. Zod 4 re-exports Zod 3 under\n// `zod/v3`, but different packages can still resolve to different *copies*\n// of Zod (e.g. `zod@3.25.x` vs `zod@4.x`) depending on their own lockfile\n// or hoisting. When that happens, TypeScript sees two structurally-similar\n// but *nominally-different* types and falls back to a full structural\n// comparison.\n//\n// The real Zod types are massive: ~3,400+ lines of deeply-nested,\n// mutually-recursive generics (`ZodType` → `ZodTypeDef` → `ZodEffects` →\n// `ZodType` → …). A structural comparison walks every branch of this tree\n// for *every* callsite that touches an `InteropZodType`. In a large\n// monorepo this quickly causes:\n//\n// • The TypeScript language server becoming unresponsive\n// • `tsc` exhausting the default heap and OOM-ing\n// • \"Type instantiation is excessively deep and possibly infinite\" errors\n//\n// We replace every Zod type that appears in an *exported* signature with the\n// minimal structural interface defined below. Each interface captures only\n// the properties that @langchain/core actually reads at runtime (e.g.\n// `_type`, `_output`, `_def`, `parse`, `_zod.def.type`, etc.).\n//\n// Because these interfaces are plain object shapes with no imports from the\n// `zod` package, TypeScript can check assignability in O(1) — there is\n// nothing recursive to walk. A real `z3.ZodString` or `z4.$ZodString` is\n// still assignable to `ZodV3Like<string>` or `ZodV4Like<string>` (they have\n// the required properties), so call-site compatibility is preserved.\n\nexport interface ZodV3TypeDef {\n typeName?: string;\n description?: string;\n [key: string]: any;\n}\n\nexport interface ZodV3Like<Output = any, Input = Output> {\n readonly _type: Output;\n readonly _output: Output;\n readonly _input: Input;\n readonly _def: ZodV3TypeDef;\n readonly description?: string;\n parse(data: unknown, params?: any): Output;\n safeParse(\n data: unknown,\n params?: any\n ): { success: boolean; data?: Output; error?: unknown };\n parseAsync(data: unknown, params?: any): Promise<Output>;\n safeParseAsync(\n data: unknown,\n params?: any\n ): Promise<{ success: boolean; data?: Output; error?: unknown }>;\n optional?(): ZodV3Like<Output | undefined, Input | undefined>;\n \"~standard\"?: any;\n}\n\nexport interface ZodV3ObjectLike extends ZodV3Like {\n readonly shape: Record<string, any>;\n extend(augmentation: Record<string, any>): ZodV3ObjectLike;\n partial(): ZodV3ObjectLike;\n strict(): ZodV3ObjectLike;\n passthrough(): ZodV3ObjectLike;\n}\n\nexport interface ZodV4Internals<O = any, I = any> {\n def: any;\n output: O;\n input: I;\n [key: string]: any;\n}\n\nexport interface ZodV4Like<Output = any, Input = Output> {\n _zod: ZodV4Internals<Output, Input>;\n \"~standard\"?: any;\n}\n\nexport interface ZodV4ObjectLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"object\"; shape: Record<string, any>; [key: string]: any };\n };\n}\n\nexport interface ZodV4ArrayLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"array\"; element: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4OptionalLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"optional\"; innerType: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4NullableLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"nullable\"; innerType: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4PipeLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"pipe\"; in: InteropZodType; [key: string]: unknown };\n [key: string]: unknown;\n };\n}\n\nexport interface ZodV3EffectsLike extends ZodV3Like {\n _def: ZodV3TypeDef & {\n typeName: \"ZodEffects\";\n schema: InteropZodType;\n };\n}\n\n// Aliases\n\nexport type ZodStringV3 = ZodV3Like<string>;\nexport type ZodStringV4 = ZodV4Like<string, unknown>;\n\nexport type ZodObjectV3 = ZodV3ObjectLike;\nexport type ZodObjectV4 = ZodV4ObjectLike;\nexport type ZodObjectV4Classic = ZodV4ObjectLike;\nexport type ZodObjectMain = ZodV4ObjectLike;\n\nexport type ZodDefaultV3<T extends ZodV3Like> = ZodV3Like<\n T extends ZodV3Like<infer O, any> ? O : any\n>;\nexport type ZodDefaultV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O : any\n>;\nexport type ZodOptionalV3<T extends ZodV3Like> = ZodV3Like<\n T extends ZodV3Like<infer O, any> ? O | undefined : any\n>;\nexport type ZodOptionalV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O | undefined : any\n>;\nexport type ZodNullableV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O | null : any\n>;\n\n// Interop types\n\nexport type InteropZodType<Output = any, Input = Output> =\n | ZodV3Like<Output, Input>\n | ZodV4Like<Output, Input>;\n\nexport type InteropZodObject = ZodV3ObjectLike | ZodV4ObjectLike;\n\nexport type InteropZodDefault<T = InteropZodObject> = T extends ZodV3Like\n ? ZodDefaultV3<T>\n : T extends ZodV4Like\n ? ZodDefaultV4<T>\n : never;\n\nexport type InteropZodOptional<T = InteropZodObject> = T extends ZodV3Like\n ? ZodOptionalV3<T>\n : T extends ZodV4Like\n ? ZodOptionalV4<T>\n : never;\n\nexport type InteropZodObjectShape<\n T extends InteropZodObject = InteropZodObject,\n> = T extends ZodV3ObjectLike\n ? { [K in keyof T[\"shape\"]]: T[\"shape\"][K] }\n : T extends ZodV4ObjectLike\n ? { [K in keyof T[\"_zod\"][\"def\"][\"shape\"]]: T[\"_zod\"][\"def\"][\"shape\"][K] }\n : never;\n\nexport interface InteropZodIssue {\n message: string;\n path: (string | number)[];\n [key: string]: unknown;\n}\n\nexport type InferInteropZodInput<T> =\n T extends ZodV3Like<unknown, infer Input>\n ? Input\n : T extends ZodV4Like<unknown, infer Input>\n ? Input\n : T extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\nexport type InferInteropZodOutput<T> =\n T extends ZodV3Like<infer Output, unknown>\n ? Output\n : T extends ZodV4Like<infer Output, unknown>\n ? Output\n : T extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\nexport type InteropZodLiteral = ZodV3Like | ZodV4Like;\n\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nexport function isZodSchemaV4(\n schema: unknown\n): schema is ZodV4Like<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 ZodV3Like<unknown, 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: ZodV3Like<RunOutput> | Record<string, unknown>\n): schema is ZodV3Like<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 (isZodSchemaV4(input) || isZodSchemaV3(input)) {\n return true;\n }\n return false;\n}\n\nexport function isZodLiteralV3(obj: unknown): obj is ZodV3Like {\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 ZodV4Like {\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\nexport interface InteropZodError {\n issues: InteropZodIssue[];\n}\n\ntype InteropZodSafeParseResult<T> =\n | { success: true; data: T; error?: never }\n | { success: false; error: InteropZodError; data?: never };\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 as z4.$ZodType<T>, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as InteropZodError,\n };\n }\n }\n if (isZodSchemaV3(schema)) {\n return (await schema.safeParseAsync(input)) as InteropZodSafeParseResult<T>;\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 as z4.$ZodType<T>, input);\n }\n if (isZodSchemaV3(schema)) {\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 as z4.$ZodType<T>, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as InteropZodError,\n };\n }\n }\n if (isZodSchemaV3(schema)) {\n return schema.safeParse(input) as InteropZodSafeParseResult<T>;\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 as z4.$ZodType<T>, input);\n }\n if (isZodSchemaV3(schema)) {\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, standard schema, 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: SerializableSchema | InteropZodType<unknown> | Record<string, unknown>\n): string | undefined {\n if (isZodSchemaV4(schema)) {\n return globalRegistry.get(schema as z4.$ZodType)?.description;\n }\n if (isZodSchemaV3(schema)) {\n return schema.description;\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)) {\n const def = schema._def;\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)) {\n const def = schema._def;\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 ZodV4ObjectLike {\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 ZodV4ArrayLike {\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\nexport function isZodOptionalV4(obj: unknown): obj is ZodV4OptionalLike {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 optional schemas have _zod.def.type === \"optional\"\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 === \"optional\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodNullableV4(obj: unknown): obj is ZodV4NullableLike {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 nullable schemas have _zod.def.type === \"nullable\"\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 === \"nullable\"\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 as InteropZodObjectShape<T>;\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);\n }\n if (isZodSchemaV4(schema)) {\n return util.extend(schema as z4.$ZodObject, 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 as z4.$ZodObject, 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 (isZodObjectV3(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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = 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;\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(elementSchema, recursive);\n }\n outputShape[key] = clone(keySchema as unknown as z4.$ZodType, {\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 as z4.$ZodType);\n if (meta) globalRegistry.add(outputShape[key] as z4.$ZodType, meta);\n }\n }\n const modifiedSchema = clone<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _never($ZodNever),\n });\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\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: boolean = 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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = 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;\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 ZodV4ObjectLike;\n }\n outputShape[key] = clone(keySchema as unknown as z4.$ZodType, {\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 as z4.$ZodType);\n if (meta) globalRegistry.add(outputShape[key] as z4.$ZodType, meta);\n }\n }\n const modifiedSchema = clone<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _unknown($ZodUnknown),\n });\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema as InteropZodObject;\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 as z4.$ZodType, undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction isZodTransformV3(schema: InteropZodType): schema is ZodV3EffectsLike {\n return (\n isZodSchemaV3(schema) &&\n \"typeName\" in schema._def &&\n schema._def.typeName === \"ZodEffects\"\n );\n}\n\nfunction isZodTransformV4(schema: InteropZodType): schema is ZodV4PipeLike {\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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = {};\n for (const [key, keySchema] of Object.entries(\n outputSchema._zod.def.shape\n )) {\n outputShape[key] = interopZodTransformInputSchemaImpl(\n keySchema as InteropZodType,\n recursive,\n cache\n );\n }\n outputSchema = clone<z4.$ZodObject>(outputSchema as z4.$ZodObject, {\n ...outputSchema._zod.def,\n shape: outputShape,\n }) as InteropZodType;\n }\n // Handle nested array schemas\n else if (isZodArrayV4(outputSchema)) {\n const elementSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.element as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodArray>(\n outputSchema as unknown as z4.$ZodArray,\n {\n ...outputSchema._zod.def,\n element: elementSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n // Handle optional schemas\n else if (isZodOptionalV4(outputSchema)) {\n const innerSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.innerType as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodOptional>(\n outputSchema as unknown as z4.$ZodOptional,\n {\n ...outputSchema._zod.def,\n innerType: innerSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n // Handle nullable schemas\n else if (isZodNullableV4(outputSchema)) {\n const innerSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.innerType as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodNullable>(\n outputSchema as unknown as z4.$ZodNullable,\n {\n ...outputSchema._zod.def,\n innerType: innerSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n }\n const meta = globalRegistry.get(schema as z4.$ZodType);\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 as InteropZodObject);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value as InteropZodType)) {\n // Make this field optional using v3 methods\n modifiedShape[key] = value.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 InteropZodObject;\n }\n\n if (isZodSchemaV4(schema)) {\n const shape = getInteropZodObjectShape(schema as InteropZodObject);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = {\n ...schema._zod.def.shape,\n };\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value as InteropZodType)) {\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<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n });\n\n // Preserve metadata\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n\n return modifiedSchema as InteropZodObject;\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 // oxlint-disable-next-line no-instanceof/no-instanceof\n e instanceof Error &&\n (e.constructor.name === \"ZodError\" || e.constructor.name === \"$ZodError\")\n );\n}\n"],"mappings":";;;AAgOA,SAAgB,cACd,QACuC;AACvC,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;;AAId,SAAgB,cACd,QACuC;AACvC,KAAI,OAAO,WAAW,YAAY,WAAW,KAC3C,QAAO;CAGT,MAAM,MAAM;AACZ,KAAI,EAAE,UAAU,QAAQ,UAAU,IAChC,QAAO;CAGT,MAAM,MAAM,IAAI;AAChB,QACE,OAAO,QAAQ,YACf,OAAO,QACP,cAAe;;;AAKnB,SAAgB,YAGd,QACgC;AAChC,KAAI,cAAc,OAAO,CACvB,SAAQ,KACN,4HACD;AAEH,QAAO,cAAc,OAAO;;;;;;;;AAS9B,SAAgB,mBAAmB,OAAyC;AAC1E,KAAI,CAAC,MACH,QAAO;AAET,KAAI,OAAO,UAAU,SACnB,QAAO;AAET,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO;AAET,KAAI,cAAc,MAAM,IAAI,cAAc,MAAM,CAC9C,QAAO;AAET,QAAO;;AAGT,SAAgB,eAAe,KAAgC;AAE7D,KACE,OAAO,QAAQ,YACf,QAAQ,QACR,UAAU,OACV,OAAO,IAAI,SAAS,YACpB,IAAI,SAAS,QACb,cAAc,IAAI,QAClB,IAAI,KAAK,aAAa,aAEtB,QAAO;AAET,QAAO;;AAGT,SAAgB,eAAe,KAA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AAQ,yBAAyB,OAA2B;EAElE,MAAM,cAAmC,EACvC,GAAG,OAAO,KAAK,IAAI,OACpB;AAED,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,KAAI,UAAU,KAAK,MAAwB,CAEzC,aAAY,OAAO,IAAIE,YAAAA,aAAa;GAClC,MAAM;GACN,WAAW;GACZ,CAAC;EAKN,MAAM,kBAAA,GAAA,YAAA,OAAsC,QAAyB;GACnE,GAAG,OAAO,KAAK;GACf,OAAO;GACR,CAAC;EAGF,MAAM,OAAOF,YAAAA,eAAe,IAAI,OAAiC;AACjE,MAAI,KAAM,aAAA,eAAe,IAAI,gBAAgB,KAAK;AAElD,SAAO;;AAGT,OAAM,IAAI,MACR,8DACD;;AAGH,SAAgB,kBAAkB,GAAY;AAC5C,QAEE,aAAa,UACZ,EAAE,YAAY,SAAS,cAAc,EAAE,YAAY,SAAS"}
|
|
1
|
+
{"version":3,"file":"zod.cjs","names":["globalRegistry","util","$ZodOptional","$ZodNever","$ZodUnknown"],"sources":["../../../src/utils/types/zod.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\n\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\n// Internal-only type import – used for casts inside function bodies.\n// Never appears in exported type signatures, so it won't leak into\n// downstream .d.ts files or trigger cross-version structural comparisons.\nimport type * as z4 from \"zod/v4/core\";\n\nimport { SerializableSchema } from \"../standard_schema.js\";\n\n// @langchain/core's public API exposes types like `InteropZodType` (a union\n// of Zod v3 and v4 schema types) in function signatures, class properties,\n// and generic constraints. When those types were defined in terms of the\n// *real* Zod type imports (`z3.ZodType`, `z4.$ZodType`), they worked fine as\n// long as every package in the workspace resolved the exact same Zod version.\n//\n// In practice that assumption breaks. Zod 4 re-exports Zod 3 under\n// `zod/v3`, but different packages can still resolve to different *copies*\n// of Zod (e.g. `zod@3.25.x` vs `zod@4.x`) depending on their own lockfile\n// or hoisting. When that happens, TypeScript sees two structurally-similar\n// but *nominally-different* types and falls back to a full structural\n// comparison.\n//\n// The real Zod types are massive: ~3,400+ lines of deeply-nested,\n// mutually-recursive generics (`ZodType` → `ZodTypeDef` → `ZodEffects` →\n// `ZodType` → …). A structural comparison walks every branch of this tree\n// for *every* callsite that touches an `InteropZodType`. In a large\n// monorepo this quickly causes:\n//\n// • The TypeScript language server becoming unresponsive\n// • `tsc` exhausting the default heap and OOM-ing\n// • \"Type instantiation is excessively deep and possibly infinite\" errors\n//\n// We replace every Zod type that appears in an *exported* signature with the\n// minimal structural interface defined below. Each interface captures only\n// the properties that @langchain/core actually reads at runtime (e.g.\n// `_type`, `_output`, `_def`, `parse`, `_zod.def.type`, etc.).\n//\n// Because these interfaces are plain object shapes with no imports from the\n// `zod` package, TypeScript can check assignability in O(1) — there is\n// nothing recursive to walk. A real `z3.ZodString` or `z4.$ZodString` is\n// still assignable to `ZodV3Like<string>` or `ZodV4Like<string>` (they have\n// the required properties), so call-site compatibility is preserved.\n\nexport interface ZodV3TypeDef {\n typeName?: string;\n description?: string;\n [key: string]: any;\n}\n\nexport interface ZodV3Like<Output = any, Input = Output> {\n readonly _type: Output;\n readonly _output: Output;\n readonly _input: Input;\n readonly _def: ZodV3TypeDef;\n readonly description?: string;\n parse(data: unknown, params?: any): Output;\n safeParse(\n data: unknown,\n params?: any\n ): { success: boolean; data?: Output; error?: unknown };\n parseAsync(data: unknown, params?: any): Promise<Output>;\n safeParseAsync(\n data: unknown,\n params?: any\n ): Promise<{ success: boolean; data?: Output; error?: unknown }>;\n optional?(): ZodV3Like<Output | undefined, Input | undefined>;\n \"~standard\"?: any;\n}\n\nexport interface ZodV3ObjectLike extends ZodV3Like {\n readonly shape: Record<string, any>;\n extend(augmentation: Record<string, any>): ZodV3ObjectLike;\n partial(): ZodV3ObjectLike;\n strict(): ZodV3ObjectLike;\n passthrough(): ZodV3ObjectLike;\n}\n\nexport interface ZodV4Internals<O = any, I = any> {\n def: any;\n output: O;\n input: I;\n [key: string]: any;\n}\n\nexport interface ZodV4Like<Output = any, Input = Output> {\n _zod: ZodV4Internals<Output, Input>;\n \"~standard\"?: any;\n}\n\nexport interface ZodV4ObjectLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"object\"; shape: Record<string, any>; [key: string]: any };\n };\n}\n\nexport interface ZodV4ArrayLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"array\"; element: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4OptionalLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"optional\"; innerType: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4NullableLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"nullable\"; innerType: ZodV4Like; [key: string]: unknown };\n };\n}\n\nexport interface ZodV4PipeLike extends ZodV4Like {\n _zod: ZodV4Internals & {\n def: { type: \"pipe\"; in: InteropZodType; [key: string]: unknown };\n [key: string]: unknown;\n };\n}\n\nexport interface ZodV3EffectsLike extends ZodV3Like {\n _def: ZodV3TypeDef & {\n typeName: \"ZodEffects\";\n schema: InteropZodType;\n };\n}\n\n// Aliases\n\nexport type ZodStringV3 = ZodV3Like<string>;\nexport type ZodStringV4 = ZodV4Like<string, unknown>;\n\nexport type ZodObjectV3 = ZodV3ObjectLike;\nexport type ZodObjectV4 = ZodV4ObjectLike;\nexport type ZodObjectV4Classic = ZodV4ObjectLike;\nexport type ZodObjectMain = ZodV4ObjectLike;\n\nexport type ZodDefaultV3<T extends ZodV3Like> = ZodV3Like<\n T extends ZodV3Like<infer O, any> ? O : any\n>;\nexport type ZodDefaultV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O : any\n>;\nexport type ZodOptionalV3<T extends ZodV3Like> = ZodV3Like<\n T extends ZodV3Like<infer O, any> ? O | undefined : any\n>;\nexport type ZodOptionalV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O | undefined : any\n>;\nexport type ZodNullableV4<T extends ZodV4Like> = ZodV4Like<\n T extends ZodV4Like<infer O, any> ? O | null : any\n>;\n\n// Interop types\n\nexport type InteropZodType<Output = any, Input = Output> =\n | ZodV3Like<Output, Input>\n | ZodV4Like<Output, Input>;\n\nexport type InteropZodObject = ZodV3ObjectLike | ZodV4ObjectLike;\n\nexport type InteropZodDefault<T = InteropZodObject> = T extends ZodV3Like\n ? ZodDefaultV3<T>\n : T extends ZodV4Like\n ? ZodDefaultV4<T>\n : never;\n\nexport type InteropZodOptional<T = InteropZodObject> = T extends ZodV3Like\n ? ZodOptionalV3<T>\n : T extends ZodV4Like\n ? ZodOptionalV4<T>\n : never;\n\nexport type InteropZodObjectShape<\n T extends InteropZodObject = InteropZodObject,\n> = T extends ZodV3ObjectLike\n ? { [K in keyof T[\"shape\"]]: T[\"shape\"][K] }\n : T extends ZodV4ObjectLike\n ? { [K in keyof T[\"_zod\"][\"def\"][\"shape\"]]: T[\"_zod\"][\"def\"][\"shape\"][K] }\n : never;\n\nexport interface InteropZodIssue {\n message: string;\n path: (string | number)[];\n [key: string]: unknown;\n}\n\nexport type InferInteropZodInput<T> =\n T extends ZodV3Like<unknown, infer Input>\n ? Input\n : T extends ZodV4Like<unknown, infer Input>\n ? Input\n : T extends { _zod: { input: infer Input } }\n ? Input\n : never;\n\nexport type InferInteropZodOutput<T> =\n T extends ZodV3Like<infer Output, unknown>\n ? Output\n : T extends ZodV4Like<infer Output, unknown>\n ? Output\n : T extends { _zod: { output: infer Output } }\n ? Output\n : never;\n\nexport type InteropZodLiteral = ZodV3Like | ZodV4Like;\n\nexport type Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nexport function isZodSchemaV4(\n schema: unknown\n): schema is ZodV4Like<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 ZodV3Like<unknown, 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: ZodV3Like<RunOutput> | Record<string, unknown>\n): schema is ZodV3Like<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 (isZodSchemaV4(input) || isZodSchemaV3(input)) {\n return true;\n }\n return false;\n}\n\nexport function isZodLiteralV3(obj: unknown): obj is ZodV3Like {\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 ZodV4Like {\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\nexport interface InteropZodError {\n issues: InteropZodIssue[];\n}\n\ntype InteropZodSafeParseResult<T> =\n | { success: true; data: T; error?: never }\n | { success: false; error: InteropZodError; data?: never };\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 as z4.$ZodType<T>, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as InteropZodError,\n };\n }\n }\n if (isZodSchemaV3(schema)) {\n return (await schema.safeParseAsync(input)) as InteropZodSafeParseResult<T>;\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 as z4.$ZodType<T>, input);\n }\n if (isZodSchemaV3(schema)) {\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 as z4.$ZodType<T>, input);\n return {\n success: true,\n data,\n };\n } catch (error) {\n return {\n success: false,\n error: error as InteropZodError,\n };\n }\n }\n if (isZodSchemaV3(schema)) {\n return schema.safeParse(input) as InteropZodSafeParseResult<T>;\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 as z4.$ZodType<T>, input);\n }\n if (isZodSchemaV3(schema)) {\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, standard schema, 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: SerializableSchema | InteropZodType<unknown> | Record<string, unknown>\n): string | undefined {\n if (isZodSchemaV4(schema)) {\n return globalRegistry.get(schema as z4.$ZodType)?.description;\n }\n if (isZodSchemaV3(schema)) {\n return schema.description;\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)) {\n const def = schema._def;\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)) {\n const def = schema._def;\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 ZodV4ObjectLike {\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 ZodV4ArrayLike {\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\nexport function isZodOptionalV4(obj: unknown): obj is ZodV4OptionalLike {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 optional schemas have _zod.def.type === \"optional\"\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 === \"optional\"\n ) {\n return true;\n }\n return false;\n}\n\nexport function isZodNullableV4(obj: unknown): obj is ZodV4NullableLike {\n if (!isZodSchemaV4(obj)) return false;\n // Zod v4 nullable schemas have _zod.def.type === \"nullable\"\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 === \"nullable\"\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 as InteropZodObjectShape<T>;\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);\n }\n if (isZodSchemaV4(schema)) {\n return util.extend(schema as z4.$ZodObject, 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 as z4.$ZodObject, 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 (isZodObjectV3(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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = 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;\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(elementSchema, recursive);\n }\n outputShape[key] = clone(keySchema as unknown as z4.$ZodType, {\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 as z4.$ZodType);\n if (meta) globalRegistry.add(outputShape[key] as z4.$ZodType, meta);\n }\n }\n const modifiedSchema = clone<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _never($ZodNever),\n });\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\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: boolean = 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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = 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;\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 ZodV4ObjectLike;\n }\n outputShape[key] = clone(keySchema as unknown as z4.$ZodType, {\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 as z4.$ZodType);\n if (meta) globalRegistry.add(outputShape[key] as z4.$ZodType, meta);\n }\n }\n const modifiedSchema = clone<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n catchall: _unknown($ZodUnknown),\n });\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n return modifiedSchema as InteropZodObject;\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 as z4.$ZodType, undefined);\n return () => defaultValue as InferInteropZodOutput<T>;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction isZodTransformV3(schema: InteropZodType): schema is ZodV3EffectsLike {\n return (\n isZodSchemaV3(schema) &&\n \"typeName\" in schema._def &&\n schema._def.typeName === \"ZodEffects\"\n );\n}\n\nfunction isZodTransformV4(schema: InteropZodType): schema is ZodV4PipeLike {\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 // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = {};\n for (const [key, keySchema] of Object.entries(\n outputSchema._zod.def.shape\n )) {\n outputShape[key] = interopZodTransformInputSchemaImpl(\n keySchema as InteropZodType,\n recursive,\n cache\n );\n }\n outputSchema = clone<z4.$ZodObject>(outputSchema as z4.$ZodObject, {\n ...outputSchema._zod.def,\n shape: outputShape,\n }) as InteropZodType;\n }\n // Handle nested array schemas\n else if (isZodArrayV4(outputSchema)) {\n const elementSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.element as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodArray>(\n outputSchema as unknown as z4.$ZodArray,\n {\n ...outputSchema._zod.def,\n element: elementSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n // Handle optional schemas\n else if (isZodOptionalV4(outputSchema)) {\n const innerSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.innerType as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodOptional>(\n outputSchema as unknown as z4.$ZodOptional,\n {\n ...outputSchema._zod.def,\n innerType: innerSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n // Handle nullable schemas\n else if (isZodNullableV4(outputSchema)) {\n const innerSchema = interopZodTransformInputSchemaImpl(\n outputSchema._zod.def.innerType as InteropZodType,\n recursive,\n cache\n );\n outputSchema = clone<z4.$ZodNullable>(\n outputSchema as unknown as z4.$ZodNullable,\n {\n ...outputSchema._zod.def,\n innerType: innerSchema as z4.$ZodType,\n }\n ) as InteropZodType;\n }\n }\n const meta = globalRegistry.get(schema as z4.$ZodType);\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 as InteropZodObject);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const modifiedShape: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value as InteropZodType)) {\n // Make this field optional using v3 methods\n modifiedShape[key] = value.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 InteropZodObject;\n }\n\n if (isZodSchemaV4(schema)) {\n const shape = getInteropZodObjectShape(schema as InteropZodObject);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const outputShape: Record<string, any> = {\n ...schema._zod.def.shape,\n };\n\n for (const [key, value] of Object.entries(shape)) {\n if (predicate(key, value as InteropZodType)) {\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<z4.$ZodObject>(schema as z4.$ZodObject, {\n ...schema._zod.def,\n shape: outputShape,\n });\n\n // Preserve metadata\n const meta = globalRegistry.get(schema as unknown as z4.$ZodType);\n if (meta) globalRegistry.add(modifiedSchema, meta);\n\n return modifiedSchema as InteropZodObject;\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 // oxlint-disable-next-line no-instanceof/no-instanceof\n e instanceof Error &&\n (e.constructor.name === \"ZodError\" || e.constructor.name === \"$ZodError\")\n );\n}\n"],"mappings":";;;AAgOA,SAAgB,cACd,QACuC;AACvC,KAAI,OAAO,WAAW,YAAY,WAAW,KAC3C,QAAO;CAGT,MAAM,MAAM;AACZ,KAAI,EAAE,UAAU,KACd,QAAO;CAGT,MAAM,MAAM,IAAI;AAChB,Q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