@google/adk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +9 -0
- package/dist/cjs/agents/active_streaming_tool.js +44 -0
- package/dist/cjs/agents/base_agent.js +245 -0
- package/dist/cjs/agents/base_llm_processor.js +44 -0
- package/dist/cjs/agents/callback_context.js +98 -0
- package/dist/cjs/agents/content_processor_utils.js +299 -0
- package/dist/cjs/agents/functions.js +394 -0
- package/dist/cjs/agents/instructions.js +110 -0
- package/dist/cjs/agents/invocation_context.js +109 -0
- package/dist/cjs/agents/live_request_queue.js +136 -0
- package/dist/cjs/agents/llm_agent.js +859 -0
- package/dist/cjs/agents/loop_agent.js +68 -0
- package/dist/cjs/agents/parallel_agent.js +78 -0
- package/dist/cjs/agents/readonly_context.js +68 -0
- package/dist/cjs/agents/run_config.js +74 -0
- package/dist/cjs/agents/sequential_agent.js +84 -0
- package/dist/cjs/agents/transcription_entry.js +27 -0
- package/dist/cjs/artifacts/base_artifact_service.js +27 -0
- package/dist/cjs/artifacts/in_memory_artifact_service.js +119 -0
- package/dist/cjs/auth/auth_credential.js +46 -0
- package/dist/cjs/auth/auth_handler.js +92 -0
- package/dist/cjs/auth/auth_schemes.js +62 -0
- package/dist/cjs/auth/auth_tool.js +27 -0
- package/dist/cjs/auth/credential_service/base_credential_service.js +27 -0
- package/dist/cjs/auth/credential_service/in_memory_credential_service.js +63 -0
- package/dist/cjs/code_executors/base_code_executor.js +76 -0
- package/dist/cjs/code_executors/built_in_code_executor.js +58 -0
- package/dist/cjs/code_executors/code_execution_utils.js +142 -0
- package/dist/cjs/code_executors/code_executor_context.js +198 -0
- package/dist/cjs/common.js +161 -0
- package/dist/cjs/events/event.js +107 -0
- package/dist/cjs/events/event_actions.js +83 -0
- package/dist/cjs/examples/base_example_provider.js +40 -0
- package/dist/cjs/examples/example.js +27 -0
- package/dist/cjs/examples/example_util.js +107 -0
- package/dist/cjs/index.js +40 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/index_web.js +33 -0
- package/dist/cjs/memory/base_memory_service.js +27 -0
- package/dist/cjs/memory/in_memory_memory_service.js +97 -0
- package/dist/cjs/memory/memory_entry.js +27 -0
- package/dist/cjs/models/base_llm.js +77 -0
- package/dist/cjs/models/base_llm_connection.js +27 -0
- package/dist/cjs/models/gemini_llm_connection.js +132 -0
- package/dist/cjs/models/google_llm.js +321 -0
- package/dist/cjs/models/llm_request.js +82 -0
- package/dist/cjs/models/llm_response.js +71 -0
- package/dist/cjs/models/registry.js +121 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/plugins/base_plugin.js +236 -0
- package/dist/cjs/plugins/logging_plugin.js +222 -0
- package/dist/cjs/plugins/plugin_manager.js +239 -0
- package/dist/cjs/plugins/security_plugin.js +153 -0
- package/dist/cjs/runner/in_memory_runner.js +58 -0
- package/dist/cjs/runner/runner.js +276 -0
- package/dist/cjs/sessions/base_session_service.js +71 -0
- package/dist/cjs/sessions/in_memory_session_service.js +184 -0
- package/dist/cjs/sessions/session.js +48 -0
- package/dist/cjs/sessions/state.js +101 -0
- package/dist/cjs/tools/agent_tool.js +134 -0
- package/dist/cjs/tools/base_tool.js +107 -0
- package/dist/cjs/tools/base_toolset.js +76 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +71 -0
- package/dist/cjs/tools/function_tool.js +101 -0
- package/dist/cjs/tools/google_search_tool.js +76 -0
- package/dist/cjs/tools/long_running_tool.js +63 -0
- package/dist/cjs/tools/mcp/mcp_session_manager.js +65 -0
- package/dist/cjs/tools/mcp/mcp_tool.js +65 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +61 -0
- package/dist/cjs/tools/tool_confirmation.js +49 -0
- package/dist/cjs/tools/tool_context.js +129 -0
- package/dist/cjs/utils/deep_clone.js +44 -0
- package/dist/cjs/utils/env_aware_utils.js +83 -0
- package/dist/cjs/utils/gemini_schema_util.js +88 -0
- package/dist/cjs/utils/logger.js +121 -0
- package/dist/cjs/utils/model_name.js +64 -0
- package/dist/cjs/utils/simple_zod_to_json.js +191 -0
- package/dist/cjs/utils/variant_utils.js +55 -0
- package/dist/cjs/version.js +39 -0
- package/dist/esm/agents/active_streaming_tool.js +14 -0
- package/dist/esm/agents/base_agent.js +214 -0
- package/dist/esm/agents/base_llm_processor.js +13 -0
- package/dist/esm/agents/callback_context.js +68 -0
- package/dist/esm/agents/content_processor_utils.js +268 -0
- package/dist/esm/agents/functions.js +353 -0
- package/dist/esm/agents/instructions.js +80 -0
- package/dist/esm/agents/invocation_context.js +78 -0
- package/dist/esm/agents/live_request_queue.js +106 -0
- package/dist/esm/agents/llm_agent.js +828 -0
- package/dist/esm/agents/loop_agent.js +38 -0
- package/dist/esm/agents/parallel_agent.js +48 -0
- package/dist/esm/agents/readonly_context.js +38 -0
- package/dist/esm/agents/run_config.js +43 -0
- package/dist/esm/agents/sequential_agent.js +54 -0
- package/dist/esm/agents/transcription_entry.js +5 -0
- package/dist/esm/artifacts/base_artifact_service.js +5 -0
- package/dist/esm/artifacts/in_memory_artifact_service.js +89 -0
- package/dist/esm/auth/auth_credential.js +16 -0
- package/dist/esm/auth/auth_handler.js +62 -0
- package/dist/esm/auth/auth_schemes.js +31 -0
- package/dist/esm/auth/auth_tool.js +5 -0
- package/dist/esm/auth/credential_service/base_credential_service.js +5 -0
- package/dist/esm/auth/credential_service/in_memory_credential_service.js +33 -0
- package/dist/esm/code_executors/base_code_executor.js +46 -0
- package/dist/esm/code_executors/built_in_code_executor.js +28 -0
- package/dist/esm/code_executors/code_execution_utils.js +108 -0
- package/dist/esm/code_executors/code_executor_context.js +168 -0
- package/dist/esm/common.js +85 -0
- package/dist/esm/events/event.js +72 -0
- package/dist/esm/events/event_actions.js +52 -0
- package/dist/esm/examples/base_example_provider.js +10 -0
- package/dist/esm/examples/example.js +5 -0
- package/dist/esm/examples/example_util.js +76 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/index_web.js +6 -0
- package/dist/esm/memory/base_memory_service.js +5 -0
- package/dist/esm/memory/in_memory_memory_service.js +67 -0
- package/dist/esm/memory/memory_entry.js +5 -0
- package/dist/esm/models/base_llm.js +47 -0
- package/dist/esm/models/base_llm_connection.js +5 -0
- package/dist/esm/models/gemini_llm_connection.js +102 -0
- package/dist/esm/models/google_llm.js +291 -0
- package/dist/esm/models/llm_request.js +50 -0
- package/dist/esm/models/llm_response.js +41 -0
- package/dist/esm/models/registry.js +91 -0
- package/dist/esm/plugins/base_plugin.js +206 -0
- package/dist/esm/plugins/logging_plugin.js +192 -0
- package/dist/esm/plugins/plugin_manager.js +209 -0
- package/dist/esm/plugins/security_plugin.js +119 -0
- package/dist/esm/runner/in_memory_runner.js +28 -0
- package/dist/esm/runner/runner.js +246 -0
- package/dist/esm/sessions/base_session_service.js +41 -0
- package/dist/esm/sessions/in_memory_session_service.js +154 -0
- package/dist/esm/sessions/session.js +18 -0
- package/dist/esm/sessions/state.js +71 -0
- package/dist/esm/tools/agent_tool.js +104 -0
- package/dist/esm/tools/base_tool.js +77 -0
- package/dist/esm/tools/base_toolset.js +46 -0
- package/dist/esm/tools/forwarding_artifact_service.js +41 -0
- package/dist/esm/tools/function_tool.js +71 -0
- package/dist/esm/tools/google_search_tool.js +46 -0
- package/dist/esm/tools/long_running_tool.js +33 -0
- package/dist/esm/tools/mcp/mcp_session_manager.js +35 -0
- package/dist/esm/tools/mcp/mcp_tool.js +35 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +31 -0
- package/dist/esm/tools/tool_confirmation.js +19 -0
- package/dist/esm/tools/tool_context.js +99 -0
- package/dist/esm/utils/deep_clone.js +14 -0
- package/dist/esm/utils/env_aware_utils.js +49 -0
- package/dist/esm/utils/gemini_schema_util.js +58 -0
- package/dist/esm/utils/logger.js +89 -0
- package/dist/esm/utils/model_name.js +31 -0
- package/dist/esm/utils/simple_zod_to_json.js +160 -0
- package/dist/esm/utils/variant_utils.js +24 -0
- package/dist/esm/version.js +9 -0
- package/dist/types/agents/active_streaming_tool.d.ts +29 -0
- package/dist/types/agents/base_agent.d.ts +167 -0
- package/dist/types/agents/base_llm_processor.d.ts +27 -0
- package/dist/types/agents/callback_context.d.ts +42 -0
- package/dist/types/agents/content_processor_utils.d.ts +36 -0
- package/dist/types/agents/functions.d.ts +90 -0
- package/dist/types/agents/instructions.d.ts +32 -0
- package/dist/types/agents/invocation_context.d.ts +155 -0
- package/dist/types/agents/live_request_queue.d.ts +67 -0
- package/dist/types/agents/llm_agent.d.ts +333 -0
- package/dist/types/agents/loop_agent.d.ts +31 -0
- package/dist/types/agents/parallel_agent.d.ts +21 -0
- package/dist/types/agents/readonly_context.d.ts +31 -0
- package/dist/types/agents/run_config.d.ts +76 -0
- package/dist/types/agents/sequential_agent.d.ts +26 -0
- package/dist/types/agents/transcription_entry.d.ts +17 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +127 -0
- package/dist/types/artifacts/in_memory_artifact_service.d.ts +18 -0
- package/dist/types/auth/auth_credential.d.ts +227 -0
- package/dist/types/auth/auth_handler.d.ts +27 -0
- package/dist/types/auth/auth_schemes.d.ts +36 -0
- package/dist/types/auth/auth_tool.d.ts +51 -0
- package/dist/types/auth/credential_service/base_credential_service.d.ts +27 -0
- package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +19 -0
- package/dist/types/code_executors/base_code_executor.d.ts +60 -0
- package/dist/types/code_executors/built_in_code_executor.d.ts +13 -0
- package/dist/types/code_executors/code_execution_utils.d.ts +99 -0
- package/dist/types/code_executors/code_executor_context.d.ts +92 -0
- package/dist/types/common.d.ts +51 -0
- package/dist/types/events/event.d.ts +81 -0
- package/dist/types/events/event_actions.d.ts +74 -0
- package/dist/types/examples/base_example_provider.d.ts +20 -0
- package/dist/types/examples/example.d.ts +19 -0
- package/dist/types/examples/example_util.d.ts +13 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index_web.d.ts +6 -0
- package/dist/types/memory/base_memory_service.d.ts +47 -0
- package/dist/types/memory/in_memory_memory_service.d.ts +18 -0
- package/dist/types/memory/memory_entry.d.ts +24 -0
- package/dist/types/models/base_llm.d.ts +46 -0
- package/dist/types/models/base_llm_connection.d.ts +51 -0
- package/dist/types/models/gemini_llm_connection.d.ts +54 -0
- package/dist/types/models/google_llm.d.ts +88 -0
- package/dist/types/models/llm_request.d.ts +49 -0
- package/dist/types/models/llm_response.d.ts +79 -0
- package/dist/types/models/registry.d.ts +45 -0
- package/dist/types/plugins/base_plugin.d.ts +310 -0
- package/dist/types/plugins/logging_plugin.d.ts +104 -0
- package/dist/types/plugins/plugin_manager.d.ts +155 -0
- package/dist/types/plugins/security_plugin.d.ts +60 -0
- package/dist/types/runner/in_memory_runner.d.ts +15 -0
- package/dist/types/runner/runner.d.ts +80 -0
- package/dist/types/sessions/base_session_service.d.ts +129 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +32 -0
- package/dist/types/sessions/session.d.ts +46 -0
- package/dist/types/sessions/state.d.ts +57 -0
- package/dist/types/tools/agent_tool.d.ts +37 -0
- package/dist/types/tools/base_tool.d.ts +84 -0
- package/dist/types/tools/base_toolset.d.ts +64 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +21 -0
- package/dist/types/tools/function_tool.d.ts +48 -0
- package/dist/types/tools/google_search_tool.d.ts +18 -0
- package/dist/types/tools/long_running_tool.d.ts +18 -0
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +57 -0
- package/dist/types/tools/mcp/mcp_tool.d.ts +30 -0
- package/dist/types/tools/mcp/mcp_toolset.d.ts +39 -0
- package/dist/types/tools/tool_confirmation.d.ts +25 -0
- package/dist/types/tools/tool_context.d.ts +63 -0
- package/dist/types/utils/deep_clone.d.ts +1 -0
- package/dist/types/utils/env_aware_utils.d.ts +31 -0
- package/dist/types/utils/gemini_schema_util.d.ts +23 -0
- package/dist/types/utils/logger.d.ts +41 -0
- package/dist/types/utils/model_name.d.ts +34 -0
- package/dist/types/utils/simple_zod_to_json.d.ts +12 -0
- package/dist/types/utils/variant_utils.d.ts +24 -0
- package/dist/types/version.d.ts +6 -0
- package/dist/web/agents/active_streaming_tool.js +14 -0
- package/dist/web/agents/base_agent.js +265 -0
- package/dist/web/agents/base_llm_processor.js +13 -0
- package/dist/web/agents/callback_context.js +68 -0
- package/dist/web/agents/content_processor_utils.js +268 -0
- package/dist/web/agents/functions.js +353 -0
- package/dist/web/agents/instructions.js +80 -0
- package/dist/web/agents/invocation_context.js +78 -0
- package/dist/web/agents/live_request_queue.js +124 -0
- package/dist/web/agents/llm_agent.js +973 -0
- package/dist/web/agents/loop_agent.js +71 -0
- package/dist/web/agents/parallel_agent.js +83 -0
- package/dist/web/agents/readonly_context.js +38 -0
- package/dist/web/agents/run_config.js +43 -0
- package/dist/web/agents/sequential_agent.js +99 -0
- package/dist/web/agents/transcription_entry.js +5 -0
- package/dist/web/artifacts/base_artifact_service.js +5 -0
- package/dist/web/artifacts/in_memory_artifact_service.js +89 -0
- package/dist/web/auth/auth_credential.js +16 -0
- package/dist/web/auth/auth_handler.js +62 -0
- package/dist/web/auth/auth_schemes.js +31 -0
- package/dist/web/auth/auth_tool.js +5 -0
- package/dist/web/auth/credential_service/base_credential_service.js +5 -0
- package/dist/web/auth/credential_service/in_memory_credential_service.js +33 -0
- package/dist/web/code_executors/base_code_executor.js +46 -0
- package/dist/web/code_executors/built_in_code_executor.js +28 -0
- package/dist/web/code_executors/code_execution_utils.js +105 -0
- package/dist/web/code_executors/code_executor_context.js +168 -0
- package/dist/web/common.js +85 -0
- package/dist/web/events/event.js +90 -0
- package/dist/web/events/event_actions.js +67 -0
- package/dist/web/examples/base_example_provider.js +10 -0
- package/dist/web/examples/example.js +5 -0
- package/dist/web/examples/example_util.js +75 -0
- package/dist/web/index.js +13 -0
- package/dist/web/index.js.map +7 -0
- package/dist/web/index_web.js +6 -0
- package/dist/web/memory/base_memory_service.js +5 -0
- package/dist/web/memory/in_memory_memory_service.js +67 -0
- package/dist/web/memory/memory_entry.js +5 -0
- package/dist/web/models/base_llm.js +47 -0
- package/dist/web/models/base_llm_connection.js +5 -0
- package/dist/web/models/gemini_llm_connection.js +120 -0
- package/dist/web/models/google_llm.js +332 -0
- package/dist/web/models/llm_request.js +50 -0
- package/dist/web/models/llm_response.js +41 -0
- package/dist/web/models/registry.js +91 -0
- package/dist/web/plugins/base_plugin.js +206 -0
- package/dist/web/plugins/logging_plugin.js +192 -0
- package/dist/web/plugins/plugin_manager.js +209 -0
- package/dist/web/plugins/security_plugin.js +119 -0
- package/dist/web/runner/in_memory_runner.js +28 -0
- package/dist/web/runner/runner.js +277 -0
- package/dist/web/sessions/base_session_service.js +41 -0
- package/dist/web/sessions/in_memory_session_service.js +154 -0
- package/dist/web/sessions/session.js +18 -0
- package/dist/web/sessions/state.js +87 -0
- package/dist/web/tools/agent_tool.js +118 -0
- package/dist/web/tools/base_tool.js +77 -0
- package/dist/web/tools/base_toolset.js +46 -0
- package/dist/web/tools/forwarding_artifact_service.js +41 -0
- package/dist/web/tools/function_tool.js +71 -0
- package/dist/web/tools/google_search_tool.js +46 -0
- package/dist/web/tools/long_running_tool.js +50 -0
- package/dist/web/tools/mcp/mcp_session_manager.js +35 -0
- package/dist/web/tools/mcp/mcp_tool.js +35 -0
- package/dist/web/tools/mcp/mcp_toolset.js +31 -0
- package/dist/web/tools/tool_confirmation.js +19 -0
- package/dist/web/tools/tool_context.js +99 -0
- package/dist/web/utils/deep_clone.js +14 -0
- package/dist/web/utils/env_aware_utils.js +49 -0
- package/dist/web/utils/gemini_schema_util.js +58 -0
- package/dist/web/utils/logger.js +89 -0
- package/dist/web/utils/model_name.js +31 -0
- package/dist/web/utils/simple_zod_to_json.js +174 -0
- package/dist/web/utils/variant_utils.js +24 -0
- package/dist/web/version.js +9 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2025 Google LLC
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @google/adk
|
|
2
|
+
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> **API Stability:** Mostly stable, but expect potential breaking changes
|
|
5
|
+
> before 1.0.
|
|
6
|
+
> **Production Use:** Not recommended yet. Use at your own risk.
|
|
7
|
+
> **Collaboration:** General contributions are closed (issues/PRs). We are,
|
|
8
|
+
> however, accepting organized teams that can follow our coding standards and
|
|
9
|
+
> planning. Please contact us if you are interested.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var active_streaming_tool_exports = {};
|
|
26
|
+
__export(active_streaming_tool_exports, {
|
|
27
|
+
ActiveStreamingTool: () => ActiveStreamingTool
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(active_streaming_tool_exports);
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2025 Google LLC
|
|
33
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
34
|
+
*/
|
|
35
|
+
class ActiveStreamingTool {
|
|
36
|
+
constructor(params = {}) {
|
|
37
|
+
this.task = params.task;
|
|
38
|
+
this.stream = params.stream;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
42
|
+
0 && (module.exports = {
|
|
43
|
+
ActiveStreamingTool
|
|
44
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var base_agent_exports = {};
|
|
26
|
+
__export(base_agent_exports, {
|
|
27
|
+
BaseAgent: () => BaseAgent,
|
|
28
|
+
getCannonicalCallback: () => getCannonicalCallback
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(base_agent_exports);
|
|
31
|
+
var import_api = require("@opentelemetry/api");
|
|
32
|
+
var import_event = require("../events/event.js");
|
|
33
|
+
var import_callback_context = require("./callback_context.js");
|
|
34
|
+
var import_invocation_context = require("./invocation_context.js");
|
|
35
|
+
/**
|
|
36
|
+
* @license
|
|
37
|
+
* Copyright 2025 Google LLC
|
|
38
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
39
|
+
*/
|
|
40
|
+
class BaseAgent {
|
|
41
|
+
constructor(config) {
|
|
42
|
+
this.name = validateAgentName(config.name);
|
|
43
|
+
this.description = config.description;
|
|
44
|
+
this.parentAgent = config.parentAgent;
|
|
45
|
+
this.subAgents = config.subAgents || [];
|
|
46
|
+
this.rootAgent = getRootAgent(this);
|
|
47
|
+
this.beforeAgentCallback = getCannonicalCallback(config.beforeAgentCallback);
|
|
48
|
+
this.afterAgentCallback = getCannonicalCallback(config.afterAgentCallback);
|
|
49
|
+
this.setParentAgentForSubAgents();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Entry method to run an agent via text-based conversation.
|
|
53
|
+
*
|
|
54
|
+
* @param parentContext The invocation context of the parent agent.
|
|
55
|
+
* @yields The events generated by the agent.
|
|
56
|
+
* @returns An AsyncGenerator that yields the events generated by the agent.
|
|
57
|
+
*/
|
|
58
|
+
async *runAsync(parentContext) {
|
|
59
|
+
const span = import_api.trace.getTracer("gcp.vertex.agent").startSpan(`agent_run [${this.name}]`);
|
|
60
|
+
try {
|
|
61
|
+
const context = this.createInvocationContext(parentContext);
|
|
62
|
+
const beforeAgentCallbackEvent = await this.handleBeforeAgentCallback(context);
|
|
63
|
+
if (beforeAgentCallbackEvent) {
|
|
64
|
+
yield beforeAgentCallbackEvent;
|
|
65
|
+
}
|
|
66
|
+
if (context.endInvocation) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
for await (const event of this.runAsyncImpl(context)) {
|
|
70
|
+
yield event;
|
|
71
|
+
}
|
|
72
|
+
if (context.endInvocation) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const afterAgentCallbackEvent = await this.handleAfterAgentCallback(context);
|
|
76
|
+
if (afterAgentCallbackEvent) {
|
|
77
|
+
yield afterAgentCallbackEvent;
|
|
78
|
+
}
|
|
79
|
+
} finally {
|
|
80
|
+
span.end();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Entry method to run an agent via video/audio-based conversation.
|
|
85
|
+
*
|
|
86
|
+
* @param parentContext The invocation context of the parent agent.
|
|
87
|
+
* @yields The events generated by the agent.
|
|
88
|
+
* @returns An AsyncGenerator that yields the events generated by the agent.
|
|
89
|
+
*/
|
|
90
|
+
async *runLive(parentContext) {
|
|
91
|
+
const span = import_api.trace.getTracer("gcp.vertex.agent").startSpan(`agent_run [${this.name}]`);
|
|
92
|
+
try {
|
|
93
|
+
throw new Error("Live mode is not implemented yet.");
|
|
94
|
+
} finally {
|
|
95
|
+
span.end();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Finds the agent with the given name in this agent and its descendants.
|
|
100
|
+
*
|
|
101
|
+
* @param name The name of the agent to find.
|
|
102
|
+
* @return The agent with the given name, or undefined if not found.
|
|
103
|
+
*/
|
|
104
|
+
findAgent(name) {
|
|
105
|
+
if (this.name === name) {
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
return this.findSubAgent(name);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Finds the agent with the given name in this agent's descendants.
|
|
112
|
+
*
|
|
113
|
+
* @param name The name of the agent to find.
|
|
114
|
+
* @return The agent with the given name, or undefined if not found.
|
|
115
|
+
*/
|
|
116
|
+
findSubAgent(name) {
|
|
117
|
+
for (const subAgent of this.subAgents) {
|
|
118
|
+
const result = subAgent.findAgent(name);
|
|
119
|
+
if (result) {
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return void 0;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Creates an invocation context for this agent.
|
|
127
|
+
*
|
|
128
|
+
* @param parentContext The invocation context of the parent agent.
|
|
129
|
+
* @return The invocation context for this agent.
|
|
130
|
+
*/
|
|
131
|
+
createInvocationContext(parentContext) {
|
|
132
|
+
return new import_invocation_context.InvocationContext({
|
|
133
|
+
...parentContext,
|
|
134
|
+
agent: this
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Runs the before agent callback if it exists.
|
|
139
|
+
*
|
|
140
|
+
* @param invocationContext The invocation context of the agent.
|
|
141
|
+
* @return The event to return to the user, or undefined if no event is
|
|
142
|
+
* generated.
|
|
143
|
+
*/
|
|
144
|
+
async handleBeforeAgentCallback(invocationContext) {
|
|
145
|
+
if (this.beforeAgentCallback.length === 0) {
|
|
146
|
+
return void 0;
|
|
147
|
+
}
|
|
148
|
+
const callbackContext = new import_callback_context.CallbackContext({ invocationContext });
|
|
149
|
+
for (const callback of this.beforeAgentCallback) {
|
|
150
|
+
const content = await callback(callbackContext);
|
|
151
|
+
if (content) {
|
|
152
|
+
invocationContext.endInvocation = true;
|
|
153
|
+
return (0, import_event.createEvent)({
|
|
154
|
+
invocationId: invocationContext.invocationId,
|
|
155
|
+
author: this.name,
|
|
156
|
+
branch: invocationContext.branch,
|
|
157
|
+
content,
|
|
158
|
+
actions: callbackContext.eventActions
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (callbackContext.state.hasDelta()) {
|
|
163
|
+
return (0, import_event.createEvent)({
|
|
164
|
+
invocationId: invocationContext.invocationId,
|
|
165
|
+
author: this.name,
|
|
166
|
+
branch: invocationContext.branch,
|
|
167
|
+
actions: callbackContext.eventActions
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return void 0;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Runs the after agent callback if it exists.
|
|
174
|
+
*
|
|
175
|
+
* @param invocationContext The invocation context of the agent.
|
|
176
|
+
* @return The event to return to the user, or undefined if no event is
|
|
177
|
+
* generated.
|
|
178
|
+
*/
|
|
179
|
+
async handleAfterAgentCallback(invocationContext) {
|
|
180
|
+
if (this.afterAgentCallback.length === 0) {
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
const callbackContext = new import_callback_context.CallbackContext({ invocationContext });
|
|
184
|
+
for (const callback of this.afterAgentCallback) {
|
|
185
|
+
const content = await callback(callbackContext);
|
|
186
|
+
if (content) {
|
|
187
|
+
return (0, import_event.createEvent)({
|
|
188
|
+
invocationId: invocationContext.invocationId,
|
|
189
|
+
author: this.name,
|
|
190
|
+
branch: invocationContext.branch,
|
|
191
|
+
content,
|
|
192
|
+
actions: callbackContext.eventActions
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (callbackContext.state.hasDelta()) {
|
|
197
|
+
return (0, import_event.createEvent)({
|
|
198
|
+
invocationId: invocationContext.invocationId,
|
|
199
|
+
author: this.name,
|
|
200
|
+
branch: invocationContext.branch,
|
|
201
|
+
actions: callbackContext.eventActions
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
setParentAgentForSubAgents() {
|
|
207
|
+
for (const subAgent of this.subAgents) {
|
|
208
|
+
if (subAgent.parentAgent) {
|
|
209
|
+
throw new Error(`Agent "${subAgent.name}" already has a parent agent, current parent: "${subAgent.parentAgent.name}", trying to add: "${this.name}"`);
|
|
210
|
+
}
|
|
211
|
+
subAgent.parentAgent = this;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function validateAgentName(name) {
|
|
216
|
+
if (!isIdentifier(name)) {
|
|
217
|
+
throw new Error(`Found invalid agent name: "${name}". Agent name must be a valid identifier. It should start with a letter (a-z, A-Z) or an underscore (_), and can only contain letters, digits (0-9), and underscores.`);
|
|
218
|
+
}
|
|
219
|
+
if (name === "user") {
|
|
220
|
+
throw new Error(
|
|
221
|
+
`Agent name cannot be 'user'. 'user' is reserved for end-user's input.`
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
return name;
|
|
225
|
+
}
|
|
226
|
+
function isIdentifier(str) {
|
|
227
|
+
return /^[\p{ID_Start}$_][\p{ID_Continue}$_]*$/u.test(str);
|
|
228
|
+
}
|
|
229
|
+
function getRootAgent(rootAgent) {
|
|
230
|
+
while (rootAgent.parentAgent) {
|
|
231
|
+
rootAgent = rootAgent.parentAgent;
|
|
232
|
+
}
|
|
233
|
+
return rootAgent;
|
|
234
|
+
}
|
|
235
|
+
function getCannonicalCallback(callbacks) {
|
|
236
|
+
if (!callbacks) {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
return Array.isArray(callbacks) ? callbacks : [callbacks];
|
|
240
|
+
}
|
|
241
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
242
|
+
0 && (module.exports = {
|
|
243
|
+
BaseAgent,
|
|
244
|
+
getCannonicalCallback
|
|
245
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var base_llm_processor_exports = {};
|
|
26
|
+
__export(base_llm_processor_exports, {
|
|
27
|
+
BaseLlmRequestProcessor: () => BaseLlmRequestProcessor,
|
|
28
|
+
BaseLlmResponseProcessor: () => BaseLlmResponseProcessor
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(base_llm_processor_exports);
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
* Copyright 2025 Google LLC
|
|
34
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
35
|
+
*/
|
|
36
|
+
class BaseLlmRequestProcessor {
|
|
37
|
+
}
|
|
38
|
+
class BaseLlmResponseProcessor {
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
BaseLlmRequestProcessor,
|
|
43
|
+
BaseLlmResponseProcessor
|
|
44
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 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 __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var callback_context_exports = {};
|
|
26
|
+
__export(callback_context_exports, {
|
|
27
|
+
CallbackContext: () => CallbackContext
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(callback_context_exports);
|
|
30
|
+
var import_event_actions = require("../events/event_actions.js");
|
|
31
|
+
var import_state = require("../sessions/state.js");
|
|
32
|
+
var import_readonly_context = require("./readonly_context.js");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2025 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
class CallbackContext extends import_readonly_context.ReadonlyContext {
|
|
39
|
+
constructor({ invocationContext, eventActions }) {
|
|
40
|
+
super(invocationContext);
|
|
41
|
+
this.eventActions = eventActions || (0, import_event_actions.createEventActions)();
|
|
42
|
+
this._state = new import_state.State(
|
|
43
|
+
invocationContext.session.state,
|
|
44
|
+
this.eventActions.stateDelta
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The delta-aware state of the current session.
|
|
49
|
+
*/
|
|
50
|
+
get state() {
|
|
51
|
+
return this._state;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Loads an artifact attached to the current session.
|
|
55
|
+
*
|
|
56
|
+
* @param filename The filename of the artifact.
|
|
57
|
+
* @param version The version of the artifact. If not provided, the latest
|
|
58
|
+
* version will be used.
|
|
59
|
+
* @return A promise that resolves to the loaded artifact.
|
|
60
|
+
*/
|
|
61
|
+
loadArtifact(filename, version) {
|
|
62
|
+
if (!this.invocationContext.artifactService) {
|
|
63
|
+
throw new Error("Artifact service is not initialized.");
|
|
64
|
+
}
|
|
65
|
+
return this.invocationContext.artifactService.loadArtifact({
|
|
66
|
+
appName: this.invocationContext.appName,
|
|
67
|
+
userId: this.invocationContext.userId,
|
|
68
|
+
sessionId: this.invocationContext.session.id,
|
|
69
|
+
filename,
|
|
70
|
+
version
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Saves an artifact attached to the current session.
|
|
75
|
+
*
|
|
76
|
+
* @param filename The filename of the artifact.
|
|
77
|
+
* @param artifact The artifact to save.
|
|
78
|
+
* @return A promise that resolves to the version of the saved artifact.
|
|
79
|
+
*/
|
|
80
|
+
async saveArtifact(filename, artifact) {
|
|
81
|
+
if (!this.invocationContext.artifactService) {
|
|
82
|
+
throw new Error("Artifact service is not initialized.");
|
|
83
|
+
}
|
|
84
|
+
const version = await this.invocationContext.artifactService.saveArtifact({
|
|
85
|
+
appName: this.invocationContext.appName,
|
|
86
|
+
userId: this.invocationContext.userId,
|
|
87
|
+
sessionId: this.invocationContext.session.id,
|
|
88
|
+
filename,
|
|
89
|
+
artifact
|
|
90
|
+
});
|
|
91
|
+
this.eventActions.artifactDelta[filename] = version;
|
|
92
|
+
return version;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
CallbackContext
|
|
98
|
+
});
|