@google/adk 0.2.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/part_converter_utils.js +210 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +46 -24
- package/dist/cjs/agents/base_llm_processor.js +1 -1
- package/dist/cjs/agents/callback_context.js +5 -2
- package/dist/cjs/agents/content_processor_utils.js +16 -8
- package/dist/cjs/agents/functions.js +81 -30
- package/dist/cjs/agents/instructions.js +1 -1
- package/dist/cjs/agents/invocation_context.js +1 -1
- package/dist/cjs/agents/live_request_queue.js +1 -1
- package/dist/cjs/agents/llm_agent.js +106 -62
- package/dist/cjs/agents/loop_agent.js +3 -2
- package/dist/cjs/agents/parallel_agent.js +4 -5
- package/dist/cjs/agents/readonly_context.js +13 -1
- package/dist/cjs/agents/run_config.js +2 -1
- package/dist/cjs/agents/sequential_agent.js +1 -1
- package/dist/cjs/agents/transcription_entry.js +1 -1
- package/dist/cjs/artifacts/base_artifact_service.js +1 -1
- package/dist/cjs/artifacts/file_artifact_service.js +491 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +145 -58
- package/dist/cjs/artifacts/in_memory_artifact_service.js +72 -10
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +4 -2
- package/dist/cjs/auth/auth_schemes.js +1 -1
- package/dist/cjs/auth/auth_tool.js +1 -1
- package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
- package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
- package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
- package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
- package/dist/cjs/code_executors/base_code_executor.js +4 -2
- package/dist/cjs/code_executors/built_in_code_executor.js +8 -4
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +6 -6
- package/dist/cjs/common.js +18 -1
- package/dist/cjs/events/event.js +34 -7
- package/dist/cjs/events/event_actions.js +2 -2
- package/dist/cjs/events/structured_events.js +105 -0
- package/dist/cjs/examples/base_example_provider.js +1 -1
- package/dist/cjs/examples/example.js +1 -1
- package/dist/cjs/examples/example_util.js +1 -1
- package/dist/cjs/index.js +54 -83
- package/dist/cjs/index_web.js +1 -1
- package/dist/cjs/memory/base_memory_service.js +1 -1
- package/dist/cjs/memory/in_memory_memory_service.js +4 -2
- package/dist/cjs/memory/memory_entry.js +1 -1
- package/dist/cjs/models/apigee_llm.js +182 -0
- package/dist/cjs/models/base_llm.js +9 -5
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +2 -1
- package/dist/cjs/models/google_llm.js +73 -54
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +1 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +13 -1
- package/dist/cjs/plugins/logging_plugin.js +51 -14
- package/dist/cjs/plugins/plugin_manager.js +57 -25
- package/dist/cjs/plugins/security_plugin.js +2 -2
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +142 -96
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +364 -0
- package/dist/cjs/sessions/db/operations.js +114 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +60 -34
- package/dist/cjs/sessions/registry.js +49 -0
- package/dist/cjs/sessions/session.js +1 -1
- package/dist/cjs/sessions/state.js +1 -1
- package/dist/cjs/telemetry/google_cloud.js +8 -10
- package/dist/cjs/telemetry/setup.js +16 -8
- package/dist/cjs/telemetry/tracing.js +38 -16
- package/dist/cjs/tools/agent_tool.js +9 -5
- package/dist/cjs/tools/base_tool.js +5 -3
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/forwarding_artifact_service.js +18 -2
- package/dist/cjs/tools/function_tool.js +2 -3
- package/dist/cjs/tools/google_search_tool.js +2 -3
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +17 -11
- package/dist/cjs/tools/mcp/mcp_tool.js +2 -4
- package/dist/cjs/tools/mcp/mcp_toolset.js +2 -2
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/tools/tool_context.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +11 -2
- package/dist/cjs/utils/gemini_schema_util.js +10 -5
- package/dist/cjs/utils/logger.js +48 -4
- package/dist/cjs/utils/model_name.js +1 -1
- package/dist/cjs/utils/object_notation_utils.js +78 -0
- package/dist/cjs/utils/simple_zod_to_json.js +101 -142
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- package/dist/esm/a2a/part_converter_utils.js +171 -0
- package/dist/esm/agents/base_agent.js +50 -24
- package/dist/esm/agents/callback_context.js +4 -1
- package/dist/esm/agents/content_processor_utils.js +25 -9
- package/dist/esm/agents/functions.js +84 -29
- package/dist/esm/agents/llm_agent.js +110 -62
- package/dist/esm/agents/loop_agent.js +2 -1
- package/dist/esm/agents/parallel_agent.js +3 -4
- package/dist/esm/agents/readonly_context.js +12 -0
- package/dist/esm/agents/run_config.js +1 -0
- package/dist/esm/artifacts/file_artifact_service.js +451 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +144 -57
- package/dist/esm/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/auth/auth_handler.js +3 -1
- package/dist/esm/code_executors/base_code_executor.js +3 -1
- package/dist/esm/code_executors/built_in_code_executor.js +7 -3
- package/dist/esm/code_executors/code_executor_context.js +5 -5
- package/dist/esm/common.js +12 -2
- package/dist/esm/events/event.js +30 -5
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +18 -88
- package/dist/esm/memory/in_memory_memory_service.js +3 -1
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/base_llm.js +8 -4
- package/dist/esm/models/gemini_llm_connection.js +1 -0
- package/dist/esm/models/google_llm.js +75 -53
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +12 -0
- package/dist/esm/plugins/logging_plugin.js +55 -14
- package/dist/esm/plugins/plugin_manager.js +56 -24
- package/dist/esm/plugins/security_plugin.js +1 -1
- package/dist/esm/runner/runner.js +145 -96
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +350 -0
- package/dist/esm/sessions/db/operations.js +87 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +61 -33
- package/dist/esm/sessions/registry.js +25 -0
- package/dist/esm/telemetry/google_cloud.js +7 -9
- package/dist/esm/telemetry/setup.js +23 -9
- package/dist/esm/telemetry/tracing.js +37 -15
- package/dist/esm/tools/agent_tool.js +8 -4
- package/dist/esm/tools/base_tool.js +4 -2
- package/dist/esm/tools/forwarding_artifact_service.js +17 -1
- package/dist/esm/tools/function_tool.js +1 -2
- package/dist/esm/tools/google_search_tool.js +2 -5
- package/dist/esm/tools/long_running_tool.js +3 -1
- package/dist/esm/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/esm/tools/mcp/mcp_tool.js +1 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -1
- package/dist/esm/utils/env_aware_utils.js +9 -1
- package/dist/esm/utils/gemini_schema_util.js +9 -4
- package/dist/esm/utils/logger.js +43 -2
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/simple_zod_to_json.js +102 -141
- package/dist/esm/utils/variant_utils.js +1 -7
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/part_converter_utils.d.ts +47 -0
- package/dist/types/agents/base_agent.d.ts +2 -1
- package/dist/types/agents/callback_context.d.ts +1 -1
- package/dist/types/agents/llm_agent.d.ts +12 -12
- package/dist/types/agents/loop_agent.d.ts +1 -1
- package/dist/types/agents/parallel_agent.d.ts +1 -1
- package/dist/types/agents/readonly_context.d.ts +8 -0
- package/dist/types/agents/run_config.d.ts +6 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
- package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
- package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
- package/dist/types/artifacts/in_memory_artifact_service.d.ts +8 -5
- package/dist/types/artifacts/registry.d.ts +7 -0
- package/dist/types/code_executors/built_in_code_executor.d.ts +1 -1
- package/dist/types/code_executors/code_executor_context.d.ts +2 -4
- package/dist/types/common.d.ts +13 -3
- package/dist/types/events/event.d.ts +15 -1
- package/dist/types/events/event_actions.d.ts +1 -1
- package/dist/types/events/structured_events.d.ts +106 -0
- package/dist/types/index.d.ts +7 -3
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/base_llm_connection.d.ts +1 -1
- package/dist/types/models/google_llm.d.ts +5 -2
- package/dist/types/models/llm_response.d.ts +1 -1
- package/dist/types/plugins/logging_plugin.d.ts +12 -12
- package/dist/types/plugins/plugin_manager.d.ts +12 -12
- package/dist/types/plugins/security_plugin.d.ts +1 -1
- package/dist/types/runner/runner.d.ts +16 -1
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +31 -0
- package/dist/types/sessions/db/operations.d.ts +29 -0
- package/dist/types/sessions/db/schema.d.ts +45 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +9 -6
- package/dist/types/sessions/registry.d.ts +7 -0
- package/dist/types/telemetry/setup.d.ts +1 -1
- package/dist/types/telemetry/tracing.d.ts +7 -6
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/base_tool.d.ts +1 -1
- package/dist/types/tools/base_toolset.d.ts +2 -1
- package/dist/types/tools/forwarding_artifact_service.d.ts +4 -2
- package/dist/types/tools/function_tool.d.ts +4 -3
- package/dist/types/tools/google_search_tool.d.ts +3 -3
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +10 -3
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -2
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/gemini_schema_util.d.ts +4 -12
- package/dist/types/utils/logger.d.ts +11 -10
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/utils/simple_zod_to_json.d.ts +5 -4
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/part_converter_utils.js +171 -0
- package/dist/web/agents/base_agent.js +96 -35
- package/dist/web/agents/callback_context.js +4 -1
- package/dist/web/agents/content_processor_utils.js +25 -9
- package/dist/web/agents/functions.js +84 -29
- package/dist/web/agents/llm_agent.js +166 -83
- package/dist/web/agents/loop_agent.js +2 -1
- package/dist/web/agents/parallel_agent.js +3 -4
- package/dist/web/agents/readonly_context.js +12 -0
- package/dist/web/agents/run_config.js +2 -1
- package/dist/web/artifacts/file_artifact_service.js +506 -0
- package/dist/web/artifacts/gcs_artifact_service.js +139 -54
- package/dist/web/artifacts/in_memory_artifact_service.js +69 -8
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/auth/auth_handler.js +3 -1
- package/dist/web/code_executors/base_code_executor.js +3 -1
- package/dist/web/code_executors/built_in_code_executor.js +7 -3
- package/dist/web/code_executors/code_executor_context.js +5 -5
- package/dist/web/common.js +12 -2
- package/dist/web/events/event.js +30 -5
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +18 -8
- package/dist/web/memory/in_memory_memory_service.js +3 -1
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/base_llm.js +8 -4
- package/dist/web/models/gemini_llm_connection.js +1 -0
- package/dist/web/models/google_llm.js +75 -50
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +12 -0
- package/dist/web/plugins/logging_plugin.js +55 -14
- package/dist/web/plugins/plugin_manager.js +56 -24
- package/dist/web/plugins/security_plugin.js +1 -1
- package/dist/web/runner/runner.js +192 -108
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +368 -0
- package/dist/web/sessions/db/operations.js +87 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +61 -33
- package/dist/web/sessions/registry.js +25 -0
- package/dist/web/telemetry/google_cloud.js +7 -9
- package/dist/web/telemetry/setup.js +23 -9
- package/dist/web/telemetry/tracing.js +37 -15
- package/dist/web/tools/agent_tool.js +8 -4
- package/dist/web/tools/base_tool.js +4 -2
- package/dist/web/tools/forwarding_artifact_service.js +17 -1
- package/dist/web/tools/function_tool.js +1 -2
- package/dist/web/tools/google_search_tool.js +2 -5
- package/dist/web/tools/long_running_tool.js +3 -1
- package/dist/web/tools/mcp/mcp_session_manager.js +22 -12
- package/dist/web/tools/mcp/mcp_tool.js +1 -3
- package/dist/web/tools/mcp/mcp_toolset.js +1 -1
- package/dist/web/utils/env_aware_utils.js +9 -1
- package/dist/web/utils/gemini_schema_util.js +9 -4
- package/dist/web/utils/logger.js +43 -2
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/simple_zod_to_json.js +102 -155
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +16 -5
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/web/index.js.map +0 -7
|
@@ -36,14 +36,17 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
36
36
|
* Copyright 2025 Google LLC
|
|
37
37
|
* SPDX-License-Identifier: Apache-2.0
|
|
38
38
|
*/
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
createPartFromText,
|
|
41
|
+
FinishReason,
|
|
42
|
+
GoogleGenAI
|
|
43
|
+
} from "@google/genai";
|
|
44
|
+
import { getBooleanEnvVar, isBrowser } from "../utils/env_aware_utils.js";
|
|
40
45
|
import { logger } from "../utils/logger.js";
|
|
41
46
|
import { GoogleLLMVariant } from "../utils/variant_utils.js";
|
|
42
47
|
import { BaseLlm } from "./base_llm.js";
|
|
43
48
|
import { GeminiLlmConnection } from "./gemini_llm_connection.js";
|
|
44
49
|
import { createLlmResponse } from "./llm_response.js";
|
|
45
|
-
const AGENT_ENGINE_TELEMETRY_TAG = "remote_reasoning_engine";
|
|
46
|
-
const AGENT_ENGINE_TELEMETRY_ENV_VARIABLE_NAME = "GOOGLE_CLOUD_AGENT_ENGINE_ID";
|
|
47
50
|
class Gemini extends BaseLlm {
|
|
48
51
|
/**
|
|
49
52
|
* @param params The parameters for creating a Gemini instance.
|
|
@@ -60,45 +63,23 @@ class Gemini extends BaseLlm {
|
|
|
60
63
|
model = "gemini-2.5-flash";
|
|
61
64
|
}
|
|
62
65
|
super({ model });
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
if (this.vertexai) {
|
|
76
|
-
if (canReadEnv && !this.project) {
|
|
77
|
-
this.project = process.env["GOOGLE_CLOUD_PROJECT"];
|
|
78
|
-
}
|
|
79
|
-
if (canReadEnv && !this.location) {
|
|
80
|
-
this.location = process.env["GOOGLE_CLOUD_LOCATION"];
|
|
81
|
-
}
|
|
82
|
-
if (!this.project) {
|
|
83
|
-
throw new Error(
|
|
84
|
-
"VertexAI project must be provided via constructor or GOOGLE_CLOUD_PROJECT environment variable."
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
if (!this.location) {
|
|
88
|
-
throw new Error(
|
|
89
|
-
"VertexAI location must be provided via constructor or GOOGLE_CLOUD_LOCATION environment variable."
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
} else {
|
|
93
|
-
if (!this.apiKey && canReadEnv) {
|
|
94
|
-
this.apiKey = process.env["GOOGLE_GENAI_API_KEY"] || process.env["GEMINI_API_KEY"];
|
|
95
|
-
}
|
|
96
|
-
if (!this.apiKey) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
"API key must be provided via constructor or GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable."
|
|
99
|
-
);
|
|
100
|
-
}
|
|
66
|
+
const params = geminiInitParams({
|
|
67
|
+
model,
|
|
68
|
+
vertexai,
|
|
69
|
+
project,
|
|
70
|
+
location,
|
|
71
|
+
apiKey
|
|
72
|
+
});
|
|
73
|
+
if (!params.vertexai && !params.apiKey) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
"API key must be provided via constructor or GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable."
|
|
76
|
+
);
|
|
101
77
|
}
|
|
78
|
+
this.project = params.project;
|
|
79
|
+
this.location = params.location;
|
|
80
|
+
this.apiKey = params.apiKey;
|
|
81
|
+
this.headers = headers;
|
|
82
|
+
this.vertexai = !!params.vertexai;
|
|
102
83
|
}
|
|
103
84
|
/**
|
|
104
85
|
* Sends a request to the Gemini model.
|
|
@@ -198,22 +179,24 @@ class Gemini extends BaseLlm {
|
|
|
198
179
|
}
|
|
199
180
|
});
|
|
200
181
|
}
|
|
182
|
+
getHttpOptions() {
|
|
183
|
+
return { headers: __spreadValues(__spreadValues({}, this.trackingHeaders), this.headers) };
|
|
184
|
+
}
|
|
201
185
|
get apiClient() {
|
|
202
186
|
if (this._apiClient) {
|
|
203
187
|
return this._apiClient;
|
|
204
188
|
}
|
|
205
|
-
const combinedHeaders = __spreadValues(__spreadValues({}, this.trackingHeaders), this.headers);
|
|
206
189
|
if (this.vertexai) {
|
|
207
190
|
this._apiClient = new GoogleGenAI({
|
|
208
191
|
vertexai: this.vertexai,
|
|
209
192
|
project: this.project,
|
|
210
193
|
location: this.location,
|
|
211
|
-
httpOptions:
|
|
194
|
+
httpOptions: this.getHttpOptions()
|
|
212
195
|
});
|
|
213
196
|
} else {
|
|
214
197
|
this._apiClient = new GoogleGenAI({
|
|
215
198
|
apiKey: this.apiKey,
|
|
216
|
-
httpOptions:
|
|
199
|
+
httpOptions: this.getHttpOptions()
|
|
217
200
|
});
|
|
218
201
|
}
|
|
219
202
|
return this._apiClient;
|
|
@@ -230,14 +213,17 @@ class Gemini extends BaseLlm {
|
|
|
230
213
|
}
|
|
231
214
|
return this._liveApiVersion;
|
|
232
215
|
}
|
|
216
|
+
getLiveHttpOptions() {
|
|
217
|
+
return {
|
|
218
|
+
headers: this.trackingHeaders,
|
|
219
|
+
apiVersion: this.liveApiVersion
|
|
220
|
+
};
|
|
221
|
+
}
|
|
233
222
|
get liveApiClient() {
|
|
234
223
|
if (!this._liveApiClient) {
|
|
235
224
|
this._liveApiClient = new GoogleGenAI({
|
|
236
225
|
apiKey: this.apiKey,
|
|
237
|
-
httpOptions:
|
|
238
|
-
headers: this.trackingHeaders,
|
|
239
|
-
apiVersion: this.liveApiVersion
|
|
240
|
-
}
|
|
226
|
+
httpOptions: this.getLiveHttpOptions()
|
|
241
227
|
});
|
|
242
228
|
}
|
|
243
229
|
return this._liveApiClient;
|
|
@@ -264,7 +250,9 @@ class Gemini extends BaseLlm {
|
|
|
264
250
|
llmRequest.liveConnectConfig.systemInstruction = {
|
|
265
251
|
role: "system",
|
|
266
252
|
// TODO - b/425992518: validate type casting works well.
|
|
267
|
-
parts: [
|
|
253
|
+
parts: [
|
|
254
|
+
createPartFromText(llmRequest.config.systemInstruction)
|
|
255
|
+
]
|
|
268
256
|
};
|
|
269
257
|
}
|
|
270
258
|
llmRequest.liveConnectConfig.tools = (_c = llmRequest.config) == null ? void 0 : _c.tools;
|
|
@@ -313,6 +301,43 @@ function removeDisplayNameIfPresent(dataObj) {
|
|
|
313
301
|
dataObj.displayName = void 0;
|
|
314
302
|
}
|
|
315
303
|
}
|
|
304
|
+
function geminiInitParams({
|
|
305
|
+
model,
|
|
306
|
+
vertexai,
|
|
307
|
+
project,
|
|
308
|
+
location,
|
|
309
|
+
apiKey
|
|
310
|
+
}) {
|
|
311
|
+
const params = { model, vertexai, project, location, apiKey };
|
|
312
|
+
params.vertexai = !!vertexai;
|
|
313
|
+
if (!params.vertexai && !isBrowser()) {
|
|
314
|
+
params.vertexai = getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI");
|
|
315
|
+
}
|
|
316
|
+
if (params.vertexai) {
|
|
317
|
+
if (!isBrowser() && !params.project) {
|
|
318
|
+
params.project = process.env["GOOGLE_CLOUD_PROJECT"];
|
|
319
|
+
}
|
|
320
|
+
if (!isBrowser() && !params.location) {
|
|
321
|
+
params.location = process.env["GOOGLE_CLOUD_LOCATION"];
|
|
322
|
+
}
|
|
323
|
+
if (!params.project) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
"VertexAI project must be provided via constructor or GOOGLE_CLOUD_PROJECT environment variable."
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
if (!params.location) {
|
|
329
|
+
throw new Error(
|
|
330
|
+
"VertexAI location must be provided via constructor or GOOGLE_CLOUD_LOCATION environment variable."
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
if (!params.apiKey && !isBrowser()) {
|
|
335
|
+
params.apiKey = process.env["GOOGLE_GENAI_API_KEY"] || process.env["GEMINI_API_KEY"];
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return params;
|
|
339
|
+
}
|
|
316
340
|
export {
|
|
317
|
-
Gemini
|
|
341
|
+
Gemini,
|
|
342
|
+
geminiInitParams
|
|
318
343
|
};
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
|
+
import { ApigeeLlm } from "./apigee_llm.js";
|
|
7
8
|
import { Gemini } from "./google_llm.js";
|
|
8
9
|
class LRUCache {
|
|
9
10
|
constructor(maxSize) {
|
|
@@ -86,6 +87,7 @@ _LLMRegistry.llmRegistryDict = /* @__PURE__ */ new Map();
|
|
|
86
87
|
_LLMRegistry.resolveCache = new LRUCache(32);
|
|
87
88
|
let LLMRegistry = _LLMRegistry;
|
|
88
89
|
LLMRegistry.register(Gemini);
|
|
90
|
+
LLMRegistry.register(ApigeeLlm);
|
|
89
91
|
export {
|
|
90
92
|
LLMRegistry
|
|
91
93
|
};
|
|
@@ -25,6 +25,7 @@ class BasePlugin {
|
|
|
25
25
|
* value to replace the user message. Returning `undefined` to proceed
|
|
26
26
|
* normally.
|
|
27
27
|
*/
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
29
|
async onUserMessageCallback(params) {
|
|
29
30
|
return;
|
|
30
31
|
}
|
|
@@ -40,6 +41,7 @@ class BasePlugin {
|
|
|
40
41
|
* to halt execution of the runner and ends the runner with that event.
|
|
41
42
|
* Return `undefined` to proceed normally.
|
|
42
43
|
*/
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
43
45
|
async beforeRunCallback(params) {
|
|
44
46
|
return;
|
|
45
47
|
}
|
|
@@ -55,6 +57,7 @@ class BasePlugin {
|
|
|
55
57
|
* framework to modify or replace the response. Returning `undefined`
|
|
56
58
|
* allows the original response to be used.
|
|
57
59
|
*/
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
58
61
|
async onEventCallback(params) {
|
|
59
62
|
return;
|
|
60
63
|
}
|
|
@@ -67,6 +70,7 @@ class BasePlugin {
|
|
|
67
70
|
* @param params.invocationContext The context for the entire invocation.
|
|
68
71
|
* @returns undefined
|
|
69
72
|
*/
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
70
74
|
async afterRunCallback(params) {
|
|
71
75
|
return;
|
|
72
76
|
}
|
|
@@ -82,6 +86,7 @@ class BasePlugin {
|
|
|
82
86
|
* bypass the agent's callbacks and its execution, and return this value
|
|
83
87
|
* directly. Returning `undefined` allows the agent to proceed normally.
|
|
84
88
|
*/
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
85
90
|
async beforeAgentCallback(params) {
|
|
86
91
|
return;
|
|
87
92
|
}
|
|
@@ -97,6 +102,7 @@ class BasePlugin {
|
|
|
97
102
|
* replace the agent's original result. Returning `undefined` uses the
|
|
98
103
|
* original, unmodified result.
|
|
99
104
|
*/
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
100
106
|
async afterAgentCallback(params) {
|
|
101
107
|
return;
|
|
102
108
|
}
|
|
@@ -113,6 +119,7 @@ class BasePlugin {
|
|
|
113
119
|
* trigger an early exit and returns the response immediately. Returning
|
|
114
120
|
* `undefined` allows the LLM request to proceed normally.
|
|
115
121
|
*/
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
116
123
|
async beforeModelCallback(params) {
|
|
117
124
|
return;
|
|
118
125
|
}
|
|
@@ -128,6 +135,7 @@ class BasePlugin {
|
|
|
128
135
|
* framework to modify or replace the response. Returning `undefined`
|
|
129
136
|
* allows the original response to be used.
|
|
130
137
|
*/
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
139
|
async afterModelCallback(params) {
|
|
132
140
|
return;
|
|
133
141
|
}
|
|
@@ -145,6 +153,7 @@ class BasePlugin {
|
|
|
145
153
|
* used instead of propagating the error. Returning `undefined` allows
|
|
146
154
|
* the original error to be raised.
|
|
147
155
|
*/
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
148
157
|
async onModelErrorCallback(params) {
|
|
149
158
|
return;
|
|
150
159
|
}
|
|
@@ -162,6 +171,7 @@ class BasePlugin {
|
|
|
162
171
|
* the tool execution and return this response immediately. Returning
|
|
163
172
|
* `undefined` uses the original, unmodified arguments.
|
|
164
173
|
*/
|
|
174
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
165
175
|
async beforeToolCallback(params) {
|
|
166
176
|
return;
|
|
167
177
|
}
|
|
@@ -180,6 +190,7 @@ class BasePlugin {
|
|
|
180
190
|
* post-processing or altering tool outputs. Returning `undefined` uses
|
|
181
191
|
* the original, unmodified result.
|
|
182
192
|
*/
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
183
194
|
async afterToolCallback(params) {
|
|
184
195
|
return;
|
|
185
196
|
}
|
|
@@ -207,6 +218,7 @@ class BasePlugin {
|
|
|
207
218
|
* used as the tool response instead of propagating the error. Returning
|
|
208
219
|
* `undefined` allows the original error to be raised.
|
|
209
220
|
*/
|
|
221
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
210
222
|
async onToolErrorCallback(params) {
|
|
211
223
|
return;
|
|
212
224
|
}
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getFunctionCalls,
|
|
8
|
+
getFunctionResponses,
|
|
9
|
+
isFinalResponse
|
|
10
|
+
} from "../events/event.js";
|
|
7
11
|
import { logger } from "../utils/logger.js";
|
|
8
12
|
import { BasePlugin } from "./base_plugin.js";
|
|
9
13
|
class LoggingPlugin extends BasePlugin {
|
|
@@ -15,7 +19,10 @@ class LoggingPlugin extends BasePlugin {
|
|
|
15
19
|
constructor(name = "logging_plugin") {
|
|
16
20
|
super(name);
|
|
17
21
|
}
|
|
18
|
-
async onUserMessageCallback({
|
|
22
|
+
async onUserMessageCallback({
|
|
23
|
+
invocationContext,
|
|
24
|
+
userMessage
|
|
25
|
+
}) {
|
|
19
26
|
var _a;
|
|
20
27
|
this.log("\u{1F680} USER MESSAGE RECEIVED");
|
|
21
28
|
this.log(" Invocation ID: ".concat(invocationContext.invocationId));
|
|
@@ -29,14 +36,18 @@ class LoggingPlugin extends BasePlugin {
|
|
|
29
36
|
}
|
|
30
37
|
return void 0;
|
|
31
38
|
}
|
|
32
|
-
async beforeRunCallback({
|
|
39
|
+
async beforeRunCallback({
|
|
40
|
+
invocationContext
|
|
41
|
+
}) {
|
|
33
42
|
var _a;
|
|
34
43
|
this.log("\u{1F3C3} INVOCATION STARTING");
|
|
35
44
|
this.log(" Invocation ID: ".concat(invocationContext.invocationId));
|
|
36
45
|
this.log(" Starting Agent: ".concat((_a = invocationContext.agent.name) != null ? _a : "Unknown"));
|
|
37
46
|
return void 0;
|
|
38
47
|
}
|
|
39
|
-
async onEventCallback({
|
|
48
|
+
async onEventCallback({
|
|
49
|
+
event
|
|
50
|
+
}) {
|
|
40
51
|
this.log("\u{1F4E2} EVENT YIELDED");
|
|
41
52
|
this.log(" Event ID: ".concat(event.id));
|
|
42
53
|
this.log(" Author: ".concat(event.author));
|
|
@@ -57,14 +68,18 @@ class LoggingPlugin extends BasePlugin {
|
|
|
57
68
|
}
|
|
58
69
|
return void 0;
|
|
59
70
|
}
|
|
60
|
-
async afterRunCallback({
|
|
71
|
+
async afterRunCallback({
|
|
72
|
+
invocationContext
|
|
73
|
+
}) {
|
|
61
74
|
var _a;
|
|
62
75
|
this.log("\u2705 INVOCATION COMPLETED");
|
|
63
76
|
this.log(" Invocation ID: ".concat(invocationContext.invocationId));
|
|
64
77
|
this.log(" Final Agent: ".concat((_a = invocationContext.agent.name) != null ? _a : "Unknown"));
|
|
65
78
|
return void 0;
|
|
66
79
|
}
|
|
67
|
-
async beforeAgentCallback({
|
|
80
|
+
async beforeAgentCallback({
|
|
81
|
+
callbackContext
|
|
82
|
+
}) {
|
|
68
83
|
this.log("\u{1F916} AGENT STARTING");
|
|
69
84
|
this.log(" Agent Name: ".concat(callbackContext.agentName));
|
|
70
85
|
this.log(" Invocation ID: ".concat(callbackContext.invocationId));
|
|
@@ -73,13 +88,18 @@ class LoggingPlugin extends BasePlugin {
|
|
|
73
88
|
}
|
|
74
89
|
return void 0;
|
|
75
90
|
}
|
|
76
|
-
async afterAgentCallback({
|
|
91
|
+
async afterAgentCallback({
|
|
92
|
+
callbackContext
|
|
93
|
+
}) {
|
|
77
94
|
this.log("\u{1F916} AGENT COMPLETED");
|
|
78
95
|
this.log(" Agent Name: ".concat(callbackContext.agentName));
|
|
79
96
|
this.log(" Invocation ID: ".concat(callbackContext.invocationId));
|
|
80
97
|
return void 0;
|
|
81
98
|
}
|
|
82
|
-
async beforeModelCallback({
|
|
99
|
+
async beforeModelCallback({
|
|
100
|
+
callbackContext,
|
|
101
|
+
llmRequest
|
|
102
|
+
}) {
|
|
83
103
|
var _a;
|
|
84
104
|
this.log("\u{1F9E0} LLM REQUEST");
|
|
85
105
|
this.log(" Model: ".concat((_a = llmRequest.model) != null ? _a : "default"));
|
|
@@ -97,7 +117,10 @@ class LoggingPlugin extends BasePlugin {
|
|
|
97
117
|
}
|
|
98
118
|
return void 0;
|
|
99
119
|
}
|
|
100
|
-
async afterModelCallback({
|
|
120
|
+
async afterModelCallback({
|
|
121
|
+
callbackContext,
|
|
122
|
+
llmResponse
|
|
123
|
+
}) {
|
|
101
124
|
this.log("\u{1F9E0} LLM RESPONSE");
|
|
102
125
|
this.log(" Agent: ".concat(callbackContext.agentName));
|
|
103
126
|
if (llmResponse.errorCode) {
|
|
@@ -113,11 +136,17 @@ class LoggingPlugin extends BasePlugin {
|
|
|
113
136
|
}
|
|
114
137
|
}
|
|
115
138
|
if (llmResponse.usageMetadata) {
|
|
116
|
-
this.log(
|
|
139
|
+
this.log(
|
|
140
|
+
" Token Usage - Input: ".concat(llmResponse.usageMetadata.promptTokenCount, ", Output: ").concat(llmResponse.usageMetadata.candidatesTokenCount)
|
|
141
|
+
);
|
|
117
142
|
}
|
|
118
143
|
return void 0;
|
|
119
144
|
}
|
|
120
|
-
async beforeToolCallback({
|
|
145
|
+
async beforeToolCallback({
|
|
146
|
+
tool,
|
|
147
|
+
toolArgs,
|
|
148
|
+
toolContext
|
|
149
|
+
}) {
|
|
121
150
|
this.log("\u{1F527} TOOL STARTING");
|
|
122
151
|
this.log(" Tool Name: ".concat(tool.name));
|
|
123
152
|
this.log(" Agent: ".concat(toolContext.agentName));
|
|
@@ -125,7 +154,11 @@ class LoggingPlugin extends BasePlugin {
|
|
|
125
154
|
this.log(" Arguments: ".concat(this.formatArgs(toolArgs)));
|
|
126
155
|
return void 0;
|
|
127
156
|
}
|
|
128
|
-
async afterToolCallback({
|
|
157
|
+
async afterToolCallback({
|
|
158
|
+
tool,
|
|
159
|
+
toolContext,
|
|
160
|
+
result
|
|
161
|
+
}) {
|
|
129
162
|
this.log("\u{1F527} TOOL COMPLETED");
|
|
130
163
|
this.log(" Tool Name: ".concat(tool.name));
|
|
131
164
|
this.log(" Agent: ".concat(toolContext.agentName));
|
|
@@ -133,13 +166,21 @@ class LoggingPlugin extends BasePlugin {
|
|
|
133
166
|
this.log(" Result: ".concat(this.formatArgs(result)));
|
|
134
167
|
return void 0;
|
|
135
168
|
}
|
|
136
|
-
async onModelErrorCallback({
|
|
169
|
+
async onModelErrorCallback({
|
|
170
|
+
callbackContext,
|
|
171
|
+
error
|
|
172
|
+
}) {
|
|
137
173
|
this.log("\u{1F9E0} LLM ERROR");
|
|
138
174
|
this.log(" Agent: ".concat(callbackContext.agentName));
|
|
139
175
|
this.log(" Error: ".concat(error));
|
|
140
176
|
return void 0;
|
|
141
177
|
}
|
|
142
|
-
async onToolErrorCallback({
|
|
178
|
+
async onToolErrorCallback({
|
|
179
|
+
tool,
|
|
180
|
+
toolArgs,
|
|
181
|
+
toolContext,
|
|
182
|
+
error
|
|
183
|
+
}) {
|
|
143
184
|
this.log("\u{1F527} TOOL ERROR");
|
|
144
185
|
this.log(" Tool Name: ".concat(tool.name));
|
|
145
186
|
this.log(" Agent: ".concat(toolContext.agentName));
|
|
@@ -78,19 +78,22 @@ class PluginManager {
|
|
|
78
78
|
/**
|
|
79
79
|
* Runs the `onUserMessageCallback` for all plugins.
|
|
80
80
|
*/
|
|
81
|
-
async runOnUserMessageCallback({
|
|
81
|
+
async runOnUserMessageCallback({
|
|
82
|
+
userMessage,
|
|
83
|
+
invocationContext
|
|
84
|
+
}) {
|
|
82
85
|
return await this.runCallbacks(
|
|
83
86
|
this.plugins,
|
|
84
|
-
(plugin) => plugin.onUserMessageCallback(
|
|
85
|
-
{ userMessage, invocationContext }
|
|
86
|
-
),
|
|
87
|
+
(plugin) => plugin.onUserMessageCallback({ userMessage, invocationContext }),
|
|
87
88
|
"onUserMessageCallback"
|
|
88
89
|
);
|
|
89
90
|
}
|
|
90
91
|
/**
|
|
91
92
|
* Runs the `beforeRunCallback` for all plugins.
|
|
92
93
|
*/
|
|
93
|
-
async runBeforeRunCallback({
|
|
94
|
+
async runBeforeRunCallback({
|
|
95
|
+
invocationContext
|
|
96
|
+
}) {
|
|
94
97
|
return await this.runCallbacks(
|
|
95
98
|
this.plugins,
|
|
96
99
|
(plugin) => plugin.beforeRunCallback({ invocationContext }),
|
|
@@ -100,7 +103,9 @@ class PluginManager {
|
|
|
100
103
|
/**
|
|
101
104
|
* Runs the `afterRunCallback` for all plugins.
|
|
102
105
|
*/
|
|
103
|
-
async runAfterRunCallback({
|
|
106
|
+
async runAfterRunCallback({
|
|
107
|
+
invocationContext
|
|
108
|
+
}) {
|
|
104
109
|
await this.runCallbacks(
|
|
105
110
|
this.plugins,
|
|
106
111
|
(plugin) => plugin.afterRunCallback({ invocationContext }),
|
|
@@ -110,7 +115,10 @@ class PluginManager {
|
|
|
110
115
|
/**
|
|
111
116
|
* Runs the `onEventCallback` for all plugins.
|
|
112
117
|
*/
|
|
113
|
-
async runOnEventCallback({
|
|
118
|
+
async runOnEventCallback({
|
|
119
|
+
invocationContext,
|
|
120
|
+
event
|
|
121
|
+
}) {
|
|
114
122
|
return await this.runCallbacks(
|
|
115
123
|
this.plugins,
|
|
116
124
|
(plugin) => plugin.onEventCallback({ invocationContext, event }),
|
|
@@ -120,7 +128,10 @@ class PluginManager {
|
|
|
120
128
|
/**
|
|
121
129
|
* Runs the `beforeAgentCallback` for all plugins.
|
|
122
130
|
*/
|
|
123
|
-
async runBeforeAgentCallback({
|
|
131
|
+
async runBeforeAgentCallback({
|
|
132
|
+
agent,
|
|
133
|
+
callbackContext
|
|
134
|
+
}) {
|
|
124
135
|
return await this.runCallbacks(
|
|
125
136
|
this.plugins,
|
|
126
137
|
(plugin) => plugin.beforeAgentCallback({ agent, callbackContext }),
|
|
@@ -130,7 +141,10 @@ class PluginManager {
|
|
|
130
141
|
/**
|
|
131
142
|
* Runs the `afterAgentCallback` for all plugins.
|
|
132
143
|
*/
|
|
133
|
-
async runAfterAgentCallback({
|
|
144
|
+
async runAfterAgentCallback({
|
|
145
|
+
agent,
|
|
146
|
+
callbackContext
|
|
147
|
+
}) {
|
|
134
148
|
return await this.runCallbacks(
|
|
135
149
|
this.plugins,
|
|
136
150
|
(plugin) => plugin.afterAgentCallback({ agent, callbackContext }),
|
|
@@ -140,7 +154,11 @@ class PluginManager {
|
|
|
140
154
|
/**
|
|
141
155
|
* Runs the `beforeToolCallback` for all plugins.
|
|
142
156
|
*/
|
|
143
|
-
async runBeforeToolCallback({
|
|
157
|
+
async runBeforeToolCallback({
|
|
158
|
+
tool,
|
|
159
|
+
toolArgs,
|
|
160
|
+
toolContext
|
|
161
|
+
}) {
|
|
144
162
|
return await this.runCallbacks(
|
|
145
163
|
this.plugins,
|
|
146
164
|
(plugin) => plugin.beforeToolCallback({ tool, toolArgs, toolContext }),
|
|
@@ -150,31 +168,39 @@ class PluginManager {
|
|
|
150
168
|
/**
|
|
151
169
|
* Runs the `afterToolCallback` for all plugins.
|
|
152
170
|
*/
|
|
153
|
-
async runAfterToolCallback({
|
|
171
|
+
async runAfterToolCallback({
|
|
172
|
+
tool,
|
|
173
|
+
toolArgs,
|
|
174
|
+
toolContext,
|
|
175
|
+
result
|
|
176
|
+
}) {
|
|
154
177
|
return await this.runCallbacks(
|
|
155
178
|
this.plugins,
|
|
156
|
-
(plugin) => plugin.afterToolCallback(
|
|
157
|
-
{ tool, toolArgs, toolContext, result }
|
|
158
|
-
),
|
|
179
|
+
(plugin) => plugin.afterToolCallback({ tool, toolArgs, toolContext, result }),
|
|
159
180
|
"afterToolCallback"
|
|
160
181
|
);
|
|
161
182
|
}
|
|
162
183
|
/**
|
|
163
184
|
* Runs the `onModelErrorCallback` for all plugins.
|
|
164
185
|
*/
|
|
165
|
-
async runOnModelErrorCallback({
|
|
186
|
+
async runOnModelErrorCallback({
|
|
187
|
+
callbackContext,
|
|
188
|
+
llmRequest,
|
|
189
|
+
error
|
|
190
|
+
}) {
|
|
166
191
|
return await this.runCallbacks(
|
|
167
192
|
this.plugins,
|
|
168
|
-
(plugin) => plugin.onModelErrorCallback(
|
|
169
|
-
{ callbackContext, llmRequest, error }
|
|
170
|
-
),
|
|
193
|
+
(plugin) => plugin.onModelErrorCallback({ callbackContext, llmRequest, error }),
|
|
171
194
|
"onModelErrorCallback"
|
|
172
195
|
);
|
|
173
196
|
}
|
|
174
197
|
/**
|
|
175
198
|
* Runs the `beforeModelCallback` for all plugins.
|
|
176
199
|
*/
|
|
177
|
-
async runBeforeModelCallback({
|
|
200
|
+
async runBeforeModelCallback({
|
|
201
|
+
callbackContext,
|
|
202
|
+
llmRequest
|
|
203
|
+
}) {
|
|
178
204
|
return await this.runCallbacks(
|
|
179
205
|
this.plugins,
|
|
180
206
|
(plugin) => plugin.beforeModelCallback({ callbackContext, llmRequest }),
|
|
@@ -184,7 +210,10 @@ class PluginManager {
|
|
|
184
210
|
/**
|
|
185
211
|
* Runs the `afterModelCallback` for all plugins.
|
|
186
212
|
*/
|
|
187
|
-
async runAfterModelCallback({
|
|
213
|
+
async runAfterModelCallback({
|
|
214
|
+
callbackContext,
|
|
215
|
+
llmResponse
|
|
216
|
+
}) {
|
|
188
217
|
return await this.runCallbacks(
|
|
189
218
|
this.plugins,
|
|
190
219
|
(plugin) => plugin.afterModelCallback({ callbackContext, llmResponse }),
|
|
@@ -194,12 +223,15 @@ class PluginManager {
|
|
|
194
223
|
/**
|
|
195
224
|
* Runs the `onToolErrorCallback` for all plugins.
|
|
196
225
|
*/
|
|
197
|
-
async runOnToolErrorCallback({
|
|
226
|
+
async runOnToolErrorCallback({
|
|
227
|
+
tool,
|
|
228
|
+
toolArgs,
|
|
229
|
+
toolContext,
|
|
230
|
+
error
|
|
231
|
+
}) {
|
|
198
232
|
return await this.runCallbacks(
|
|
199
233
|
this.plugins,
|
|
200
|
-
(plugin) => plugin.onToolErrorCallback(
|
|
201
|
-
{ tool, toolArgs, toolContext, error }
|
|
202
|
-
),
|
|
234
|
+
(plugin) => plugin.onToolErrorCallback({ tool, toolArgs, toolContext, error }),
|
|
203
235
|
"onToolErrorCallback"
|
|
204
236
|
);
|
|
205
237
|
}
|
|
@@ -14,7 +14,7 @@ var PolicyOutcome = /* @__PURE__ */ ((PolicyOutcome2) => {
|
|
|
14
14
|
return PolicyOutcome2;
|
|
15
15
|
})(PolicyOutcome || {});
|
|
16
16
|
class InMemoryPolicyEngine {
|
|
17
|
-
async evaluate(
|
|
17
|
+
async evaluate() {
|
|
18
18
|
return Promise.resolve({
|
|
19
19
|
outcome: "ALLOW" /* ALLOW */,
|
|
20
20
|
reason: "For prototyping purpose, all tool calls are allowed."
|