@google/adk 0.3.0 → 0.5.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_event.js +290 -0
- package/dist/cjs/a2a/event_converter_utils.js +201 -0
- package/dist/cjs/a2a/executor_context.js +53 -0
- package/dist/cjs/a2a/metadata_converter_utils.js +125 -0
- package/dist/cjs/a2a/part_converter_utils.js +212 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +6 -6
- package/dist/cjs/agents/content_processor_utils.js +1 -1
- package/dist/cjs/{tools/tool_context.js → agents/context.js} +71 -16
- package/dist/cjs/agents/functions.js +4 -3
- 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 +76 -711
- package/dist/cjs/agents/loop_agent.js +1 -1
- package/dist/cjs/agents/parallel_agent.js +1 -1
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +132 -0
- package/dist/cjs/agents/{base_llm_processor.js → processors/base_llm_processor.js} +1 -1
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +68 -0
- package/dist/cjs/agents/processors/code_execution_request_processor.js +389 -0
- package/dist/cjs/agents/processors/content_request_processor.js +66 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +54 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +85 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +165 -0
- 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 +127 -48
- package/dist/cjs/artifacts/in_memory_artifact_service.js +54 -6
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +1 -1
- 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 +1 -1
- package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +1 -1
- package/dist/cjs/common.js +25 -8
- package/dist/cjs/events/event.js +33 -4
- 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 +24 -17
- package/dist/cjs/index.js.map +4 -4
- 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 +1 -1
- 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 +1 -1
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +1 -1
- package/dist/cjs/models/google_llm.js +70 -51
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +3 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +2 -2
- package/dist/cjs/plugins/logging_plugin.js +1 -1
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/security_plugin.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +33 -2
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +367 -0
- package/dist/cjs/sessions/db/operations.js +126 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +24 -22
- 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 +1 -1
- package/dist/cjs/telemetry/setup.js +1 -1
- package/dist/cjs/telemetry/tracing.js +1 -1
- package/dist/cjs/tools/agent_tool.js +1 -1
- package/dist/cjs/tools/base_tool.js +4 -1
- package/dist/cjs/tools/base_toolset.js +14 -4
- package/dist/cjs/tools/exit_loop_tool.js +63 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +17 -1
- package/dist/cjs/tools/function_tool.js +1 -1
- package/dist/cjs/tools/google_search_tool.js +1 -1
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +1 -1
- package/dist/cjs/tools/mcp/mcp_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_toolset.js +10 -6
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +10 -1
- package/dist/cjs/utils/gemini_schema_util.js +1 -1
- package/dist/cjs/utils/logger.js +62 -55
- 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 +1 -1
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- package/dist/esm/a2a/a2a_event.js +243 -0
- package/dist/esm/a2a/event_converter_utils.js +187 -0
- package/dist/esm/a2a/executor_context.js +23 -0
- package/dist/esm/a2a/metadata_converter_utils.js +90 -0
- package/dist/esm/a2a/part_converter_utils.js +175 -0
- package/dist/esm/agents/base_agent.js +5 -5
- package/dist/esm/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +3 -2
- package/dist/esm/agents/llm_agent.js +69 -720
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +101 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +37 -0
- package/dist/esm/agents/processors/code_execution_request_processor.js +363 -0
- package/dist/esm/agents/processors/content_request_processor.js +38 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +23 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +54 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +140 -0
- 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 +126 -47
- package/dist/esm/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/common.js +20 -10
- package/dist/esm/events/event.js +29 -2
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +24 -17
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/google_llm.js +67 -49
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +32 -1
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +353 -0
- package/dist/esm/sessions/db/operations.js +111 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +23 -21
- package/dist/esm/sessions/registry.js +25 -0
- package/dist/esm/tools/base_tool.js +3 -0
- package/dist/esm/tools/base_toolset.js +11 -2
- package/dist/esm/tools/exit_loop_tool.js +32 -0
- package/dist/esm/tools/forwarding_artifact_service.js +16 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +9 -5
- package/dist/esm/utils/env_aware_utils.js +8 -0
- package/dist/esm/utils/logger.js +51 -54
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/variant_utils.js +1 -7
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_event.d.ts +122 -0
- package/dist/types/a2a/event_converter_utils.d.ts +20 -0
- package/dist/types/a2a/executor_context.d.ts +33 -0
- package/dist/types/a2a/metadata_converter_utils.d.ts +62 -0
- package/dist/types/a2a/part_converter_utils.d.ts +48 -0
- package/dist/types/agents/base_agent.d.ts +2 -2
- package/dist/types/{tools/tool_context.d.ts → agents/context.d.ts} +43 -8
- package/dist/types/agents/llm_agent.d.ts +19 -42
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +18 -0
- package/dist/types/agents/{base_llm_processor.d.ts → processors/base_llm_processor.d.ts} +4 -4
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/code_execution_request_processor.d.ts +34 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/instructions_llm_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +13 -0
- 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 +5 -2
- package/dist/types/artifacts/registry.d.ts +7 -0
- package/dist/types/auth/credential_service/base_credential_service.d.ts +3 -3
- package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +3 -3
- package/dist/types/common.d.ts +15 -6
- 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 +5 -1
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/google_llm.d.ts +5 -2
- package/dist/types/models/llm_response.d.ts +5 -1
- package/dist/types/plugins/base_plugin.d.ts +12 -13
- package/dist/types/plugins/logging_plugin.d.ts +9 -10
- package/dist/types/plugins/plugin_manager.d.ts +9 -10
- package/dist/types/plugins/security_plugin.d.ts +2 -2
- package/dist/types/runner/runner.d.ts +15 -0
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +32 -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 +4 -1
- package/dist/types/sessions/registry.d.ts +7 -0
- package/dist/types/tools/base_tool.d.ts +3 -3
- package/dist/types/tools/base_toolset.d.ts +12 -3
- package/dist/types/tools/exit_loop_tool.d.ts +24 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +5 -3
- package/dist/types/tools/function_tool.d.ts +2 -2
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -1
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_event.js +243 -0
- package/dist/web/a2a/event_converter_utils.js +201 -0
- package/dist/web/a2a/executor_context.js +23 -0
- package/dist/web/a2a/metadata_converter_utils.js +107 -0
- package/dist/web/a2a/part_converter_utils.js +175 -0
- package/dist/web/agents/base_agent.js +5 -5
- package/dist/web/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/web/agents/functions.js +3 -2
- package/dist/web/agents/llm_agent.js +90 -717
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +100 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +71 -0
- package/dist/web/agents/processors/code_execution_request_processor.js +365 -0
- package/dist/web/agents/processors/content_request_processor.js +56 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +41 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +72 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +158 -0
- 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 +123 -46
- package/dist/web/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/common.js +20 -10
- package/dist/web/events/event.js +29 -2
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +7 -2
- package/dist/web/index.js.map +4 -4
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/google_llm.js +67 -46
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +34 -1
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +371 -0
- package/dist/web/sessions/db/operations.js +111 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +23 -21
- package/dist/web/sessions/registry.js +25 -0
- package/dist/web/tools/base_tool.js +3 -0
- package/dist/web/tools/base_toolset.js +11 -2
- package/dist/web/tools/exit_loop_tool.js +32 -0
- package/dist/web/tools/forwarding_artifact_service.js +16 -0
- package/dist/web/tools/mcp/mcp_toolset.js +27 -5
- package/dist/web/utils/env_aware_utils.js +8 -0
- package/dist/web/utils/logger.js +51 -54
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +13 -3
- package/dist/cjs/agents/callback_context.js +0 -101
- package/dist/esm/agents/callback_context.js +0 -71
- package/dist/types/agents/callback_context.d.ts +0 -42
- package/dist/web/agents/callback_context.js +0 -71
- /package/dist/esm/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
- /package/dist/web/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { Context } from '../../agents/context.js';
|
|
7
7
|
import { AuthCredential } from '../auth_credential.js';
|
|
8
8
|
import { AuthConfig } from '../auth_tool.js';
|
|
9
9
|
/**
|
|
@@ -22,6 +22,6 @@ export interface BaseCredentialService {
|
|
|
22
22
|
* trying to load the credential.
|
|
23
23
|
* @return A promise that resolves to the credential saved in the store.
|
|
24
24
|
*/
|
|
25
|
-
loadCredential(authConfig: AuthConfig, toolContext:
|
|
26
|
-
saveCredential(authConfig: AuthConfig, toolContext:
|
|
25
|
+
loadCredential(authConfig: AuthConfig, toolContext: Context): Promise<AuthCredential | undefined>;
|
|
26
|
+
saveCredential(authConfig: AuthConfig, toolContext: Context): Promise<void>;
|
|
27
27
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { Context } from '../../agents/context.js';
|
|
7
7
|
import { AuthCredential } from '../auth_credential.js';
|
|
8
8
|
import { AuthConfig } from '../auth_tool.js';
|
|
9
9
|
import { BaseCredentialService } from './base_credential_service.js';
|
|
@@ -13,7 +13,7 @@ import { BaseCredentialService } from './base_credential_service.js';
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class InMemoryCredentialService implements BaseCredentialService {
|
|
15
15
|
private readonly credentials;
|
|
16
|
-
loadCredential(authConfig: AuthConfig, toolContext:
|
|
17
|
-
saveCredential(authConfig: AuthConfig, toolContext:
|
|
16
|
+
loadCredential(authConfig: AuthConfig, toolContext: Context): Promise<AuthCredential | undefined>;
|
|
17
|
+
saveCredential(authConfig: AuthConfig, toolContext: Context): Promise<void>;
|
|
18
18
|
private getBucketForCurrentContext;
|
|
19
19
|
}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -7,23 +7,24 @@ export { ActiveStreamingTool } from './agents/active_streaming_tool.js';
|
|
|
7
7
|
export type { ActiveStreamingToolParams } from './agents/active_streaming_tool.js';
|
|
8
8
|
export { BaseAgent, isBaseAgent } from './agents/base_agent.js';
|
|
9
9
|
export type { AfterAgentCallback, BaseAgentConfig, BeforeAgentCallback, SingleAgentCallback, } from './agents/base_agent.js';
|
|
10
|
-
export {
|
|
11
|
-
export { CallbackContext } from './agents/callback_context.js';
|
|
10
|
+
export { Context } from './agents/context.js';
|
|
12
11
|
export { functionsExportedForTestingOnly } from './agents/functions.js';
|
|
13
12
|
export { InvocationContext } from './agents/invocation_context.js';
|
|
14
13
|
export type { InvocationContextParams } from './agents/invocation_context.js';
|
|
15
14
|
export { LiveRequestQueue } from './agents/live_request_queue.js';
|
|
16
15
|
export type { LiveRequest } from './agents/live_request_queue.js';
|
|
17
16
|
export { LlmAgent, isLlmAgent } from './agents/llm_agent.js';
|
|
18
|
-
export type { AfterModelCallback, AfterToolCallback, BeforeModelCallback, BeforeToolCallback, InstructionProvider, LlmAgentConfig, SingleAfterModelCallback, SingleAfterToolCallback, SingleBeforeModelCallback, SingleBeforeToolCallback, ToolUnion, } from './agents/llm_agent.js';
|
|
17
|
+
export type { AfterModelCallback, AfterToolCallback, BeforeModelCallback, BeforeToolCallback, InstructionProvider, LlmAgentConfig, LlmAgentSchema, SingleAfterModelCallback, SingleAfterToolCallback, SingleBeforeModelCallback, SingleBeforeToolCallback, ToolUnion, } from './agents/llm_agent.js';
|
|
19
18
|
export { LoopAgent, isLoopAgent } from './agents/loop_agent.js';
|
|
20
19
|
export type { LoopAgentConfig } from './agents/loop_agent.js';
|
|
21
20
|
export { ParallelAgent, isParallelAgent } from './agents/parallel_agent.js';
|
|
21
|
+
export { BaseLlmRequestProcessor, BaseLlmResponseProcessor, } from './agents/processors/base_llm_processor.js';
|
|
22
22
|
export { ReadonlyContext } from './agents/readonly_context.js';
|
|
23
23
|
export { StreamingMode } from './agents/run_config.js';
|
|
24
24
|
export type { RunConfig } from './agents/run_config.js';
|
|
25
25
|
export { SequentialAgent, isSequentialAgent } from './agents/sequential_agent.js';
|
|
26
26
|
export type { TranscriptionEntry } from './agents/transcription_entry.js';
|
|
27
|
+
export type { BaseArtifactService, DeleteArtifactRequest, ListArtifactKeysRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest, } from './artifacts/base_artifact_service.js';
|
|
27
28
|
export { InMemoryArtifactService } from './artifacts/in_memory_artifact_service.js';
|
|
28
29
|
export { AuthCredentialTypes } from './auth/auth_credential.js';
|
|
29
30
|
export type { AuthCredential, HttpAuth, HttpCredentials, OAuth2Auth, ServiceAccount, ServiceAccountCredential, } from './auth/auth_credential.js';
|
|
@@ -38,13 +39,18 @@ export { createEvent, getFunctionCalls, getFunctionResponses, hasTrailingCodeExe
|
|
|
38
39
|
export type { Event } from './events/event.js';
|
|
39
40
|
export { createEventActions } from './events/event_actions.js';
|
|
40
41
|
export type { EventActions } from './events/event_actions.js';
|
|
42
|
+
export { EventType, toStructuredEvents } from './events/structured_events.js';
|
|
43
|
+
export type { ActivityEvent, CallCodeEvent, CodeResultEvent, ContentEvent, ErrorEvent, FinishedEvent, StructuredEvent, ThoughtEvent, ToolCallEvent, ToolConfirmationEvent, ToolResultEvent, } from './events/structured_events.js';
|
|
41
44
|
export { BaseExampleProvider, isBaseExampleProvider, } from './examples/base_example_provider.js';
|
|
42
45
|
export type { Example } from './examples/example.js';
|
|
46
|
+
export type { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse, } from './memory/base_memory_service.js';
|
|
43
47
|
export { InMemoryMemoryService } from './memory/in_memory_memory_service.js';
|
|
44
48
|
export type { MemoryEntry } from './memory/memory_entry.js';
|
|
49
|
+
export { ApigeeLlm } from './models/apigee_llm.js';
|
|
50
|
+
export type { ApigeeLlmParams } from './models/apigee_llm.js';
|
|
45
51
|
export { BaseLlm, isBaseLlm } from './models/base_llm.js';
|
|
46
52
|
export type { BaseLlmConnection } from './models/base_llm_connection.js';
|
|
47
|
-
export { Gemini } from './models/google_llm.js';
|
|
53
|
+
export { Gemini, geminiInitParams } from './models/google_llm.js';
|
|
48
54
|
export type { GeminiParams } from './models/google_llm.js';
|
|
49
55
|
export type { LlmRequest } from './models/llm_request.js';
|
|
50
56
|
export type { LlmResponse } from './models/llm_response.js';
|
|
@@ -58,6 +64,8 @@ export type { BasePolicyEngine, PolicyCheckResult, ToolCallPolicyContext, } from
|
|
|
58
64
|
export { InMemoryRunner } from './runner/in_memory_runner.js';
|
|
59
65
|
export { Runner } from './runner/runner.js';
|
|
60
66
|
export type { RunnerConfig } from './runner/runner.js';
|
|
67
|
+
export { BaseSessionService } from './sessions/base_session_service.js';
|
|
68
|
+
export type { AppendEventRequest, CreateSessionRequest, DeleteSessionRequest, GetSessionConfig, GetSessionRequest, ListSessionsRequest, ListSessionsResponse, } from './sessions/base_session_service.js';
|
|
61
69
|
export { InMemorySessionService } from './sessions/in_memory_session_service.js';
|
|
62
70
|
export { createSession } from './sessions/session.js';
|
|
63
71
|
export type { Session } from './sessions/session.js';
|
|
@@ -65,14 +73,15 @@ export { State } from './sessions/state.js';
|
|
|
65
73
|
export { AgentTool, isAgentTool } from './tools/agent_tool.js';
|
|
66
74
|
export type { AgentToolConfig } from './tools/agent_tool.js';
|
|
67
75
|
export { BaseTool, isBaseTool } from './tools/base_tool.js';
|
|
68
|
-
export {
|
|
76
|
+
export type { BaseToolParams, RunAsyncToolRequest, ToolProcessLlmRequest, } from './tools/base_tool.js';
|
|
77
|
+
export { BaseToolset, isBaseToolset } from './tools/base_toolset.js';
|
|
69
78
|
export type { ToolPredicate } from './tools/base_toolset.js';
|
|
79
|
+
export { EXIT_LOOP, ExitLoopTool } from './tools/exit_loop_tool.js';
|
|
70
80
|
export { FunctionTool, isFunctionTool } from './tools/function_tool.js';
|
|
71
81
|
export type { ToolExecuteArgument, ToolExecuteFunction, ToolInputParameters, ToolOptions, } from './tools/function_tool.js';
|
|
72
82
|
export { GOOGLE_SEARCH, GoogleSearchTool } from './tools/google_search_tool.js';
|
|
73
83
|
export { LongRunningFunctionTool } from './tools/long_running_tool.js';
|
|
74
84
|
export { ToolConfirmation } from './tools/tool_confirmation.js';
|
|
75
|
-
export { ToolContext } from './tools/tool_context.js';
|
|
76
85
|
export { LogLevel, getLogger, setLogLevel, setLogger } from './utils/logger.js';
|
|
77
86
|
export type { Logger } from './utils/logger.js';
|
|
78
87
|
export { isGemini2OrAbove } from './utils/model_name.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { FunctionCall, FunctionResponse } from '@google/genai';
|
|
@@ -86,3 +86,17 @@ export declare function stringifyContent(event: Event): string;
|
|
|
86
86
|
* Generates a new unique ID for the event.
|
|
87
87
|
*/
|
|
88
88
|
export declare function createNewEventId(): string;
|
|
89
|
+
/**
|
|
90
|
+
* Transforms a snake_cased event object to a camelCased Event object.
|
|
91
|
+
*
|
|
92
|
+
* @param event The snake_cased event object.
|
|
93
|
+
* @returns The camelCased Event object.
|
|
94
|
+
*/
|
|
95
|
+
export declare function transformToCamelCaseEvent(event: Record<string, unknown>): Event;
|
|
96
|
+
/**
|
|
97
|
+
* Transforms a camelCased event object to a snake_cased Event object.
|
|
98
|
+
*
|
|
99
|
+
* @param event The camelCased event object.
|
|
100
|
+
* @returns The snake_cased Event object.
|
|
101
|
+
*/
|
|
102
|
+
export declare function transformToSnakeCaseEvent(event: Event): Record<string, unknown>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CodeExecutionResult, ExecutableCode, FunctionCall, FunctionResponse } from '@google/genai';
|
|
7
|
+
import { Event } from './event.js';
|
|
8
|
+
/**
|
|
9
|
+
* The types of events that can be parsed from a raw Event.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum EventType {
|
|
12
|
+
THOUGHT = "thought",
|
|
13
|
+
CONTENT = "content",
|
|
14
|
+
TOOL_CALL = "tool_call",
|
|
15
|
+
TOOL_RESULT = "tool_result",
|
|
16
|
+
CALL_CODE = "call_code",
|
|
17
|
+
CODE_RESULT = "code_result",
|
|
18
|
+
ERROR = "error",
|
|
19
|
+
ACTIVITY = "activity",
|
|
20
|
+
TOOL_CONFIRMATION = "tool_confirmation",
|
|
21
|
+
FINISHED = "finished"
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Represents a reasoning trace (thought) from the agent.
|
|
25
|
+
*/
|
|
26
|
+
export interface ThoughtEvent {
|
|
27
|
+
type: EventType.THOUGHT;
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Represents partial content (text delta) intended for the user.
|
|
32
|
+
*/
|
|
33
|
+
export interface ContentEvent {
|
|
34
|
+
type: EventType.CONTENT;
|
|
35
|
+
content: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents a request to execute a tool.
|
|
39
|
+
*/
|
|
40
|
+
export interface ToolCallEvent {
|
|
41
|
+
type: EventType.TOOL_CALL;
|
|
42
|
+
call: FunctionCall;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Represents the result of a tool execution.
|
|
46
|
+
*/
|
|
47
|
+
export interface ToolResultEvent {
|
|
48
|
+
type: EventType.TOOL_RESULT;
|
|
49
|
+
result: FunctionResponse;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Represents a request to execute code.
|
|
53
|
+
*/
|
|
54
|
+
export interface CallCodeEvent {
|
|
55
|
+
type: EventType.CALL_CODE;
|
|
56
|
+
code: ExecutableCode;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Represents the result of code execution.
|
|
60
|
+
*/
|
|
61
|
+
export interface CodeResultEvent {
|
|
62
|
+
type: EventType.CODE_RESULT;
|
|
63
|
+
result: CodeExecutionResult;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Represents a runtime error.
|
|
67
|
+
*/
|
|
68
|
+
export interface ErrorEvent {
|
|
69
|
+
type: EventType.ERROR;
|
|
70
|
+
error: Error;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Represents a generic activity or status update.
|
|
74
|
+
*/
|
|
75
|
+
export interface ActivityEvent {
|
|
76
|
+
type: EventType.ACTIVITY;
|
|
77
|
+
kind: string;
|
|
78
|
+
detail: Record<string, unknown>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Represents a request for tool confirmation.
|
|
82
|
+
*/
|
|
83
|
+
export interface ToolConfirmationEvent {
|
|
84
|
+
type: EventType.TOOL_CONFIRMATION;
|
|
85
|
+
confirmations: Record<string, unknown>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Represents the final completion of the agent's task.
|
|
89
|
+
*/
|
|
90
|
+
export interface FinishedEvent {
|
|
91
|
+
type: EventType.FINISHED;
|
|
92
|
+
output?: unknown;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A standard structured event parsed from the raw Event stream.
|
|
96
|
+
*/
|
|
97
|
+
export type StructuredEvent = ThoughtEvent | ContentEvent | ToolCallEvent | ToolResultEvent | CallCodeEvent | CodeResultEvent | ErrorEvent | ActivityEvent | ToolConfirmationEvent | FinishedEvent;
|
|
98
|
+
/**
|
|
99
|
+
* Converts an internal Event to a list of structured events.
|
|
100
|
+
* This is an optional utility for callers who want to easily identify
|
|
101
|
+
* the type of event they are handling.
|
|
102
|
+
*
|
|
103
|
+
* @param event - The raw event to convert.
|
|
104
|
+
* @returns The structured events.
|
|
105
|
+
*/
|
|
106
|
+
export declare function toStructuredEvents(event: Event): StructuredEvent[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,8 +3,12 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export { FileArtifactService } from './artifacts/file_artifact_service.js';
|
|
7
|
+
export { GcsArtifactService } from './artifacts/gcs_artifact_service.js';
|
|
8
|
+
export { getArtifactServiceFromUri } from './artifacts/registry.js';
|
|
7
9
|
export * from './common.js';
|
|
10
|
+
export { DatabaseSessionService } from './sessions/database_session_service.js';
|
|
11
|
+
export { getSessionServiceFromUri } from './sessions/registry.js';
|
|
8
12
|
export * from './telemetry/google_cloud.js';
|
|
9
13
|
export * from './telemetry/setup.js';
|
|
10
14
|
export * from './tools/mcp/mcp_session_manager.js';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { HttpOptions } from '@google/genai';
|
|
7
|
+
import { BaseLlmConnection } from './base_llm_connection.js';
|
|
8
|
+
import { Gemini, GeminiParams } from './google_llm.js';
|
|
9
|
+
import { LlmRequest } from './llm_request.js';
|
|
10
|
+
import { LlmResponse } from './llm_response.js';
|
|
11
|
+
export interface ApigeeLlmParams extends GeminiParams {
|
|
12
|
+
/**
|
|
13
|
+
* The name of the model to use. The model string specifies the LLM provider
|
|
14
|
+
* (e.g., Vertex AI, Gemini), API version, and the model ID. Supported format:
|
|
15
|
+
* `apigee/[<provider>/][<version>/]<model_id>`
|
|
16
|
+
* Components:
|
|
17
|
+
* `provider` (optional): `vertex_ai` or `gemini`.
|
|
18
|
+
* `version` (optional): The API version (e.g., `v1`, `v1beta`). If not
|
|
19
|
+
* provided, a default version will selected based on the provider.
|
|
20
|
+
* `model_id` (required): The model identifier (e.g.,
|
|
21
|
+
* `gemini-2.5-flash`).
|
|
22
|
+
* Examples:
|
|
23
|
+
* - `apigee/gemini-2.5-flash`
|
|
24
|
+
* - `apigee/v1/gemini-2.5-flash`
|
|
25
|
+
* - `apigee/vertex_ai/gemini-2.5-flash`
|
|
26
|
+
* - `apigee/gemini/v1/gemini-2.5-flash`
|
|
27
|
+
* - `apigee/vertex_ai/v1beta/gemini-2.5-flash`
|
|
28
|
+
*/
|
|
29
|
+
model: string;
|
|
30
|
+
/**
|
|
31
|
+
* The proxy URL for the provider API. If not provided, it will look for
|
|
32
|
+
* the APIGEE_PROXY_URL environment variable.
|
|
33
|
+
*/
|
|
34
|
+
proxyUrl?: string;
|
|
35
|
+
/**
|
|
36
|
+
* API key to use. If not provided, it will look for
|
|
37
|
+
* the GOOGLE_GENAI_API_KEY or GEMINI_API_KEY environment variable. If gemini
|
|
38
|
+
* provider is selected and no key is provided, the fake key "-" will be
|
|
39
|
+
* used for the "x-goog-api-key" header.
|
|
40
|
+
*/
|
|
41
|
+
apiKey?: string;
|
|
42
|
+
}
|
|
43
|
+
export declare class ApigeeLlm extends Gemini {
|
|
44
|
+
private readonly proxyUrl;
|
|
45
|
+
/**
|
|
46
|
+
* A list of model name patterns that are supported by this LLM.
|
|
47
|
+
*
|
|
48
|
+
* @returns A list of supported models.
|
|
49
|
+
*/
|
|
50
|
+
static readonly supportedModels: Array<string | RegExp>;
|
|
51
|
+
constructor({ model, proxyUrl, apiKey, vertexai, location, project, headers, }: ApigeeLlmParams);
|
|
52
|
+
protected getHttpOptions(): HttpOptions;
|
|
53
|
+
protected getLiveHttpOptions(): HttpOptions;
|
|
54
|
+
private identifyApiVersion;
|
|
55
|
+
private _apigeeLiveApiVersion?;
|
|
56
|
+
get liveApiVersion(): string;
|
|
57
|
+
generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void>;
|
|
58
|
+
connect(llmRequest: LlmRequest): Promise<BaseLlmConnection>;
|
|
59
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { GoogleGenAI } from '@google/genai';
|
|
6
|
+
import { GoogleGenAI, HttpOptions } from '@google/genai';
|
|
7
7
|
import { GoogleLLMVariant } from '../utils/variant_utils.js';
|
|
8
8
|
import { BaseLlm } from './base_llm.js';
|
|
9
9
|
import { BaseLlmConnection } from './base_llm_connection.js';
|
|
@@ -45,7 +45,7 @@ export interface GeminiParams {
|
|
|
45
45
|
*/
|
|
46
46
|
export declare class Gemini extends BaseLlm {
|
|
47
47
|
private readonly apiKey?;
|
|
48
|
-
|
|
48
|
+
protected readonly vertexai: boolean;
|
|
49
49
|
private readonly project?;
|
|
50
50
|
private readonly location?;
|
|
51
51
|
private readonly headers?;
|
|
@@ -72,9 +72,11 @@ export declare class Gemini extends BaseLlm {
|
|
|
72
72
|
* @yields LlmResponse: The model response.
|
|
73
73
|
*/
|
|
74
74
|
generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void>;
|
|
75
|
+
protected getHttpOptions(): HttpOptions;
|
|
75
76
|
get apiClient(): GoogleGenAI;
|
|
76
77
|
get apiBackend(): GoogleLLMVariant;
|
|
77
78
|
get liveApiVersion(): string;
|
|
79
|
+
protected getLiveHttpOptions(): HttpOptions;
|
|
78
80
|
get liveApiClient(): GoogleGenAI;
|
|
79
81
|
/**
|
|
80
82
|
* Connects to the Gemini model and returns an llm connection.
|
|
@@ -85,3 +87,4 @@ export declare class Gemini extends BaseLlm {
|
|
|
85
87
|
connect(llmRequest: LlmRequest): Promise<BaseLlmConnection>;
|
|
86
88
|
private preprocessRequest;
|
|
87
89
|
}
|
|
90
|
+
export declare function geminiInitParams({ model, vertexai, project, location, apiKey, }: GeminiParams): GeminiParams;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { Content, FinishReason, GenerateContentResponse, GenerateContentResponseUsageMetadata, GroundingMetadata, LiveServerSessionResumptionUpdate, Transcription } from '@google/genai';
|
|
6
|
+
import { CitationMetadata, Content, FinishReason, GenerateContentResponse, GenerateContentResponseUsageMetadata, GroundingMetadata, LiveServerSessionResumptionUpdate, Transcription } from '@google/genai';
|
|
7
7
|
/**
|
|
8
8
|
* LLM response class that provides the first candidate response from the
|
|
9
9
|
* model if available. Otherwise, returns error code and message.
|
|
@@ -17,6 +17,10 @@ export interface LlmResponse {
|
|
|
17
17
|
* The grounding metadata of the response.
|
|
18
18
|
*/
|
|
19
19
|
groundingMetadata?: GroundingMetadata;
|
|
20
|
+
/**
|
|
21
|
+
* The citation metadata of the response.
|
|
22
|
+
*/
|
|
23
|
+
citationMetadata?: CitationMetadata;
|
|
20
24
|
/**
|
|
21
25
|
* Indicates whether the text content is part of a unfinished text stream.
|
|
22
26
|
* Only used for streaming mode and when the content is plain text.
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Content } from '@google/genai';
|
|
7
7
|
import { BaseAgent } from '../agents/base_agent.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
9
|
import { InvocationContext } from '../agents/invocation_context.js';
|
|
10
10
|
import { Event } from '../events/event.js';
|
|
11
11
|
import { LlmRequest } from '../models/llm_request.js';
|
|
12
12
|
import { LlmResponse } from '../models/llm_response.js';
|
|
13
13
|
import { BaseTool } from '../tools/base_tool.js';
|
|
14
|
-
import { ToolContext } from '../tools/tool_context.js';
|
|
15
14
|
/**
|
|
16
15
|
* Base class for creating plugins.
|
|
17
16
|
*
|
|
@@ -60,7 +59,7 @@ import { ToolContext } from '../tools/tool_context.js';
|
|
|
60
59
|
* {tool, toolArgs, toolContext}: {
|
|
61
60
|
* tool: BaseTool,
|
|
62
61
|
* toolArgs: Record<string, unknown>,
|
|
63
|
-
* toolContext:
|
|
62
|
+
* toolContext: Context,
|
|
64
63
|
* },
|
|
65
64
|
* ): Promise<Record<string, unknown> | undefined> {
|
|
66
65
|
* this.logger.info(
|
|
@@ -75,7 +74,7 @@ import { ToolContext } from '../tools/tool_context.js';
|
|
|
75
74
|
* {tool, toolArgs, toolContext, result}: {
|
|
76
75
|
* tool: BaseTool,
|
|
77
76
|
* toolArgs: Record<string, unknown>,
|
|
78
|
-
* toolContext:
|
|
77
|
+
* toolContext: Context,
|
|
79
78
|
* result: Record<string, unknown>,
|
|
80
79
|
* },
|
|
81
80
|
* ): Promise<Record<string, unknown> | undefined> {
|
|
@@ -177,7 +176,7 @@ export declare abstract class BasePlugin {
|
|
|
177
176
|
*/
|
|
178
177
|
beforeAgentCallback(params: {
|
|
179
178
|
agent: BaseAgent;
|
|
180
|
-
callbackContext:
|
|
179
|
+
callbackContext: Context;
|
|
181
180
|
}): Promise<Content | undefined>;
|
|
182
181
|
/**
|
|
183
182
|
* Callback executed after an agent's primary logic has completed.
|
|
@@ -193,7 +192,7 @@ export declare abstract class BasePlugin {
|
|
|
193
192
|
*/
|
|
194
193
|
afterAgentCallback(params: {
|
|
195
194
|
agent: BaseAgent;
|
|
196
|
-
callbackContext:
|
|
195
|
+
callbackContext: Context;
|
|
197
196
|
}): Promise<Content | undefined>;
|
|
198
197
|
/**
|
|
199
198
|
* Callback executed before a request is sent to the model.
|
|
@@ -209,7 +208,7 @@ export declare abstract class BasePlugin {
|
|
|
209
208
|
* `undefined` allows the LLM request to proceed normally.
|
|
210
209
|
*/
|
|
211
210
|
beforeModelCallback(params: {
|
|
212
|
-
callbackContext:
|
|
211
|
+
callbackContext: Context;
|
|
213
212
|
llmRequest: LlmRequest;
|
|
214
213
|
}): Promise<LlmResponse | undefined>;
|
|
215
214
|
/**
|
|
@@ -225,7 +224,7 @@ export declare abstract class BasePlugin {
|
|
|
225
224
|
* allows the original response to be used.
|
|
226
225
|
*/
|
|
227
226
|
afterModelCallback(params: {
|
|
228
|
-
callbackContext:
|
|
227
|
+
callbackContext: Context;
|
|
229
228
|
llmResponse: LlmResponse;
|
|
230
229
|
}): Promise<LlmResponse | undefined>;
|
|
231
230
|
/**
|
|
@@ -243,7 +242,7 @@ export declare abstract class BasePlugin {
|
|
|
243
242
|
* the original error to be raised.
|
|
244
243
|
*/
|
|
245
244
|
onModelErrorCallback(params: {
|
|
246
|
-
callbackContext:
|
|
245
|
+
callbackContext: Context;
|
|
247
246
|
llmRequest: LlmRequest;
|
|
248
247
|
error: Error;
|
|
249
248
|
}): Promise<LlmResponse | undefined>;
|
|
@@ -264,7 +263,7 @@ export declare abstract class BasePlugin {
|
|
|
264
263
|
beforeToolCallback(params: {
|
|
265
264
|
tool: BaseTool;
|
|
266
265
|
toolArgs: Record<string, unknown>;
|
|
267
|
-
toolContext:
|
|
266
|
+
toolContext: Context;
|
|
268
267
|
}): Promise<Record<string, unknown> | undefined>;
|
|
269
268
|
/**
|
|
270
269
|
* Callback executed after a tool has been called.
|
|
@@ -284,14 +283,14 @@ export declare abstract class BasePlugin {
|
|
|
284
283
|
afterToolCallback(params: {
|
|
285
284
|
tool: BaseTool;
|
|
286
285
|
toolArgs: Record<string, unknown>;
|
|
287
|
-
toolContext:
|
|
286
|
+
toolContext: Context;
|
|
288
287
|
result: Record<string, unknown>;
|
|
289
288
|
}): Promise<Record<string, unknown> | undefined>;
|
|
290
289
|
/**
|
|
291
290
|
* Callback executed when a tool call encounters an error.
|
|
292
291
|
tool: BaseTool;
|
|
293
292
|
toolArgs: Record<string, unknown>;
|
|
294
|
-
toolContext:
|
|
293
|
+
toolContext: Context;
|
|
295
294
|
result: Record<string, unknown>;
|
|
296
295
|
}): Promise<Record<string, unknown> | undefined> {
|
|
297
296
|
return;
|
|
@@ -314,7 +313,7 @@ export declare abstract class BasePlugin {
|
|
|
314
313
|
onToolErrorCallback(params: {
|
|
315
314
|
tool: BaseTool;
|
|
316
315
|
toolArgs: Record<string, unknown>;
|
|
317
|
-
toolContext:
|
|
316
|
+
toolContext: Context;
|
|
318
317
|
error: Error;
|
|
319
318
|
}): Promise<Record<string, unknown> | undefined>;
|
|
320
319
|
}
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Content } from '@google/genai';
|
|
7
7
|
import { BaseAgent } from '../agents/base_agent.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
9
|
import { InvocationContext } from '../agents/invocation_context.js';
|
|
10
10
|
import { Event } from '../events/event.js';
|
|
11
11
|
import { LlmRequest } from '../models/llm_request.js';
|
|
12
12
|
import { LlmResponse } from '../models/llm_response.js';
|
|
13
13
|
import { BaseTool } from '../tools/base_tool.js';
|
|
14
|
-
import { ToolContext } from '../tools/tool_context.js';
|
|
15
14
|
import { BasePlugin } from './base_plugin.js';
|
|
16
15
|
/**
|
|
17
16
|
* A plugin that logs important information at each callback point.
|
|
@@ -62,40 +61,40 @@ export declare class LoggingPlugin extends BasePlugin {
|
|
|
62
61
|
}): Promise<void>;
|
|
63
62
|
beforeAgentCallback({ callbackContext, }: {
|
|
64
63
|
agent: BaseAgent;
|
|
65
|
-
callbackContext:
|
|
64
|
+
callbackContext: Context;
|
|
66
65
|
}): Promise<Content | undefined>;
|
|
67
66
|
afterAgentCallback({ callbackContext, }: {
|
|
68
67
|
agent: BaseAgent;
|
|
69
|
-
callbackContext:
|
|
68
|
+
callbackContext: Context;
|
|
70
69
|
}): Promise<Content | undefined>;
|
|
71
70
|
beforeModelCallback({ callbackContext, llmRequest, }: {
|
|
72
|
-
callbackContext:
|
|
71
|
+
callbackContext: Context;
|
|
73
72
|
llmRequest: LlmRequest;
|
|
74
73
|
}): Promise<LlmResponse | undefined>;
|
|
75
74
|
afterModelCallback({ callbackContext, llmResponse, }: {
|
|
76
|
-
callbackContext:
|
|
75
|
+
callbackContext: Context;
|
|
77
76
|
llmResponse: LlmResponse;
|
|
78
77
|
}): Promise<LlmResponse | undefined>;
|
|
79
78
|
beforeToolCallback({ tool, toolArgs, toolContext, }: {
|
|
80
79
|
tool: BaseTool;
|
|
81
80
|
toolArgs: Record<string, unknown>;
|
|
82
|
-
toolContext:
|
|
81
|
+
toolContext: Context;
|
|
83
82
|
}): Promise<Record<string, unknown> | undefined>;
|
|
84
83
|
afterToolCallback({ tool, toolContext, result, }: {
|
|
85
84
|
tool: BaseTool;
|
|
86
85
|
toolArgs: Record<string, unknown>;
|
|
87
|
-
toolContext:
|
|
86
|
+
toolContext: Context;
|
|
88
87
|
result: Record<string, unknown>;
|
|
89
88
|
}): Promise<Record<string, unknown> | undefined>;
|
|
90
89
|
onModelErrorCallback({ callbackContext, error, }: {
|
|
91
|
-
callbackContext:
|
|
90
|
+
callbackContext: Context;
|
|
92
91
|
llmRequest: LlmRequest;
|
|
93
92
|
error: Error;
|
|
94
93
|
}): Promise<LlmResponse | undefined>;
|
|
95
94
|
onToolErrorCallback({ tool, toolArgs, toolContext, error, }: {
|
|
96
95
|
tool: BaseTool;
|
|
97
96
|
toolArgs: Record<string, unknown>;
|
|
98
|
-
toolContext:
|
|
97
|
+
toolContext: Context;
|
|
99
98
|
error: Error;
|
|
100
99
|
}): Promise<Record<string, unknown> | undefined>;
|
|
101
100
|
private log;
|
|
@@ -5,13 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Content } from '@google/genai';
|
|
7
7
|
import { BaseAgent } from '../agents/base_agent.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
9
|
import { InvocationContext } from '../agents/invocation_context.js';
|
|
10
10
|
import { Event } from '../events/event.js';
|
|
11
11
|
import { LlmRequest } from '../models/llm_request.js';
|
|
12
12
|
import { LlmResponse } from '../models/llm_response.js';
|
|
13
13
|
import { BaseTool } from '../tools/base_tool.js';
|
|
14
|
-
import { ToolContext } from '../tools/tool_context.js';
|
|
15
14
|
import { BasePlugin } from './base_plugin.js';
|
|
16
15
|
/**
|
|
17
16
|
* Manages the registration and execution of plugins.
|
|
@@ -95,14 +94,14 @@ export declare class PluginManager {
|
|
|
95
94
|
*/
|
|
96
95
|
runBeforeAgentCallback({ agent, callbackContext, }: {
|
|
97
96
|
agent: BaseAgent;
|
|
98
|
-
callbackContext:
|
|
97
|
+
callbackContext: Context;
|
|
99
98
|
}): Promise<Content | undefined>;
|
|
100
99
|
/**
|
|
101
100
|
* Runs the `afterAgentCallback` for all plugins.
|
|
102
101
|
*/
|
|
103
102
|
runAfterAgentCallback({ agent, callbackContext, }: {
|
|
104
103
|
agent: BaseAgent;
|
|
105
|
-
callbackContext:
|
|
104
|
+
callbackContext: Context;
|
|
106
105
|
}): Promise<Content | undefined>;
|
|
107
106
|
/**
|
|
108
107
|
* Runs the `beforeToolCallback` for all plugins.
|
|
@@ -110,7 +109,7 @@ export declare class PluginManager {
|
|
|
110
109
|
runBeforeToolCallback({ tool, toolArgs, toolContext, }: {
|
|
111
110
|
tool: BaseTool;
|
|
112
111
|
toolArgs: Record<string, unknown>;
|
|
113
|
-
toolContext:
|
|
112
|
+
toolContext: Context;
|
|
114
113
|
}): Promise<Record<string, unknown> | undefined>;
|
|
115
114
|
/**
|
|
116
115
|
* Runs the `afterToolCallback` for all plugins.
|
|
@@ -118,14 +117,14 @@ export declare class PluginManager {
|
|
|
118
117
|
runAfterToolCallback({ tool, toolArgs, toolContext, result, }: {
|
|
119
118
|
tool: BaseTool;
|
|
120
119
|
toolArgs: Record<string, unknown>;
|
|
121
|
-
toolContext:
|
|
120
|
+
toolContext: Context;
|
|
122
121
|
result: Record<string, unknown>;
|
|
123
122
|
}): Promise<Record<string, unknown> | undefined>;
|
|
124
123
|
/**
|
|
125
124
|
* Runs the `onModelErrorCallback` for all plugins.
|
|
126
125
|
*/
|
|
127
126
|
runOnModelErrorCallback({ callbackContext, llmRequest, error, }: {
|
|
128
|
-
callbackContext:
|
|
127
|
+
callbackContext: Context;
|
|
129
128
|
llmRequest: LlmRequest;
|
|
130
129
|
error: Error;
|
|
131
130
|
}): Promise<LlmResponse | undefined>;
|
|
@@ -133,14 +132,14 @@ export declare class PluginManager {
|
|
|
133
132
|
* Runs the `beforeModelCallback` for all plugins.
|
|
134
133
|
*/
|
|
135
134
|
runBeforeModelCallback({ callbackContext, llmRequest, }: {
|
|
136
|
-
callbackContext:
|
|
135
|
+
callbackContext: Context;
|
|
137
136
|
llmRequest: LlmRequest;
|
|
138
137
|
}): Promise<LlmResponse | undefined>;
|
|
139
138
|
/**
|
|
140
139
|
* Runs the `afterModelCallback` for all plugins.
|
|
141
140
|
*/
|
|
142
141
|
runAfterModelCallback({ callbackContext, llmResponse, }: {
|
|
143
|
-
callbackContext:
|
|
142
|
+
callbackContext: Context;
|
|
144
143
|
llmResponse: LlmResponse;
|
|
145
144
|
}): Promise<LlmResponse | undefined>;
|
|
146
145
|
/**
|
|
@@ -149,7 +148,7 @@ export declare class PluginManager {
|
|
|
149
148
|
runOnToolErrorCallback({ tool, toolArgs, toolContext, error, }: {
|
|
150
149
|
tool: BaseTool;
|
|
151
150
|
toolArgs: Record<string, unknown>;
|
|
152
|
-
toolContext:
|
|
151
|
+
toolContext: Context;
|
|
153
152
|
error: Error;
|
|
154
153
|
}): Promise<Record<string, unknown> | undefined>;
|
|
155
154
|
}
|