@google/adk 2.4.0 → 2.5.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/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +282 -55
- package/dist/cjs/agents/base_agent.js +111 -68
- package/dist/cjs/agents/functions.js +62 -85
- package/dist/cjs/agents/instructions.js +7 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +105 -95
- package/dist/cjs/agents/processors/content_processor_utils.js +42 -15
- package/dist/cjs/agents/processors/content_request_processor.js +28 -11
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +2 -1
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +128 -9
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +158 -36
- package/dist/cjs/common.js +50 -12
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +29 -14
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +45 -21
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +1 -4
- package/dist/cjs/sessions/database_session_service.js +191 -19
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +29 -28
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -5
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +22 -34
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +60 -20
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/cjs/tools/load_artifacts_tool.js +15 -5
- package/dist/cjs/tools/load_memory_tool.js +2 -5
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +18 -6
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +47 -28
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +9 -11
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +10 -9
- package/dist/cjs/utils/gemini_schema_util.js +125 -12
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +293 -55
- package/dist/esm/agents/base_agent.js +111 -72
- package/dist/esm/agents/functions.js +67 -89
- package/dist/esm/agents/instructions.js +7 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +111 -100
- package/dist/esm/agents/processors/content_processor_utils.js +42 -15
- package/dist/esm/agents/processors/content_request_processor.js +28 -11
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +2 -1
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +128 -9
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +158 -36
- package/dist/esm/common.js +49 -6
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +27 -15
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +45 -21
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +1 -4
- package/dist/esm/sessions/database_session_service.js +191 -19
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +29 -28
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +23 -35
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +64 -21
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/esm/tools/load_artifacts_tool.js +15 -5
- package/dist/esm/tools/load_memory_tool.js +2 -5
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +18 -6
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +47 -28
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +9 -11
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +10 -9
- package/dist/esm/utils/gemini_schema_util.js +124 -11
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +121 -3
- package/dist/types/agents/base_agent.d.ts +2 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +9 -9
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +19 -2
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +49 -8
- package/dist/types/common.d.ts +16 -9
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +9 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -21
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +0 -2
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +13 -4
- package/dist/types/tools/base_toolset.d.ts +1 -1
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +2 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +5 -1
- package/dist/types/tools/load_memory_tool.d.ts +13 -7
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +7 -3
- package/dist/types/tools/toolbox_toolset.d.ts +15 -20
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +27 -6
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +86 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +13 -15
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -393
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -88
- package/dist/esm/telemetry/tracing.js +0 -361
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -143
|
@@ -16,6 +16,40 @@ function asRecord(value) {
|
|
|
16
16
|
return value !== null && typeof value === "object" ? value : void 0;
|
|
17
17
|
}
|
|
18
18
|
__name(asRecord, "asRecord");
|
|
19
|
+
function toError(error) {
|
|
20
|
+
return error instanceof Error ? error : new Error("Execution threw a non-Error value.", { cause: error });
|
|
21
|
+
}
|
|
22
|
+
__name(toError, "toError");
|
|
23
|
+
function isInvocationCancellation(error, signal) {
|
|
24
|
+
if (!(signal == null ? void 0 : signal.aborted)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28
|
+
for (let depth = 0; depth < 32 && !seen.has(error); depth++) {
|
|
29
|
+
if (Object.is(error, signal.reason)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
seen.add(error);
|
|
33
|
+
const record = asRecord(error);
|
|
34
|
+
if (!record) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const name = record["name"];
|
|
39
|
+
if (name === "AbortError" || name === "InvocationAbortedError") {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (!("cause" in record)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
error = record["cause"];
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
__name(isInvocationCancellation, "isInvocationCancellation");
|
|
19
53
|
function firstString(...values) {
|
|
20
54
|
for (const value of values) {
|
|
21
55
|
if (typeof value === "string") {
|
|
@@ -96,5 +130,7 @@ function formatError(err) {
|
|
|
96
130
|
__name(formatError, "formatError");
|
|
97
131
|
export {
|
|
98
132
|
formatError,
|
|
99
|
-
getErrorMessage
|
|
133
|
+
getErrorMessage,
|
|
134
|
+
isInvocationCancellation,
|
|
135
|
+
toError
|
|
100
136
|
};
|
|
@@ -15,10 +15,7 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
15
15
|
}
|
|
16
16
|
let selectedKey = initialKey;
|
|
17
17
|
logger.debug(`Router selected initial key: ${selectedKey}`);
|
|
18
|
-
let selectedItem = items
|
|
19
|
-
if (!selectedItem) {
|
|
20
|
-
throw new Error(`Item not found for key: ${selectedKey}`);
|
|
21
|
-
}
|
|
18
|
+
let selectedItem = getSelectedItem(items, selectedKey);
|
|
22
19
|
const triedKeys = /* @__PURE__ */ new Set([selectedKey]);
|
|
23
20
|
while (true) {
|
|
24
21
|
let firstYielded = false;
|
|
@@ -48,10 +45,7 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
48
45
|
throw error;
|
|
49
46
|
}
|
|
50
47
|
selectedKey = nextKey;
|
|
51
|
-
selectedItem = items
|
|
52
|
-
if (!selectedItem) {
|
|
53
|
-
throw new Error(`Item not found for key: ${selectedKey}`);
|
|
54
|
-
}
|
|
48
|
+
selectedItem = getSelectedItem(items, selectedKey);
|
|
55
49
|
triedKeys.add(selectedKey);
|
|
56
50
|
} else {
|
|
57
51
|
throw error;
|
|
@@ -60,8 +54,15 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
__name(runWithRouting, "runWithRouting");
|
|
57
|
+
function getSelectedItem(items, key) {
|
|
58
|
+
if (!Object.hasOwn(items, key) || items[key] === void 0) {
|
|
59
|
+
throw new Error(`Item not found for key: ${key}`);
|
|
60
|
+
}
|
|
61
|
+
return items[key];
|
|
62
|
+
}
|
|
63
|
+
__name(getSelectedItem, "getSelectedItem");
|
|
63
64
|
function isAsyncGenerator(obj) {
|
|
64
|
-
return typeof obj === "object" && typeof obj[Symbol.asyncIterator] === "function";
|
|
65
|
+
return typeof obj === "object" && obj !== null && typeof obj[Symbol.asyncIterator] === "function";
|
|
65
66
|
}
|
|
66
67
|
__name(isAsyncGenerator, "isAsyncGenerator");
|
|
67
68
|
export {
|
|
@@ -39,6 +39,66 @@ const getTypeFromArrayItem = /* @__PURE__ */ __name((mcpType) => {
|
|
|
39
39
|
}
|
|
40
40
|
return (_b = (_a = mcpType == null ? void 0 : mcpType.type) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
|
|
41
41
|
}, "getTypeFromArrayItem");
|
|
42
|
+
const STRINGIFIED_CONSTRAINT_FIELDS = [
|
|
43
|
+
"maxItems",
|
|
44
|
+
"maxLength",
|
|
45
|
+
"maxProperties",
|
|
46
|
+
"minItems",
|
|
47
|
+
"minLength",
|
|
48
|
+
"minProperties"
|
|
49
|
+
];
|
|
50
|
+
const NUMERIC_CONSTRAINT_FIELDS = ["maximum", "minimum"];
|
|
51
|
+
const PATTERN_REDUNDANT_FORMATS = /* @__PURE__ */ new Set([
|
|
52
|
+
"email",
|
|
53
|
+
"uuid"
|
|
54
|
+
]);
|
|
55
|
+
const GEMINI_INTEGER_NUMBER_FORMATS = /* @__PURE__ */ new Set([
|
|
56
|
+
"int32",
|
|
57
|
+
"int64"
|
|
58
|
+
]);
|
|
59
|
+
const GEMINI_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
60
|
+
"date-time",
|
|
61
|
+
"enum"
|
|
62
|
+
]);
|
|
63
|
+
function keepsGeminiFormat(type, format) {
|
|
64
|
+
if (typeof type !== "string" || typeof format !== "string") {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (type === "integer" || type === "number") {
|
|
68
|
+
return GEMINI_INTEGER_NUMBER_FORMATS.has(format);
|
|
69
|
+
}
|
|
70
|
+
if (type === "string") {
|
|
71
|
+
return GEMINI_STRING_FORMATS.has(format);
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
__name(keepsGeminiFormat, "keepsGeminiFormat");
|
|
76
|
+
function copySchemaConstraints(source, target) {
|
|
77
|
+
for (const field of STRINGIFIED_CONSTRAINT_FIELDS) {
|
|
78
|
+
const value = source[field];
|
|
79
|
+
if (typeof value === "number" || typeof value === "string") {
|
|
80
|
+
target[field] = String(value);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
for (const field of NUMERIC_CONSTRAINT_FIELDS) {
|
|
84
|
+
const value = source[field];
|
|
85
|
+
if (typeof value === "number") {
|
|
86
|
+
target[field] = value;
|
|
87
|
+
} else if (typeof value === "string" && value.trim() !== "" && !Number.isNaN(Number(value))) {
|
|
88
|
+
target[field] = Number(value);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const pattern = source["pattern"];
|
|
92
|
+
const format = source["format"];
|
|
93
|
+
if (typeof pattern === "string") {
|
|
94
|
+
if (typeof format === "string" && PATTERN_REDUNDANT_FORMATS.has(format)) {
|
|
95
|
+
delete target["pattern"];
|
|
96
|
+
} else {
|
|
97
|
+
target["pattern"] = pattern;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
__name(copySchemaConstraints, "copySchemaConstraints");
|
|
42
102
|
function toGeminiSchema(mcpSchema) {
|
|
43
103
|
if (!mcpSchema) {
|
|
44
104
|
return void 0;
|
|
@@ -83,6 +143,7 @@ function toGeminiSchema(mcpSchema) {
|
|
|
83
143
|
mcp = { ...rest, anyOf: anyOfItems };
|
|
84
144
|
}
|
|
85
145
|
}
|
|
146
|
+
const declaredType = mcp.type;
|
|
86
147
|
if (!mcp.type) {
|
|
87
148
|
if (mcp.properties || mcp.$ref) {
|
|
88
149
|
mcp.type = "object";
|
|
@@ -119,6 +180,9 @@ function toGeminiSchema(mcpSchema) {
|
|
|
119
180
|
if (mcp.description) {
|
|
120
181
|
geminiSchema.description = mcp.description;
|
|
121
182
|
}
|
|
183
|
+
if (keepsGeminiFormat(declaredType, mcp.format)) {
|
|
184
|
+
geminiSchema.format = mcp.format;
|
|
185
|
+
}
|
|
122
186
|
if (mcp.enum) {
|
|
123
187
|
geminiSchema.enum = mcp.enum.filter((v) => v != null).map(String);
|
|
124
188
|
}
|
|
@@ -142,6 +206,10 @@ function toGeminiSchema(mcpSchema) {
|
|
|
142
206
|
geminiSchema.items = recursiveConvert(mcp.items);
|
|
143
207
|
}
|
|
144
208
|
}
|
|
209
|
+
copySchemaConstraints(
|
|
210
|
+
mcp,
|
|
211
|
+
geminiSchema
|
|
212
|
+
);
|
|
145
213
|
return geminiSchema;
|
|
146
214
|
}
|
|
147
215
|
__name(recursiveConvert, "recursiveConvert");
|
|
@@ -174,8 +242,7 @@ const GEMINI_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
|
174
242
|
]);
|
|
175
243
|
const GEMINI_REJECTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
176
244
|
"title",
|
|
177
|
-
"default"
|
|
178
|
-
"format"
|
|
245
|
+
"default"
|
|
179
246
|
]);
|
|
180
247
|
function toGeminiSchemaField(key) {
|
|
181
248
|
return toSnakeCaseName(key).replace(
|
|
@@ -220,41 +287,87 @@ function convertSchemaField(field, value) {
|
|
|
220
287
|
if (field === "items" && isPlainObject(value)) {
|
|
221
288
|
return openApiSchemaToGeminiSchema(value);
|
|
222
289
|
}
|
|
223
|
-
if (field === "anyOf" && Array.isArray(value)) {
|
|
224
|
-
return value.map((item) => openApiSchemaToGeminiSchema(item));
|
|
225
|
-
}
|
|
226
290
|
return value;
|
|
227
291
|
}
|
|
228
292
|
__name(convertSchemaField, "convertSchemaField");
|
|
293
|
+
function isNullSchema(value) {
|
|
294
|
+
return isPlainObject(value) && value["type"] === "null";
|
|
295
|
+
}
|
|
296
|
+
__name(isNullSchema, "isNullSchema");
|
|
297
|
+
function takeUnionBranches(schema) {
|
|
298
|
+
let branches;
|
|
299
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
300
|
+
const field = toGeminiSchemaField(key);
|
|
301
|
+
if (field !== "anyOf" && field !== "oneOf") {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
delete schema[key];
|
|
305
|
+
if (Array.isArray(value)) {
|
|
306
|
+
branches = [...branches != null ? branches : [], ...value];
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
return branches;
|
|
310
|
+
}
|
|
311
|
+
__name(takeUnionBranches, "takeUnionBranches");
|
|
229
312
|
function openApiSchemaToGeminiSchema(openApiSchema) {
|
|
230
313
|
if (openApiSchema === void 0 || openApiSchema === null) {
|
|
231
314
|
return void 0;
|
|
232
315
|
}
|
|
233
316
|
if (!isPlainObject(openApiSchema)) {
|
|
234
|
-
throw new TypeError("
|
|
317
|
+
throw new TypeError("openApiSchema must be a plain object");
|
|
235
318
|
}
|
|
236
319
|
const source = { ...openApiSchema };
|
|
237
|
-
|
|
320
|
+
let unionNullable = false;
|
|
321
|
+
let anyOf;
|
|
322
|
+
const branches = takeUnionBranches(source);
|
|
323
|
+
if (branches) {
|
|
324
|
+
const nonNullBranches = branches.filter((branch) => !isNullSchema(branch));
|
|
325
|
+
unionNullable = nonNullBranches.length !== branches.length;
|
|
326
|
+
if (nonNullBranches.length === 1 && isPlainObject(nonNullBranches[0])) {
|
|
327
|
+
const merged = openApiSchemaToGeminiSchema({
|
|
328
|
+
...nonNullBranches[0],
|
|
329
|
+
...source
|
|
330
|
+
});
|
|
331
|
+
if (unionNullable) {
|
|
332
|
+
merged.nullable = true;
|
|
333
|
+
}
|
|
334
|
+
return merged;
|
|
335
|
+
} else if (nonNullBranches.length > 0) {
|
|
336
|
+
anyOf = nonNullBranches.map(
|
|
337
|
+
(branch) => openApiSchemaToGeminiSchema(branch)
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
const [schemaType, typeNullable] = normalizeJsonSchemaType(source["type"]);
|
|
238
342
|
source["type"] = schemaType;
|
|
239
|
-
if (
|
|
343
|
+
if (typeNullable || unionNullable) {
|
|
240
344
|
source["nullable"] = true;
|
|
241
345
|
}
|
|
242
|
-
if (!source["type"]) {
|
|
346
|
+
if (!source["type"] && !anyOf) {
|
|
243
347
|
source["type"] = "object";
|
|
244
348
|
}
|
|
245
349
|
const converted = {};
|
|
246
350
|
for (const [key, value] of Object.entries(source)) {
|
|
247
351
|
const field = toGeminiSchemaField(key);
|
|
248
|
-
if (!GEMINI_SCHEMA_FIELDS.has(field) || GEMINI_REJECTED_SCHEMA_FIELDS.has(field)) {
|
|
352
|
+
if (value === void 0 || !GEMINI_SCHEMA_FIELDS.has(field) || GEMINI_REJECTED_SCHEMA_FIELDS.has(field)) {
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (field === "format") {
|
|
356
|
+
if (keepsGeminiFormat(schemaType, value)) {
|
|
357
|
+
converted[field] = value;
|
|
358
|
+
}
|
|
249
359
|
continue;
|
|
250
360
|
}
|
|
251
361
|
converted[field] = convertSchemaField(field, value);
|
|
252
362
|
}
|
|
363
|
+
if (anyOf) {
|
|
364
|
+
converted["anyOf"] = anyOf;
|
|
365
|
+
}
|
|
253
366
|
return converted;
|
|
254
367
|
}
|
|
255
368
|
__name(openApiSchemaToGeminiSchema, "openApiSchemaToGeminiSchema");
|
|
256
369
|
export {
|
|
257
|
-
|
|
370
|
+
copySchemaConstraints,
|
|
258
371
|
openApiSchemaToGeminiSchema,
|
|
259
372
|
toGeminiSchema
|
|
260
373
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { randomUUID } from "./env_aware_utils.js";
|
|
11
|
+
let idProvider;
|
|
12
|
+
function setIdProvider(provider) {
|
|
13
|
+
idProvider = provider;
|
|
14
|
+
}
|
|
15
|
+
__name(setIdProvider, "setIdProvider");
|
|
16
|
+
function resetIdProvider() {
|
|
17
|
+
idProvider = void 0;
|
|
18
|
+
}
|
|
19
|
+
__name(resetIdProvider, "resetIdProvider");
|
|
20
|
+
function newId() {
|
|
21
|
+
return newIdOr(randomUUID);
|
|
22
|
+
}
|
|
23
|
+
__name(newId, "newId");
|
|
24
|
+
function newIdOr(fallback) {
|
|
25
|
+
return idProvider ? idProvider() : fallback();
|
|
26
|
+
}
|
|
27
|
+
__name(newIdOr, "newIdOr");
|
|
28
|
+
export {
|
|
29
|
+
newId,
|
|
30
|
+
newIdOr,
|
|
31
|
+
resetIdProvider,
|
|
32
|
+
setIdProvider
|
|
33
|
+
};
|
|
@@ -35,6 +35,19 @@ function parseVersion(versionString) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
__name(parseVersion, "parseVersion");
|
|
38
|
+
function getGeminiMajorVersion(modelString) {
|
|
39
|
+
if (!modelString) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
const modelName = extractModelName(modelString);
|
|
43
|
+
if (!modelName.startsWith("gemini-")) {
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
const versionString = modelName.slice("gemini-".length).split("-", 1)[0];
|
|
47
|
+
const parsedVersion = parseVersion(versionString);
|
|
48
|
+
return parsedVersion.valid ? parsedVersion.major : void 0;
|
|
49
|
+
}
|
|
50
|
+
__name(getGeminiMajorVersion, "getGeminiMajorVersion");
|
|
38
51
|
function isGemini1Model(modelString) {
|
|
39
52
|
const modelName = extractModelName(modelString);
|
|
40
53
|
return modelName.startsWith("gemini-1");
|
|
@@ -78,6 +91,7 @@ function isGeminiModelIdCheckDisabled() {
|
|
|
78
91
|
__name(isGeminiModelIdCheckDisabled, "isGeminiModelIdCheckDisabled");
|
|
79
92
|
export {
|
|
80
93
|
extractModelName,
|
|
94
|
+
getGeminiMajorVersion,
|
|
81
95
|
isGemini1Model,
|
|
82
96
|
isGemini2OrAbove,
|
|
83
97
|
isGemini35LiveTranslate,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
zodToJsonSchema as toJSONSchemaV3
|
|
13
13
|
} from "zod-to-json-schema";
|
|
14
14
|
import { toJSONSchema as toJSONSchemaV4 } from "zod/v4";
|
|
15
|
+
import { copySchemaConstraints } from "./gemini_schema_util.js";
|
|
15
16
|
function isZodSchema(obj) {
|
|
16
17
|
return obj !== null && typeof obj === "object" && "parse" in obj && typeof obj.parse === "function" && "safeParse" in obj && typeof obj.safeParse === "function";
|
|
17
18
|
}
|
|
@@ -58,21 +59,10 @@ function zodObjectToSchema(schema) {
|
|
|
58
59
|
if (jsonSchema.readOnly !== void 0) {
|
|
59
60
|
delete jsonSchema.readOnly;
|
|
60
61
|
}
|
|
61
|
-
|
|
62
|
-
jsonSchema
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
delete jsonSchema.pattern;
|
|
66
|
-
}
|
|
67
|
-
if (jsonSchema.minItems !== void 0) {
|
|
68
|
-
jsonSchema.minItems = jsonSchema.minItems.toString();
|
|
69
|
-
}
|
|
70
|
-
if (jsonSchema.minLength !== void 0) {
|
|
71
|
-
jsonSchema.minLength = jsonSchema.minLength.toString();
|
|
72
|
-
}
|
|
73
|
-
if (jsonSchema.maxLength !== void 0) {
|
|
74
|
-
jsonSchema.maxLength = jsonSchema.maxLength.toString();
|
|
75
|
-
}
|
|
62
|
+
copySchemaConstraints(
|
|
63
|
+
jsonSchema,
|
|
64
|
+
jsonSchema
|
|
65
|
+
);
|
|
76
66
|
if (((_a = jsonSchema.enum) == null ? void 0 : _a.length) === 1 && jsonSchema.enum[0] === null) {
|
|
77
67
|
jsonSchema.type = Type.NULL;
|
|
78
68
|
delete jsonSchema.enum;
|
|
@@ -93,32 +83,24 @@ function zodObjectToSchema(schema) {
|
|
|
93
83
|
$refStrategy: "none",
|
|
94
84
|
emailStrategy: "format:email",
|
|
95
85
|
postProcess: /* @__PURE__ */ __name((jsonSchema) => {
|
|
96
|
-
var _a, _b, _c
|
|
86
|
+
var _a, _b, _c;
|
|
97
87
|
if (!jsonSchema) {
|
|
98
88
|
return;
|
|
99
89
|
}
|
|
100
90
|
if (jsonSchema.additionalProperties !== void 0) {
|
|
101
91
|
delete jsonSchema.additionalProperties;
|
|
102
92
|
}
|
|
103
|
-
|
|
104
|
-
jsonSchema
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
if (jsonSchema.minLength !== void 0) {
|
|
110
|
-
jsonSchema.minLength = (_c = jsonSchema.minLength) == null ? void 0 : _c.toString();
|
|
111
|
-
}
|
|
112
|
-
if (jsonSchema.maxLength !== void 0) {
|
|
113
|
-
jsonSchema.maxLength = (_d = jsonSchema.maxLength) == null ? void 0 : _d.toString();
|
|
114
|
-
}
|
|
115
|
-
if (((_e = jsonSchema.enum) == null ? void 0 : _e.length) === 1 && jsonSchema.enum[0] === "null") {
|
|
93
|
+
copySchemaConstraints(
|
|
94
|
+
jsonSchema,
|
|
95
|
+
jsonSchema
|
|
96
|
+
);
|
|
97
|
+
if (((_a = jsonSchema.enum) == null ? void 0 : _a.length) === 1 && jsonSchema.enum[0] === "null") {
|
|
116
98
|
jsonSchema.type = Type.NULL;
|
|
117
99
|
delete jsonSchema.enum;
|
|
118
100
|
}
|
|
119
101
|
if (jsonSchema.type === "integer" && jsonSchema.format !== "int64") {
|
|
120
|
-
(
|
|
121
|
-
(
|
|
102
|
+
(_b = jsonSchema.minimum) != null ? _b : jsonSchema.minimum = Number.MIN_SAFE_INTEGER;
|
|
103
|
+
(_c = jsonSchema.maximum) != null ? _c : jsonSchema.maximum = Number.MAX_SAFE_INTEGER;
|
|
122
104
|
}
|
|
123
105
|
if (jsonSchema.type !== void 0) {
|
|
124
106
|
jsonSchema.type = jsonSchema.type.toUpperCase();
|
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
9
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
5
26
|
/**
|
|
6
27
|
* @license
|
|
7
28
|
* Copyright 2026 Google LLC
|
|
8
29
|
* SPDX-License-Identifier: Apache-2.0
|
|
9
30
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
31
|
+
const DNS_MODULE = "node:dns/promises";
|
|
32
|
+
const IPV6_CHARACTERS = /^[0-9a-f:.]+$/i;
|
|
12
33
|
const HTTP_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:"]);
|
|
13
34
|
const NON_GLOBAL_IPV4_CIDRS = [
|
|
14
35
|
"0.0.0.0/8",
|
|
@@ -87,10 +108,15 @@ function isLinkLocalAddress(address) {
|
|
|
87
108
|
return classifyAddress(address, isLinkLocalIpv4, isLinkLocalIpv6);
|
|
88
109
|
}
|
|
89
110
|
__name(isLinkLocalAddress, "isLinkLocalAddress");
|
|
111
|
+
function isIpAddress(address) {
|
|
112
|
+
return parseIpv4(address) !== null || isIpv6Literal(address);
|
|
113
|
+
}
|
|
114
|
+
__name(isIpAddress, "isIpAddress");
|
|
90
115
|
async function resolveHostAddresses(hostname) {
|
|
91
|
-
if (
|
|
116
|
+
if (isIpAddress(hostname)) {
|
|
92
117
|
return [hostname];
|
|
93
118
|
}
|
|
119
|
+
const { lookup } = await Promise.resolve().then(() => __toESM(require(DNS_MODULE)));
|
|
94
120
|
const records = await lookup(hostname, { all: true });
|
|
95
121
|
const addresses = [...new Set(records.map((record) => record.address))];
|
|
96
122
|
if (addresses.length === 0) {
|
|
@@ -123,8 +149,20 @@ function parseIpv4(address) {
|
|
|
123
149
|
return octets;
|
|
124
150
|
}
|
|
125
151
|
__name(parseIpv4, "parseIpv4");
|
|
152
|
+
function isIpv6Literal(address) {
|
|
153
|
+
if (!address.includes(":") || !IPV6_CHARACTERS.test(address)) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
new URL(`http://[${address}]/`);
|
|
158
|
+
return true;
|
|
159
|
+
} catch {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
__name(isIpv6Literal, "isIpv6Literal");
|
|
126
164
|
function parseIpv6(address) {
|
|
127
|
-
if (
|
|
165
|
+
if (!isIpv6Literal(address)) {
|
|
128
166
|
return null;
|
|
129
167
|
}
|
|
130
168
|
const [head, tail] = address.split("::");
|
|
@@ -151,14 +189,6 @@ function ipv4ToInt(octets) {
|
|
|
151
189
|
return (octets[0] << 24 | octets[1] << 16 | octets[2] << 8 | octets[3]) >>> 0;
|
|
152
190
|
}
|
|
153
191
|
__name(ipv4ToInt, "ipv4ToInt");
|
|
154
|
-
function hextetsToBigInt(hextets) {
|
|
155
|
-
let value = 0n;
|
|
156
|
-
for (const hextet of hextets) {
|
|
157
|
-
value = value << 16n | BigInt(hextet);
|
|
158
|
-
}
|
|
159
|
-
return value;
|
|
160
|
-
}
|
|
161
|
-
__name(hextetsToBigInt, "hextetsToBigInt");
|
|
162
192
|
function parseIpv4Cidr(cidr) {
|
|
163
193
|
const [address, prefix] = cidr.split("/");
|
|
164
194
|
const mask = 4294967295 << 32 - Number(prefix) >>> 0;
|
|
@@ -167,7 +197,7 @@ function parseIpv4Cidr(cidr) {
|
|
|
167
197
|
__name(parseIpv4Cidr, "parseIpv4Cidr");
|
|
168
198
|
function parseIpv6Cidr(cidr) {
|
|
169
199
|
const [address, prefix] = cidr.split("/");
|
|
170
|
-
return { base:
|
|
200
|
+
return { base: parseIpv6(address), prefix: Number(prefix) };
|
|
171
201
|
}
|
|
172
202
|
__name(parseIpv6Cidr, "parseIpv6Cidr");
|
|
173
203
|
function matchesIpv4Cidr(octets, { base, mask }) {
|
|
@@ -175,8 +205,17 @@ function matchesIpv4Cidr(octets, { base, mask }) {
|
|
|
175
205
|
}
|
|
176
206
|
__name(matchesIpv4Cidr, "matchesIpv4Cidr");
|
|
177
207
|
function matchesIpv6Cidr(hextets, { base, prefix }) {
|
|
178
|
-
|
|
179
|
-
|
|
208
|
+
for (let i = 0; i < base.length; i++) {
|
|
209
|
+
const bits = Math.min(16, prefix - i * 16);
|
|
210
|
+
if (bits <= 0) {
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
const mask = 65535 << 16 - bits & 65535;
|
|
214
|
+
if ((hextets[i] & mask) !== (base[i] & mask)) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
180
219
|
}
|
|
181
220
|
__name(matchesIpv6Cidr, "matchesIpv6Cidr");
|
|
182
221
|
function embeddedIpv4(hextets) {
|
|
@@ -222,6 +261,7 @@ function isLinkLocalIpv6(hextets) {
|
|
|
222
261
|
__name(isLinkLocalIpv6, "isLinkLocalIpv6");
|
|
223
262
|
export {
|
|
224
263
|
isHttpUrl,
|
|
264
|
+
isIpAddress,
|
|
225
265
|
isLinkLocalAddress,
|
|
226
266
|
isLocalhostHostname,
|
|
227
267
|
isNonGlobalAddress,
|
package/dist/esm/version.js
CHANGED
|
@@ -16,7 +16,7 @@ import { WorkflowNode, node } from "./node.js";
|
|
|
16
16
|
import { FunctionNode } from "./nodes/function_node.js";
|
|
17
17
|
import { JoinNode } from "./nodes/join_node.js";
|
|
18
18
|
import { NodeTool } from "./nodes/node_tool.js";
|
|
19
|
-
import { ParallelWorker } from "./nodes/parallel_worker.js";
|
|
19
|
+
import { ParallelWorker, isParallelWorker } from "./nodes/parallel_worker.js";
|
|
20
20
|
import { ToolNode } from "./nodes/tool_node.js";
|
|
21
21
|
import { DEFAULT_ROUTE, Edge, Graph } from "./graph.js";
|
|
22
22
|
import { BranchPath, commonPrefixOf, createSubBranch } from "./branch_path.js";
|
|
@@ -70,6 +70,7 @@ export {
|
|
|
70
70
|
isNodeSchemaValidationError,
|
|
71
71
|
isNodeState,
|
|
72
72
|
isNodeTimeoutError,
|
|
73
|
+
isParallelWorker,
|
|
73
74
|
isRequestInput,
|
|
74
75
|
isRunnableRoot,
|
|
75
76
|
isWorkflow,
|