@google/adk 2.2.0 → 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/a2a/event_converter_utils.js +5 -1
- package/dist/cjs/a2a/metadata_converter_utils.js +2 -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 +90 -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/abort_events.js +135 -0
- package/dist/cjs/events/event.js +4 -2
- package/dist/cjs/events/internal_metadata.js +131 -0
- 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/plugins/debug_logging_plugin.js +653 -0
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
- package/dist/cjs/runner/in_memory_runner.js +6 -11
- package/dist/cjs/runner/runner.js +121 -35
- 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/a2a/event_converter_utils.js +5 -1
- package/dist/esm/a2a/metadata_converter_utils.js +2 -1
- 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 +87 -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/abort_events.js +110 -0
- package/dist/esm/events/event.js +4 -2
- package/dist/esm/events/internal_metadata.js +97 -0
- 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/plugins/debug_logging_plugin.js +615 -0
- package/dist/esm/plugins/plugin_manager.js +1 -1
- package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
- package/dist/esm/runner/in_memory_runner.js +6 -11
- package/dist/esm/runner/runner.js +124 -35
- 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 +30 -4
- package/dist/types/events/abort_events.d.ts +43 -0
- package/dist/types/events/event.d.ts +4 -0
- package/dist/types/events/internal_metadata.d.ts +78 -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/plugins/debug_logging_plugin.d.ts +157 -0
- package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
- 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 +105 -106
- package/dist/web/index_web.js.map +4 -4
- package/package.json +8 -3
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
var _a, _b;
|
|
11
|
+
import * as yaml from "js-yaml";
|
|
12
|
+
import * as fs from "node:fs";
|
|
13
|
+
import { AuthCredentialTypes } from "../auth/auth_credential.js";
|
|
14
|
+
import { isFinalResponse } from "../events/event.js";
|
|
15
|
+
import { State } from "../sessions/state.js";
|
|
16
|
+
import { logger } from "../utils/logger.js";
|
|
17
|
+
import { toSnakeCaseKey } from "../utils/object_notation_utils.js";
|
|
18
|
+
import { BasePlugin } from "./base_plugin.js";
|
|
19
|
+
const DEBUG_LOGGING_PLUGIN_SYMBOL = /* @__PURE__ */ Symbol.for("google.adk.debugLoggingPlugin");
|
|
20
|
+
const REDACTED = "[REDACTED]";
|
|
21
|
+
const AUTH_CREDENTIAL_TYPES = /* @__PURE__ */ new Set([
|
|
22
|
+
AuthCredentialTypes.API_KEY,
|
|
23
|
+
AuthCredentialTypes.HTTP,
|
|
24
|
+
AuthCredentialTypes.OAUTH2,
|
|
25
|
+
AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
26
|
+
AuthCredentialTypes.SERVICE_ACCOUNT
|
|
27
|
+
]);
|
|
28
|
+
const SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
29
|
+
"access_token",
|
|
30
|
+
"api_key",
|
|
31
|
+
"auth_code",
|
|
32
|
+
"auth_response_uri",
|
|
33
|
+
"authorization",
|
|
34
|
+
"client_secret",
|
|
35
|
+
"code_verifier",
|
|
36
|
+
"google_access_id",
|
|
37
|
+
"id_token",
|
|
38
|
+
"password",
|
|
39
|
+
"private_key",
|
|
40
|
+
"private_key_id",
|
|
41
|
+
"proxy_authorization",
|
|
42
|
+
"refresh_token",
|
|
43
|
+
"secret",
|
|
44
|
+
"sig",
|
|
45
|
+
"signature",
|
|
46
|
+
"token",
|
|
47
|
+
"x_amz_credential",
|
|
48
|
+
"x_amz_signature",
|
|
49
|
+
"x_api_key",
|
|
50
|
+
"x_goog_credential",
|
|
51
|
+
"x_goog_security_token",
|
|
52
|
+
"x_goog_signature"
|
|
53
|
+
]);
|
|
54
|
+
const SENSITIVE_SUBSTRINGS = [
|
|
55
|
+
"api_key",
|
|
56
|
+
"credentials",
|
|
57
|
+
"passwd",
|
|
58
|
+
"password",
|
|
59
|
+
"private_key",
|
|
60
|
+
"secret"
|
|
61
|
+
];
|
|
62
|
+
const SENSITIVE_SUFFIXES = ["_token"];
|
|
63
|
+
const STATE_PREFIXES = [State.APP_PREFIX, State.USER_PREFIX];
|
|
64
|
+
const PRIVATE_KEY_BLOCK = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----|$)/g;
|
|
65
|
+
const OUTPUT_FILE_MODE = 384;
|
|
66
|
+
const MAX_WALK_DEPTH = 20;
|
|
67
|
+
function isSensitiveKey(key) {
|
|
68
|
+
if (typeof key !== "string") {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
let normalized = toSnakeCaseKey(key);
|
|
72
|
+
if (normalized.startsWith(State.TEMP_PREFIX)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
for (const prefix of STATE_PREFIXES) {
|
|
76
|
+
if (normalized.startsWith(prefix)) {
|
|
77
|
+
normalized = normalized.slice(prefix.length);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (SENSITIVE_KEYS.has(normalized) || SENSITIVE_SUFFIXES.some((suffix) => normalized.endsWith(suffix))) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return SENSITIVE_SUBSTRINGS.some((marker) => normalized.includes(marker));
|
|
85
|
+
}
|
|
86
|
+
__name(isSensitiveKey, "isSensitiveKey");
|
|
87
|
+
function redactPrivateKeys(value) {
|
|
88
|
+
return String(value).replace(PRIVATE_KEY_BLOCK, REDACTED);
|
|
89
|
+
}
|
|
90
|
+
__name(redactPrivateKeys, "redactPrivateKeys");
|
|
91
|
+
function isCredentialObject(obj) {
|
|
92
|
+
var _a2;
|
|
93
|
+
if (typeof obj !== "object" || obj === null) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const record = obj;
|
|
97
|
+
const authType = (_a2 = record["authType"]) != null ? _a2 : record["auth_type"];
|
|
98
|
+
return typeof authType === "string" && AUTH_CREDENTIAL_TYPES.has(authType);
|
|
99
|
+
}
|
|
100
|
+
__name(isCredentialObject, "isCredentialObject");
|
|
101
|
+
function isDebugLoggingPlugin(obj) {
|
|
102
|
+
return typeof obj === "object" && obj !== null && DEBUG_LOGGING_PLUGIN_SYMBOL in obj && obj[DEBUG_LOGGING_PLUGIN_SYMBOL] === true;
|
|
103
|
+
}
|
|
104
|
+
__name(isDebugLoggingPlugin, "isDebugLoggingPlugin");
|
|
105
|
+
const _DebugLoggingPlugin = class _DebugLoggingPlugin extends (_b = BasePlugin, _a = DEBUG_LOGGING_PLUGIN_SYMBOL, _b) {
|
|
106
|
+
constructor(options = {}) {
|
|
107
|
+
var _a2, _b2, _c, _d;
|
|
108
|
+
super((_a2 = options.name) != null ? _a2 : "debug_logging_plugin");
|
|
109
|
+
this[_a] = true;
|
|
110
|
+
this.invocationStates = /* @__PURE__ */ new Map();
|
|
111
|
+
this.warnedAboutOutputMode = false;
|
|
112
|
+
this.outputPath = (_b2 = options.outputPath) != null ? _b2 : "adk_debug.yaml";
|
|
113
|
+
this.includeSessionState = (_c = options.includeSessionState) != null ? _c : true;
|
|
114
|
+
this.includeSystemInstruction = (_d = options.includeSystemInstruction) != null ? _d : true;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Exposes active invocation states for testing and inspection.
|
|
118
|
+
*/
|
|
119
|
+
getInvocationState(invocationId) {
|
|
120
|
+
return this.invocationStates.get(invocationId);
|
|
121
|
+
}
|
|
122
|
+
getTimestamp() {
|
|
123
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Serializes a Gemini `Content` object to a dictionary for YAML output.
|
|
127
|
+
*/
|
|
128
|
+
serializeContent(content) {
|
|
129
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
130
|
+
if (!content) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const parts = [];
|
|
134
|
+
if (content.parts) {
|
|
135
|
+
for (const part of content.parts) {
|
|
136
|
+
const partData = {};
|
|
137
|
+
if (part.text) {
|
|
138
|
+
partData["text"] = part.text;
|
|
139
|
+
}
|
|
140
|
+
if (part.functionCall) {
|
|
141
|
+
partData["function_call"] = {
|
|
142
|
+
id: (_a2 = part.functionCall.id) != null ? _a2 : null,
|
|
143
|
+
name: (_b2 = part.functionCall.name) != null ? _b2 : null,
|
|
144
|
+
args: this.safeSerialize(part.functionCall.args)
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (part.functionResponse) {
|
|
148
|
+
partData["function_response"] = {
|
|
149
|
+
id: (_c = part.functionResponse.id) != null ? _c : null,
|
|
150
|
+
name: (_d = part.functionResponse.name) != null ? _d : null,
|
|
151
|
+
response: this.safeSerialize(part.functionResponse.response)
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
if (part.inlineData) {
|
|
155
|
+
partData["inline_data"] = {
|
|
156
|
+
mime_type: (_e = part.inlineData.mimeType) != null ? _e : null,
|
|
157
|
+
display_name: (_f = part.inlineData.displayName) != null ? _f : null,
|
|
158
|
+
_data_omitted: true
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (part.fileData) {
|
|
162
|
+
partData["file_data"] = {
|
|
163
|
+
file_uri: (_g = part.fileData.fileUri) != null ? _g : null,
|
|
164
|
+
mime_type: (_h = part.fileData.mimeType) != null ? _h : null
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (part.codeExecutionResult) {
|
|
168
|
+
partData["code_execution_result"] = {
|
|
169
|
+
outcome: String((_i = part.codeExecutionResult.outcome) != null ? _i : ""),
|
|
170
|
+
output: (_j = part.codeExecutionResult.output) != null ? _j : null
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
if (part.executableCode) {
|
|
174
|
+
partData["executable_code"] = {
|
|
175
|
+
language: String((_k = part.executableCode.language) != null ? _k : ""),
|
|
176
|
+
code: (_l = part.executableCode.code) != null ? _l : null
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (Object.keys(partData).length > 0) {
|
|
180
|
+
parts.push(partData);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
role: (_m = content.role) != null ? _m : null,
|
|
186
|
+
parts
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Safely serializes an arbitrary value to a YAML/JSON-compatible format with
|
|
191
|
+
* credential, sensitive key, and private key redaction.
|
|
192
|
+
*/
|
|
193
|
+
safeSerialize(obj, depth = 0) {
|
|
194
|
+
if (obj === null || obj === void 0) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
if (isCredentialObject(obj)) {
|
|
198
|
+
return REDACTED;
|
|
199
|
+
}
|
|
200
|
+
if (depth > MAX_WALK_DEPTH) {
|
|
201
|
+
return Array.isArray(obj) ? "<list ...>" : "<dict ...>";
|
|
202
|
+
}
|
|
203
|
+
const childDepth = depth + 1;
|
|
204
|
+
if (typeof obj === "string") {
|
|
205
|
+
return redactPrivateKeys(obj);
|
|
206
|
+
}
|
|
207
|
+
if (typeof obj === "number" || typeof obj === "boolean") {
|
|
208
|
+
return obj;
|
|
209
|
+
}
|
|
210
|
+
if (obj instanceof Date) {
|
|
211
|
+
return obj.toISOString();
|
|
212
|
+
}
|
|
213
|
+
if (Buffer.isBuffer(obj) || obj instanceof Uint8Array) {
|
|
214
|
+
return `<bytes: ${obj.byteLength} bytes>`;
|
|
215
|
+
}
|
|
216
|
+
if (Array.isArray(obj)) {
|
|
217
|
+
return obj.map((item) => this.safeSerialize(item, childDepth));
|
|
218
|
+
}
|
|
219
|
+
if (obj instanceof Set) {
|
|
220
|
+
return Array.from(obj).map(
|
|
221
|
+
(item) => this.safeSerialize(item, childDepth)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
if (obj instanceof Map) {
|
|
225
|
+
const result = {};
|
|
226
|
+
for (const [k, v] of obj.entries()) {
|
|
227
|
+
const keyStr = String(k);
|
|
228
|
+
result[keyStr] = isSensitiveKey(keyStr) ? REDACTED : this.safeSerialize(v, childDepth);
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
if (typeof obj === "object") {
|
|
233
|
+
const result = {};
|
|
234
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
235
|
+
if (v === void 0) {
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
result[k] = isSensitiveKey(k) ? REDACTED : this.safeSerialize(v, childDepth);
|
|
239
|
+
}
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
return String(obj);
|
|
244
|
+
} catch {
|
|
245
|
+
return "<unserializable>";
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
addEntry(invocationId, entryType, agentName, data = {}) {
|
|
249
|
+
var _a2;
|
|
250
|
+
const state = this.invocationStates.get(invocationId);
|
|
251
|
+
if (!state) {
|
|
252
|
+
logger.warn(
|
|
253
|
+
`No debug state for invocation ${invocationId}, skipping entry`
|
|
254
|
+
);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const entry = {
|
|
258
|
+
timestamp: this.getTimestamp(),
|
|
259
|
+
entry_type: entryType,
|
|
260
|
+
invocation_id: invocationId,
|
|
261
|
+
...agentName !== void 0 ? { agent_name: agentName } : {},
|
|
262
|
+
data: (_a2 = this.safeSerialize(data)) != null ? _a2 : {}
|
|
263
|
+
};
|
|
264
|
+
state.entries.push(entry);
|
|
265
|
+
}
|
|
266
|
+
async onUserMessageCallback({
|
|
267
|
+
invocationContext,
|
|
268
|
+
userMessage
|
|
269
|
+
}) {
|
|
270
|
+
this.addEntry(invocationContext.invocationId, "user_message", void 0, {
|
|
271
|
+
content: this.serializeContent(userMessage)
|
|
272
|
+
});
|
|
273
|
+
return void 0;
|
|
274
|
+
}
|
|
275
|
+
async beforeRunCallback({
|
|
276
|
+
invocationContext
|
|
277
|
+
}) {
|
|
278
|
+
var _a2, _b2;
|
|
279
|
+
const invocationId = invocationContext.invocationId;
|
|
280
|
+
const session = invocationContext.session;
|
|
281
|
+
const state = {
|
|
282
|
+
invocation_id: invocationId,
|
|
283
|
+
session_id: session.id,
|
|
284
|
+
app_name: session.appName,
|
|
285
|
+
...invocationContext.userId ? { user_id: invocationContext.userId } : {},
|
|
286
|
+
start_time: this.getTimestamp(),
|
|
287
|
+
entries: []
|
|
288
|
+
};
|
|
289
|
+
this.invocationStates.set(invocationId, state);
|
|
290
|
+
this.addEntry(
|
|
291
|
+
invocationId,
|
|
292
|
+
"invocation_start",
|
|
293
|
+
(_a2 = invocationContext.agent) == null ? void 0 : _a2.name,
|
|
294
|
+
{
|
|
295
|
+
branch: (_b2 = invocationContext.branch) != null ? _b2 : null
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
async onEventCallback({
|
|
301
|
+
invocationContext,
|
|
302
|
+
event
|
|
303
|
+
}) {
|
|
304
|
+
var _a2, _b2, _c, _d, _e, _f, _g, _h;
|
|
305
|
+
const invocationId = invocationContext.invocationId;
|
|
306
|
+
const eventData = {
|
|
307
|
+
event_id: event.id,
|
|
308
|
+
author: (_a2 = event.author) != null ? _a2 : null,
|
|
309
|
+
content: this.serializeContent(event.content),
|
|
310
|
+
is_final_response: isFinalResponse(event),
|
|
311
|
+
partial: (_b2 = event.partial) != null ? _b2 : null,
|
|
312
|
+
turn_complete: (_c = event.turnComplete) != null ? _c : null,
|
|
313
|
+
branch: (_d = event.branch) != null ? _d : null
|
|
314
|
+
};
|
|
315
|
+
if (event.actions) {
|
|
316
|
+
const actionsData = {};
|
|
317
|
+
if (event.actions.stateDelta && Object.keys(event.actions.stateDelta).length > 0) {
|
|
318
|
+
actionsData["state_delta"] = this.safeSerialize(
|
|
319
|
+
event.actions.stateDelta
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
if (event.actions.artifactDelta && Object.keys(event.actions.artifactDelta).length > 0) {
|
|
323
|
+
actionsData["artifact_delta"] = { ...event.actions.artifactDelta };
|
|
324
|
+
}
|
|
325
|
+
if (event.actions.transferToAgent) {
|
|
326
|
+
actionsData["transfer_to_agent"] = event.actions.transferToAgent;
|
|
327
|
+
}
|
|
328
|
+
if (event.actions.escalate) {
|
|
329
|
+
actionsData["escalate"] = event.actions.escalate;
|
|
330
|
+
}
|
|
331
|
+
if (event.actions.requestedAuthConfigs && Object.keys(event.actions.requestedAuthConfigs).length > 0) {
|
|
332
|
+
actionsData["requested_auth_configs"] = Object.keys(
|
|
333
|
+
event.actions.requestedAuthConfigs
|
|
334
|
+
).length;
|
|
335
|
+
}
|
|
336
|
+
if (Object.keys(actionsData).length > 0) {
|
|
337
|
+
eventData["actions"] = actionsData;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (event.groundingMetadata) {
|
|
341
|
+
eventData["has_grounding_metadata"] = true;
|
|
342
|
+
}
|
|
343
|
+
if (event.usageMetadata) {
|
|
344
|
+
eventData["usage_metadata"] = {
|
|
345
|
+
prompt_token_count: (_e = event.usageMetadata.promptTokenCount) != null ? _e : null,
|
|
346
|
+
candidates_token_count: (_f = event.usageMetadata.candidatesTokenCount) != null ? _f : null,
|
|
347
|
+
total_token_count: (_g = event.usageMetadata.totalTokenCount) != null ? _g : null
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
if (event.errorCode) {
|
|
351
|
+
eventData["error_code"] = event.errorCode;
|
|
352
|
+
eventData["error_message"] = (_h = event.errorMessage) != null ? _h : null;
|
|
353
|
+
}
|
|
354
|
+
if (event.longRunningToolIds && event.longRunningToolIds.length > 0) {
|
|
355
|
+
eventData["long_running_tool_ids"] = [...event.longRunningToolIds];
|
|
356
|
+
}
|
|
357
|
+
this.addEntry(invocationId, "event", event.author, eventData);
|
|
358
|
+
return void 0;
|
|
359
|
+
}
|
|
360
|
+
async afterRunCallback({
|
|
361
|
+
invocationContext
|
|
362
|
+
}) {
|
|
363
|
+
var _a2, _b2;
|
|
364
|
+
const invocationId = invocationContext.invocationId;
|
|
365
|
+
const state = this.invocationStates.get(invocationId);
|
|
366
|
+
if (!state) {
|
|
367
|
+
logger.warn(
|
|
368
|
+
`No debug state for invocation ${invocationId}, skipping write`
|
|
369
|
+
);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (this.includeSessionState) {
|
|
373
|
+
const session = invocationContext.session;
|
|
374
|
+
this.addEntry(invocationId, "session_state_snapshot", void 0, {
|
|
375
|
+
state: this.safeSerialize(session.state),
|
|
376
|
+
event_count: (_b2 = (_a2 = session.events) == null ? void 0 : _a2.length) != null ? _b2 : 0
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
this.addEntry(invocationId, "invocation_end");
|
|
380
|
+
let fd;
|
|
381
|
+
try {
|
|
382
|
+
fd = fs.openSync(
|
|
383
|
+
this.outputPath,
|
|
384
|
+
fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_APPEND,
|
|
385
|
+
OUTPUT_FILE_MODE
|
|
386
|
+
);
|
|
387
|
+
if (process.platform !== "win32" && !this.warnedAboutOutputMode && (fs.fstatSync(fd).mode & 63) !== 0) {
|
|
388
|
+
this.warnedAboutOutputMode = true;
|
|
389
|
+
logger.warn(
|
|
390
|
+
`Debug output file ${this.outputPath} is readable beyond its owner and holds whole prompts and responses; restrict it to mode 600.`
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
const yamlDoc = "---\n" + yaml.dump(state, {
|
|
394
|
+
noRefs: true,
|
|
395
|
+
lineWidth: 120,
|
|
396
|
+
sortKeys: false
|
|
397
|
+
});
|
|
398
|
+
fs.writeFileSync(fd, yamlDoc, { encoding: "utf-8" });
|
|
399
|
+
logger.debug(
|
|
400
|
+
`Wrote debug data for invocation ${invocationId} to ${this.outputPath}`
|
|
401
|
+
);
|
|
402
|
+
} catch (e) {
|
|
403
|
+
logger.error(`Failed to write debug data: ${e}`);
|
|
404
|
+
} finally {
|
|
405
|
+
if (fd !== void 0) {
|
|
406
|
+
try {
|
|
407
|
+
fs.closeSync(fd);
|
|
408
|
+
} catch {
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
this.invocationStates.delete(invocationId);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
async beforeAgentCallback({
|
|
415
|
+
callbackContext
|
|
416
|
+
}) {
|
|
417
|
+
var _a2, _b2;
|
|
418
|
+
this.addEntry(
|
|
419
|
+
callbackContext.invocationId,
|
|
420
|
+
"agent_start",
|
|
421
|
+
callbackContext.agentName,
|
|
422
|
+
{
|
|
423
|
+
branch: (_b2 = (_a2 = callbackContext.invocationContext) == null ? void 0 : _a2.branch) != null ? _b2 : null
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
return void 0;
|
|
427
|
+
}
|
|
428
|
+
async afterAgentCallback({
|
|
429
|
+
callbackContext
|
|
430
|
+
}) {
|
|
431
|
+
this.addEntry(
|
|
432
|
+
callbackContext.invocationId,
|
|
433
|
+
"agent_end",
|
|
434
|
+
callbackContext.agentName
|
|
435
|
+
);
|
|
436
|
+
return void 0;
|
|
437
|
+
}
|
|
438
|
+
async beforeModelCallback({
|
|
439
|
+
callbackContext,
|
|
440
|
+
llmRequest
|
|
441
|
+
}) {
|
|
442
|
+
var _a2, _b2, _c, _d;
|
|
443
|
+
const requestData = {
|
|
444
|
+
model: (_a2 = llmRequest.model) != null ? _a2 : null,
|
|
445
|
+
content_count: (_c = (_b2 = llmRequest.contents) == null ? void 0 : _b2.length) != null ? _c : 0,
|
|
446
|
+
contents: ((_d = llmRequest.contents) != null ? _d : []).map(
|
|
447
|
+
(c) => this.serializeContent(c)
|
|
448
|
+
)
|
|
449
|
+
};
|
|
450
|
+
if (llmRequest.toolsDict && Object.keys(llmRequest.toolsDict).length > 0) {
|
|
451
|
+
requestData["tools"] = Object.keys(llmRequest.toolsDict);
|
|
452
|
+
}
|
|
453
|
+
if (llmRequest.config) {
|
|
454
|
+
const config = llmRequest.config;
|
|
455
|
+
const configData = {};
|
|
456
|
+
if (this.includeSystemInstruction && config.systemInstruction) {
|
|
457
|
+
configData["system_instruction"] = config.systemInstruction;
|
|
458
|
+
} else if (config.systemInstruction) {
|
|
459
|
+
if (typeof config.systemInstruction === "string") {
|
|
460
|
+
configData["system_instruction_length"] = config.systemInstruction.length;
|
|
461
|
+
} else {
|
|
462
|
+
configData["has_system_instruction"] = true;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (config.temperature !== void 0 && config.temperature !== null) {
|
|
466
|
+
configData["temperature"] = config.temperature;
|
|
467
|
+
}
|
|
468
|
+
if (config.topP !== void 0 && config.topP !== null) {
|
|
469
|
+
configData["top_p"] = config.topP;
|
|
470
|
+
}
|
|
471
|
+
if (config.topK !== void 0 && config.topK !== null) {
|
|
472
|
+
configData["top_k"] = config.topK;
|
|
473
|
+
}
|
|
474
|
+
if (config.maxOutputTokens !== void 0 && config.maxOutputTokens !== null) {
|
|
475
|
+
configData["max_output_tokens"] = config.maxOutputTokens;
|
|
476
|
+
}
|
|
477
|
+
if (config.responseMimeType) {
|
|
478
|
+
configData["response_mime_type"] = config.responseMimeType;
|
|
479
|
+
}
|
|
480
|
+
if (config.responseSchema) {
|
|
481
|
+
configData["has_response_schema"] = true;
|
|
482
|
+
}
|
|
483
|
+
if (Object.keys(configData).length > 0) {
|
|
484
|
+
requestData["config"] = configData;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
this.addEntry(
|
|
488
|
+
callbackContext.invocationId,
|
|
489
|
+
"llm_request",
|
|
490
|
+
callbackContext.agentName,
|
|
491
|
+
requestData
|
|
492
|
+
);
|
|
493
|
+
return void 0;
|
|
494
|
+
}
|
|
495
|
+
async afterModelCallback({
|
|
496
|
+
callbackContext,
|
|
497
|
+
llmResponse
|
|
498
|
+
}) {
|
|
499
|
+
var _a2, _b2, _c, _d, _e, _f, _g;
|
|
500
|
+
const responseData = {
|
|
501
|
+
content: this.serializeContent(llmResponse.content),
|
|
502
|
+
partial: (_a2 = llmResponse.partial) != null ? _a2 : null,
|
|
503
|
+
turn_complete: (_b2 = llmResponse.turnComplete) != null ? _b2 : null
|
|
504
|
+
};
|
|
505
|
+
if (llmResponse.errorCode) {
|
|
506
|
+
responseData["error_code"] = llmResponse.errorCode;
|
|
507
|
+
responseData["error_message"] = (_c = llmResponse.errorMessage) != null ? _c : null;
|
|
508
|
+
}
|
|
509
|
+
if (llmResponse.usageMetadata) {
|
|
510
|
+
responseData["usage_metadata"] = {
|
|
511
|
+
prompt_token_count: (_d = llmResponse.usageMetadata.promptTokenCount) != null ? _d : null,
|
|
512
|
+
candidates_token_count: (_e = llmResponse.usageMetadata.candidatesTokenCount) != null ? _e : null,
|
|
513
|
+
total_token_count: (_f = llmResponse.usageMetadata.totalTokenCount) != null ? _f : null,
|
|
514
|
+
cached_content_token_count: (_g = llmResponse.usageMetadata.cachedContentTokenCount) != null ? _g : null
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
if (llmResponse.groundingMetadata) {
|
|
518
|
+
responseData["has_grounding_metadata"] = true;
|
|
519
|
+
}
|
|
520
|
+
if (llmResponse.finishReason) {
|
|
521
|
+
responseData["finish_reason"] = String(llmResponse.finishReason);
|
|
522
|
+
}
|
|
523
|
+
if (llmResponse.modelVersion) {
|
|
524
|
+
responseData["model_version"] = llmResponse.modelVersion;
|
|
525
|
+
}
|
|
526
|
+
this.addEntry(
|
|
527
|
+
callbackContext.invocationId,
|
|
528
|
+
"llm_response",
|
|
529
|
+
callbackContext.agentName,
|
|
530
|
+
responseData
|
|
531
|
+
);
|
|
532
|
+
return void 0;
|
|
533
|
+
}
|
|
534
|
+
async onModelErrorCallback({
|
|
535
|
+
callbackContext,
|
|
536
|
+
llmRequest,
|
|
537
|
+
error
|
|
538
|
+
}) {
|
|
539
|
+
var _a2;
|
|
540
|
+
this.addEntry(
|
|
541
|
+
callbackContext.invocationId,
|
|
542
|
+
"llm_error",
|
|
543
|
+
callbackContext.agentName,
|
|
544
|
+
{
|
|
545
|
+
error_type: error.name || "Error",
|
|
546
|
+
error_message: error.message || String(error),
|
|
547
|
+
model: (_a2 = llmRequest.model) != null ? _a2 : null
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
return void 0;
|
|
551
|
+
}
|
|
552
|
+
async beforeToolCallback({
|
|
553
|
+
tool,
|
|
554
|
+
toolArgs,
|
|
555
|
+
toolContext
|
|
556
|
+
}) {
|
|
557
|
+
var _a2;
|
|
558
|
+
this.addEntry(
|
|
559
|
+
toolContext.invocationId,
|
|
560
|
+
"tool_call",
|
|
561
|
+
toolContext.agentName,
|
|
562
|
+
{
|
|
563
|
+
tool_name: tool.name,
|
|
564
|
+
function_call_id: (_a2 = toolContext.functionCallId) != null ? _a2 : null,
|
|
565
|
+
args: this.safeSerialize(toolArgs)
|
|
566
|
+
}
|
|
567
|
+
);
|
|
568
|
+
return void 0;
|
|
569
|
+
}
|
|
570
|
+
async afterToolCallback({
|
|
571
|
+
tool,
|
|
572
|
+
toolContext,
|
|
573
|
+
result
|
|
574
|
+
}) {
|
|
575
|
+
var _a2;
|
|
576
|
+
this.addEntry(
|
|
577
|
+
toolContext.invocationId,
|
|
578
|
+
"tool_response",
|
|
579
|
+
toolContext.agentName,
|
|
580
|
+
{
|
|
581
|
+
tool_name: tool.name,
|
|
582
|
+
function_call_id: (_a2 = toolContext.functionCallId) != null ? _a2 : null,
|
|
583
|
+
result: this.safeSerialize(result)
|
|
584
|
+
}
|
|
585
|
+
);
|
|
586
|
+
return void 0;
|
|
587
|
+
}
|
|
588
|
+
async onToolErrorCallback({
|
|
589
|
+
tool,
|
|
590
|
+
toolArgs,
|
|
591
|
+
toolContext,
|
|
592
|
+
error
|
|
593
|
+
}) {
|
|
594
|
+
var _a2;
|
|
595
|
+
this.addEntry(
|
|
596
|
+
toolContext.invocationId,
|
|
597
|
+
"tool_error",
|
|
598
|
+
toolContext.agentName,
|
|
599
|
+
{
|
|
600
|
+
tool_name: tool.name,
|
|
601
|
+
function_call_id: (_a2 = toolContext.functionCallId) != null ? _a2 : null,
|
|
602
|
+
args: this.safeSerialize(toolArgs),
|
|
603
|
+
error_type: error.name || "Error",
|
|
604
|
+
error_message: error.message || String(error)
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
return void 0;
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
__name(_DebugLoggingPlugin, "DebugLoggingPlugin");
|
|
611
|
+
let DebugLoggingPlugin = _DebugLoggingPlugin;
|
|
612
|
+
export {
|
|
613
|
+
DebugLoggingPlugin,
|
|
614
|
+
isDebugLoggingPlugin
|
|
615
|
+
};
|
|
@@ -78,7 +78,7 @@ const _PluginManager = class _PluginManager {
|
|
|
78
78
|
} catch (e) {
|
|
79
79
|
const errorMessage = `Error in plugin '${plugin.name}' during '${callbackName}' callback: ${e}`;
|
|
80
80
|
logger.error(errorMessage);
|
|
81
|
-
throw new Error(errorMessage);
|
|
81
|
+
throw new Error(errorMessage, { cause: e });
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
return void 0;
|