@google/adk 0.4.0 → 0.6.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/README.md +1 -1
- package/dist/cjs/a2a/a2a_event.js +317 -0
- package/dist/cjs/a2a/a2a_remote_agent.js +174 -0
- package/dist/cjs/a2a/a2a_remote_agent_run_processor.js +198 -0
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +165 -0
- package/dist/cjs/a2a/agent_card.js +380 -0
- package/dist/cjs/a2a/agent_executor.js +221 -0
- package/dist/cjs/a2a/agent_to_a2a.js +115 -0
- package/dist/cjs/a2a/event_converter_utils.js +201 -0
- package/dist/cjs/a2a/event_processor_utils.js +180 -0
- package/dist/cjs/a2a/executor_context.js +53 -0
- package/dist/cjs/a2a/metadata_converter_utils.js +126 -0
- package/dist/cjs/a2a/part_converter_utils.js +47 -34
- package/dist/cjs/agents/base_agent.js +3 -3
- package/dist/cjs/{tools/tool_context.js → agents/context.js} +70 -15
- package/dist/cjs/agents/functions.js +2 -2
- package/dist/cjs/agents/llm_agent.js +38 -674
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +132 -0
- 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/{content_processor_utils.js → processors/content_processor_utils.js} +21 -2
- package/dist/cjs/agents/processors/content_request_processor.js +87 -0
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +61 -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/artifacts/file_artifact_service.js +35 -4
- package/dist/cjs/common.js +48 -7
- package/dist/cjs/context/base_context_compactor.js +27 -0
- package/dist/cjs/context/summarizers/base_summarizer.js +27 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +93 -0
- package/dist/cjs/context/token_based_context_compactor.js +135 -0
- package/dist/cjs/context/truncating_context_compactor.js +58 -0
- package/dist/cjs/events/compacted_event.js +53 -0
- package/dist/cjs/index.js +113 -53
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/memory/in_memory_memory_service.js +1 -1
- package/dist/cjs/models/llm_response.js +2 -0
- package/dist/cjs/plugins/base_plugin.js +1 -1
- package/dist/cjs/runner/runner.js +20 -11
- package/dist/cjs/sessions/database_session_service.js +4 -1
- package/dist/cjs/sessions/db/operations.js +25 -23
- package/dist/cjs/sessions/state.js +2 -2
- package/dist/cjs/tools/agent_tool.js +6 -5
- package/dist/cjs/tools/base_tool.js +3 -0
- package/dist/cjs/tools/base_toolset.js +13 -3
- package/dist/cjs/tools/exit_loop_tool.js +63 -0
- package/dist/cjs/tools/load_artifacts_tool.js +188 -0
- package/dist/cjs/tools/load_memory_tool.js +107 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +9 -5
- package/dist/cjs/tools/preload_memory_tool.js +109 -0
- package/dist/cjs/utils/logger.js +62 -54
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_event.js +269 -0
- package/dist/esm/a2a/a2a_remote_agent.js +148 -0
- package/dist/esm/a2a/a2a_remote_agent_run_processor.js +175 -0
- package/dist/esm/a2a/a2a_remote_agent_utils.js +131 -0
- package/dist/esm/a2a/agent_card.js +340 -0
- package/dist/esm/a2a/agent_executor.js +202 -0
- package/dist/esm/a2a/agent_to_a2a.js +80 -0
- package/dist/esm/a2a/event_converter_utils.js +187 -0
- package/dist/esm/a2a/event_processor_utils.js +159 -0
- package/dist/esm/a2a/executor_context.js +23 -0
- package/dist/esm/a2a/metadata_converter_utils.js +91 -0
- package/dist/esm/a2a/part_converter_utils.js +49 -34
- package/dist/esm/agents/base_agent.js +3 -3
- package/dist/{web/tools/tool_context.js → esm/agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +2 -2
- package/dist/esm/agents/llm_agent.js +31 -683
- 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/{content_processor_utils.js → processors/content_processor_utils.js} +23 -2
- package/dist/esm/agents/processors/content_request_processor.js +59 -0
- package/dist/esm/agents/processors/context_compactor_request_processor.js +31 -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/artifacts/file_artifact_service.js +30 -3
- package/dist/esm/common.js +44 -10
- package/dist/esm/context/base_context_compactor.js +5 -0
- package/dist/esm/context/summarizers/base_summarizer.js +5 -0
- package/dist/esm/context/summarizers/llm_summarizer.js +65 -0
- package/dist/esm/context/token_based_context_compactor.js +105 -0
- package/dist/esm/context/truncating_context_compactor.js +28 -0
- package/dist/esm/events/compacted_event.js +22 -0
- package/dist/esm/index.js +119 -18
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/memory/in_memory_memory_service.js +1 -1
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +18 -10
- package/dist/esm/sessions/database_session_service.js +4 -1
- package/dist/esm/sessions/db/operations.js +32 -18
- package/dist/esm/sessions/state.js +2 -2
- package/dist/esm/tools/agent_tool.js +6 -5
- 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/load_artifacts_tool.js +159 -0
- package/dist/esm/tools/load_memory_tool.js +78 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +9 -5
- package/dist/esm/tools/preload_memory_tool.js +80 -0
- package/dist/esm/utils/logger.js +52 -54
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_event.d.ts +139 -0
- package/dist/types/a2a/a2a_remote_agent.d.ts +63 -0
- package/dist/types/a2a/a2a_remote_agent_run_processor.d.ts +31 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +38 -0
- package/dist/types/a2a/agent_card.d.ts +23 -0
- package/dist/types/a2a/agent_executor.d.ts +52 -0
- package/dist/types/a2a/agent_to_a2a.d.ts +45 -0
- package/dist/types/a2a/event_converter_utils.d.ts +20 -0
- package/dist/types/a2a/event_processor_utils.d.ts +24 -0
- package/dist/types/a2a/executor_context.d.ts +33 -0
- package/dist/types/a2a/metadata_converter_utils.d.ts +63 -0
- package/dist/types/a2a/part_converter_utils.d.ts +4 -3
- 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 +14 -31
- package/dist/types/agents/loop_agent.d.ts +1 -1
- 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/{content_processor_utils.d.ts → processors/content_processor_utils.d.ts} +1 -1
- package/dist/types/agents/processors/content_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/context_compactor_request_processor.d.ts +22 -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/artifacts/file_artifact_service.d.ts +4 -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 +20 -5
- package/dist/types/context/base_context_compactor.d.ts +24 -0
- package/dist/types/context/summarizers/base_summarizer.d.ts +19 -0
- package/dist/types/context/summarizers/llm_summarizer.d.ts +23 -0
- package/dist/types/context/token_based_context_compactor.d.ts +33 -0
- package/dist/types/context/truncating_context_compactor.d.ts +24 -0
- package/dist/types/events/compacted_event.d.ts +33 -0
- package/dist/types/index.d.ts +8 -0
- 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 +13 -0
- package/dist/types/sessions/database_session_service.d.ts +2 -1
- package/dist/types/sessions/db/operations.d.ts +3 -4
- 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 +2 -2
- package/dist/types/tools/function_tool.d.ts +2 -2
- package/dist/types/tools/load_artifacts_tool.d.ts +21 -0
- package/dist/types/tools/load_memory_tool.d.ts +22 -0
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -1
- package/dist/types/tools/preload_memory_tool.d.ts +23 -0
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_event.js +269 -0
- package/dist/web/a2a/a2a_remote_agent.js +193 -0
- package/dist/web/a2a/a2a_remote_agent_run_processor.js +175 -0
- package/dist/web/a2a/a2a_remote_agent_utils.js +131 -0
- package/dist/web/a2a/agent_card.js +340 -0
- package/dist/web/a2a/agent_executor.js +216 -0
- package/dist/web/a2a/agent_to_a2a.js +80 -0
- package/dist/web/a2a/event_converter_utils.js +201 -0
- package/dist/web/a2a/event_processor_utils.js +168 -0
- package/dist/web/a2a/executor_context.js +23 -0
- package/dist/web/a2a/metadata_converter_utils.js +108 -0
- package/dist/web/a2a/part_converter_utils.js +49 -34
- package/dist/web/agents/base_agent.js +3 -3
- package/dist/{esm/tools/tool_context.js → web/agents/context.js} +66 -11
- package/dist/web/agents/functions.js +2 -2
- package/dist/web/agents/llm_agent.js +31 -661
- 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/{content_processor_utils.js → processors/content_processor_utils.js} +22 -2
- package/dist/web/agents/processors/content_request_processor.js +77 -0
- package/dist/web/agents/processors/context_compactor_request_processor.js +49 -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/artifacts/file_artifact_service.js +30 -3
- package/dist/web/common.js +44 -10
- package/dist/web/context/base_context_compactor.js +5 -0
- package/dist/web/context/summarizers/base_summarizer.js +5 -0
- package/dist/web/context/summarizers/llm_summarizer.js +74 -0
- package/dist/web/context/token_based_context_compactor.js +105 -0
- package/dist/web/context/truncating_context_compactor.js +28 -0
- package/dist/web/events/compacted_event.js +40 -0
- package/dist/web/index.js +13 -18
- package/dist/web/index.js.map +7 -0
- package/dist/web/memory/in_memory_memory_service.js +1 -1
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +18 -10
- package/dist/web/sessions/database_session_service.js +4 -1
- package/dist/web/sessions/db/operations.js +32 -18
- package/dist/web/sessions/state.js +2 -2
- package/dist/web/tools/agent_tool.js +6 -5
- 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/load_artifacts_tool.js +150 -0
- package/dist/web/tools/load_memory_tool.js +77 -0
- package/dist/web/tools/mcp/mcp_toolset.js +27 -5
- package/dist/web/tools/preload_memory_tool.js +75 -0
- package/dist/web/utils/logger.js +52 -54
- package/dist/web/version.js +1 -1
- package/package.json +7 -4
- 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/cjs/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
- /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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { InvocationContext } from '../agents/invocation_context.js';
|
|
7
|
+
/**
|
|
8
|
+
* Interface for compacting the context history in an agent session.
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseContextCompactor {
|
|
11
|
+
/**
|
|
12
|
+
* Determines whether the context should be compacted.
|
|
13
|
+
*
|
|
14
|
+
* @param invocationContext The current invocation context.
|
|
15
|
+
* @returns A boolean or a promise resolving to a boolean indicating if compaction should occur.
|
|
16
|
+
*/
|
|
17
|
+
shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* Compacts the context in place.
|
|
20
|
+
*
|
|
21
|
+
* @param invocationContext The current invocation context.
|
|
22
|
+
*/
|
|
23
|
+
compact(invocationContext: InvocationContext): void | Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Event } from '../../events/event.js';
|
|
7
|
+
import { CompactedEvent } from '../../events/compacted_event.js';
|
|
8
|
+
/**
|
|
9
|
+
* Interface for summarizing a list of events into a single CompactedEvent.
|
|
10
|
+
*/
|
|
11
|
+
export interface BaseSummarizer {
|
|
12
|
+
/**
|
|
13
|
+
* Summarizes the given events into a CompactedEvent.
|
|
14
|
+
*
|
|
15
|
+
* @param events The events to summarize.
|
|
16
|
+
* @returns A promise resolving to the CompactedEvent representation of the events.
|
|
17
|
+
*/
|
|
18
|
+
summarize(events: Event[]): Promise<CompactedEvent>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { CompactedEvent } from '../../events/compacted_event.js';
|
|
7
|
+
import { Event } from '../../events/event.js';
|
|
8
|
+
import { BaseLlm } from '../../models/base_llm.js';
|
|
9
|
+
import { BaseSummarizer } from './base_summarizer.js';
|
|
10
|
+
export interface LlmSummarizerOptions {
|
|
11
|
+
llm: BaseLlm;
|
|
12
|
+
prompt?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A summarizer that uses an LLM to generate a compacted representation
|
|
16
|
+
* of existing events.
|
|
17
|
+
*/
|
|
18
|
+
export declare class LlmSummarizer implements BaseSummarizer {
|
|
19
|
+
private readonly llm;
|
|
20
|
+
private readonly prompt;
|
|
21
|
+
constructor(options: LlmSummarizerOptions);
|
|
22
|
+
summarize(events: Event[]): Promise<CompactedEvent>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { InvocationContext } from '../agents/invocation_context.js';
|
|
7
|
+
import { BaseContextCompactor } from './base_context_compactor.js';
|
|
8
|
+
import { BaseSummarizer } from './summarizers/base_summarizer.js';
|
|
9
|
+
export interface TokenBasedContextCompactorOptions {
|
|
10
|
+
/** The maximum number of tokens to retain in the session history before compaction. */
|
|
11
|
+
tokenThreshold: number;
|
|
12
|
+
/**
|
|
13
|
+
* The minimum number of raw events to keep at the end of the session.
|
|
14
|
+
* Compaction will not affect these tail events (unless needed for tool splits).
|
|
15
|
+
*/
|
|
16
|
+
eventRetentionSize: number;
|
|
17
|
+
/** The summarizer used to create the compacted event content. */
|
|
18
|
+
summarizer: BaseSummarizer;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A context compactor that uses token count to determine when to compact events.
|
|
22
|
+
* Oldest events are summarized into a CompactedEvent when the session
|
|
23
|
+
* history exceeds the token threshold.
|
|
24
|
+
*/
|
|
25
|
+
export declare class TokenBasedContextCompactor implements BaseContextCompactor {
|
|
26
|
+
private readonly tokenThreshold;
|
|
27
|
+
private readonly eventRetentionSize;
|
|
28
|
+
private readonly summarizer;
|
|
29
|
+
constructor(options: TokenBasedContextCompactorOptions);
|
|
30
|
+
private getActiveEvents;
|
|
31
|
+
shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
|
|
32
|
+
compact(invocationContext: InvocationContext): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { InvocationContext } from '../agents/invocation_context.js';
|
|
7
|
+
import { BaseContextCompactor } from './base_context_compactor.js';
|
|
8
|
+
export interface TruncatingContextCompactorOptions {
|
|
9
|
+
/** The maximum number of events to retain in the session history. */
|
|
10
|
+
threshold: number;
|
|
11
|
+
/** Keep the first X events in the history, which often act as the initial grounding prompt. */
|
|
12
|
+
preserveLeadingEvents?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A simple context compactor that truncates the oldest events to get under
|
|
16
|
+
* the given threshold limit.
|
|
17
|
+
*/
|
|
18
|
+
export declare class TruncatingContextCompactor implements BaseContextCompactor {
|
|
19
|
+
private readonly threshold;
|
|
20
|
+
private readonly preserveLeadingEvents;
|
|
21
|
+
constructor(options: TruncatingContextCompactorOptions);
|
|
22
|
+
shouldCompact(invocationContext: InvocationContext): boolean;
|
|
23
|
+
compact(invocationContext: InvocationContext): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Event } from './event.js';
|
|
7
|
+
/**
|
|
8
|
+
* A specialized Event type that represents a synthesized summary of past events.
|
|
9
|
+
* This is used to compress session history without losing critical context.
|
|
10
|
+
*/
|
|
11
|
+
export interface CompactedEvent extends Event {
|
|
12
|
+
/**
|
|
13
|
+
* Identifies this event as a compacted event.
|
|
14
|
+
*/
|
|
15
|
+
readonly isCompacted: true;
|
|
16
|
+
/**
|
|
17
|
+
* The start time of the context that was compacted.
|
|
18
|
+
*/
|
|
19
|
+
startTime: number;
|
|
20
|
+
/**
|
|
21
|
+
* The end time of the context that was compacted.
|
|
22
|
+
*/
|
|
23
|
+
endTime: number;
|
|
24
|
+
/**
|
|
25
|
+
* The summarized content of the compacted events.
|
|
26
|
+
*/
|
|
27
|
+
compactedContent: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if an event is a CompactedEvent.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isCompactedEvent(event: Event): event is CompactedEvent;
|
|
33
|
+
export declare function createCompactedEvent(params?: Partial<CompactedEvent>): CompactedEvent;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
export { AGENT_CARD_PATH, RemoteA2AAgent } from './a2a/a2a_remote_agent.js';
|
|
7
|
+
export type { A2AStreamEventData, AfterA2ARequestCallback, BeforeA2ARequestCallback, RemoteA2AAgentConfig, } from './a2a/a2a_remote_agent.js';
|
|
8
|
+
export { getA2AAgentCard } from './a2a/agent_card.js';
|
|
9
|
+
export { A2AAgentExecutor } from './a2a/agent_executor.js';
|
|
10
|
+
export type { AfterEventCallback, AfterExecuteCallback, AgentExecutorConfig, BeforeExecuteCallback, RunnerOrRunnerConfig, } from './a2a/agent_executor.js';
|
|
11
|
+
export { toA2a } from './a2a/agent_to_a2a.js';
|
|
12
|
+
export type { ToA2aOptions } from './a2a/agent_to_a2a.js';
|
|
13
|
+
export type { ExecutorContext } from './a2a/executor_context.js';
|
|
6
14
|
export { FileArtifactService } from './artifacts/file_artifact_service.js';
|
|
7
15
|
export { GcsArtifactService } from './artifacts/gcs_artifact_service.js';
|
|
8
16
|
export { getArtifactServiceFromUri } from './artifacts/registry.js';
|
|
@@ -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
|
}
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { FunctionCall } from '@google/genai';
|
|
7
|
+
import { Context } from '../agents/context.js';
|
|
7
8
|
import { Event } from '../events/event.js';
|
|
8
9
|
import { BasePlugin } from '../plugins/base_plugin.js';
|
|
9
10
|
import { BaseTool } from '../tools/base_tool.js';
|
|
10
|
-
import { ToolContext } from '../tools/tool_context.js';
|
|
11
11
|
export declare const REQUEST_CONFIRMATION_FUNCTION_CALL_NAME = "adk_request_confirmation";
|
|
12
12
|
/**
|
|
13
13
|
* The outcome of a policy check.
|
|
@@ -44,7 +44,7 @@ export declare class SecurityPlugin extends BasePlugin {
|
|
|
44
44
|
toolArgs: {
|
|
45
45
|
[key: string]: unknown;
|
|
46
46
|
};
|
|
47
|
-
toolContext:
|
|
47
|
+
toolContext: Context;
|
|
48
48
|
}): Promise<{
|
|
49
49
|
[key: string]: unknown;
|
|
50
50
|
} | undefined>;
|
|
@@ -31,7 +31,19 @@ export interface RunnerConfig {
|
|
|
31
31
|
memoryService?: BaseMemoryService;
|
|
32
32
|
credentialService?: BaseCredentialService;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* A unique symbol to identify ADK agent classes.
|
|
36
|
+
* Defined once and shared by all Runner instances.
|
|
37
|
+
*/
|
|
38
|
+
declare const RUNNER_SIGNATURE_SYMBOL: unique symbol;
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if an object is an instance of Runner.
|
|
41
|
+
* @param obj The object to check.
|
|
42
|
+
* @returns True if the object is an instance of Runner, false otherwise.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isRunner(obj: unknown): obj is Runner;
|
|
34
45
|
export declare class Runner {
|
|
46
|
+
readonly [RUNNER_SIGNATURE_SYMBOL] = true;
|
|
35
47
|
readonly appName: string;
|
|
36
48
|
readonly agent: BaseAgent;
|
|
37
49
|
readonly pluginManager: PluginManager;
|
|
@@ -101,3 +113,4 @@ export declare class Runner {
|
|
|
101
113
|
*/
|
|
102
114
|
private isRoutableLlmAgent;
|
|
103
115
|
}
|
|
116
|
+
export {};
|
|
@@ -20,7 +20,8 @@ export declare function isDatabaseConnectionString(uri?: string): boolean;
|
|
|
20
20
|
export declare class DatabaseSessionService extends BaseSessionService {
|
|
21
21
|
private orm?;
|
|
22
22
|
private initialized;
|
|
23
|
-
private options
|
|
23
|
+
private options?;
|
|
24
|
+
private connectionString?;
|
|
24
25
|
constructor(connectionStringOrOptions: MikroDBOptions | string);
|
|
25
26
|
init(): Promise<void>;
|
|
26
27
|
createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
|
|
@@ -11,15 +11,14 @@ import { MikroORM, Options as MikroORMOptions } from '@mikro-orm/core';
|
|
|
11
11
|
* @returns MikroORM Options configured for the database
|
|
12
12
|
* @throws Error if the URI is invalid or unsupported
|
|
13
13
|
*/
|
|
14
|
-
export declare function getConnectionOptionsFromUri(uri: string): MikroORMOptions
|
|
14
|
+
export declare function getConnectionOptionsFromUri(uri: string): Promise<MikroORMOptions>;
|
|
15
15
|
/**
|
|
16
16
|
* Creates a database and tables if they don't exist.
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
18
|
+
* @param orm The MikroORM instance.
|
|
19
19
|
* @returns Promise<void>
|
|
20
|
-
* @throws Error if the URI is invalid or unsupported
|
|
21
20
|
*/
|
|
22
|
-
export declare function ensureDatabaseCreated(
|
|
21
|
+
export declare function ensureDatabaseCreated(orm: MikroORM): Promise<void>;
|
|
23
22
|
/**
|
|
24
23
|
* Validates the schema version.
|
|
25
24
|
*
|
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { FunctionDeclaration } from '@google/genai';
|
|
7
7
|
import { LlmRequest } from '../models/llm_request.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
9
|
/**
|
|
10
10
|
* The parameters for `runAsync`.
|
|
11
11
|
*/
|
|
12
12
|
export interface RunAsyncToolRequest {
|
|
13
13
|
args: Record<string, unknown>;
|
|
14
|
-
toolContext:
|
|
14
|
+
toolContext: Context;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
17
|
* The parameters for `processLlmRequest`.
|
|
18
18
|
*/
|
|
19
19
|
export interface ToolProcessLlmRequest {
|
|
20
|
-
toolContext:
|
|
20
|
+
toolContext: Context;
|
|
21
21
|
llmRequest: LlmRequest;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
@@ -5,14 +5,20 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ReadonlyContext } from '../agents/readonly_context.js';
|
|
7
7
|
import { LlmRequest } from '../models/llm_request.js';
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
8
9
|
import { BaseTool } from './base_tool.js';
|
|
9
|
-
import { ToolContext } from './tool_context.js';
|
|
10
10
|
/**
|
|
11
11
|
* Function to decide whether a tool should be exposed to LLM. Toolset
|
|
12
12
|
* implementer could consider whether to accept such instance in the toolset's
|
|
13
13
|
* constructor and apply the predicate in getTools method.
|
|
14
14
|
*/
|
|
15
15
|
export type ToolPredicate = (tool: BaseTool, readonlyContext: ReadonlyContext) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A unique symbol to identify ADK agent classes.
|
|
18
|
+
* Defined once and shared by all BaseTool instances.
|
|
19
|
+
*/
|
|
20
|
+
declare const BASE_TOOLSET_SIGNATURE_SYMBOL: unique symbol;
|
|
21
|
+
export declare function isBaseToolset(obj: unknown): obj is BaseToolset;
|
|
16
22
|
/**
|
|
17
23
|
* Base class for toolset.
|
|
18
24
|
*
|
|
@@ -20,7 +26,9 @@ export type ToolPredicate = (tool: BaseTool, readonlyContext: ReadonlyContext) =
|
|
|
20
26
|
*/
|
|
21
27
|
export declare abstract class BaseToolset {
|
|
22
28
|
readonly toolFilter: ToolPredicate | string[];
|
|
23
|
-
|
|
29
|
+
readonly prefix?: string | undefined;
|
|
30
|
+
readonly [BASE_TOOLSET_SIGNATURE_SYMBOL] = true;
|
|
31
|
+
constructor(toolFilter: ToolPredicate | string[], prefix?: string | undefined);
|
|
24
32
|
/**
|
|
25
33
|
* Returns the tools that should be exposed to LLM.
|
|
26
34
|
*
|
|
@@ -60,6 +68,7 @@ export declare abstract class BaseToolset {
|
|
|
60
68
|
* @param toolContext The context of the tool.
|
|
61
69
|
* @param llmRequest The outgoing LLM request, mutable this method.
|
|
62
70
|
*/
|
|
63
|
-
processLlmRequest(toolContext:
|
|
71
|
+
processLlmRequest(toolContext: Context, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
64
72
|
llmRequest: LlmRequest): Promise<void>;
|
|
65
73
|
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FunctionDeclaration } from '@google/genai';
|
|
7
|
+
import { BaseTool, RunAsyncToolRequest } from './base_tool.js';
|
|
8
|
+
/**
|
|
9
|
+
* Tool for exiting execution of a {@link LoopAgent}.
|
|
10
|
+
*
|
|
11
|
+
* When called by an LLM agent inside a LoopAgent, this tool sets the
|
|
12
|
+
* `escalate` and `skipSummarization` flags on the event actions,
|
|
13
|
+
* causing the LoopAgent to stop iterating and exit the loop.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare class ExitLoopTool extends BaseTool {
|
|
17
|
+
constructor();
|
|
18
|
+
_getDeclaration(): FunctionDeclaration;
|
|
19
|
+
runAsync({ toolContext, }: RunAsyncToolRequest): Promise<unknown>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A global instance of {@link ExitLoopTool}.
|
|
23
|
+
*/
|
|
24
|
+
export declare const EXIT_LOOP: ExitLoopTool;
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Part } from '@google/genai';
|
|
7
7
|
import { ArtifactVersion, BaseArtifactService, DeleteArtifactRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest } from '../artifacts/base_artifact_service.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Context } from '../agents/context.js';
|
|
9
9
|
/**
|
|
10
10
|
* Artifact service that forwards to the parent tool context.
|
|
11
11
|
*/
|
|
12
12
|
export declare class ForwardingArtifactService implements BaseArtifactService {
|
|
13
13
|
private readonly toolContext;
|
|
14
14
|
private readonly invocationContext;
|
|
15
|
-
constructor(toolContext:
|
|
15
|
+
constructor(toolContext: Context);
|
|
16
16
|
saveArtifact(request: SaveArtifactRequest): Promise<number>;
|
|
17
17
|
loadArtifact(request: LoadArtifactRequest): Promise<Part | undefined>;
|
|
18
18
|
listArtifactKeys(): Promise<string[]>;
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
import { FunctionDeclaration, Schema } from '@google/genai';
|
|
7
7
|
import { z as z3 } from 'zod/v3';
|
|
8
8
|
import { z as z4 } from 'zod/v4';
|
|
9
|
+
import { Context } from '../agents/context.js';
|
|
9
10
|
import { BaseTool, RunAsyncToolRequest } from './base_tool.js';
|
|
10
|
-
import { ToolContext } from './tool_context.js';
|
|
11
11
|
/**
|
|
12
12
|
* Input parameters of the function tool.
|
|
13
13
|
*/
|
|
14
14
|
export type ToolInputParameters = z3.ZodObject<z3.ZodRawShape> | z4.ZodObject<z4.ZodRawShape> | Schema | undefined;
|
|
15
15
|
export type ToolExecuteArgument<TParameters extends ToolInputParameters> = TParameters extends z3.ZodObject<infer T, infer U, infer V> ? z3.infer<z3.ZodObject<T, U, V>> : TParameters extends z4.ZodObject<infer T> ? z4.infer<z4.ZodObject<T>> : TParameters extends Schema ? unknown : string;
|
|
16
|
-
export type ToolExecuteFunction<TParameters extends ToolInputParameters> = (input: ToolExecuteArgument<TParameters>, tool_context?:
|
|
16
|
+
export type ToolExecuteFunction<TParameters extends ToolInputParameters> = (input: ToolExecuteArgument<TParameters>, tool_context?: Context) => Promise<unknown> | unknown;
|
|
17
17
|
/**
|
|
18
18
|
* The configuration options for creating a function-based tool.
|
|
19
19
|
* The `name`, `description` and `parameters` fields are used to generate the
|