@google/adk 2.2.1 → 2.3.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 +4 -1
- package/dist/cjs/a2a/agent_card.js +102 -26
- package/dist/cjs/a2a/agent_to_a2a.js +1 -1
- package/dist/cjs/agents/functions.js +199 -25
- package/dist/cjs/agents/instructions.js +4 -1
- package/dist/cjs/agents/invocation_context.js +26 -4
- package/dist/cjs/agents/langgraph_agent.js +152 -0
- package/dist/cjs/agents/llm_agent.js +175 -101
- package/dist/cjs/agents/processors/code_execution_request_processor.js +10 -6
- package/dist/cjs/agents/remote_agent.js +187 -0
- package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/cjs/auth/auth_handler.js +37 -5
- package/dist/cjs/auth/auth_schemes.js +9 -0
- package/dist/cjs/cli/cli_eval.js +532 -0
- package/dist/cjs/cli/utils/envs.js +116 -0
- package/dist/cjs/cli/utils/evals.js +137 -0
- package/dist/cjs/cli/utils/logs.js +150 -0
- package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/cjs/code_executors/code_execution_utils.js +48 -16
- package/dist/cjs/code_executors/code_executor_context.js +6 -2
- package/dist/cjs/common.js +72 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
- package/dist/cjs/context/token_based_context_compactor.js +2 -1
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/examples/example_util.js +23 -2
- package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
- package/dist/cjs/index.js +97 -1
- package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +16 -8
- package/dist/cjs/models/google_llm.js +13 -16
- package/dist/cjs/models/llm_response.js +9 -1
- package/dist/cjs/models/registry.js +1 -1
- package/dist/cjs/models/routed_llm.js +9 -8
- package/dist/cjs/planners/plan_re_act_planner.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +105 -33
- package/dist/cjs/sessions/db/operations.js +1 -1
- package/dist/cjs/sessions/in_memory_session_service.js +3 -1
- package/dist/cjs/sessions/state.js +8 -4
- package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
- package/dist/cjs/telemetry/tracing.js +97 -66
- package/dist/cjs/tools/agent_tool.js +44 -0
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +142 -0
- package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
- package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
- package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +185 -0
- package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +603 -0
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +219 -0
- package/dist/cjs/tools/crewai_tool.js +132 -0
- package/dist/cjs/tools/example_tool.js +10 -0
- package/dist/cjs/tools/function_tool.js +319 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +97 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +226 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +58 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
- package/dist/cjs/tools/google_api_tool/index.js +64 -0
- package/dist/cjs/tools/langchain_tool.js +172 -0
- package/dist/cjs/tools/mcp/index.js +12 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
- package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
- package/dist/cjs/tools/toolbox_tool.js +108 -0
- package/dist/cjs/utils/env_aware_utils.js +6 -8
- package/dist/cjs/utils/error_utils.js +11 -11
- package/dist/cjs/utils/file_extension_utils.js +11 -0
- package/dist/cjs/utils/file_utils.js +2 -24
- package/dist/cjs/utils/gemini_schema_util.js +4 -1
- package/dist/cjs/utils/json_utils.js +49 -0
- package/dist/cjs/utils/live_connection_utils.js +4 -5
- package/dist/cjs/utils/logger_node.js +7 -1
- package/dist/cjs/utils/object_notation_utils.js +6 -3
- package/dist/cjs/utils/streaming_utils.js +12 -12
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_remote_agent.js +4 -1
- package/dist/esm/a2a/agent_card.js +103 -27
- package/dist/esm/a2a/agent_to_a2a.js +5 -2
- package/dist/esm/agents/functions.js +198 -25
- package/dist/esm/agents/instructions.js +4 -1
- package/dist/esm/agents/invocation_context.js +24 -4
- package/dist/esm/agents/langgraph_agent.js +123 -0
- package/dist/esm/agents/llm_agent.js +185 -104
- package/dist/esm/agents/processors/code_execution_request_processor.js +13 -8
- package/dist/esm/agents/remote_agent.js +164 -0
- package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
- package/dist/esm/auth/auth_handler.js +37 -5
- package/dist/esm/auth/auth_schemes.js +8 -0
- package/dist/esm/cli/cli_eval.js +510 -0
- package/dist/esm/cli/utils/envs.js +78 -0
- package/dist/esm/cli/utils/evals.js +109 -0
- package/dist/esm/cli/utils/logs.js +111 -0
- package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
- package/dist/esm/code_executors/code_execution_utils.js +46 -16
- package/dist/esm/code_executors/code_executor_context.js +5 -2
- package/dist/esm/common.js +67 -3
- package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
- package/dist/esm/context/token_based_context_compactor.js +2 -1
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/examples/example_util.js +21 -1
- package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
- package/dist/esm/index.js +99 -1
- package/dist/esm/integrations/agent_registry/helpers.js +1 -1
- package/dist/esm/models/gemini_llm_connection.js +16 -8
- package/dist/esm/models/google_llm.js +14 -17
- package/dist/esm/models/llm_response.js +9 -1
- package/dist/esm/models/registry.js +1 -1
- package/dist/esm/models/routed_llm.js +9 -8
- package/dist/esm/planners/plan_re_act_planner.js +1 -1
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +105 -33
- package/dist/esm/sessions/db/operations.js +1 -1
- package/dist/esm/sessions/in_memory_session_service.js +3 -1
- package/dist/esm/sessions/state.js +8 -4
- package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
- package/dist/esm/telemetry/tracing.js +97 -66
- package/dist/esm/tools/agent_tool.js +44 -0
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +106 -0
- package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
- package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
- package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +163 -0
- package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +561 -0
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +215 -0
- package/dist/esm/tools/crewai_tool.js +107 -0
- package/dist/esm/tools/example_tool.js +13 -1
- package/dist/esm/tools/function_tool.js +316 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +70 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +188 -0
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +24 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
- package/dist/esm/tools/google_api_tool/index.js +33 -0
- package/dist/esm/tools/langchain_tool.js +148 -0
- package/dist/esm/tools/mcp/index.js +6 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -1
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
- package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
- package/dist/esm/tools/toolbox_tool.js +80 -0
- package/dist/esm/utils/env_aware_utils.js +6 -8
- package/dist/esm/utils/error_utils.js +9 -10
- package/dist/esm/utils/file_extension_utils.js +11 -0
- package/dist/esm/utils/file_utils.js +2 -23
- package/dist/esm/utils/gemini_schema_util.js +4 -1
- package/dist/esm/utils/json_utils.js +21 -0
- package/dist/esm/utils/live_connection_utils.js +4 -5
- package/dist/esm/utils/logger_node.js +7 -1
- package/dist/esm/utils/object_notation_utils.js +4 -2
- package/dist/esm/utils/streaming_utils.js +11 -11
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
- package/dist/types/a2a/agent_card.d.ts +44 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
- package/dist/types/a2a/index.d.ts +1 -0
- package/dist/types/agents/functions.d.ts +33 -1
- package/dist/types/agents/invocation_context.d.ts +20 -1
- package/dist/types/agents/langgraph_agent.d.ts +153 -0
- package/dist/types/agents/remote_agent.d.ts +68 -0
- package/dist/types/auth/auth_handler.d.ts +28 -1
- package/dist/types/auth/auth_schemes.d.ts +13 -0
- package/dist/types/cli/cli_eval.d.ts +173 -0
- package/dist/types/cli/utils/envs.d.ts +23 -0
- package/dist/types/cli/utils/evals.d.ts +47 -0
- package/dist/types/cli/utils/logs.d.ts +38 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
- package/dist/types/code_executors/code_executor_context.d.ts +1 -0
- package/dist/types/common.d.ts +27 -4
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/examples/example_util.d.ts +17 -0
- package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
- package/dist/types/index.d.ts +16 -1
- package/dist/types/models/gemini_llm_connection.d.ts +6 -7
- package/dist/types/models/routed_llm.d.ts +1 -1
- package/dist/types/runner/in_memory_runner.d.ts +2 -1
- package/dist/types/runner/runner.d.ts +34 -0
- package/dist/types/sessions/state.d.ts +5 -1
- package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
- package/dist/types/skills/skill.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +4 -2
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +122 -0
- package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
- package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
- package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +86 -0
- package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +215 -0
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
- package/dist/types/tools/crewai_tool.d.ts +85 -0
- package/dist/types/tools/example_tool.d.ts +10 -0
- package/dist/types/tools/function_tool.d.ts +32 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +30 -0
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +78 -0
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +33 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +164 -0
- package/dist/types/tools/google_api_tool/index.d.ts +11 -0
- package/dist/types/tools/langchain_tool.d.ts +103 -0
- package/dist/types/tools/mcp/index.d.ts +3 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
- package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
- package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
- package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
- package/dist/types/tools/toolbox_tool.d.ts +73 -0
- package/dist/types/utils/env_aware_utils.d.ts +18 -2
- package/dist/types/utils/error_utils.d.ts +7 -0
- package/dist/types/utils/file_utils.d.ts +6 -1
- package/dist/types/utils/gemini_schema_util.d.ts +1 -2
- package/dist/types/utils/json_utils.d.ts +11 -0
- package/dist/types/utils/object_notation_utils.d.ts +7 -0
- package/dist/types/utils/streaming_utils.d.ts +11 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +102 -103
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
- package/dist/cjs/models/gemini_continuation.js +0 -232
- package/dist/esm/models/gemini_continuation.js +0 -205
- package/dist/types/models/gemini_continuation.d.ts +0 -59
package/dist/cjs/common.js
CHANGED
|
@@ -41,6 +41,7 @@ __export(common_exports, {
|
|
|
41
41
|
AuthHandler: () => import_auth_handler.AuthHandler,
|
|
42
42
|
AuthPreprocessor: () => import_auth_preprocessor.AuthPreprocessor,
|
|
43
43
|
AuthProviderRegistry: () => import_auth_provider_registry.AuthProviderRegistry,
|
|
44
|
+
AuthSchemeType: () => import_auth_schemes.AuthSchemeType,
|
|
44
45
|
BaseAgent: () => import_base_agent.BaseAgent,
|
|
45
46
|
BaseCodeExecutor: () => import_base_code_executor.BaseCodeExecutor,
|
|
46
47
|
BaseEnvironment: () => import_base_environment.BaseEnvironment,
|
|
@@ -64,6 +65,7 @@ __export(common_exports, {
|
|
|
64
65
|
ChromeBuiltInLlm: () => import_chrome_prompt_llm.ChromeBuiltInLlm,
|
|
65
66
|
ChromeModelUnavailableError: () => import_chrome_prompt_llm.ChromeModelUnavailableError,
|
|
66
67
|
CodeExecutionLanguage: () => import_code_execution_utils.CodeExecutionLanguage,
|
|
68
|
+
CodeExecutionResponseProcessor: () => import_code_execution_request_processor.CodeExecutionResponseProcessor,
|
|
67
69
|
ConsolidateContextTool: () => import_consolidate_context_tool.ConsolidateContextTool,
|
|
68
70
|
ContentRequestProcessor: () => import_content_request_processor.ContentRequestProcessor,
|
|
69
71
|
Context: () => import_context.Context,
|
|
@@ -71,6 +73,7 @@ __export(common_exports, {
|
|
|
71
73
|
ContextCompactorRequestProcessor: () => import_context_compactor_request_processor.ContextCompactorRequestProcessor,
|
|
72
74
|
CredentialExchangeError: () => import_base_credential_exchanger.CredentialExchangeError,
|
|
73
75
|
CredentialRefresherRegistry: () => import_credential_refresher_registry.CredentialRefresherRegistry,
|
|
76
|
+
CrewaiTool: () => import_crewai_tool.CrewaiTool,
|
|
74
77
|
DEFAULT_ROUTE: () => import_workflow.DEFAULT_ROUTE,
|
|
75
78
|
ENTERPRISE_WEB_SEARCH: () => import_enterprise_web_search_tool.ENTERPRISE_WEB_SEARCH,
|
|
76
79
|
EXIT_LOOP: () => import_exit_loop_tool.EXIT_LOOP,
|
|
@@ -111,10 +114,13 @@ __export(common_exports, {
|
|
|
111
114
|
LLMRegistry: () => import_registry.LLMRegistry,
|
|
112
115
|
LOAD_ARTIFACTS: () => import_load_artifacts_tool.LOAD_ARTIFACTS,
|
|
113
116
|
LOAD_MEMORY: () => import_load_memory_tool.LOAD_MEMORY,
|
|
117
|
+
LangGraphAgent: () => import_langgraph_agent.LangGraphAgent,
|
|
118
|
+
LangchainTool: () => import_langchain_tool.LangchainTool,
|
|
114
119
|
ListSkillsTool: () => import_list_skills_tool.ListSkillsTool,
|
|
115
120
|
LiveRequestQueue: () => import_live_request_queue.LiveRequestQueue,
|
|
116
121
|
LlamaIndexRetrieval: () => import_llama_index_retrieval.LlamaIndexRetrieval,
|
|
117
122
|
LlmAgent: () => import_llm_agent.LlmAgent,
|
|
123
|
+
LlmCallsLimitExceededError: () => import_invocation_context.LlmCallsLimitExceededError,
|
|
118
124
|
LlmSummarizer: () => import_llm_summarizer.LlmSummarizer,
|
|
119
125
|
LoadArtifactsTool: () => import_load_artifacts_tool.LoadArtifactsTool,
|
|
120
126
|
LoadMemoryTool: () => import_load_memory_tool.LoadMemoryTool,
|
|
@@ -149,6 +155,7 @@ __export(common_exports, {
|
|
|
149
155
|
ReadonlyContext: () => import_readonly_context.ReadonlyContext,
|
|
150
156
|
ReflectAndRetryModelPlugin: () => import_reflect_retry_model_plugin.ReflectAndRetryModelPlugin,
|
|
151
157
|
ReflectAndRetryToolPlugin: () => import_reflect_retry_tool_plugin.ReflectAndRetryToolPlugin,
|
|
158
|
+
RemoteAgent: () => import_remote_agent.RemoteAgent,
|
|
152
159
|
RequestInput: () => import_workflow.RequestInput,
|
|
153
160
|
RoutedAgent: () => import_routed_agent.RoutedAgent,
|
|
154
161
|
RoutedLlm: () => import_routed_llm.RoutedLlm,
|
|
@@ -173,6 +180,7 @@ __export(common_exports, {
|
|
|
173
180
|
ToolErrorType: () => import_tool_execution_error.ToolErrorType,
|
|
174
181
|
ToolExecutionError: () => import_tool_execution_error.ToolExecutionError,
|
|
175
182
|
ToolNode: () => import_workflow.ToolNode,
|
|
183
|
+
ToolboxTool: () => import_toolbox_tool.ToolboxTool,
|
|
176
184
|
TrackingScope: () => import_reflect_retry_utils.TrackingScope,
|
|
177
185
|
TrajectoryThoughtPruningCompactor: () => import_trajectory_thought_pruning_compactor.TrajectoryThoughtPruningCompactor,
|
|
178
186
|
TruncatingContextCompactor: () => import_truncating_context_compactor.TruncatingContextCompactor,
|
|
@@ -185,13 +193,21 @@ __export(common_exports, {
|
|
|
185
193
|
WebMCPToolset: () => import_webmcp_toolset.WebMCPToolset,
|
|
186
194
|
Workflow: () => import_workflow.Workflow,
|
|
187
195
|
WorkflowNode: () => import_workflow.WorkflowNode,
|
|
196
|
+
appendInstructions: () => import_llm_request.appendInstructions,
|
|
188
197
|
asRunnableRoot: () => import_workflow.asRunnableRoot,
|
|
198
|
+
buildFunctionDeclarationForLangchain: () => import_function_tool2.buildFunctionDeclarationForLangchain,
|
|
199
|
+
buildFunctionDeclarationForParamsForCrewai: () => import_function_tool2.buildFunctionDeclarationForParamsForCrewai,
|
|
200
|
+
buildFunctionDeclarationUtil: () => import_function_tool2.buildFunctionDeclarationUtil,
|
|
189
201
|
commonPrefixOf: () => import_workflow.commonPrefixOf,
|
|
202
|
+
convertSessionToEvalFormat: () => import_evals.convertSessionToEvalFormat,
|
|
203
|
+
createEmptyState: () => import_evals.createEmptyState,
|
|
190
204
|
createEvent: () => import_event.createEvent,
|
|
191
205
|
createEventActions: () => import_event_actions.createEventActions,
|
|
206
|
+
createLlmResponse: () => import_llm_response.createLlmResponse,
|
|
192
207
|
createNodeErrorEvent: () => import_workflow.createNodeErrorEvent,
|
|
193
208
|
createNodeState: () => import_workflow.createNodeState,
|
|
194
209
|
createResumabilityConfig: () => import_resumability_config.createResumabilityConfig,
|
|
210
|
+
createRunConfig: () => import_run_config.createRunConfig,
|
|
195
211
|
createSession: () => import_session.createSession,
|
|
196
212
|
createSubBranch: () => import_workflow.createSubBranch,
|
|
197
213
|
determineAgentForResumption: () => import_runner.determineAgentForResumption,
|
|
@@ -200,16 +216,20 @@ __export(common_exports, {
|
|
|
200
216
|
findMatchingFunctionCall: () => import_functions.findMatchingFunctionCall,
|
|
201
217
|
functionsExportedForTestingOnly: () => import_functions.functionsExportedForTestingOnly,
|
|
202
218
|
geminiInitParams: () => import_google_llm.geminiInitParams,
|
|
219
|
+
genaiSchemaToJsonSchema: () => import_genai_schema_to_json.genaiSchemaToJsonSchema,
|
|
203
220
|
generateClientFunctionCallId: () => import_event.generateClientFunctionCallId,
|
|
204
221
|
getAskUserConfirmationFunctionCalls: () => import_security_plugin.getAskUserConfirmationFunctionCalls,
|
|
205
222
|
getClientLabels: () => import_client_labels.getClientLabels,
|
|
206
223
|
getFunctionCalls: () => import_event.getFunctionCalls,
|
|
207
224
|
getFunctionResponses: () => import_event.getFunctionResponses,
|
|
225
|
+
getLastHumanMessages: () => import_langgraph_agent.getLastHumanMessages,
|
|
208
226
|
getLogger: () => import_logger.getLogger,
|
|
209
227
|
getModelContext: () => import_webmcp_types.getModelContext,
|
|
228
|
+
getOAuthGrantTypeFromFlow: () => import_auth_schemes.getOAuthGrantTypeFromFlow,
|
|
210
229
|
getPendingUserInputRequests: () => import_user_input_request.getPendingUserInputRequests,
|
|
211
230
|
getUserChoiceTool: () => import_get_user_choice_tool.getUserChoiceTool,
|
|
212
231
|
getUserInputRequests: () => import_user_input_request.getUserInputRequests,
|
|
232
|
+
handleFunctionCallsLive: () => import_functions.handleFunctionCallsLive,
|
|
213
233
|
hasThoughts: () => import_event.hasThoughts,
|
|
214
234
|
hasTrailingCodeExecutionResult: () => import_event.hasTrailingCodeExecutionResult,
|
|
215
235
|
isAgentTool: () => import_agent_tool.isAgentTool,
|
|
@@ -219,10 +239,12 @@ __export(common_exports, {
|
|
|
219
239
|
isBaseExampleProvider: () => import_base_example_provider.isBaseExampleProvider,
|
|
220
240
|
isBaseLlm: () => import_base_llm.isBaseLlm,
|
|
221
241
|
isBasePlanner: () => import_base_planner.isBasePlanner,
|
|
242
|
+
isBaseRetrievalTool: () => import_base_retrieval_tool2.isBaseRetrievalTool,
|
|
222
243
|
isBaseTool: () => import_base_tool.isBaseTool,
|
|
223
244
|
isBaseToolset: () => import_base_toolset.isBaseToolset,
|
|
224
245
|
isBuiltInPlanner: () => import_built_in_planner.isBuiltInPlanner,
|
|
225
246
|
isCompactedEvent: () => import_compacted_event.isCompactedEvent,
|
|
247
|
+
isCrewaiTool: () => import_crewai_tool.isCrewaiTool,
|
|
226
248
|
isFinalResponse: () => import_event.isFinalResponse,
|
|
227
249
|
isFunctionTool: () => import_function_tool.isFunctionTool,
|
|
228
250
|
isGemini2OrAbove: () => import_model_name.isGemini2OrAbove,
|
|
@@ -230,7 +252,10 @@ __export(common_exports, {
|
|
|
230
252
|
isGemini3xFlashLive: () => import_model_name.isGemini3xFlashLive,
|
|
231
253
|
isGemini3xLive: () => import_model_name.isGemini3xLive,
|
|
232
254
|
isIntentMismatchError: () => import_tool_confirmation.isIntentMismatchError,
|
|
255
|
+
isLangGraphAgent: () => import_langgraph_agent.isLangGraphAgent,
|
|
256
|
+
isLangchainTool: () => import_langchain_tool.isLangchainTool,
|
|
233
257
|
isLlmAgent: () => import_llm_agent.isLlmAgent,
|
|
258
|
+
isLlmCallsLimitExceededError: () => import_invocation_context.isLlmCallsLimitExceededError,
|
|
234
259
|
isLoopAgent: () => import_loop_agent.isLoopAgent,
|
|
235
260
|
isNodeErrorEvent: () => import_workflow.isNodeErrorEvent,
|
|
236
261
|
isNodeReportedError: () => import_workflow.isNodeReportedError,
|
|
@@ -238,6 +263,7 @@ __export(common_exports, {
|
|
|
238
263
|
isNodeState: () => import_workflow.isNodeState,
|
|
239
264
|
isNodeTimeoutError: () => import_workflow.isNodeTimeoutError,
|
|
240
265
|
isParallelAgent: () => import_parallel_agent.isParallelAgent,
|
|
266
|
+
isRemoteAgent: () => import_remote_agent.isRemoteAgent,
|
|
241
267
|
isRequestInput: () => import_workflow.isRequestInput,
|
|
242
268
|
isRoutableLlmAgent: () => import_runner.isRoutableLlmAgent,
|
|
243
269
|
isRoutedAgent: () => import_routed_agent.isRoutedAgent,
|
|
@@ -248,6 +274,7 @@ __export(common_exports, {
|
|
|
248
274
|
isSessionArtifactService: () => import_session_artifact_service.isSessionArtifactService,
|
|
249
275
|
isStateSchemaError: () => import_state.isStateSchemaError,
|
|
250
276
|
isToolNotFound: () => import_functions.isToolNotFound,
|
|
277
|
+
isToolboxTool: () => import_toolbox_tool.isToolboxTool,
|
|
251
278
|
isWebMCPSupported: () => import_webmcp_types.isWebMCPSupported,
|
|
252
279
|
isWorkflow: () => import_workflow.isWorkflow,
|
|
253
280
|
logger: () => import_logger.logger,
|
|
@@ -271,6 +298,8 @@ __export(common_exports, {
|
|
|
271
298
|
setLogger: () => import_logger.setLogger,
|
|
272
299
|
stringifyContent: () => import_event.stringifyContent,
|
|
273
300
|
stripAdkIdentityPreamble: () => import_chrome_prompt_llm.stripAdkIdentityPreamble,
|
|
301
|
+
toGeminiSchema: () => import_gemini_schema_util.toGeminiSchema,
|
|
302
|
+
toJsonSchema: () => import_schema.toJsonSchema,
|
|
274
303
|
toSnakeCaseName: () => import_case_utils.toSnakeCaseName,
|
|
275
304
|
toStructuredEvents: () => import_structured_events.toStructuredEvents,
|
|
276
305
|
validateAppName: () => import_app.validateAppName,
|
|
@@ -283,16 +312,19 @@ var import_base_agent = require("./agents/base_agent.js");
|
|
|
283
312
|
var import_context = require("./agents/context.js");
|
|
284
313
|
var import_functions = require("./agents/functions.js");
|
|
285
314
|
var import_invocation_context = require("./agents/invocation_context.js");
|
|
315
|
+
var import_langgraph_agent = require("./agents/langgraph_agent.js");
|
|
286
316
|
var import_live_request_queue = require("./agents/live_request_queue.js");
|
|
287
317
|
var import_llm_agent = require("./agents/llm_agent.js");
|
|
288
318
|
var import_loop_agent = require("./agents/loop_agent.js");
|
|
289
319
|
var import_parallel_agent = require("./agents/parallel_agent.js");
|
|
290
320
|
var import_agent_transfer_llm_request_processor = require("./agents/processors/agent_transfer_llm_request_processor.js");
|
|
291
321
|
var import_base_llm_processor = require("./agents/processors/base_llm_processor.js");
|
|
322
|
+
var import_code_execution_request_processor = require("./agents/processors/code_execution_request_processor.js");
|
|
292
323
|
var import_content_request_processor = require("./agents/processors/content_request_processor.js");
|
|
293
324
|
var import_context_compactor_request_processor = require("./agents/processors/context_compactor_request_processor.js");
|
|
294
325
|
var import_interactions_request_processor = require("./agents/processors/interactions_request_processor.js");
|
|
295
326
|
var import_readonly_context = require("./agents/readonly_context.js");
|
|
327
|
+
var import_remote_agent = require("./agents/remote_agent.js");
|
|
296
328
|
var import_routed_agent = require("./agents/routed_agent.js");
|
|
297
329
|
var import_run_config = require("./agents/run_config.js");
|
|
298
330
|
var import_sequential_agent = require("./agents/sequential_agent.js");
|
|
@@ -339,6 +371,8 @@ var import_apigee_llm = require("./models/apigee_llm.js");
|
|
|
339
371
|
var import_base_llm = require("./models/base_llm.js");
|
|
340
372
|
var import_chrome_prompt_llm = require("./models/chrome_prompt_llm.js");
|
|
341
373
|
var import_google_llm = require("./models/google_llm.js");
|
|
374
|
+
var import_llm_request = require("./models/llm_request.js");
|
|
375
|
+
var import_llm_response = require("./models/llm_response.js");
|
|
342
376
|
var import_registry = require("./models/registry.js");
|
|
343
377
|
var import_routed_llm = require("./models/routed_llm.js");
|
|
344
378
|
var import_base_planner = require("./planners/base_planner.js");
|
|
@@ -391,8 +425,11 @@ var import_webmcp_types = require("./tools/webmcp/webmcp_types.js");
|
|
|
391
425
|
var import_async_queue = require("./utils/async_queue.js");
|
|
392
426
|
var import_case_utils = require("./utils/case_utils.js");
|
|
393
427
|
var import_client_labels = require("./utils/client_labels.js");
|
|
428
|
+
var import_gemini_schema_util = require("./utils/gemini_schema_util.js");
|
|
429
|
+
var import_genai_schema_to_json = require("./utils/genai_schema_to_json.js");
|
|
394
430
|
var import_logger = require("./utils/logger.js");
|
|
395
431
|
var import_model_name = require("./utils/model_name.js");
|
|
432
|
+
var import_schema = require("./utils/schema.js");
|
|
396
433
|
var import_simple_zod_to_json = require("./utils/simple_zod_to_json.js");
|
|
397
434
|
var import_task = require("./utils/task.js");
|
|
398
435
|
var import_variant_utils = require("./utils/variant_utils.js");
|
|
@@ -412,6 +449,12 @@ __reExport(common_exports, require("./features/feature_registry.js"), module.exp
|
|
|
412
449
|
__reExport(common_exports, require("./memory/base_memory_service.js"), module.exports);
|
|
413
450
|
__reExport(common_exports, require("./sessions/base_session_service.js"), module.exports);
|
|
414
451
|
__reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
452
|
+
var import_evals = require("./cli/utils/evals.js");
|
|
453
|
+
var import_crewai_tool = require("./tools/crewai_tool.js");
|
|
454
|
+
var import_function_tool2 = require("./tools/function_tool.js");
|
|
455
|
+
var import_langchain_tool = require("./tools/langchain_tool.js");
|
|
456
|
+
var import_base_retrieval_tool2 = require("./tools/retrieval/base_retrieval_tool.js");
|
|
457
|
+
var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
415
458
|
/**
|
|
416
459
|
* @license
|
|
417
460
|
* Copyright 2025 Google LLC
|
|
@@ -435,6 +478,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
435
478
|
AuthHandler,
|
|
436
479
|
AuthPreprocessor,
|
|
437
480
|
AuthProviderRegistry,
|
|
481
|
+
AuthSchemeType,
|
|
438
482
|
BaseAgent,
|
|
439
483
|
BaseCodeExecutor,
|
|
440
484
|
BaseEnvironment,
|
|
@@ -458,6 +502,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
458
502
|
ChromeBuiltInLlm,
|
|
459
503
|
ChromeModelUnavailableError,
|
|
460
504
|
CodeExecutionLanguage,
|
|
505
|
+
CodeExecutionResponseProcessor,
|
|
461
506
|
ConsolidateContextTool,
|
|
462
507
|
ContentRequestProcessor,
|
|
463
508
|
Context,
|
|
@@ -465,6 +510,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
465
510
|
ContextCompactorRequestProcessor,
|
|
466
511
|
CredentialExchangeError,
|
|
467
512
|
CredentialRefresherRegistry,
|
|
513
|
+
CrewaiTool,
|
|
468
514
|
DEFAULT_ROUTE,
|
|
469
515
|
ENTERPRISE_WEB_SEARCH,
|
|
470
516
|
EXIT_LOOP,
|
|
@@ -505,10 +551,13 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
505
551
|
LLMRegistry,
|
|
506
552
|
LOAD_ARTIFACTS,
|
|
507
553
|
LOAD_MEMORY,
|
|
554
|
+
LangGraphAgent,
|
|
555
|
+
LangchainTool,
|
|
508
556
|
ListSkillsTool,
|
|
509
557
|
LiveRequestQueue,
|
|
510
558
|
LlamaIndexRetrieval,
|
|
511
559
|
LlmAgent,
|
|
560
|
+
LlmCallsLimitExceededError,
|
|
512
561
|
LlmSummarizer,
|
|
513
562
|
LoadArtifactsTool,
|
|
514
563
|
LoadMemoryTool,
|
|
@@ -543,6 +592,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
543
592
|
ReadonlyContext,
|
|
544
593
|
ReflectAndRetryModelPlugin,
|
|
545
594
|
ReflectAndRetryToolPlugin,
|
|
595
|
+
RemoteAgent,
|
|
546
596
|
RequestInput,
|
|
547
597
|
RoutedAgent,
|
|
548
598
|
RoutedLlm,
|
|
@@ -567,6 +617,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
567
617
|
ToolErrorType,
|
|
568
618
|
ToolExecutionError,
|
|
569
619
|
ToolNode,
|
|
620
|
+
ToolboxTool,
|
|
570
621
|
TrackingScope,
|
|
571
622
|
TrajectoryThoughtPruningCompactor,
|
|
572
623
|
TruncatingContextCompactor,
|
|
@@ -579,13 +630,21 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
579
630
|
WebMCPToolset,
|
|
580
631
|
Workflow,
|
|
581
632
|
WorkflowNode,
|
|
633
|
+
appendInstructions,
|
|
582
634
|
asRunnableRoot,
|
|
635
|
+
buildFunctionDeclarationForLangchain,
|
|
636
|
+
buildFunctionDeclarationForParamsForCrewai,
|
|
637
|
+
buildFunctionDeclarationUtil,
|
|
583
638
|
commonPrefixOf,
|
|
639
|
+
convertSessionToEvalFormat,
|
|
640
|
+
createEmptyState,
|
|
584
641
|
createEvent,
|
|
585
642
|
createEventActions,
|
|
643
|
+
createLlmResponse,
|
|
586
644
|
createNodeErrorEvent,
|
|
587
645
|
createNodeState,
|
|
588
646
|
createResumabilityConfig,
|
|
647
|
+
createRunConfig,
|
|
589
648
|
createSession,
|
|
590
649
|
createSubBranch,
|
|
591
650
|
determineAgentForResumption,
|
|
@@ -594,16 +653,20 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
594
653
|
findMatchingFunctionCall,
|
|
595
654
|
functionsExportedForTestingOnly,
|
|
596
655
|
geminiInitParams,
|
|
656
|
+
genaiSchemaToJsonSchema,
|
|
597
657
|
generateClientFunctionCallId,
|
|
598
658
|
getAskUserConfirmationFunctionCalls,
|
|
599
659
|
getClientLabels,
|
|
600
660
|
getFunctionCalls,
|
|
601
661
|
getFunctionResponses,
|
|
662
|
+
getLastHumanMessages,
|
|
602
663
|
getLogger,
|
|
603
664
|
getModelContext,
|
|
665
|
+
getOAuthGrantTypeFromFlow,
|
|
604
666
|
getPendingUserInputRequests,
|
|
605
667
|
getUserChoiceTool,
|
|
606
668
|
getUserInputRequests,
|
|
669
|
+
handleFunctionCallsLive,
|
|
607
670
|
hasThoughts,
|
|
608
671
|
hasTrailingCodeExecutionResult,
|
|
609
672
|
isAgentTool,
|
|
@@ -613,10 +676,12 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
613
676
|
isBaseExampleProvider,
|
|
614
677
|
isBaseLlm,
|
|
615
678
|
isBasePlanner,
|
|
679
|
+
isBaseRetrievalTool,
|
|
616
680
|
isBaseTool,
|
|
617
681
|
isBaseToolset,
|
|
618
682
|
isBuiltInPlanner,
|
|
619
683
|
isCompactedEvent,
|
|
684
|
+
isCrewaiTool,
|
|
620
685
|
isFinalResponse,
|
|
621
686
|
isFunctionTool,
|
|
622
687
|
isGemini2OrAbove,
|
|
@@ -624,7 +689,10 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
624
689
|
isGemini3xFlashLive,
|
|
625
690
|
isGemini3xLive,
|
|
626
691
|
isIntentMismatchError,
|
|
692
|
+
isLangGraphAgent,
|
|
693
|
+
isLangchainTool,
|
|
627
694
|
isLlmAgent,
|
|
695
|
+
isLlmCallsLimitExceededError,
|
|
628
696
|
isLoopAgent,
|
|
629
697
|
isNodeErrorEvent,
|
|
630
698
|
isNodeReportedError,
|
|
@@ -632,6 +700,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
632
700
|
isNodeState,
|
|
633
701
|
isNodeTimeoutError,
|
|
634
702
|
isParallelAgent,
|
|
703
|
+
isRemoteAgent,
|
|
635
704
|
isRequestInput,
|
|
636
705
|
isRoutableLlmAgent,
|
|
637
706
|
isRoutedAgent,
|
|
@@ -642,6 +711,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
642
711
|
isSessionArtifactService,
|
|
643
712
|
isStateSchemaError,
|
|
644
713
|
isToolNotFound,
|
|
714
|
+
isToolboxTool,
|
|
645
715
|
isWebMCPSupported,
|
|
646
716
|
isWorkflow,
|
|
647
717
|
logger,
|
|
@@ -665,6 +735,8 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
665
735
|
setLogger,
|
|
666
736
|
stringifyContent,
|
|
667
737
|
stripAdkIdentityPreamble,
|
|
738
|
+
toGeminiSchema,
|
|
739
|
+
toJsonSchema,
|
|
668
740
|
toSnakeCaseName,
|
|
669
741
|
toStructuredEvents,
|
|
670
742
|
validateAppName,
|
|
@@ -53,7 +53,7 @@ const _LlmSummarizer = class _LlmSummarizer {
|
|
|
53
53
|
* @throws {Error} If `events` is empty or the LLM returns no content.
|
|
54
54
|
*/
|
|
55
55
|
async summarize(events) {
|
|
56
|
-
var _a, _b
|
|
56
|
+
var _a, _b;
|
|
57
57
|
if (events.length === 0) {
|
|
58
58
|
throw new Error("Cannot summarize an empty list of events.");
|
|
59
59
|
}
|
|
@@ -75,18 +75,20 @@ ${formattedEvents}`;
|
|
|
75
75
|
toolsDict: {},
|
|
76
76
|
liveConnectConfig: {}
|
|
77
77
|
};
|
|
78
|
-
const responseGen = this.llm.generateContentAsync(request, false);
|
|
79
78
|
let compactedContent = "";
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
for await (const response of this.llm.generateContentAsync(
|
|
80
|
+
request,
|
|
81
|
+
false
|
|
82
|
+
)) {
|
|
83
|
+
for (const part of (_b = (_a = response.content) == null ? void 0 : _a.parts) != null ? _b : []) {
|
|
84
|
+
if (part.text && !part.thought) {
|
|
85
|
+
compactedContent += part.text;
|
|
86
|
+
}
|
|
88
87
|
}
|
|
89
88
|
}
|
|
89
|
+
if (!compactedContent) {
|
|
90
|
+
throw new Error("LLM failed to return a valid summary.");
|
|
91
|
+
}
|
|
90
92
|
return (0, import_compacted_event.createCompactedEvent)({
|
|
91
93
|
author: "system",
|
|
92
94
|
content: {
|
|
@@ -109,7 +109,8 @@ let TokenBasedContextCompactor = _TokenBasedContextCompactor;
|
|
|
109
109
|
function latestPromptTokenCount(activeEvents, invocationContext) {
|
|
110
110
|
var _a;
|
|
111
111
|
for (let i = activeEvents.length - 1; i >= 0; i--) {
|
|
112
|
-
const
|
|
112
|
+
const usage = activeEvents[i].usageMetadata;
|
|
113
|
+
const count = (_a = usage == null ? void 0 : usage.initialPromptTokenCount) != null ? _a : usage == null ? void 0 : usage.promptTokenCount;
|
|
113
114
|
if (count !== void 0) {
|
|
114
115
|
return count;
|
|
115
116
|
}
|
package/dist/cjs/events/event.js
CHANGED
|
@@ -132,8 +132,10 @@ function stringifyContent(event) {
|
|
|
132
132
|
__name(stringifyContent, "stringifyContent");
|
|
133
133
|
function getEventTokens(event) {
|
|
134
134
|
var _a;
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
const usage = event.usageMetadata;
|
|
136
|
+
const promptTokenCount = (_a = usage == null ? void 0 : usage.initialPromptTokenCount) != null ? _a : usage == null ? void 0 : usage.promptTokenCount;
|
|
137
|
+
if (promptTokenCount !== void 0) {
|
|
138
|
+
return promptTokenCount;
|
|
137
139
|
}
|
|
138
140
|
const contentStr = stringifyContent(event);
|
|
139
141
|
return Math.ceil(contentStr.length / 4);
|
|
@@ -28,9 +28,12 @@ __export(example_util_exports, {
|
|
|
28
28
|
_getLatestMessageFromUser: () => _getLatestMessageFromUser,
|
|
29
29
|
buildExampleSi: () => buildExampleSi,
|
|
30
30
|
convertExamplesToText: () => convertExamplesToText,
|
|
31
|
-
getLatestMessageFromUser: () => getLatestMessageFromUser
|
|
31
|
+
getLatestMessageFromUser: () => getLatestMessageFromUser,
|
|
32
|
+
validateExamples: () => validateExamples
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(example_util_exports);
|
|
35
|
+
var import_zod = require("zod");
|
|
36
|
+
var import_input_validation_error = require("../errors/input_validation_error.js");
|
|
34
37
|
var import_event = require("../events/event.js");
|
|
35
38
|
var import_logger = require("../utils/logger.js");
|
|
36
39
|
var import_base_example_provider = require("./base_example_provider.js");
|
|
@@ -39,6 +42,23 @@ var import_base_example_provider = require("./base_example_provider.js");
|
|
|
39
42
|
* Copyright 2025 Google LLC
|
|
40
43
|
* SPDX-License-Identifier: Apache-2.0
|
|
41
44
|
*/
|
|
45
|
+
const contentSchema = import_zod.z.object({
|
|
46
|
+
role: import_zod.z.string().optional(),
|
|
47
|
+
parts: import_zod.z.array(import_zod.z.object({}).loose()).optional()
|
|
48
|
+
}).loose();
|
|
49
|
+
const examplesSchema = import_zod.z.array(
|
|
50
|
+
import_zod.z.object({ input: contentSchema, output: import_zod.z.array(contentSchema) })
|
|
51
|
+
);
|
|
52
|
+
function validateExamples(examples) {
|
|
53
|
+
const result = examplesSchema.safeParse(examples);
|
|
54
|
+
if (!result.success) {
|
|
55
|
+
throw new import_input_validation_error.InputValidationError(
|
|
56
|
+
`Invalid few-shot examples:
|
|
57
|
+
${import_zod.z.prettifyError(result.error)}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
__name(validateExamples, "validateExamples");
|
|
42
62
|
const EXAMPLES_INTRO = "<EXAMPLES>\nBegin few-shot\nThe following are examples of user queries and model responses using the available tools.\n\n";
|
|
43
63
|
const EXAMPLES_END = "End few-shot\n<EXAMPLES>";
|
|
44
64
|
const EXAMPLE_START = "EXAMPLE {}:\nBegin example\n";
|
|
@@ -130,5 +150,6 @@ __name(buildExampleSi, "buildExampleSi");
|
|
|
130
150
|
_getLatestMessageFromUser,
|
|
131
151
|
buildExampleSi,
|
|
132
152
|
convertExamplesToText,
|
|
133
|
-
getLatestMessageFromUser
|
|
153
|
+
getLatestMessageFromUser,
|
|
154
|
+
validateExamples
|
|
134
155
|
});
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var audio_transcriber_exports = {};
|
|
27
|
+
__export(audio_transcriber_exports, {
|
|
28
|
+
AudioEncoding: () => AudioEncoding,
|
|
29
|
+
AudioTranscriber: () => AudioTranscriber
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(audio_transcriber_exports);
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2026 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
var AudioEncoding = /* @__PURE__ */ ((AudioEncoding2) => {
|
|
38
|
+
AudioEncoding2[AudioEncoding2["ENCODING_UNSPECIFIED"] = 0] = "ENCODING_UNSPECIFIED";
|
|
39
|
+
AudioEncoding2[AudioEncoding2["LINEAR16"] = 1] = "LINEAR16";
|
|
40
|
+
return AudioEncoding2;
|
|
41
|
+
})(AudioEncoding || {});
|
|
42
|
+
function isSpeechClientLike(value) {
|
|
43
|
+
return typeof value === "object" && value !== null && typeof value.recognize === "function";
|
|
44
|
+
}
|
|
45
|
+
__name(isSpeechClientLike, "isSpeechClientLike");
|
|
46
|
+
function isContentEntry(data) {
|
|
47
|
+
return "parts" in data || !("data" in data) && !("mimeType" in data);
|
|
48
|
+
}
|
|
49
|
+
__name(isContentEntry, "isContentEntry");
|
|
50
|
+
function blobDataToBytes(data) {
|
|
51
|
+
if (typeof data !== "string") {
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
if (data.length > 0 && data.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/.test(data)) {
|
|
55
|
+
const atobFn = globalThis.atob;
|
|
56
|
+
if (typeof Buffer === "undefined" && typeof atobFn === "function") {
|
|
57
|
+
const binary = atobFn(data);
|
|
58
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
59
|
+
}
|
|
60
|
+
return new Uint8Array(Buffer.from(data, "base64"));
|
|
61
|
+
}
|
|
62
|
+
return new TextEncoder().encode(data);
|
|
63
|
+
}
|
|
64
|
+
__name(blobDataToBytes, "blobDataToBytes");
|
|
65
|
+
function concatBytes(first, second) {
|
|
66
|
+
const merged = new Uint8Array(first.length + second.length);
|
|
67
|
+
merged.set(first, 0);
|
|
68
|
+
merged.set(second, first.length);
|
|
69
|
+
return merged;
|
|
70
|
+
}
|
|
71
|
+
__name(concatBytes, "concatBytes");
|
|
72
|
+
const _AudioTranscriber = class _AudioTranscriber {
|
|
73
|
+
constructor(optionsOrClient) {
|
|
74
|
+
if (isSpeechClientLike(optionsOrClient)) {
|
|
75
|
+
this.client = optionsOrClient;
|
|
76
|
+
} else if (optionsOrClient == null ? void 0 : optionsOrClient.client) {
|
|
77
|
+
this.client = optionsOrClient.client;
|
|
78
|
+
} else {
|
|
79
|
+
this.client = {
|
|
80
|
+
recognize() {
|
|
81
|
+
throw new Error(
|
|
82
|
+
"SpeechClient is not configured on AudioTranscriber. Pass a SpeechClientLike implementation to new AudioTranscriber({client})."
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Bundles consecutive audio blobs from the same speaker in
|
|
90
|
+
* `invocationContext.transcriptionCache`, transcribes user audio bundles into
|
|
91
|
+
* text `Content` entries, preserves already-transcribed `Content`
|
|
92
|
+
* entries in order, clears `invocationContext.transcriptionCache`, and
|
|
93
|
+
* returns the resulting content list.
|
|
94
|
+
*
|
|
95
|
+
* @param invocationContext The invocation context holding `transcriptionCache`.
|
|
96
|
+
* @returns Ordered list of transcribed `Content` objects.
|
|
97
|
+
*/
|
|
98
|
+
async transcribeFile(invocationContext) {
|
|
99
|
+
var _a, _b, _c, _d;
|
|
100
|
+
const bundledAudio = [];
|
|
101
|
+
const transcriptionHistory = [];
|
|
102
|
+
let currentSpeaker = void 0;
|
|
103
|
+
let currentAudioData = new Uint8Array(0);
|
|
104
|
+
for (const transcriptionEntry of (_a = invocationContext.transcriptionCache) != null ? _a : []) {
|
|
105
|
+
const speaker = transcriptionEntry.role;
|
|
106
|
+
const audioData = transcriptionEntry.data;
|
|
107
|
+
if (isContentEntry(audioData)) {
|
|
108
|
+
if (currentSpeaker !== void 0) {
|
|
109
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
110
|
+
currentSpeaker = void 0;
|
|
111
|
+
currentAudioData = new Uint8Array(0);
|
|
112
|
+
}
|
|
113
|
+
bundledAudio.push([speaker, audioData]);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const rawData = audioData.data;
|
|
117
|
+
if (!rawData) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const chunkBytes = blobDataToBytes(rawData);
|
|
121
|
+
if (chunkBytes.length === 0) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (speaker === currentSpeaker) {
|
|
125
|
+
currentAudioData = concatBytes(currentAudioData, chunkBytes);
|
|
126
|
+
} else {
|
|
127
|
+
if (currentSpeaker !== void 0) {
|
|
128
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
129
|
+
}
|
|
130
|
+
currentSpeaker = speaker;
|
|
131
|
+
currentAudioData = chunkBytes;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (currentSpeaker !== void 0) {
|
|
135
|
+
bundledAudio.push([currentSpeaker, currentAudioData]);
|
|
136
|
+
}
|
|
137
|
+
invocationContext.transcriptionCache = [];
|
|
138
|
+
for (const [speaker, data] of bundledAudio) {
|
|
139
|
+
if (ArrayBuffer.isView(data)) {
|
|
140
|
+
const audio = { content: data };
|
|
141
|
+
const config = {
|
|
142
|
+
encoding: 1 /* LINEAR16 */,
|
|
143
|
+
sampleRateHertz: 16e3,
|
|
144
|
+
languageCode: "en-US"
|
|
145
|
+
};
|
|
146
|
+
const rawResponse = await this.client.recognize({ config, audio });
|
|
147
|
+
const response = Array.isArray(rawResponse) ? rawResponse[0] : rawResponse;
|
|
148
|
+
for (const result of (_b = response.results) != null ? _b : []) {
|
|
149
|
+
const transcript = (_d = (_c = result.alternatives) == null ? void 0 : _c[0]) == null ? void 0 : _d.transcript;
|
|
150
|
+
if (transcript !== void 0 && transcript !== null) {
|
|
151
|
+
transcriptionHistory.push({
|
|
152
|
+
role: speaker ? speaker.toLowerCase() : "user",
|
|
153
|
+
parts: [{ text: transcript }]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
transcriptionHistory.push(data);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return transcriptionHistory;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
__name(_AudioTranscriber, "AudioTranscriber");
|
|
165
|
+
let AudioTranscriber = _AudioTranscriber;
|
|
166
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
167
|
+
0 && (module.exports = {
|
|
168
|
+
AudioEncoding,
|
|
169
|
+
AudioTranscriber
|
|
170
|
+
});
|