@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
|
@@ -70,14 +70,10 @@ function randomUUID() {
|
|
|
70
70
|
__name(randomUUID, "randomUUID");
|
|
71
71
|
function base64Encode(data) {
|
|
72
72
|
if (isBrowser()) {
|
|
73
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
73
74
|
let strData = "";
|
|
74
|
-
|
|
75
|
-
strData
|
|
76
|
-
} else {
|
|
77
|
-
const len = data.byteLength;
|
|
78
|
-
for (let i = 0; i < len; i++) {
|
|
79
|
-
strData += String.fromCharCode(data[i]);
|
|
80
|
-
}
|
|
75
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
76
|
+
strData += String.fromCharCode(bytes[i]);
|
|
81
77
|
}
|
|
82
78
|
return window.btoa(strData);
|
|
83
79
|
}
|
|
@@ -86,7 +82,9 @@ function base64Encode(data) {
|
|
|
86
82
|
__name(base64Encode, "base64Encode");
|
|
87
83
|
function base64Decode(data) {
|
|
88
84
|
if (isBrowser()) {
|
|
89
|
-
|
|
85
|
+
const binary = window.atob(data);
|
|
86
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
87
|
+
return new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
|
|
90
88
|
}
|
|
91
89
|
return Buffer.from(data, "base64").toString();
|
|
92
90
|
}
|
|
@@ -25,7 +25,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
26
|
var error_utils_exports = {};
|
|
27
27
|
__export(error_utils_exports, {
|
|
28
|
-
formatError: () => formatError
|
|
28
|
+
formatError: () => formatError,
|
|
29
|
+
getErrorMessage: () => getErrorMessage
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(error_utils_exports);
|
|
31
32
|
/**
|
|
@@ -55,16 +56,14 @@ function truncateBody(body) {
|
|
|
55
56
|
return body.length > MAX_RESPONSE_BODY_LENGTH ? body.slice(0, MAX_RESPONSE_BODY_LENGTH) + TRUNCATION_MARKER : body;
|
|
56
57
|
}
|
|
57
58
|
__name(truncateBody, "truncateBody");
|
|
58
|
-
function
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (typeof err === "string") {
|
|
63
|
-
return err;
|
|
59
|
+
function getErrorMessage(err) {
|
|
60
|
+
const record = asRecord(err);
|
|
61
|
+
if (record !== void 0 && typeof record["message"] === "string") {
|
|
62
|
+
return record["message"];
|
|
64
63
|
}
|
|
65
64
|
return String(err);
|
|
66
65
|
}
|
|
67
|
-
__name(
|
|
66
|
+
__name(getErrorMessage, "getErrorMessage");
|
|
68
67
|
function extractHttpDetails(err) {
|
|
69
68
|
var _a, _b;
|
|
70
69
|
const record = asRecord(err);
|
|
@@ -97,7 +96,7 @@ function formatErrorRecursive(err, seen) {
|
|
|
97
96
|
}
|
|
98
97
|
if (typeof err === "object") {
|
|
99
98
|
if (seen.has(err)) {
|
|
100
|
-
return
|
|
99
|
+
return getErrorMessage(err);
|
|
101
100
|
}
|
|
102
101
|
seen.add(err);
|
|
103
102
|
}
|
|
@@ -105,7 +104,7 @@ function formatErrorRecursive(err, seen) {
|
|
|
105
104
|
return err.errors.map((sub) => formatErrorRecursive(sub, seen)).join(" | ");
|
|
106
105
|
}
|
|
107
106
|
const http = extractHttpDetails(err);
|
|
108
|
-
const base =
|
|
107
|
+
const base = getErrorMessage(err);
|
|
109
108
|
const cause = (_a = asRecord(err)) == null ? void 0 : _a["cause"];
|
|
110
109
|
const causeMessage = cause !== void 0 ? formatErrorRecursive(cause, seen) : void 0;
|
|
111
110
|
let message = base.length > 0 ? base : UNKNOWN_ERROR;
|
|
@@ -124,5 +123,6 @@ function formatError(err) {
|
|
|
124
123
|
__name(formatError, "formatError");
|
|
125
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
125
|
0 && (module.exports = {
|
|
127
|
-
formatError
|
|
126
|
+
formatError,
|
|
127
|
+
getErrorMessage
|
|
128
128
|
});
|
|
@@ -37,7 +37,17 @@ var import_code_execution_utils = require("../code_executors/code_execution_util
|
|
|
37
37
|
*/
|
|
38
38
|
const MIME_TYPE_MAP = {
|
|
39
39
|
".js": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
40
|
+
".cjs": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
41
|
+
".mjs": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
42
|
+
".ts": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
43
|
+
".cts": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
44
|
+
".mts": { mimeType: "text/javascript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
40
45
|
".py": { mimeType: "text/x-python", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
46
|
+
".sh": { mimeType: "text/x-shellscript", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
47
|
+
".bash": {
|
|
48
|
+
mimeType: "text/x-shellscript",
|
|
49
|
+
encoding: import_code_execution_utils.FileContentEncoding.UTF8
|
|
50
|
+
},
|
|
41
51
|
".md": { mimeType: "text/markdown", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
42
52
|
".txt": { mimeType: "text/plain", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
43
53
|
".html": { mimeType: "text/html", encoding: import_code_execution_utils.FileContentEncoding.UTF8 },
|
|
@@ -51,6 +61,7 @@ const MIME_TYPE_MAP = {
|
|
|
51
61
|
".png": { mimeType: "image/png", encoding: import_code_execution_utils.FileContentEncoding.BASE64 },
|
|
52
62
|
".jpg": { mimeType: "image/jpeg", encoding: import_code_execution_utils.FileContentEncoding.BASE64 },
|
|
53
63
|
".jpeg": { mimeType: "image/jpeg", encoding: import_code_execution_utils.FileContentEncoding.BASE64 },
|
|
64
|
+
".gif": { mimeType: "image/gif", encoding: import_code_execution_utils.FileContentEncoding.BASE64 },
|
|
54
65
|
".pdf": { mimeType: "application/pdf", encoding: import_code_execution_utils.FileContentEncoding.BASE64 }
|
|
55
66
|
};
|
|
56
67
|
const EXTENSION_TO_LANGUAGE = {
|
|
@@ -35,13 +35,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
35
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
36
|
var file_utils_exports = {};
|
|
37
37
|
__export(file_utils_exports, {
|
|
38
|
-
EXTENSION_TO_MIME_TYPE: () => EXTENSION_TO_MIME_TYPE,
|
|
39
38
|
guessMimeType: () => guessMimeType,
|
|
40
39
|
materializeFiles: () => materializeFiles
|
|
41
40
|
});
|
|
42
41
|
module.exports = __toCommonJS(file_utils_exports);
|
|
43
42
|
var fs = __toESM(require("node:fs/promises"), 1);
|
|
44
43
|
var path = __toESM(require("node:path"), 1);
|
|
44
|
+
var import_file_extension_utils = require("./file_extension_utils.js");
|
|
45
45
|
/**
|
|
46
46
|
* @license
|
|
47
47
|
* Copyright 2026 Google LLC
|
|
@@ -97,34 +97,12 @@ async function materializeFiles(files, dir) {
|
|
|
97
97
|
return createdFiles;
|
|
98
98
|
}
|
|
99
99
|
__name(materializeFiles, "materializeFiles");
|
|
100
|
-
const EXTENSION_TO_MIME_TYPE = {
|
|
101
|
-
"pdf": "application/pdf",
|
|
102
|
-
"jpg": "image/jpeg",
|
|
103
|
-
"jpeg": "image/jpeg",
|
|
104
|
-
"png": "image/png",
|
|
105
|
-
"gif": "image/gif",
|
|
106
|
-
"csv": "text/csv",
|
|
107
|
-
"json": "application/json",
|
|
108
|
-
"xml": "application/xml",
|
|
109
|
-
"sh": "text/x-shellscript",
|
|
110
|
-
"bash": "text/x-shellscript",
|
|
111
|
-
"py": "text/x-python",
|
|
112
|
-
"js": "text/javascript",
|
|
113
|
-
"cjs": "text/javascript",
|
|
114
|
-
"mjs": "text/javascript",
|
|
115
|
-
"ts": "text/javascript",
|
|
116
|
-
"cts": "text/javascript",
|
|
117
|
-
"mts": "text/javascript"
|
|
118
|
-
};
|
|
119
100
|
function guessMimeType(filePath) {
|
|
120
|
-
|
|
121
|
-
const ext = ((_a = filePath.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
122
|
-
return EXTENSION_TO_MIME_TYPE[ext] || "application/octet-stream";
|
|
101
|
+
return (0, import_file_extension_utils.getMimeTypeAndEncoding)(path.extname(filePath)).mimeType;
|
|
123
102
|
}
|
|
124
103
|
__name(guessMimeType, "guessMimeType");
|
|
125
104
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
105
|
0 && (module.exports = {
|
|
127
|
-
EXTENSION_TO_MIME_TYPE,
|
|
128
106
|
guessMimeType,
|
|
129
107
|
materializeFiles
|
|
130
108
|
});
|
|
@@ -72,6 +72,9 @@ function toGeminiSchema(mcpSchema) {
|
|
|
72
72
|
}
|
|
73
73
|
function recursiveConvert(mcp) {
|
|
74
74
|
var _a;
|
|
75
|
+
if (typeof mcp === "boolean") {
|
|
76
|
+
mcp = { type: "object" };
|
|
77
|
+
}
|
|
75
78
|
const sourceType = (_a = mcp.anyOf) != null ? _a : mcp.type;
|
|
76
79
|
let isNullable = false;
|
|
77
80
|
let nonNullTypes;
|
|
@@ -162,7 +165,7 @@ function toGeminiSchema(mcpSchema) {
|
|
|
162
165
|
geminiSchema.required = mcp.required;
|
|
163
166
|
}
|
|
164
167
|
} else if (geminiType === import_genai.Type.ARRAY) {
|
|
165
|
-
if (mcp.items) {
|
|
168
|
+
if (mcp.items || mcp.items === false) {
|
|
166
169
|
geminiSchema.items = recursiveConvert(mcp.items);
|
|
167
170
|
}
|
|
168
171
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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 json_utils_exports = {};
|
|
27
|
+
__export(json_utils_exports, {
|
|
28
|
+
isJsonObject: () => isJsonObject,
|
|
29
|
+
toJsonObject: () => toJsonObject
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(json_utils_exports);
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2026 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
function isJsonObject(value) {
|
|
38
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
__name(isJsonObject, "isJsonObject");
|
|
41
|
+
function toJsonObject(value) {
|
|
42
|
+
return isJsonObject(value) ? value : {};
|
|
43
|
+
}
|
|
44
|
+
__name(toJsonObject, "toJsonObject");
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
isJsonObject,
|
|
48
|
+
toJsonObject
|
|
49
|
+
});
|
|
@@ -204,12 +204,11 @@ const _LiveResponseAggregator = class _LiveResponseAggregator {
|
|
|
204
204
|
yield this.buildFullTextResponse(this.text, this.isThought);
|
|
205
205
|
this.text = "";
|
|
206
206
|
this.isThought = false;
|
|
207
|
-
} else {
|
|
208
|
-
yield {
|
|
209
|
-
interrupted: serverContent.interrupted,
|
|
210
|
-
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
211
|
-
};
|
|
212
207
|
}
|
|
208
|
+
yield {
|
|
209
|
+
interrupted: serverContent.interrupted,
|
|
210
|
+
...this.modelVersion ? { modelVersion: this.modelVersion } : {}
|
|
211
|
+
};
|
|
213
212
|
}
|
|
214
213
|
}
|
|
215
214
|
if (message.toolCall) {
|
|
@@ -46,6 +46,12 @@ var import_logger = require("./logger.js");
|
|
|
46
46
|
* Copyright 2026 Google LLC
|
|
47
47
|
* SPDX-License-Identifier: Apache-2.0
|
|
48
48
|
*/
|
|
49
|
+
const WINSTON_LEVEL_NAMES = {
|
|
50
|
+
[import_logger.LogLevel.DEBUG]: "debug",
|
|
51
|
+
[import_logger.LogLevel.INFO]: "info",
|
|
52
|
+
[import_logger.LogLevel.WARN]: "warn",
|
|
53
|
+
[import_logger.LogLevel.ERROR]: "error"
|
|
54
|
+
};
|
|
49
55
|
const _WinstonLogger = class _WinstonLogger {
|
|
50
56
|
constructor() {
|
|
51
57
|
this.logLevel = import_logger.LogLevel.INFO;
|
|
@@ -79,7 +85,7 @@ const _WinstonLogger = class _WinstonLogger {
|
|
|
79
85
|
if (this.logLevel > level) {
|
|
80
86
|
return;
|
|
81
87
|
}
|
|
82
|
-
this.logger.log(level
|
|
88
|
+
this.logger.log(WINSTON_LEVEL_NAMES[level], messages.join(" "));
|
|
83
89
|
}
|
|
84
90
|
debug(...messages) {
|
|
85
91
|
if (this.logLevel > import_logger.LogLevel.DEBUG) {
|
|
@@ -26,7 +26,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
26
26
|
var object_notation_utils_exports = {};
|
|
27
27
|
__export(object_notation_utils_exports, {
|
|
28
28
|
toCamelCase: () => toCamelCase,
|
|
29
|
-
toSnakeCase: () => toSnakeCase
|
|
29
|
+
toSnakeCase: () => toSnakeCase,
|
|
30
|
+
toSnakeCaseKey: () => toSnakeCaseKey
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(object_notation_utils_exports);
|
|
32
33
|
/**
|
|
@@ -46,7 +47,8 @@ const toCamelCaseKey = /* @__PURE__ */ __name((key) => key.replace(
|
|
|
46
47
|
/_([a-z])/g,
|
|
47
48
|
(_match, letter) => letter.toUpperCase()
|
|
48
49
|
), "toCamelCaseKey");
|
|
49
|
-
const
|
|
50
|
+
const CAMEL_BOUNDARY = /(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g;
|
|
51
|
+
const toSnakeCaseKey = /* @__PURE__ */ __name((key) => key.replace(CAMEL_BOUNDARY, "_").toLowerCase().replace(/-/g, "_"), "toSnakeCaseKey");
|
|
50
52
|
function toNotation(obj, converter, parentKey = "", preserveKeys = []) {
|
|
51
53
|
if (Array.isArray(obj)) {
|
|
52
54
|
return obj.map(
|
|
@@ -78,5 +80,6 @@ __name(toNotation, "toNotation");
|
|
|
78
80
|
// Annotate the CommonJS export names for ESM import in node:
|
|
79
81
|
0 && (module.exports = {
|
|
80
82
|
toCamelCase,
|
|
81
|
-
toSnakeCase
|
|
83
|
+
toSnakeCase,
|
|
84
|
+
toSnakeCaseKey
|
|
82
85
|
});
|
|
@@ -25,7 +25,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
26
|
var streaming_utils_exports = {};
|
|
27
27
|
__export(streaming_utils_exports, {
|
|
28
|
-
|
|
28
|
+
GeminiStreamingResponseAggregator: () => GeminiStreamingResponseAggregator,
|
|
29
29
|
isEmptyContentPart: () => isEmptyContentPart
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(streaming_utils_exports);
|
|
@@ -231,7 +231,7 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
|
|
|
231
231
|
this.thoughtText = "";
|
|
232
232
|
}
|
|
233
233
|
async *processResponse(llmResponse) {
|
|
234
|
-
var _a;
|
|
234
|
+
var _a, _b;
|
|
235
235
|
if ((_a = llmResponse.content) == null ? void 0 : _a.parts) {
|
|
236
236
|
const nonTextParts = [];
|
|
237
237
|
let sawTextPart = false;
|
|
@@ -251,7 +251,8 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
|
|
|
251
251
|
nonTextParts.push(part);
|
|
252
252
|
}
|
|
253
253
|
if (nonTextParts.length > 0) {
|
|
254
|
-
|
|
254
|
+
const startsWithInlineData = !!((_b = llmResponse.content.parts[0]) == null ? void 0 : _b.inlineData);
|
|
255
|
+
if (!startsWithInlineData && (this.thoughtText || this.text)) {
|
|
255
256
|
const parts = [];
|
|
256
257
|
if (this.thoughtText) {
|
|
257
258
|
parts.push({ text: this.thoughtText, thought: true });
|
|
@@ -302,13 +303,12 @@ const _NonProgressiveStrategy = class _NonProgressiveStrategy {
|
|
|
302
303
|
};
|
|
303
304
|
__name(_NonProgressiveStrategy, "NonProgressiveStrategy");
|
|
304
305
|
let NonProgressiveStrategy = _NonProgressiveStrategy;
|
|
305
|
-
const
|
|
306
|
-
constructor(
|
|
307
|
-
import_feature_registry.FeatureName.PROGRESSIVE_SSE_STREAMING
|
|
308
|
-
)
|
|
309
|
-
this.isProgressiveMode = isProgressiveMode;
|
|
306
|
+
const _GeminiStreamingResponseAggregator = class _GeminiStreamingResponseAggregator {
|
|
307
|
+
constructor({
|
|
308
|
+
isProgressiveMode = (0, import_feature_registry.isFeatureEnabled)(import_feature_registry.FeatureName.PROGRESSIVE_SSE_STREAMING)
|
|
309
|
+
} = {}) {
|
|
310
310
|
this.lastThoughtSignature = {};
|
|
311
|
-
this.strategy =
|
|
311
|
+
this.strategy = isProgressiveMode ? new ProgressiveStrategy() : new NonProgressiveStrategy();
|
|
312
312
|
}
|
|
313
313
|
async *processResponse(response) {
|
|
314
314
|
var _a, _b;
|
|
@@ -381,14 +381,14 @@ const _StreamingResponseAggregator = class _StreamingResponseAggregator {
|
|
|
381
381
|
};
|
|
382
382
|
}
|
|
383
383
|
};
|
|
384
|
-
__name(
|
|
385
|
-
let
|
|
384
|
+
__name(_GeminiStreamingResponseAggregator, "GeminiStreamingResponseAggregator");
|
|
385
|
+
let GeminiStreamingResponseAggregator = _GeminiStreamingResponseAggregator;
|
|
386
386
|
function isEmptyContentPart(part) {
|
|
387
387
|
return !part.functionCall && !part.functionResponse && !part.fileData && !part.inlineData && !part.executableCode && !part.codeExecutionResult && (!part.text || part.text === "");
|
|
388
388
|
}
|
|
389
389
|
__name(isEmptyContentPart, "isEmptyContentPart");
|
|
390
390
|
// Annotate the CommonJS export names for ESM import in node:
|
|
391
391
|
0 && (module.exports = {
|
|
392
|
-
|
|
392
|
+
GeminiStreamingResponseAggregator,
|
|
393
393
|
isEmptyContentPart
|
|
394
394
|
});
|
package/dist/cjs/version.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(version_exports);
|
|
|
32
32
|
* Copyright 2025 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
34
|
*/
|
|
35
|
-
const version = "2.
|
|
35
|
+
const version = "2.3.0";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|
|
@@ -43,7 +43,10 @@ const _RemoteA2AAgent = class _RemoteA2AAgent extends BaseAgent {
|
|
|
43
43
|
this.client = this.a2aConfig.client;
|
|
44
44
|
}
|
|
45
45
|
if (this.a2aConfig.agentCard) {
|
|
46
|
-
this.card = await resolveAgentCard(
|
|
46
|
+
this.card = await resolveAgentCard(
|
|
47
|
+
this.a2aConfig.agentCard,
|
|
48
|
+
this.a2aConfig.resolveAgentCardOptions
|
|
49
|
+
);
|
|
47
50
|
if (!this.client) {
|
|
48
51
|
const factory = this.a2aConfig.clientFactory || new ClientFactory();
|
|
49
52
|
this.client = await factory.createFromAgentCard(this.card);
|
|
@@ -22,25 +22,27 @@ import { isBaseTool } from "../tools/base_tool.js";
|
|
|
22
22
|
import { isBaseToolset } from "../tools/base_toolset.js";
|
|
23
23
|
import { logger } from "../utils/logger.js";
|
|
24
24
|
import {
|
|
25
|
-
isHttpUrl,
|
|
26
25
|
isLinkLocalAddress,
|
|
26
|
+
isLocalhostHostname,
|
|
27
27
|
normalizeHost,
|
|
28
28
|
resolveHostAddresses
|
|
29
29
|
} from "../utils/ssrf_guard.js";
|
|
30
30
|
import { isWorkflow } from "../workflow/workflow.js";
|
|
31
|
-
|
|
32
|
-
async function resolveAgentCard(agentCard) {
|
|
31
|
+
async function resolveAgentCard(agentCard, options = {}) {
|
|
33
32
|
if (typeof agentCard === "object") {
|
|
34
33
|
return agentCard;
|
|
35
34
|
}
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
await
|
|
35
|
+
const source = agentCard;
|
|
36
|
+
if (source.startsWith("http://") || source.startsWith("https://")) {
|
|
37
|
+
await refuseLinkLocalHost(source);
|
|
39
38
|
const resolver = new DefaultAgentCardResolver({
|
|
40
|
-
fetchImpl:
|
|
39
|
+
fetchImpl: refuseRedirectFetch
|
|
41
40
|
});
|
|
42
|
-
|
|
41
|
+
const card = await resolver.resolve(source);
|
|
42
|
+
validateCardRpcTargets(card, source, options);
|
|
43
|
+
return card;
|
|
43
44
|
}
|
|
45
|
+
const url = parseCardUrl(source);
|
|
44
46
|
if (url && url.protocol !== "file:") {
|
|
45
47
|
throw new Error(
|
|
46
48
|
`Unsupported agent card URL scheme "${url.protocol}": ${agentCard}. Use http://, https:// or file://, or pass a filesystem path with no scheme.`
|
|
@@ -49,6 +51,31 @@ async function resolveAgentCard(agentCard) {
|
|
|
49
51
|
return readAgentCardFile(agentCard, url);
|
|
50
52
|
}
|
|
51
53
|
__name(resolveAgentCard, "resolveAgentCard");
|
|
54
|
+
const WINDOWS_DRIVE_PROTOCOL = /^[a-z]:$/i;
|
|
55
|
+
async function refuseLinkLocalHost(source) {
|
|
56
|
+
const hostname = normalizeHost(new URL(source).hostname);
|
|
57
|
+
if (isLocalhostHostname(hostname)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const addresses = await resolveHostAddresses(hostname);
|
|
61
|
+
if (addresses.some((address) => isLinkLocalAddress(address))) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Refusing to fetch agent card from a link-local address: ${hostname}`
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
__name(refuseLinkLocalHost, "refuseLinkLocalHost");
|
|
68
|
+
async function refuseRedirectFetch(url, init) {
|
|
69
|
+
const response = await fetch(url, { ...init, redirect: "manual" });
|
|
70
|
+
if (response.status === 0 || response.status >= 300 && response.status < 400) {
|
|
71
|
+
const location = response.headers.get("location");
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Refusing to follow a redirect from the agent card endpoint (status ${response.status}, location ${location}): ${url}`
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
return response;
|
|
77
|
+
}
|
|
78
|
+
__name(refuseRedirectFetch, "refuseRedirectFetch");
|
|
52
79
|
function parseCardUrl(source) {
|
|
53
80
|
let url;
|
|
54
81
|
try {
|
|
@@ -71,32 +98,81 @@ async function readAgentCardFile(source, url) {
|
|
|
71
98
|
}
|
|
72
99
|
}
|
|
73
100
|
__name(readAgentCardFile, "readAgentCardFile");
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
101
|
+
function validateCardRpcTargets(card, source, options) {
|
|
102
|
+
var _a;
|
|
103
|
+
let parsedSource;
|
|
104
|
+
try {
|
|
105
|
+
parsedSource = new URL(source);
|
|
106
|
+
} catch (err) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`Invalid agent card source URL: ${source}: ${err.message}`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
const rpcUrls = [
|
|
112
|
+
card.url,
|
|
113
|
+
...((_a = card.additionalInterfaces) != null ? _a : []).map((i) => i.url)
|
|
114
|
+
];
|
|
115
|
+
for (const rpcUrl of rpcUrls) {
|
|
116
|
+
let parsed;
|
|
117
|
+
try {
|
|
118
|
+
parsed = new URL(rpcUrl);
|
|
119
|
+
} catch (err) {
|
|
78
120
|
throw new Error(
|
|
79
|
-
`
|
|
121
|
+
`Invalid RPC URL in agent card: ${rpcUrl}: ${err.message}`
|
|
80
122
|
);
|
|
81
123
|
}
|
|
82
|
-
|
|
83
|
-
|
|
124
|
+
if (parsed.protocol !== "https:" && !isLoopbackHost(parsed.hostname)) {
|
|
125
|
+
if (options.allowInsecureRpc === true) {
|
|
126
|
+
logger.warn(
|
|
127
|
+
`SECURITY WARNING: accepting a plaintext http RPC URL on a non-loopback host because \`allowInsecureRpc: true\` was set: ${rpcUrl}. This connection can be intercepted or altered by anything on the network path.`
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
throw new Error(
|
|
131
|
+
`Agent card RPC URL must use https, or http on a loopback host: ${rpcUrl}`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (!sameOriginForRpc(parsedSource, parsed)) {
|
|
136
|
+
if (options.allowCrossOriginRpc === true) {
|
|
137
|
+
logger.warn(
|
|
138
|
+
`SECURITY WARNING: accepting an agent card RPC URL whose origin differs from the location the card was fetched from because \`allowCrossOriginRpc: true\` was set (fetched from ${source}): ${rpcUrl}.`
|
|
139
|
+
);
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Agent card RPC URL must have the same origin as the location the card was fetched from (${source}): ${rpcUrl}`
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
84
147
|
}
|
|
85
|
-
__name(
|
|
86
|
-
function
|
|
87
|
-
|
|
148
|
+
__name(validateCardRpcTargets, "validateCardRpcTargets");
|
|
149
|
+
function sameOriginForRpc(source, rpc) {
|
|
150
|
+
const sourceIsLoopback = isLoopbackHost(source.hostname);
|
|
151
|
+
const rpcIsLoopback = isLoopbackHost(rpc.hostname);
|
|
152
|
+
if (sourceIsLoopback && rpcIsLoopback) {
|
|
153
|
+
return source.protocol === rpc.protocol && effectivePort(source) === effectivePort(rpc);
|
|
154
|
+
}
|
|
155
|
+
return source.origin === rpc.origin;
|
|
88
156
|
}
|
|
89
|
-
__name(
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
157
|
+
__name(sameOriginForRpc, "sameOriginForRpc");
|
|
158
|
+
function effectivePort(url) {
|
|
159
|
+
if (url.port) {
|
|
160
|
+
return url.port;
|
|
161
|
+
}
|
|
162
|
+
if (url.protocol === "https:") {
|
|
163
|
+
return "443";
|
|
97
164
|
}
|
|
165
|
+
if (url.protocol === "http:") {
|
|
166
|
+
return "80";
|
|
167
|
+
}
|
|
168
|
+
return url.port;
|
|
169
|
+
}
|
|
170
|
+
__name(effectivePort, "effectivePort");
|
|
171
|
+
function isLoopbackHost(hostname) {
|
|
172
|
+
const bare = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
173
|
+
return bare === "localhost" || bare === "127.0.0.1" || bare === "::1" || bare === "0.0.0.0" || bare === "::" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(bare);
|
|
98
174
|
}
|
|
99
|
-
__name(
|
|
175
|
+
__name(isLoopbackHost, "isLoopbackHost");
|
|
100
176
|
async function getA2AAgentCard(agent, transports) {
|
|
101
177
|
return {
|
|
102
178
|
name: agent.name,
|
|
@@ -34,7 +34,10 @@ import { StreamingMode } from "../agents/run_config.js";
|
|
|
34
34
|
import { InMemorySessionService } from "../sessions/in_memory_session_service.js";
|
|
35
35
|
import { logger } from "../utils/logger.js";
|
|
36
36
|
import { loadOptionalPeer } from "../utils/optional_peer.js";
|
|
37
|
-
import {
|
|
37
|
+
import {
|
|
38
|
+
getA2AAgentCard,
|
|
39
|
+
resolveAgentCard
|
|
40
|
+
} from "./agent_card.js";
|
|
38
41
|
import { A2AAgentExecutor } from "./agent_executor.js";
|
|
39
42
|
import {
|
|
40
43
|
AdkDefaultRequestHandler,
|
|
@@ -73,7 +76,7 @@ async function toA2a(agent, options = {}) {
|
|
|
73
76
|
const protocol = (_c = options.protocol) != null ? _c : "http";
|
|
74
77
|
const basePath = options.basePath || "";
|
|
75
78
|
const rpcUrl = `${protocol}://${host}:${port}${basePath}`;
|
|
76
|
-
const agentCard = options.agentCard ? await resolveAgentCard(options.agentCard) : await getA2AAgentCard(agent, [
|
|
79
|
+
const agentCard = options.agentCard ? await resolveAgentCard(options.agentCard, options.resolveAgentCardOptions) : await getA2AAgentCard(agent, [
|
|
77
80
|
{
|
|
78
81
|
url: `${rpcUrl}/jsonrpc`,
|
|
79
82
|
transport: "JSONRPC"
|