@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
|
@@ -0,0 +1,187 @@
|
|
|
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 __decorateClass = (decorators, target, key, kind) => {
|
|
27
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
28
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
29
|
+
if (decorator = decorators[i])
|
|
30
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
31
|
+
if (kind && result) __defProp(target, key, result);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
var remote_agent_exports = {};
|
|
35
|
+
__export(remote_agent_exports, {
|
|
36
|
+
RemoteAgent: () => RemoteAgent,
|
|
37
|
+
isRemoteAgent: () => isRemoteAgent
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(remote_agent_exports);
|
|
40
|
+
var import_event = require("../events/event.js");
|
|
41
|
+
var import_experimental = require("../utils/experimental.js");
|
|
42
|
+
var import_base_agent = require("./base_agent.js");
|
|
43
|
+
/**
|
|
44
|
+
* @license
|
|
45
|
+
* Copyright 2026 Google LLC
|
|
46
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
47
|
+
*/
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const DEFAULT_REMOTE_AGENT_TIMEOUT_MS = 12e4;
|
|
50
|
+
const MILLIS_PER_SECOND = 1e3;
|
|
51
|
+
const SESSION_PRESERVE_KEYS = /* @__PURE__ */ new Set(["state", "events"]);
|
|
52
|
+
const EVENT_PRESERVE_KEYS = /* @__PURE__ */ new Set([
|
|
53
|
+
"actions.state_delta",
|
|
54
|
+
"actions.artifact_delta",
|
|
55
|
+
"actions.requested_auth_configs",
|
|
56
|
+
"actions.requested_tool_confirmations",
|
|
57
|
+
"actions.custom_metadata",
|
|
58
|
+
"custom_metadata",
|
|
59
|
+
"content.parts.function_call.args",
|
|
60
|
+
"content.parts.function_response.response",
|
|
61
|
+
"output",
|
|
62
|
+
"route",
|
|
63
|
+
"actions.agent_state"
|
|
64
|
+
]);
|
|
65
|
+
const REMOTE_AGENT_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.remoteAgent");
|
|
66
|
+
function isRemoteAgent(obj) {
|
|
67
|
+
return typeof obj === "object" && obj !== null && REMOTE_AGENT_SIGNATURE_SYMBOL in obj && obj[REMOTE_AGENT_SIGNATURE_SYMBOL] === true;
|
|
68
|
+
}
|
|
69
|
+
__name(isRemoteAgent, "isRemoteAgent");
|
|
70
|
+
function isRecord(value) {
|
|
71
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
72
|
+
}
|
|
73
|
+
__name(isRecord, "isRecord");
|
|
74
|
+
function stripNullish(value, preserveKeys, parentKey = "") {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return value.map((item) => stripNullish(item, preserveKeys, parentKey));
|
|
77
|
+
}
|
|
78
|
+
if (value !== null && typeof value === "object") {
|
|
79
|
+
return stripNullishRecord(value, preserveKeys, parentKey);
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
__name(stripNullish, "stripNullish");
|
|
84
|
+
function stripNullishRecord(record, preserveKeys, parentKey = "") {
|
|
85
|
+
const result = {};
|
|
86
|
+
for (const [key, entryValue] of Object.entries(record)) {
|
|
87
|
+
if (entryValue === void 0 || entryValue === null) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const fullPath = parentKey !== "" ? `${parentKey}.${key}` : key;
|
|
91
|
+
result[key] = preserveKeys.has(fullPath) ? entryValue : stripNullish(entryValue, preserveKeys, fullPath);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
__name(stripNullishRecord, "stripNullishRecord");
|
|
96
|
+
function serializeEventToSnakeCase(event) {
|
|
97
|
+
const snakeEvent = (0, import_event.transformToSnakeCaseEvent)(event);
|
|
98
|
+
snakeEvent["timestamp"] = event.timestamp / MILLIS_PER_SECOND;
|
|
99
|
+
return stripNullishRecord(snakeEvent, EVENT_PRESERVE_KEYS);
|
|
100
|
+
}
|
|
101
|
+
__name(serializeEventToSnakeCase, "serializeEventToSnakeCase");
|
|
102
|
+
function serializeSessionToSnakeCase(session) {
|
|
103
|
+
return stripNullishRecord(
|
|
104
|
+
{
|
|
105
|
+
id: session.id,
|
|
106
|
+
app_name: session.appName,
|
|
107
|
+
user_id: session.userId,
|
|
108
|
+
state: session.state,
|
|
109
|
+
events: session.events.map((event) => serializeEventToSnakeCase(event)),
|
|
110
|
+
last_update_time: session.lastUpdateTime / MILLIS_PER_SECOND
|
|
111
|
+
},
|
|
112
|
+
SESSION_PRESERVE_KEYS
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
__name(serializeSessionToSnakeCase, "serializeSessionToSnakeCase");
|
|
116
|
+
let RemoteAgent = class extends (_b = import_base_agent.BaseAgent, _a = REMOTE_AGENT_SIGNATURE_SYMBOL, _b) {
|
|
117
|
+
constructor(config) {
|
|
118
|
+
var _a2, _b2;
|
|
119
|
+
const runtimeSubAgents = config.subAgents;
|
|
120
|
+
if (Array.isArray(runtimeSubAgents) ? runtimeSubAgents.length > 0 : Boolean(runtimeSubAgents)) {
|
|
121
|
+
throw new Error("subAgents is disabled in RemoteAgent.");
|
|
122
|
+
}
|
|
123
|
+
super({ ...config, subAgents: [] });
|
|
124
|
+
this[_a] = true;
|
|
125
|
+
this.url = config.url;
|
|
126
|
+
this.timeoutMs = (_a2 = config.timeoutMs) != null ? _a2 : DEFAULT_REMOTE_AGENT_TIMEOUT_MS;
|
|
127
|
+
this.fetchImpl = (_b2 = config.fetchImpl) != null ? _b2 : globalThis.fetch;
|
|
128
|
+
}
|
|
129
|
+
async *runAsyncImpl(ctx) {
|
|
130
|
+
var _a2;
|
|
131
|
+
const data = {
|
|
132
|
+
invocation_id: ctx.invocationId,
|
|
133
|
+
session: serializeSessionToSnakeCase(ctx.session)
|
|
134
|
+
};
|
|
135
|
+
const timeoutSignal = AbortSignal.timeout(this.timeoutMs);
|
|
136
|
+
const signal = ctx.abortSignal ? AbortSignal.any([ctx.abortSignal, timeoutSignal]) : timeoutSignal;
|
|
137
|
+
const response = await this.fetchImpl(this.url, {
|
|
138
|
+
method: "POST",
|
|
139
|
+
headers: { "Content-Type": "application/json" },
|
|
140
|
+
body: JSON.stringify(data),
|
|
141
|
+
signal
|
|
142
|
+
});
|
|
143
|
+
if (response.status >= 400) {
|
|
144
|
+
throw new Error(
|
|
145
|
+
`RemoteAgent request to '${this.url}' failed with HTTP status ${response.status}.`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
const rawEvents = await response.json();
|
|
149
|
+
if (!Array.isArray(rawEvents)) {
|
|
150
|
+
throw new Error(
|
|
151
|
+
`RemoteAgent expected a JSON array of events from '${this.url}'.`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
for (const rawEvent of rawEvents) {
|
|
155
|
+
if (!isRecord(rawEvent)) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
`RemoteAgent expected each item in the response from '${this.url}' to be a JSON event object.`
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
if ((_a2 = ctx.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const camelEvent = (0, import_event.transformToCamelCaseEvent)(rawEvent);
|
|
164
|
+
const invocationId = camelEvent.invocationId !== void 0 && camelEvent.invocationId !== "" ? camelEvent.invocationId : ctx.invocationId;
|
|
165
|
+
const timestamp = typeof camelEvent.timestamp === "number" ? camelEvent.timestamp * MILLIS_PER_SECOND : void 0;
|
|
166
|
+
yield (0, import_event.createEvent)({
|
|
167
|
+
...camelEvent,
|
|
168
|
+
invocationId,
|
|
169
|
+
timestamp,
|
|
170
|
+
author: this.name
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async *runLiveImpl(_ctx) {
|
|
175
|
+
yield* [];
|
|
176
|
+
throw new Error("This is not supported yet for RemoteAgent.");
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
__name(RemoteAgent, "RemoteAgent");
|
|
180
|
+
RemoteAgent = __decorateClass([
|
|
181
|
+
import_experimental.experimental
|
|
182
|
+
], RemoteAgent);
|
|
183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
184
|
+
0 && (module.exports = {
|
|
185
|
+
RemoteAgent,
|
|
186
|
+
isRemoteAgent
|
|
187
|
+
});
|
|
@@ -63,6 +63,13 @@ const _InMemoryArtifactService = class _InMemoryArtifactService {
|
|
|
63
63
|
const version = this.artifacts[path].length;
|
|
64
64
|
const metadata = {
|
|
65
65
|
version,
|
|
66
|
+
canonicalUri: getCanonicalUri(
|
|
67
|
+
appName,
|
|
68
|
+
userId,
|
|
69
|
+
sessionId,
|
|
70
|
+
filename,
|
|
71
|
+
version
|
|
72
|
+
),
|
|
66
73
|
customMetadata
|
|
67
74
|
};
|
|
68
75
|
if (!artifact.inlineData && artifact.text === void 0) {
|
|
@@ -189,6 +196,13 @@ function artifactPrefix(scope, ...parts) {
|
|
|
189
196
|
return `${[scope, ...parts].map(encodeURIComponent).join("/")}/`;
|
|
190
197
|
}
|
|
191
198
|
__name(artifactPrefix, "artifactPrefix");
|
|
199
|
+
function getCanonicalUri(appName, userId, sessionId, filename, version) {
|
|
200
|
+
if (fileHasUserNamespace(filename)) {
|
|
201
|
+
return `memory://apps/${appName}/users/${userId}/artifacts/${filename}/versions/${version}`;
|
|
202
|
+
}
|
|
203
|
+
return `memory://apps/${appName}/users/${userId}/sessions/${sessionId}/artifacts/${filename}/versions/${version}`;
|
|
204
|
+
}
|
|
205
|
+
__name(getCanonicalUri, "getCanonicalUri");
|
|
192
206
|
function fileHasUserNamespace(filename) {
|
|
193
207
|
return filename.startsWith("user:");
|
|
194
208
|
}
|
|
@@ -28,6 +28,7 @@ __export(auth_handler_exports, {
|
|
|
28
28
|
AuthHandler: () => AuthHandler
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(auth_handler_exports);
|
|
31
|
+
var import_lodash_es = require("lodash-es");
|
|
31
32
|
var import_env_aware_utils = require("../utils/env_aware_utils.js");
|
|
32
33
|
var import_oauth2_credential_exchanger = require("./oauth2/oauth2_credential_exchanger.js");
|
|
33
34
|
var import_oauth2_utils = require("./oauth2/oauth2_utils.js");
|
|
@@ -38,6 +39,11 @@ var import_oauth2_utils = require("./oauth2/oauth2_utils.js");
|
|
|
38
39
|
*/
|
|
39
40
|
const S256_CODE_CHALLENGE_METHOD = "S256";
|
|
40
41
|
const _AuthHandler = class _AuthHandler {
|
|
42
|
+
/**
|
|
43
|
+
* @param authConfig The auth config this handler reads. It stays readable
|
|
44
|
+
* and replaceable after construction; each method reads the current
|
|
45
|
+
* value.
|
|
46
|
+
*/
|
|
41
47
|
constructor(authConfig) {
|
|
42
48
|
this.authConfig = authConfig;
|
|
43
49
|
}
|
|
@@ -70,14 +76,32 @@ const _AuthHandler = class _AuthHandler {
|
|
|
70
76
|
state.set(credentialKey, exchangedCredential.credential);
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Builds the auth request to send to the client.
|
|
81
|
+
*
|
|
82
|
+
* The result is always a new object, and its `exchangedAuthCredential` is
|
|
83
|
+
* never an object held by {@link authConfig}. A caller that fills in the
|
|
84
|
+
* response, for example `exchangedAuthCredential.oauth2.authResponseUri`,
|
|
85
|
+
* therefore leaves the handler's credentials unchanged.
|
|
86
|
+
*
|
|
87
|
+
* When the config is returned as is, because the scheme is not OAuth2 or
|
|
88
|
+
* OpenID Connect or the exchanged credential already has an auth URI, the
|
|
89
|
+
* result is a deep copy of the whole config. In the other branches only the
|
|
90
|
+
* exchanged credential is guaranteed independent: `authScheme` and
|
|
91
|
+
* `rawAuthCredential` are the handler's own objects.
|
|
92
|
+
*
|
|
93
|
+
* @return The auth config to request from the client.
|
|
94
|
+
* @throws Error: If an OAuth2 or OpenID Connect scheme has no raw
|
|
95
|
+
* credential, no `oauth2` on it, or no client ID and secret.
|
|
96
|
+
*/
|
|
73
97
|
generateAuthRequest() {
|
|
74
98
|
var _a, _b;
|
|
75
99
|
const authSchemeType = this.authConfig.authScheme.type;
|
|
76
100
|
if (!["oauth2", "openIdConnect"].includes(authSchemeType)) {
|
|
77
|
-
return this.authConfig;
|
|
101
|
+
return (0, import_lodash_es.cloneDeep)(this.authConfig);
|
|
78
102
|
}
|
|
79
103
|
if ((_b = (_a = this.authConfig.exchangedAuthCredential) == null ? void 0 : _a.oauth2) == null ? void 0 : _b.authUri) {
|
|
80
|
-
return this.authConfig;
|
|
104
|
+
return (0, import_lodash_es.cloneDeep)(this.authConfig);
|
|
81
105
|
}
|
|
82
106
|
if (!this.authConfig.rawAuthCredential) {
|
|
83
107
|
throw new Error(`Auth Scheme ${authSchemeType} requires authCredential.`);
|
|
@@ -92,7 +116,7 @@ const _AuthHandler = class _AuthHandler {
|
|
|
92
116
|
credentialKey: this.authConfig.credentialKey,
|
|
93
117
|
authScheme: this.authConfig.authScheme,
|
|
94
118
|
rawAuthCredential: this.authConfig.rawAuthCredential,
|
|
95
|
-
exchangedAuthCredential: this.authConfig.rawAuthCredential
|
|
119
|
+
exchangedAuthCredential: (0, import_lodash_es.cloneDeep)(this.authConfig.rawAuthCredential)
|
|
96
120
|
};
|
|
97
121
|
}
|
|
98
122
|
if (!this.authConfig.rawAuthCredential.oauth2.clientId || !this.authConfig.rawAuthCredential.oauth2.clientSecret) {
|
|
@@ -114,6 +138,10 @@ const _AuthHandler = class _AuthHandler {
|
|
|
114
138
|
* challenge derived from the credential's code verifier, and the returned
|
|
115
139
|
* credential carries the verifier the later token exchange must send.
|
|
116
140
|
*
|
|
141
|
+
* The URI leaves out `redirect_uri` when the credential has no
|
|
142
|
+
* `redirectUri`, so the provider uses the redirect registered for the
|
|
143
|
+
* client, and leaves out `scope` when the scheme lists no scopes.
|
|
144
|
+
*
|
|
117
145
|
* @return An AuthCredential object containing the auth URI and state.
|
|
118
146
|
* @throws Error: If the authorization endpoint is not configured in the
|
|
119
147
|
* auth scheme, or the credential requests a code challenge method other
|
|
@@ -157,9 +185,13 @@ const _AuthHandler = class _AuthHandler {
|
|
|
157
185
|
const state = (0, import_env_aware_utils.randomUUID)();
|
|
158
186
|
const url = new URL(authorizationEndpoint);
|
|
159
187
|
url.searchParams.set("client_id", oauth2.clientId || "");
|
|
160
|
-
|
|
188
|
+
if (oauth2.redirectUri) {
|
|
189
|
+
url.searchParams.set("redirect_uri", oauth2.redirectUri);
|
|
190
|
+
}
|
|
161
191
|
url.searchParams.set("response_type", "code");
|
|
162
|
-
|
|
192
|
+
if (scopes.length > 0) {
|
|
193
|
+
url.searchParams.set("scope", scopes.join(" "));
|
|
194
|
+
}
|
|
163
195
|
url.searchParams.set("state", state);
|
|
164
196
|
url.searchParams.set("access_type", "offline");
|
|
165
197
|
url.searchParams.set("prompt", "consent");
|
|
@@ -25,6 +25,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
26
|
var auth_schemes_exports = {};
|
|
27
27
|
__export(auth_schemes_exports, {
|
|
28
|
+
AuthSchemeType: () => AuthSchemeType,
|
|
28
29
|
OAuthGrantType: () => OAuthGrantType,
|
|
29
30
|
getOAuthGrantTypeFromFlow: () => getOAuthGrantTypeFromFlow
|
|
30
31
|
});
|
|
@@ -34,6 +35,13 @@ module.exports = __toCommonJS(auth_schemes_exports);
|
|
|
34
35
|
* Copyright 2025 Google LLC
|
|
35
36
|
* SPDX-License-Identifier: Apache-2.0
|
|
36
37
|
*/
|
|
38
|
+
var AuthSchemeType = /* @__PURE__ */ ((AuthSchemeType2) => {
|
|
39
|
+
AuthSchemeType2["API_KEY"] = "apiKey";
|
|
40
|
+
AuthSchemeType2["HTTP"] = "http";
|
|
41
|
+
AuthSchemeType2["OAUTH2"] = "oauth2";
|
|
42
|
+
AuthSchemeType2["OPEN_ID_CONNECT"] = "openIdConnect";
|
|
43
|
+
return AuthSchemeType2;
|
|
44
|
+
})(AuthSchemeType || {});
|
|
37
45
|
var OAuthGrantType = /* @__PURE__ */ ((OAuthGrantType2) => {
|
|
38
46
|
OAuthGrantType2["CLIENT_CREDENTIALS"] = "client_credentials";
|
|
39
47
|
OAuthGrantType2["AUTHORIZATION_CODE"] = "authorization_code";
|
|
@@ -59,6 +67,7 @@ function getOAuthGrantTypeFromFlow(flow) {
|
|
|
59
67
|
__name(getOAuthGrantTypeFromFlow, "getOAuthGrantTypeFromFlow");
|
|
60
68
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
69
|
0 && (module.exports = {
|
|
70
|
+
AuthSchemeType,
|
|
62
71
|
OAuthGrantType,
|
|
63
72
|
getOAuthGrantTypeFromFlow
|
|
64
73
|
});
|