@google/adk 0.2.5 → 0.4.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/part_converter_utils.js +210 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +46 -24
- package/dist/cjs/agents/base_llm_processor.js +1 -1
- package/dist/cjs/agents/callback_context.js +5 -2
- package/dist/cjs/agents/content_processor_utils.js +16 -8
- package/dist/cjs/agents/functions.js +81 -30
- package/dist/cjs/agents/instructions.js +1 -1
- package/dist/cjs/agents/invocation_context.js +1 -1
- package/dist/cjs/agents/live_request_queue.js +1 -1
- package/dist/cjs/agents/llm_agent.js +106 -62
- package/dist/cjs/agents/loop_agent.js +3 -2
- package/dist/cjs/agents/parallel_agent.js +4 -5
- package/dist/cjs/agents/readonly_context.js +13 -1
- package/dist/cjs/agents/run_config.js +2 -1
- package/dist/cjs/agents/sequential_agent.js +1 -1
- package/dist/cjs/agents/transcription_entry.js +1 -1
- package/dist/cjs/artifacts/base_artifact_service.js +1 -1
- package/dist/cjs/artifacts/file_artifact_service.js +491 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +145 -58
- package/dist/cjs/artifacts/in_memory_artifact_service.js +72 -10
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +4 -2
- package/dist/cjs/auth/auth_schemes.js +1 -1
- package/dist/cjs/auth/auth_tool.js +1 -1
- package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
- package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
- package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
- package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
- package/dist/cjs/code_executors/base_code_executor.js +4 -2
- package/dist/cjs/code_executors/built_in_code_executor.js +8 -4
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +6 -6
- package/dist/cjs/common.js +18 -1
- package/dist/cjs/events/event.js +34 -7
- package/dist/cjs/events/event_actions.js +2 -2
- package/dist/cjs/events/structured_events.js +105 -0
- package/dist/cjs/examples/base_example_provider.js +1 -1
- package/dist/cjs/examples/example.js +1 -1
- package/dist/cjs/examples/example_util.js +1 -1
- package/dist/cjs/index.js +54 -83
- package/dist/cjs/index_web.js +1 -1
- package/dist/cjs/memory/base_memory_service.js +1 -1
- package/dist/cjs/memory/in_memory_memory_service.js +4 -2
- package/dist/cjs/memory/memory_entry.js +1 -1
- package/dist/cjs/models/apigee_llm.js +182 -0
- package/dist/cjs/models/base_llm.js +9 -5
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +2 -1
- package/dist/cjs/models/google_llm.js +73 -54
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +1 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +13 -1
- package/dist/cjs/plugins/logging_plugin.js +51 -14
- package/dist/cjs/plugins/plugin_manager.js +57 -25
- package/dist/cjs/plugins/security_plugin.js +2 -2
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +142 -96
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +364 -0
- package/dist/cjs/sessions/db/operations.js +114 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +60 -34
- package/dist/cjs/sessions/registry.js +49 -0
- package/dist/cjs/sessions/session.js +1 -1
- package/dist/cjs/sessions/state.js +1 -1
- package/dist/cjs/telemetry/google_cloud.js +8 -10
- package/dist/cjs/telemetry/setup.js +16 -8
- package/dist/cjs/telemetry/tracing.js +38 -16
- package/dist/cjs/tools/agent_tool.js +9 -5
- package/dist/cjs/tools/base_tool.js +5 -3
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/forwarding_artifact_service.js +18 -2
- package/dist/cjs/tools/function_tool.js +2 -3
- package/dist/cjs/tools/google_search_tool.js +2 -3
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +17 -11
- package/dist/cjs/tools/mcp/mcp_tool.js +2 -4
- package/dist/cjs/tools/mcp/mcp_toolset.js +2 -2
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/tools/tool_context.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +11 -2
- package/dist/cjs/utils/gemini_schema_util.js +10 -5
- package/dist/cjs/utils/logger.js +48 -4
- package/dist/cjs/utils/model_name.js +1 -1
- package/dist/cjs/utils/object_notation_utils.js +78 -0
- package/dist/cjs/utils/simple_zod_to_json.js +101 -142
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- package/dist/esm/a2a/part_converter_utils.js +171 -0
- package/dist/esm/agents/base_agent.js +50 -24
- package/dist/esm/agents/callback_context.js +4 -1
- package/dist/esm/agents/content_processor_utils.js +25 -9
- package/dist/esm/agents/functions.js +84 -29
- package/dist/esm/agents/llm_agent.js +110 -62
- package/dist/esm/agents/loop_agent.js +2 -1
- package/dist/esm/agents/parallel_agent.js +3 -4
- package/dist/esm/agents/readonly_context.js +12 -0
- package/dist/esm/agents/run_config.js +1 -0
- package/dist/esm/artifacts/file_artifact_service.js +451 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +144 -57
- package/dist/esm/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/auth/auth_handler.js +3 -1
- package/dist/esm/code_executors/base_code_executor.js +3 -1
- package/dist/esm/code_executors/built_in_code_executor.js +7 -3
- package/dist/esm/code_executors/code_executor_context.js +5 -5
- package/dist/esm/common.js +12 -2
- package/dist/esm/events/event.js +30 -5
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +18 -88
- package/dist/esm/memory/in_memory_memory_service.js +3 -1
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/base_llm.js +8 -4
- package/dist/esm/models/gemini_llm_connection.js +1 -0
- package/dist/esm/models/google_llm.js +75 -53
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +12 -0
- package/dist/esm/plugins/logging_plugin.js +55 -14
- package/dist/esm/plugins/plugin_manager.js +56 -24
- package/dist/esm/plugins/security_plugin.js +1 -1
- package/dist/esm/runner/runner.js +145 -96
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +350 -0
- package/dist/esm/sessions/db/operations.js +87 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +61 -33
- package/dist/esm/sessions/registry.js +25 -0
- package/dist/esm/telemetry/google_cloud.js +7 -9
- package/dist/esm/telemetry/setup.js +23 -9
- package/dist/esm/telemetry/tracing.js +37 -15
- package/dist/esm/tools/agent_tool.js +8 -4
- package/dist/esm/tools/base_tool.js +4 -2
- package/dist/esm/tools/forwarding_artifact_service.js +17 -1
- package/dist/esm/tools/function_tool.js +1 -2
- package/dist/esm/tools/google_search_tool.js +2 -5
- package/dist/esm/tools/long_running_tool.js +3 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/esm/tools/mcp/mcp_tool.js +1 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
- package/dist/esm/utils/env_aware_utils.js +9 -1
- package/dist/esm/utils/gemini_schema_util.js +9 -4
- package/dist/esm/utils/logger.js +43 -2
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/simple_zod_to_json.js +102 -141
- package/dist/esm/utils/variant_utils.js +1 -7
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/part_converter_utils.d.ts +47 -0
- package/dist/types/agents/base_agent.d.ts +2 -1
- package/dist/types/agents/callback_context.d.ts +1 -1
- package/dist/types/agents/llm_agent.d.ts +12 -12
- package/dist/types/agents/loop_agent.d.ts +1 -1
- package/dist/types/agents/parallel_agent.d.ts +1 -1
- package/dist/types/agents/readonly_context.d.ts +8 -0
- package/dist/types/agents/run_config.d.ts +6 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
- package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
- package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
- package/dist/types/artifacts/in_memory_artifact_service.d.ts +8 -5
- package/dist/types/artifacts/registry.d.ts +7 -0
- package/dist/types/code_executors/built_in_code_executor.d.ts +1 -1
- package/dist/types/code_executors/code_executor_context.d.ts +2 -4
- package/dist/types/common.d.ts +13 -3
- package/dist/types/events/event.d.ts +15 -1
- package/dist/types/events/event_actions.d.ts +1 -1
- package/dist/types/events/structured_events.d.ts +106 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/base_llm_connection.d.ts +1 -1
- package/dist/types/models/google_llm.d.ts +5 -2
- package/dist/types/models/llm_response.d.ts +1 -1
- package/dist/types/plugins/logging_plugin.d.ts +12 -12
- package/dist/types/plugins/plugin_manager.d.ts +12 -12
- package/dist/types/plugins/security_plugin.d.ts +1 -1
- package/dist/types/runner/runner.d.ts +16 -1
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +31 -0
- package/dist/types/sessions/db/operations.d.ts +29 -0
- package/dist/types/sessions/db/schema.d.ts +45 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +9 -6
- package/dist/types/sessions/registry.d.ts +7 -0
- package/dist/types/telemetry/setup.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +7 -6
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/base_tool.d.ts +1 -1
- package/dist/types/tools/base_toolset.d.ts +2 -1
- package/dist/types/tools/forwarding_artifact_service.d.ts +4 -2
- package/dist/types/tools/function_tool.d.ts +4 -3
- package/dist/types/tools/google_search_tool.d.ts +3 -3
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +10 -3
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -2
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/gemini_schema_util.d.ts +4 -12
- package/dist/types/utils/logger.d.ts +11 -10
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/utils/simple_zod_to_json.d.ts +5 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/part_converter_utils.js +171 -0
- package/dist/web/agents/base_agent.js +96 -35
- package/dist/web/agents/callback_context.js +4 -1
- package/dist/web/agents/content_processor_utils.js +25 -9
- package/dist/web/agents/functions.js +84 -29
- package/dist/web/agents/llm_agent.js +166 -83
- package/dist/web/agents/loop_agent.js +2 -1
- package/dist/web/agents/parallel_agent.js +3 -4
- package/dist/web/agents/readonly_context.js +12 -0
- package/dist/web/agents/run_config.js +2 -1
- package/dist/web/artifacts/file_artifact_service.js +506 -0
- package/dist/web/artifacts/gcs_artifact_service.js +139 -54
- package/dist/web/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/auth/auth_handler.js +3 -1
- package/dist/web/code_executors/base_code_executor.js +3 -1
- package/dist/web/code_executors/built_in_code_executor.js +7 -3
- package/dist/web/code_executors/code_executor_context.js +5 -5
- package/dist/web/common.js +12 -2
- package/dist/web/events/event.js +30 -5
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +18 -8
- package/dist/web/memory/in_memory_memory_service.js +3 -1
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/base_llm.js +8 -4
- package/dist/web/models/gemini_llm_connection.js +1 -0
- package/dist/web/models/google_llm.js +75 -50
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +12 -0
- package/dist/web/plugins/logging_plugin.js +55 -14
- package/dist/web/plugins/plugin_manager.js +56 -24
- package/dist/web/plugins/security_plugin.js +1 -1
- package/dist/web/runner/runner.js +192 -108
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +368 -0
- package/dist/web/sessions/db/operations.js +87 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +61 -33
- package/dist/web/sessions/registry.js +25 -0
- package/dist/web/telemetry/google_cloud.js +7 -9
- package/dist/web/telemetry/setup.js +23 -9
- package/dist/web/telemetry/tracing.js +37 -15
- package/dist/web/tools/agent_tool.js +8 -4
- package/dist/web/tools/base_tool.js +4 -2
- package/dist/web/tools/forwarding_artifact_service.js +17 -1
- package/dist/web/tools/function_tool.js +1 -2
- package/dist/web/tools/google_search_tool.js +2 -5
- package/dist/web/tools/long_running_tool.js +3 -1
- package/dist/web/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/web/tools/mcp/mcp_tool.js +1 -3
- package/dist/web/tools/mcp/mcp_toolset.js +1 -1
- package/dist/web/utils/env_aware_utils.js +9 -1
- package/dist/web/utils/gemini_schema_util.js +9 -4
- package/dist/web/utils/logger.js +43 -2
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/simple_zod_to_json.js +102 -155
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +16 -5
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/web/index.js.map +0 -7
package/dist/web/utils/logger.js
CHANGED
|
@@ -61,6 +61,18 @@ class SimpleLogger {
|
|
|
61
61
|
console.error(getColoredPrefix(3 /* ERROR */), ...args);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
class NoOpLogger {
|
|
65
|
+
log(_level, ..._args) {
|
|
66
|
+
}
|
|
67
|
+
debug(..._args) {
|
|
68
|
+
}
|
|
69
|
+
info(..._args) {
|
|
70
|
+
}
|
|
71
|
+
warn(..._args) {
|
|
72
|
+
}
|
|
73
|
+
error(..._args) {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
64
76
|
const LOG_LEVEL_STR = {
|
|
65
77
|
[0 /* DEBUG */]: "DEBUG",
|
|
66
78
|
[1 /* INFO */]: "INFO",
|
|
@@ -81,9 +93,38 @@ const RESET_COLOR = "\x1B[0m";
|
|
|
81
93
|
function getColoredPrefix(level) {
|
|
82
94
|
return "".concat(CONSOLE_COLOR_MAP[level], "[ADK ").concat(LOG_LEVEL_STR[level], "]:").concat(RESET_COLOR);
|
|
83
95
|
}
|
|
84
|
-
|
|
96
|
+
let currentLogger = new SimpleLogger();
|
|
97
|
+
function setLogger(customLogger) {
|
|
98
|
+
currentLogger = customLogger != null ? customLogger : new NoOpLogger();
|
|
99
|
+
}
|
|
100
|
+
function getLogger() {
|
|
101
|
+
return currentLogger;
|
|
102
|
+
}
|
|
103
|
+
function resetLogger() {
|
|
104
|
+
currentLogger = new SimpleLogger();
|
|
105
|
+
}
|
|
106
|
+
const logger = {
|
|
107
|
+
log(level, ...args) {
|
|
108
|
+
currentLogger.log(level, ...args);
|
|
109
|
+
},
|
|
110
|
+
debug(...args) {
|
|
111
|
+
currentLogger.debug(...args);
|
|
112
|
+
},
|
|
113
|
+
info(...args) {
|
|
114
|
+
currentLogger.info(...args);
|
|
115
|
+
},
|
|
116
|
+
warn(...args) {
|
|
117
|
+
currentLogger.warn(...args);
|
|
118
|
+
},
|
|
119
|
+
error(...args) {
|
|
120
|
+
currentLogger.error(...args);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
85
123
|
export {
|
|
86
124
|
LogLevel,
|
|
125
|
+
getLogger,
|
|
87
126
|
logger,
|
|
88
|
-
|
|
127
|
+
resetLogger,
|
|
128
|
+
setLogLevel,
|
|
129
|
+
setLogger
|
|
89
130
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
function toCamelCase(obj, preserveKeys = []) {
|
|
7
|
+
return toNotation(obj, toCamelCaseKey, "", preserveKeys);
|
|
8
|
+
}
|
|
9
|
+
function toSnakeCase(obj, preserveKeys = []) {
|
|
10
|
+
return toNotation(obj, toSnakeCaseKey, "", preserveKeys);
|
|
11
|
+
}
|
|
12
|
+
const toCamelCaseKey = (key) => key.replace(
|
|
13
|
+
/_([a-z])/g,
|
|
14
|
+
(_match, letter) => letter.toUpperCase()
|
|
15
|
+
);
|
|
16
|
+
const toSnakeCaseKey = (key) => key.replace(/[A-Z]/g, (g) => "_" + g.toLowerCase());
|
|
17
|
+
function toNotation(obj, converter, parentKey = "", preserveKeys = []) {
|
|
18
|
+
if (Array.isArray(obj)) {
|
|
19
|
+
return obj.map(
|
|
20
|
+
(item) => toNotation(item, converter, parentKey, preserveKeys)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === "object" && obj !== null) {
|
|
24
|
+
const source = obj;
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const key of Object.keys(source)) {
|
|
27
|
+
const convertedKey = converter(key);
|
|
28
|
+
const fullPath = parentKey !== "" ? parentKey + "." + key : key;
|
|
29
|
+
if (preserveKeys.includes(fullPath)) {
|
|
30
|
+
result[convertedKey] = source[key];
|
|
31
|
+
} else {
|
|
32
|
+
result[convertedKey] = toNotation(
|
|
33
|
+
source[key],
|
|
34
|
+
converter,
|
|
35
|
+
fullPath,
|
|
36
|
+
preserveKeys
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
toCamelCase,
|
|
46
|
+
toSnakeCase
|
|
47
|
+
};
|
|
@@ -1,172 +1,119 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
/**
|
|
18
2
|
* @license
|
|
19
3
|
* Copyright 2025 Google LLC
|
|
20
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
21
5
|
*/
|
|
22
6
|
import { Type } from "@google/genai";
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
import {
|
|
8
|
+
zodToJsonSchema as toJSONSchemaV3
|
|
9
|
+
} from "zod-to-json-schema";
|
|
10
|
+
import { toJSONSchema as toJSONSchemaV4 } from "zod/v4";
|
|
11
|
+
function isZodSchema(obj) {
|
|
12
|
+
return obj !== null && typeof obj === "object" && "parse" in obj && typeof obj.parse === "function" && "safeParse" in obj && typeof obj.safeParse === "function";
|
|
13
|
+
}
|
|
14
|
+
function isZodV3Schema(obj) {
|
|
15
|
+
return isZodSchema(obj) && !("_zod" in obj);
|
|
27
16
|
}
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
17
|
+
function isZodV4Schema(obj) {
|
|
18
|
+
return isZodSchema(obj) && "_zod" in obj;
|
|
19
|
+
}
|
|
20
|
+
function getZodTypeName(schema) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const schemaAny = schema;
|
|
23
|
+
if ((_a = schemaAny._def) == null ? void 0 : _a.typeName) {
|
|
24
|
+
return schemaAny._def.typeName;
|
|
32
25
|
}
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const returnResult = (result2) => {
|
|
37
|
-
if (result2.description === void 0) {
|
|
38
|
-
delete result2.description;
|
|
39
|
-
}
|
|
40
|
-
return result2;
|
|
41
|
-
};
|
|
42
|
-
switch (def.typeName) {
|
|
43
|
-
case z.ZodFirstPartyTypeKind.ZodString:
|
|
44
|
-
result.type = Type.STRING;
|
|
45
|
-
for (const check of def.checks || []) {
|
|
46
|
-
if (check.kind === "min")
|
|
47
|
-
result.minLength = check.value.toString();
|
|
48
|
-
else if (check.kind === "max")
|
|
49
|
-
result.maxLength = check.value.toString();
|
|
50
|
-
else if (check.kind === "email")
|
|
51
|
-
result.format = "email";
|
|
52
|
-
else if (check.kind === "uuid")
|
|
53
|
-
result.format = "uuid";
|
|
54
|
-
else if (check.kind === "url")
|
|
55
|
-
result.format = "uri";
|
|
56
|
-
else if (check.kind === "regex")
|
|
57
|
-
result.pattern = check.regex.source;
|
|
58
|
-
}
|
|
59
|
-
return returnResult(result);
|
|
60
|
-
case z.ZodFirstPartyTypeKind.ZodNumber:
|
|
61
|
-
result.type = Type.NUMBER;
|
|
62
|
-
for (const check of def.checks || []) {
|
|
63
|
-
if (check.kind === "min")
|
|
64
|
-
result.minimum = check.value;
|
|
65
|
-
else if (check.kind === "max")
|
|
66
|
-
result.maximum = check.value;
|
|
67
|
-
else if (check.kind === "int")
|
|
68
|
-
result.type = Type.INTEGER;
|
|
69
|
-
}
|
|
70
|
-
return returnResult(result);
|
|
71
|
-
case z.ZodFirstPartyTypeKind.ZodBoolean:
|
|
72
|
-
result.type = Type.BOOLEAN;
|
|
73
|
-
return returnResult(result);
|
|
74
|
-
case z.ZodFirstPartyTypeKind.ZodArray:
|
|
75
|
-
result.type = Type.ARRAY;
|
|
76
|
-
result.items = parseZodType(def.type);
|
|
77
|
-
if (def.minLength) result.minItems = def.minLength.value.toString();
|
|
78
|
-
if (def.maxLength) result.maxItems = def.maxLength.value.toString();
|
|
79
|
-
return returnResult(result);
|
|
80
|
-
case z.ZodFirstPartyTypeKind.ZodObject: {
|
|
81
|
-
const nestedSchema = zodObjectToSchema(zodType);
|
|
82
|
-
return nestedSchema;
|
|
83
|
-
}
|
|
84
|
-
case z.ZodFirstPartyTypeKind.ZodLiteral:
|
|
85
|
-
const literalType = typeof def.value;
|
|
86
|
-
result.enum = [def.value.toString()];
|
|
87
|
-
if (literalType === "string") {
|
|
88
|
-
result.type = Type.STRING;
|
|
89
|
-
} else if (literalType === "number") {
|
|
90
|
-
result.type = Type.NUMBER;
|
|
91
|
-
} else if (literalType === "boolean") {
|
|
92
|
-
result.type = Type.BOOLEAN;
|
|
93
|
-
} else if (def.value === null) {
|
|
94
|
-
result.type = Type.NULL;
|
|
95
|
-
} else {
|
|
96
|
-
throw new Error("Unsupported ZodLiteral value type: ".concat(literalType));
|
|
97
|
-
}
|
|
98
|
-
return returnResult(result);
|
|
99
|
-
case z.ZodFirstPartyTypeKind.ZodEnum:
|
|
100
|
-
result.type = Type.STRING;
|
|
101
|
-
result.enum = def.values;
|
|
102
|
-
return returnResult(result);
|
|
103
|
-
case z.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
104
|
-
result.type = Type.STRING;
|
|
105
|
-
result.enum = Object.values(def.values);
|
|
106
|
-
return returnResult(result);
|
|
107
|
-
case z.ZodFirstPartyTypeKind.ZodUnion:
|
|
108
|
-
result.anyOf = def.options.map(parseZodType);
|
|
109
|
-
return returnResult(result);
|
|
110
|
-
case z.ZodFirstPartyTypeKind.ZodOptional:
|
|
111
|
-
return parseZodType(def.innerType);
|
|
112
|
-
case z.ZodFirstPartyTypeKind.ZodNullable:
|
|
113
|
-
const nullableInner = parseZodType(def.innerType);
|
|
114
|
-
return nullableInner ? returnResult(__spreadValues({
|
|
115
|
-
anyOf: [nullableInner, { type: Type.NULL }]
|
|
116
|
-
}, description && { description })) : returnResult(__spreadValues({ type: Type.NULL }, description && { description }));
|
|
117
|
-
case z.ZodFirstPartyTypeKind.ZodDefault:
|
|
118
|
-
const defaultInner = parseZodType(def.innerType);
|
|
119
|
-
if (defaultInner) defaultInner.default = def.defaultValue();
|
|
120
|
-
return defaultInner;
|
|
121
|
-
case z.ZodFirstPartyTypeKind.ZodBranded:
|
|
122
|
-
return parseZodType(def.type);
|
|
123
|
-
case z.ZodFirstPartyTypeKind.ZodReadonly:
|
|
124
|
-
return parseZodType(def.innerType);
|
|
125
|
-
case z.ZodFirstPartyTypeKind.ZodNull:
|
|
126
|
-
result.type = Type.NULL;
|
|
127
|
-
return returnResult(result);
|
|
128
|
-
case z.ZodFirstPartyTypeKind.ZodAny:
|
|
129
|
-
case z.ZodFirstPartyTypeKind.ZodUnknown:
|
|
130
|
-
return returnResult(__spreadValues({}, description && { description }));
|
|
131
|
-
default:
|
|
132
|
-
throw new Error("Unsupported Zod type: ".concat(def.typeName));
|
|
26
|
+
const zod4Type = (_b = schemaAny._def) == null ? void 0 : _b.type;
|
|
27
|
+
if (typeof zod4Type === "string" && zod4Type) {
|
|
28
|
+
return "Zod" + zod4Type.charAt(0).toUpperCase() + zod4Type.slice(1);
|
|
133
29
|
}
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
function isZodObject(obj) {
|
|
33
|
+
return isZodSchema(obj) && getZodTypeName(obj) === "ZodObject";
|
|
134
34
|
}
|
|
135
35
|
function zodObjectToSchema(schema) {
|
|
136
|
-
if (schema
|
|
137
|
-
throw new Error("Expected a
|
|
36
|
+
if (!isZodObject(schema)) {
|
|
37
|
+
throw new Error("Expected a Zod Object");
|
|
138
38
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
39
|
+
if (isZodV4Schema(schema)) {
|
|
40
|
+
return toJSONSchemaV4(schema, {
|
|
41
|
+
target: "openapi-3.0",
|
|
42
|
+
io: "input",
|
|
43
|
+
override: (ctx) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const { jsonSchema } = ctx;
|
|
46
|
+
if (jsonSchema.additionalProperties !== void 0) {
|
|
47
|
+
delete jsonSchema.additionalProperties;
|
|
48
|
+
}
|
|
49
|
+
if (jsonSchema.readOnly !== void 0) {
|
|
50
|
+
delete jsonSchema.readOnly;
|
|
51
|
+
}
|
|
52
|
+
if (jsonSchema.maxItems !== void 0) {
|
|
53
|
+
jsonSchema.maxItems = jsonSchema.maxItems.toString();
|
|
54
|
+
}
|
|
55
|
+
if (jsonSchema.format === "email" || jsonSchema.format === "uuid") {
|
|
56
|
+
delete jsonSchema.pattern;
|
|
57
|
+
}
|
|
58
|
+
if (jsonSchema.minItems !== void 0) {
|
|
59
|
+
jsonSchema.minItems = jsonSchema.minItems.toString();
|
|
60
|
+
}
|
|
61
|
+
if (jsonSchema.minLength !== void 0) {
|
|
62
|
+
jsonSchema.minLength = jsonSchema.minLength.toString();
|
|
63
|
+
}
|
|
64
|
+
if (jsonSchema.maxLength !== void 0) {
|
|
65
|
+
jsonSchema.maxLength = jsonSchema.maxLength.toString();
|
|
66
|
+
}
|
|
67
|
+
if (((_a = jsonSchema.enum) == null ? void 0 : _a.length) === 1 && jsonSchema.enum[0] === null) {
|
|
68
|
+
jsonSchema.type = Type.NULL;
|
|
69
|
+
delete jsonSchema.enum;
|
|
70
|
+
}
|
|
71
|
+
if (jsonSchema.type !== void 0) {
|
|
72
|
+
jsonSchema.type = jsonSchema.type.toUpperCase();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
157
76
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
77
|
+
if (isZodV3Schema(schema)) {
|
|
78
|
+
return toJSONSchemaV3(schema, {
|
|
79
|
+
target: "openApi3",
|
|
80
|
+
emailStrategy: "format:email",
|
|
81
|
+
postProcess: (jsonSchema) => {
|
|
82
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
83
|
+
if (!jsonSchema) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
if (jsonSchema.additionalProperties !== void 0) {
|
|
87
|
+
delete jsonSchema.additionalProperties;
|
|
88
|
+
}
|
|
89
|
+
if (jsonSchema.maxItems !== void 0) {
|
|
90
|
+
jsonSchema.maxItems = (_a = jsonSchema.maxItems) == null ? void 0 : _a.toString();
|
|
91
|
+
}
|
|
92
|
+
if (jsonSchema.minItems !== void 0) {
|
|
93
|
+
jsonSchema.minItems = (_b = jsonSchema.minItems) == null ? void 0 : _b.toString();
|
|
94
|
+
}
|
|
95
|
+
if (jsonSchema.minLength !== void 0) {
|
|
96
|
+
jsonSchema.minLength = (_c = jsonSchema.minLength) == null ? void 0 : _c.toString();
|
|
97
|
+
}
|
|
98
|
+
if (jsonSchema.maxLength !== void 0) {
|
|
99
|
+
jsonSchema.maxLength = (_d = jsonSchema.maxLength) == null ? void 0 : _d.toString();
|
|
100
|
+
}
|
|
101
|
+
if (((_e = jsonSchema.enum) == null ? void 0 : _e.length) === 1 && jsonSchema.enum[0] === "null") {
|
|
102
|
+
jsonSchema.type = Type.NULL;
|
|
103
|
+
delete jsonSchema.enum;
|
|
104
|
+
}
|
|
105
|
+
if (jsonSchema.type === "integer" && jsonSchema.format !== "int64") {
|
|
106
|
+
(_f = jsonSchema.minimum) != null ? _f : jsonSchema.minimum = Number.MIN_SAFE_INTEGER;
|
|
107
|
+
(_g = jsonSchema.maximum) != null ? _g : jsonSchema.maximum = Number.MAX_SAFE_INTEGER;
|
|
108
|
+
}
|
|
109
|
+
if (jsonSchema.type !== void 0) {
|
|
110
|
+
jsonSchema.type = jsonSchema.type.toUpperCase();
|
|
111
|
+
}
|
|
112
|
+
return jsonSchema;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
164
115
|
}
|
|
165
|
-
|
|
166
|
-
type: Type.OBJECT,
|
|
167
|
-
properties,
|
|
168
|
-
required: required.length > 0 ? required : []
|
|
169
|
-
}, schema._def.description ? { description: schema._def.description } : {});
|
|
116
|
+
throw new Error("Unsupported Zod schema version.");
|
|
170
117
|
}
|
|
171
118
|
export {
|
|
172
119
|
isZodObject,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { getBooleanEnvVar } from "./env_aware_utils.js";
|
|
6
7
|
var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
7
8
|
GoogleLLMVariant2["VERTEX_AI"] = "VERTEX_AI";
|
|
8
9
|
GoogleLLMVariant2["GEMINI_API"] = "GEMINI_API";
|
|
@@ -11,13 +12,6 @@ var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
|
11
12
|
function getGoogleLlmVariant() {
|
|
12
13
|
return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
|
|
13
14
|
}
|
|
14
|
-
function getBooleanEnvVar(envVar) {
|
|
15
|
-
if (!process.env) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
19
|
-
return ["true", "1"].includes(envVar.toLowerCase());
|
|
20
|
-
}
|
|
21
15
|
export {
|
|
22
16
|
GoogleLLMVariant,
|
|
23
17
|
getGoogleLlmVariant
|
package/dist/web/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/adk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Google ADK JS",
|
|
5
5
|
"author": "Google",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,29 +30,40 @@
|
|
|
30
30
|
"scripts": {
|
|
31
31
|
"clean": "rm -rf dist",
|
|
32
32
|
"clean:all": "npm run clean && rm -rf node_modules",
|
|
33
|
+
"rebuild": "npm run clean:all && npm install && npm run build",
|
|
33
34
|
"build": "tsc --emitDeclarationOnly && node ./build.js",
|
|
34
35
|
"build:bundle": "tsc --emitDeclarationOnly && node ./build.js --bundle",
|
|
35
36
|
"build:watch": "concurrently \"tsc --noEmit --watch --preserveWatchOutput\" \"node ./build.js --watch\"",
|
|
36
37
|
"test": "vitest",
|
|
37
38
|
"lint": "eslint 'src/**/*.ts'",
|
|
38
39
|
"format": "prettier --write 'src/**/*.ts'",
|
|
39
|
-
"prepublishOnly": "npm run build
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
43
|
+
"@a2a-js/sdk": "^0.3.10",
|
|
42
44
|
"@google/genai": "^1.37.0",
|
|
43
|
-
"@
|
|
45
|
+
"@mikro-orm/core": "^6.6.6",
|
|
46
|
+
"@mikro-orm/reflection": "^6.6.6",
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
44
48
|
"google-auth-library": "^10.3.0",
|
|
45
49
|
"lodash-es": "^4.17.23",
|
|
46
|
-
"zod": "
|
|
50
|
+
"zod": "^4.2.1",
|
|
51
|
+
"zod-to-json-schema": "^3.25.1"
|
|
47
52
|
},
|
|
48
53
|
"devDependencies": {
|
|
49
54
|
"@types/lodash-es": "^4.17.12",
|
|
50
|
-
"openapi-types": "^12.1.3"
|
|
55
|
+
"openapi-types": "^12.1.3",
|
|
56
|
+
"@mikro-orm/sqlite": "^6.6.6"
|
|
51
57
|
},
|
|
52
58
|
"peerDependencies": {
|
|
53
59
|
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
|
|
54
60
|
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
|
|
55
61
|
"@google-cloud/storage": "^7.17.1",
|
|
62
|
+
"@mikro-orm/mariadb": "^6.6.6",
|
|
63
|
+
"@mikro-orm/mssql": "^6.6.6",
|
|
64
|
+
"@mikro-orm/mysql": "^6.6.6",
|
|
65
|
+
"@mikro-orm/postgresql": "^6.6.6",
|
|
66
|
+
"@mikro-orm/sqlite": "^6.6.6",
|
|
56
67
|
"@opentelemetry/api": "1.9.0",
|
|
57
68
|
"@opentelemetry/api-logs": "^0.205.0",
|
|
58
69
|
"@opentelemetry/exporter-logs-otlp-http": "^0.205.0",
|