@google/adk 1.3.0 → 1.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/agent_to_a2a.js +18 -2
- package/dist/cjs/a2a/event_converter_utils.js +8 -4
- package/dist/cjs/a2a/metadata_converter_utils.js +1 -1
- package/dist/cjs/agents/active_streaming_tool.js +6 -1
- package/dist/cjs/agents/base_agent.js +39 -0
- package/dist/cjs/agents/context.js +1 -11
- package/dist/cjs/agents/functions.js +39 -35
- package/dist/cjs/agents/instructions.js +23 -5
- package/dist/cjs/agents/invocation_context.js +2 -5
- package/dist/cjs/agents/llm_agent.js +10 -7
- package/dist/cjs/agents/loop_agent.js +15 -3
- package/dist/cjs/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/cjs/agents/processors/content_processor_utils.js +18 -4
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/cjs/agents/processors/interactions_request_processor.js +63 -0
- package/dist/cjs/agents/routed_agent.js +31 -0
- package/dist/cjs/agents/run_config.js +3 -2
- package/dist/cjs/apps/app.js +79 -0
- package/dist/cjs/apps/resumability_config.js +44 -0
- package/dist/cjs/artifacts/file_artifact_service.js +14 -1
- package/dist/cjs/artifacts/gcs_artifact_service.js +57 -15
- package/dist/cjs/artifacts/in_memory_artifact_service.js +12 -1
- package/dist/cjs/artifacts/scoped_artifact_service.js +101 -0
- package/dist/cjs/artifacts/session_artifact_service.js +27 -0
- package/dist/cjs/auth/oauth2/oauth2_discovery.js +17 -5
- package/dist/cjs/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/cjs/common.js +76 -0
- package/dist/cjs/context/agent_controlled_context_compactor.js +109 -0
- package/dist/cjs/context/anchored_context_compactor.js +127 -0
- package/dist/cjs/context/compaction_utils.js +52 -0
- package/dist/cjs/context/token_based_context_compactor.js +52 -33
- package/dist/cjs/context/trajectory_thought_pruning_compactor.js +71 -0
- package/dist/cjs/events/compacted_event.js +9 -3
- package/dist/cjs/events/event.js +52 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
- package/dist/cjs/models/google_llm.js +25 -10
- package/dist/cjs/models/interactions_utils.js +732 -0
- package/dist/cjs/plugins/base_plugin.js +1 -0
- package/dist/cjs/plugins/global_instruction_plugin.js +97 -0
- package/dist/cjs/runner/in_memory_runner.js +13 -2
- package/dist/cjs/runner/runner.js +143 -83
- package/dist/cjs/sessions/base_session_service.js +6 -1
- package/dist/cjs/sessions/database_session_service.js +24 -7
- package/dist/cjs/sessions/vertex_ai_session_service.js +19 -4
- package/dist/cjs/skills/loader.js +2 -2
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/consolidate_context_tool.js +79 -0
- package/dist/cjs/tools/enterprise_web_search_tool.js +81 -0
- package/dist/cjs/tools/example_tool.js +68 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +16 -28
- package/dist/cjs/tools/load_web_page.js +250 -0
- package/dist/cjs/tools/mcp/load_mcp_resource_tool.js +140 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +63 -0
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
- package/dist/cjs/tools/skill/run_skill_inline_script_tool.js +54 -4
- package/dist/cjs/tools/skill/skill_toolset.js +4 -2
- package/dist/cjs/utils/async_hooks_shim.js +52 -0
- package/dist/cjs/utils/branch_trie.js +41 -0
- package/dist/cjs/utils/client_labels.js +41 -3
- package/dist/cjs/utils/env_aware_utils.js +10 -1
- package/dist/cjs/utils/streaming_utils.js +15 -9
- package/dist/cjs/utils/task.js +62 -0
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/agent_to_a2a.js +18 -2
- package/dist/esm/a2a/event_converter_utils.js +8 -4
- package/dist/esm/a2a/metadata_converter_utils.js +1 -1
- package/dist/esm/agents/active_streaming_tool.js +6 -1
- package/dist/esm/agents/base_agent.js +39 -0
- package/dist/esm/agents/context.js +1 -11
- package/dist/esm/agents/functions.js +43 -32
- package/dist/esm/agents/instructions.js +23 -5
- package/dist/esm/agents/invocation_context.js +2 -5
- package/dist/esm/agents/llm_agent.js +12 -9
- package/dist/esm/agents/loop_agent.js +15 -3
- package/dist/esm/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/esm/agents/processors/content_processor_utils.js +16 -3
- package/dist/esm/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/esm/agents/processors/interactions_request_processor.js +34 -0
- package/dist/esm/agents/routed_agent.js +31 -0
- package/dist/esm/agents/run_config.js +3 -2
- package/dist/esm/apps/app.js +49 -0
- package/dist/esm/apps/resumability_config.js +16 -0
- package/dist/esm/artifacts/file_artifact_service.js +14 -1
- package/dist/esm/artifacts/gcs_artifact_service.js +57 -15
- package/dist/esm/artifacts/in_memory_artifact_service.js +12 -1
- package/dist/esm/artifacts/scoped_artifact_service.js +73 -0
- package/dist/esm/artifacts/session_artifact_service.js +7 -0
- package/dist/esm/auth/oauth2/oauth2_discovery.js +14 -4
- package/dist/esm/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/esm/common.js +67 -3
- package/dist/esm/context/agent_controlled_context_compactor.js +81 -0
- package/dist/esm/context/anchored_context_compactor.js +99 -0
- package/dist/esm/context/compaction_utils.js +27 -0
- package/dist/esm/context/token_based_context_compactor.js +52 -33
- package/dist/esm/context/trajectory_thought_pruning_compactor.js +43 -0
- package/dist/esm/events/compacted_event.js +7 -2
- package/dist/esm/events/event.js +46 -0
- package/dist/esm/index.js +6 -1
- package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
- package/dist/esm/models/google_llm.js +23 -9
- package/dist/esm/models/interactions_utils.js +697 -0
- package/dist/esm/plugins/base_plugin.js +1 -0
- package/dist/esm/plugins/global_instruction_plugin.js +69 -0
- package/dist/esm/runner/in_memory_runner.js +13 -2
- package/dist/esm/runner/runner.js +141 -84
- package/dist/esm/sessions/base_session_service.js +6 -1
- package/dist/esm/sessions/database_session_service.js +24 -7
- package/dist/esm/sessions/vertex_ai_session_service.js +17 -3
- package/dist/esm/skills/loader.js +2 -2
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/consolidate_context_tool.js +51 -0
- package/dist/esm/tools/enterprise_web_search_tool.js +55 -0
- package/dist/esm/tools/example_tool.js +42 -0
- package/dist/esm/tools/forwarding_artifact_service.js +16 -28
- package/dist/esm/tools/load_web_page.js +221 -0
- package/dist/esm/tools/mcp/load_mcp_resource_tool.js +114 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +63 -0
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
- package/dist/esm/tools/skill/run_skill_inline_script_tool.js +53 -4
- package/dist/esm/tools/skill/skill_toolset.js +4 -2
- package/dist/esm/utils/async_hooks_shim.js +24 -0
- package/dist/esm/utils/branch_trie.js +13 -0
- package/dist/esm/utils/client_labels.js +38 -2
- package/dist/esm/utils/env_aware_utils.js +10 -1
- package/dist/esm/utils/streaming_utils.js +11 -5
- package/dist/esm/utils/task.js +34 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_remote_agent.d.ts +5 -1
- package/dist/types/a2a/agent_to_a2a.d.ts +38 -0
- package/dist/types/agents/active_streaming_tool.d.ts +3 -4
- package/dist/types/agents/base_agent.d.ts +29 -1
- package/dist/types/agents/functions.d.ts +12 -17
- package/dist/types/agents/invocation_context.d.ts +7 -3
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/loop_agent.d.ts +2 -2
- package/dist/types/agents/processors/content_processor_utils.d.ts +8 -0
- package/dist/types/agents/processors/interactions_request_processor.d.ts +17 -0
- package/dist/types/agents/routed_agent.d.ts +24 -1
- package/dist/types/agents/run_config.d.ts +1 -1
- package/dist/types/apps/app.d.ts +52 -0
- package/dist/types/apps/resumability_config.d.ts +27 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +6 -36
- package/dist/types/artifacts/gcs_artifact_service.d.ts +2 -1
- package/dist/types/artifacts/scoped_artifact_service.d.ts +25 -0
- package/dist/types/artifacts/session_artifact_service.d.ts +25 -0
- package/dist/types/auth/oauth2/oauth2_discovery.d.ts +11 -0
- package/dist/types/common.d.ts +29 -5
- package/dist/types/context/agent_controlled_context_compactor.d.ts +24 -0
- package/dist/types/context/anchored_context_compactor.d.ts +35 -0
- package/dist/types/context/base_context_compactor.d.ts +3 -0
- package/dist/types/context/compaction_utils.d.ts +15 -0
- package/dist/types/context/token_based_context_compactor.d.ts +6 -1
- package/dist/types/context/trajectory_thought_pruning_compactor.d.ts +27 -0
- package/dist/types/events/compacted_event.d.ts +10 -0
- package/dist/types/events/event.d.ts +21 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/models/google_llm.d.ts +15 -1
- package/dist/types/models/interactions_utils.d.ts +92 -0
- package/dist/types/models/llm_request.d.ts +4 -0
- package/dist/types/models/llm_response.d.ts +4 -0
- package/dist/types/plugins/base_plugin.d.ts +2 -1
- package/dist/types/plugins/global_instruction_plugin.d.ts +38 -0
- package/dist/types/runner/in_memory_runner.d.ts +7 -1
- package/dist/types/runner/runner.d.ts +44 -10
- package/dist/types/sessions/base_session_service.d.ts +3 -16
- package/dist/types/sessions/session.d.ts +11 -0
- package/dist/types/sessions/vertex_ai_session_service.d.ts +9 -1
- package/dist/types/tools/consolidate_context_tool.d.ts +19 -0
- package/dist/types/tools/enterprise_web_search_tool.d.ts +26 -0
- package/dist/types/tools/example_tool.d.ts +21 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +3 -2
- package/dist/types/tools/load_web_page.d.ts +33 -0
- package/dist/types/tools/mcp/load_mcp_resource_tool.d.ts +26 -0
- package/dist/types/tools/mcp/mcp_toolset.d.ts +27 -0
- package/dist/types/tools/skill/run_skill_inline_script_tool.d.ts +25 -0
- package/dist/types/tools/skill/skill_toolset.d.ts +9 -0
- package/dist/types/utils/async_hooks_shim.d.ts +10 -0
- package/dist/types/utils/branch_trie.d.ts +14 -0
- package/dist/types/utils/client_labels.d.ts +10 -0
- package/dist/types/utils/env_aware_utils.d.ts +3 -3
- package/dist/types/utils/task.d.ts +24 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/agent_to_a2a.js +18 -2
- package/dist/web/a2a/event_converter_utils.js +8 -4
- package/dist/web/a2a/metadata_converter_utils.js +1 -1
- package/dist/web/agents/active_streaming_tool.js +6 -1
- package/dist/web/agents/base_agent.js +39 -0
- package/dist/web/agents/context.js +1 -11
- package/dist/web/agents/functions.js +43 -32
- package/dist/web/agents/instructions.js +23 -5
- package/dist/web/agents/invocation_context.js +2 -5
- package/dist/web/agents/llm_agent.js +12 -9
- package/dist/web/agents/loop_agent.js +27 -3
- package/dist/web/agents/processors/code_execution_request_processor.js +0 -3
- package/dist/web/agents/processors/content_processor_utils.js +16 -3
- package/dist/web/agents/processors/context_compactor_request_processor.js +4 -2
- package/dist/web/agents/processors/interactions_request_processor.js +52 -0
- package/dist/web/agents/routed_agent.js +31 -0
- package/dist/web/agents/run_config.js +8 -3
- package/dist/web/apps/app.js +49 -0
- package/dist/web/apps/resumability_config.js +31 -0
- package/dist/web/artifacts/file_artifact_service.js +14 -1
- package/dist/web/artifacts/gcs_artifact_service.js +55 -15
- package/dist/web/artifacts/in_memory_artifact_service.js +12 -1
- package/dist/web/artifacts/scoped_artifact_service.js +86 -0
- package/dist/web/artifacts/session_artifact_service.js +7 -0
- package/dist/web/auth/oauth2/oauth2_discovery.js +14 -4
- package/dist/web/auth/oauth2/oauth2_utils.js +12 -1
- package/dist/web/common.js +67 -3
- package/dist/web/context/agent_controlled_context_compactor.js +81 -0
- package/dist/web/context/anchored_context_compactor.js +117 -0
- package/dist/web/context/compaction_utils.js +27 -0
- package/dist/web/context/token_based_context_compactor.js +52 -33
- package/dist/web/context/trajectory_thought_pruning_compactor.js +43 -0
- package/dist/web/events/compacted_event.js +7 -2
- package/dist/web/events/event.js +44 -0
- package/dist/web/index.js +6 -1
- package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
- package/dist/web/models/google_llm.js +54 -9
- package/dist/web/models/interactions_utils.js +728 -0
- package/dist/web/plugins/base_plugin.js +1 -0
- package/dist/web/plugins/global_instruction_plugin.js +67 -0
- package/dist/web/runner/in_memory_runner.js +13 -2
- package/dist/web/runner/runner.js +157 -84
- package/dist/web/sessions/base_session_service.js +6 -1
- package/dist/web/sessions/database_session_service.js +24 -7
- package/dist/web/sessions/vertex_ai_session_service.js +17 -3
- package/dist/web/skills/loader.js +2 -2
- package/dist/web/tools/base_toolset.js +1 -1
- package/dist/web/tools/consolidate_context_tool.js +51 -0
- package/dist/web/tools/enterprise_web_search_tool.js +55 -0
- package/dist/web/tools/example_tool.js +42 -0
- package/dist/web/tools/forwarding_artifact_service.js +16 -28
- package/dist/web/tools/load_web_page.js +221 -0
- package/dist/web/tools/mcp/load_mcp_resource_tool.js +107 -0
- package/dist/web/tools/mcp/mcp_toolset.js +63 -0
- package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
- package/dist/web/tools/skill/run_skill_inline_script_tool.js +51 -4
- package/dist/web/tools/skill/skill_toolset.js +4 -2
- package/dist/web/utils/async_hooks_shim.js +24 -0
- package/dist/web/utils/branch_trie.js +13 -0
- package/dist/web/utils/client_labels.js +38 -2
- package/dist/web/utils/env_aware_utils.js +10 -1
- package/dist/web/utils/streaming_utils.js +11 -5
- package/dist/web/utils/task.js +34 -0
- package/dist/web/version.js +1 -1
- package/package.json +2 -2
|
@@ -4,16 +4,11 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { Part } from '@google/genai';
|
|
7
|
+
import { CompositeSessionKey } from '../sessions/session.js';
|
|
7
8
|
/**
|
|
8
9
|
* The parameters for `saveArtifact`.
|
|
9
10
|
*/
|
|
10
|
-
export interface SaveArtifactRequest {
|
|
11
|
-
/** The app name. */
|
|
12
|
-
appName: string;
|
|
13
|
-
/** The user ID. */
|
|
14
|
-
userId: string;
|
|
15
|
-
/** The session ID. */
|
|
16
|
-
sessionId: string;
|
|
11
|
+
export interface SaveArtifactRequest extends CompositeSessionKey {
|
|
17
12
|
/** The filename of the artifact. */
|
|
18
13
|
filename: string;
|
|
19
14
|
/** The artifact to save. */
|
|
@@ -26,13 +21,7 @@ export interface SaveArtifactRequest {
|
|
|
26
21
|
/**
|
|
27
22
|
* The parameters for `loadArtifact`.
|
|
28
23
|
*/
|
|
29
|
-
export interface LoadArtifactRequest {
|
|
30
|
-
/** The app name. */
|
|
31
|
-
appName: string;
|
|
32
|
-
/** The user ID. */
|
|
33
|
-
userId: string;
|
|
34
|
-
/** The session ID. */
|
|
35
|
-
sessionId: string;
|
|
24
|
+
export interface LoadArtifactRequest extends CompositeSessionKey {
|
|
36
25
|
/** The filename of the artifact. */
|
|
37
26
|
filename: string;
|
|
38
27
|
/**
|
|
@@ -44,37 +33,18 @@ export interface LoadArtifactRequest {
|
|
|
44
33
|
/**
|
|
45
34
|
* The parameters for `listArtifactKeys`.
|
|
46
35
|
*/
|
|
47
|
-
export
|
|
48
|
-
/** The app name. */
|
|
49
|
-
appName: string;
|
|
50
|
-
/** The user ID. */
|
|
51
|
-
userId: string;
|
|
52
|
-
/** The session ID. */
|
|
53
|
-
sessionId: string;
|
|
54
|
-
}
|
|
36
|
+
export type ListArtifactKeysRequest = CompositeSessionKey;
|
|
55
37
|
/**
|
|
56
38
|
* The parameters for `deleteArtifact`.
|
|
57
39
|
*/
|
|
58
|
-
export interface DeleteArtifactRequest {
|
|
59
|
-
/** The app name. */
|
|
60
|
-
appName: string;
|
|
61
|
-
/** The user ID. */
|
|
62
|
-
userId: string;
|
|
63
|
-
/** The session ID. */
|
|
64
|
-
sessionId: string;
|
|
40
|
+
export interface DeleteArtifactRequest extends CompositeSessionKey {
|
|
65
41
|
/** The filename of the artifact. */
|
|
66
42
|
filename: string;
|
|
67
43
|
}
|
|
68
44
|
/**
|
|
69
45
|
* The parameters for `listVersions`.
|
|
70
46
|
*/
|
|
71
|
-
export interface ListVersionsRequest {
|
|
72
|
-
/** The app name. */
|
|
73
|
-
appName: string;
|
|
74
|
-
/** The user ID. */
|
|
75
|
-
userId: string;
|
|
76
|
-
/** The session ID. */
|
|
77
|
-
sessionId: string;
|
|
47
|
+
export interface ListVersionsRequest extends CompositeSessionKey {
|
|
78
48
|
/** The filename of the artifact. */
|
|
79
49
|
filename: string;
|
|
80
50
|
}
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { StorageOptions } from '@google-cloud/storage';
|
|
6
7
|
import { Part } from '@google/genai';
|
|
7
8
|
import { ArtifactVersion, BaseArtifactService, DeleteArtifactRequest, ListArtifactKeysRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest } from './base_artifact_service.js';
|
|
8
9
|
export declare class GcsArtifactService implements BaseArtifactService {
|
|
9
10
|
private readonly bucket;
|
|
10
|
-
constructor(bucket: string);
|
|
11
|
+
constructor(bucket: string, options?: StorageOptions);
|
|
11
12
|
saveArtifact(request: SaveArtifactRequest): Promise<number>;
|
|
12
13
|
loadArtifact(request: LoadArtifactRequest): Promise<Part | undefined>;
|
|
13
14
|
listArtifactKeys(request: ListArtifactKeysRequest): Promise<string[]>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part } from '@google/genai';
|
|
7
|
+
import { ArtifactVersion, BaseArtifactService } from './base_artifact_service.js';
|
|
8
|
+
import { SessionArtifactService, SessionLoadArtifactRequest, SessionSaveArtifactRequest } from './session_artifact_service.js';
|
|
9
|
+
/**
|
|
10
|
+
* A wrapper that scopes a BaseArtifactService to a specific session.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ScopedArtifactService implements SessionArtifactService {
|
|
13
|
+
private readonly delegate;
|
|
14
|
+
private readonly appName;
|
|
15
|
+
private readonly userId;
|
|
16
|
+
private readonly sessionId;
|
|
17
|
+
constructor(delegate: BaseArtifactService, appName: string, userId: string, sessionId: string);
|
|
18
|
+
saveArtifact(request: SessionSaveArtifactRequest): Promise<number>;
|
|
19
|
+
loadArtifact(request: SessionLoadArtifactRequest): Promise<Part | undefined>;
|
|
20
|
+
listArtifactKeys(): Promise<string[]>;
|
|
21
|
+
deleteArtifact(filename: string): Promise<void>;
|
|
22
|
+
listVersions(filename: string): Promise<number[]>;
|
|
23
|
+
listArtifactVersions(filename: string): Promise<ArtifactVersion[]>;
|
|
24
|
+
getArtifactVersion(request: SessionLoadArtifactRequest): Promise<ArtifactVersion | undefined>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Part } from '@google/genai';
|
|
7
|
+
import { ArtifactVersion } from './base_artifact_service.js';
|
|
8
|
+
export interface SessionSaveArtifactRequest {
|
|
9
|
+
filename: string;
|
|
10
|
+
artifact: Part;
|
|
11
|
+
customMetadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionLoadArtifactRequest {
|
|
14
|
+
filename: string;
|
|
15
|
+
version?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface SessionArtifactService {
|
|
18
|
+
saveArtifact(request: SessionSaveArtifactRequest): Promise<number>;
|
|
19
|
+
loadArtifact(request: SessionLoadArtifactRequest): Promise<Part | undefined>;
|
|
20
|
+
listArtifactKeys(): Promise<string[]>;
|
|
21
|
+
deleteArtifact(filename: string): Promise<void>;
|
|
22
|
+
listVersions(filename: string): Promise<number[]>;
|
|
23
|
+
listArtifactVersions(filename: string): Promise<ArtifactVersion[]>;
|
|
24
|
+
getArtifactVersion(request: SessionLoadArtifactRequest): Promise<ArtifactVersion | undefined>;
|
|
25
|
+
}
|
|
@@ -36,3 +36,14 @@ export declare class OAuth2DiscoveryManager {
|
|
|
36
36
|
*/
|
|
37
37
|
discoverResourceMetadata(resourceUrl: string): Promise<ProtectedResourceMetadata | undefined>;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Normalises the hostname returned by the WHATWG URL parser so that
|
|
41
|
+
* IPv4-mapped IPv6 addresses (e.g. [::ffff:7f00:1]) are converted to
|
|
42
|
+
* their canonical dotted-decimal IPv4 form (127.0.0.1) before any
|
|
43
|
+
* blocklist checks are applied.
|
|
44
|
+
*
|
|
45
|
+
* Without this step an attacker can bypass every IPv4 block by encoding
|
|
46
|
+
* the address as its IPv4-mapped IPv6 equivalent (CWE-918).
|
|
47
|
+
*/
|
|
48
|
+
export declare function normaliseHostname(raw: string): string;
|
|
49
|
+
export declare function validateDiscoveryUrl(urlStr: string): boolean;
|
package/dist/types/common.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export type { ActiveStreamingToolParams } from './agents/active_streaming_tool.j
|
|
|
8
8
|
export { BaseAgent, isBaseAgent } from './agents/base_agent.js';
|
|
9
9
|
export type { AfterAgentCallback, BaseAgentConfig, BeforeAgentCallback, SingleAgentCallback, } from './agents/base_agent.js';
|
|
10
10
|
export { Context } from './agents/context.js';
|
|
11
|
-
export { functionsExportedForTestingOnly } from './agents/functions.js';
|
|
11
|
+
export { findEventByFunctionCallId, findMatchingFunctionCall, functionsExportedForTestingOnly, } from './agents/functions.js';
|
|
12
12
|
export { InvocationContext } from './agents/invocation_context.js';
|
|
13
13
|
export type { InvocationContextParams } from './agents/invocation_context.js';
|
|
14
14
|
export { LiveRequestQueue } from './agents/live_request_queue.js';
|
|
@@ -22,6 +22,7 @@ export { AgentTransferLlmRequestProcessor } from './agents/processors/agent_tran
|
|
|
22
22
|
export { BaseLlmRequestProcessor, BaseLlmResponseProcessor, } from './agents/processors/base_llm_processor.js';
|
|
23
23
|
export { CONTENT_REQUEST_PROCESSOR, ContentRequestProcessor, } from './agents/processors/content_request_processor.js';
|
|
24
24
|
export { ContextCompactorRequestProcessor } from './agents/processors/context_compactor_request_processor.js';
|
|
25
|
+
export { INTERACTIONS_REQUEST_PROCESSOR, InteractionsRequestProcessor, } from './agents/processors/interactions_request_processor.js';
|
|
25
26
|
export { ReadonlyContext } from './agents/readonly_context.js';
|
|
26
27
|
export { RoutedAgent, isRoutedAgent } from './agents/routed_agent.js';
|
|
27
28
|
export type { AgentRouter, RoutedAgentConfig } from './agents/routed_agent.js';
|
|
@@ -29,8 +30,11 @@ export { StreamingMode } from './agents/run_config.js';
|
|
|
29
30
|
export type { RunConfig } from './agents/run_config.js';
|
|
30
31
|
export { SequentialAgent, isSequentialAgent } from './agents/sequential_agent.js';
|
|
31
32
|
export type { TranscriptionEntry } from './agents/transcription_entry.js';
|
|
33
|
+
export { createResumabilityConfig } from './apps/resumability_config.js';
|
|
34
|
+
export type { ResumabilityConfig } from './apps/resumability_config.js';
|
|
32
35
|
export type { BaseArtifactService, DeleteArtifactRequest, ListArtifactKeysRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest, } from './artifacts/base_artifact_service.js';
|
|
33
36
|
export { InMemoryArtifactService } from './artifacts/in_memory_artifact_service.js';
|
|
37
|
+
export type { SessionArtifactService, SessionLoadArtifactRequest, SessionSaveArtifactRequest, } from './artifacts/session_artifact_service.js';
|
|
34
38
|
export { AuthCredentialTypes } from './auth/auth_credential.js';
|
|
35
39
|
export type { AuthCredential, HttpAuth, HttpCredentials, OAuth2Auth, ServiceAccount, ServiceAccountCredential, } from './auth/auth_credential.js';
|
|
36
40
|
export { AuthHandler } from './auth/auth_handler.js';
|
|
@@ -53,17 +57,22 @@ export { BaseCodeExecutor } from './code_executors/base_code_executor.js';
|
|
|
53
57
|
export type { ExecuteCodeParams } from './code_executors/base_code_executor.js';
|
|
54
58
|
export { BuiltInCodeExecutor } from './code_executors/built_in_code_executor.js';
|
|
55
59
|
export { CodeExecutionLanguage, FileContentEncoding, type CodeExecutionInput, type CodeExecutionResult, type File, } from './code_executors/code_execution_utils.js';
|
|
60
|
+
export { AgentControlledContextCompactor } from './context/agent_controlled_context_compactor.js';
|
|
61
|
+
export { AnchoredContextCompactor } from './context/anchored_context_compactor.js';
|
|
62
|
+
export type { AnchoredContextCompactorOptions } from './context/anchored_context_compactor.js';
|
|
56
63
|
export type { BaseContextCompactor } from './context/base_context_compactor.js';
|
|
57
64
|
export type { BaseSummarizer } from './context/summarizers/base_summarizer.js';
|
|
58
65
|
export { LlmSummarizer } from './context/summarizers/llm_summarizer.js';
|
|
59
66
|
export type { LlmSummarizerOptions } from './context/summarizers/llm_summarizer.js';
|
|
60
67
|
export { TokenBasedContextCompactor } from './context/token_based_context_compactor.js';
|
|
61
68
|
export type { TokenBasedContextCompactorOptions } from './context/token_based_context_compactor.js';
|
|
69
|
+
export { TrajectoryThoughtPruningCompactor } from './context/trajectory_thought_pruning_compactor.js';
|
|
70
|
+
export type { TrajectoryThoughtPruningCompactorOptions } from './context/trajectory_thought_pruning_compactor.js';
|
|
62
71
|
export { TruncatingContextCompactor } from './context/truncating_context_compactor.js';
|
|
63
72
|
export type { TruncatingContextCompactorOptions } from './context/truncating_context_compactor.js';
|
|
64
|
-
export { isCompactedEvent } from './events/compacted_event.js';
|
|
73
|
+
export { isCompactedEvent, isScratchpadEvent } from './events/compacted_event.js';
|
|
65
74
|
export type { CompactedEvent } from './events/compacted_event.js';
|
|
66
|
-
export { createEvent, getFunctionCalls, getFunctionResponses, hasTrailingCodeExecutionResult, isFinalResponse, stringifyContent, } from './events/event.js';
|
|
75
|
+
export { createEvent, generateClientFunctionCallId, getFunctionCalls, getFunctionResponses, hasThoughts, hasTrailingCodeExecutionResult, isFinalResponse, populateClientFunctionCallId, pruneThoughts, stringifyContent, } from './events/event.js';
|
|
67
76
|
export type { Event } from './events/event.js';
|
|
68
77
|
export { createEventActions } from './events/event_actions.js';
|
|
69
78
|
export type { EventActions } from './events/event_actions.js';
|
|
@@ -89,18 +98,19 @@ export type { BaseLlmType } from './models/registry.js';
|
|
|
89
98
|
export { RoutedLlm } from './models/routed_llm.js';
|
|
90
99
|
export type { LlmRouter } from './models/routed_llm.js';
|
|
91
100
|
export { BasePlugin, ContextCompactionTrigger } from './plugins/base_plugin.js';
|
|
101
|
+
export { GlobalInstructionPlugin } from './plugins/global_instruction_plugin.js';
|
|
92
102
|
export { LoggingPlugin } from './plugins/logging_plugin.js';
|
|
93
103
|
export { PluginManager } from './plugins/plugin_manager.js';
|
|
94
104
|
export { InMemoryPolicyEngine, PolicyOutcome, REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, SecurityPlugin, getAskUserConfirmationFunctionCalls, } from './plugins/security_plugin.js';
|
|
95
105
|
export type { BasePolicyEngine, PolicyCheckResult, ToolCallPolicyContext, } from './plugins/security_plugin.js';
|
|
96
106
|
export { InMemoryRunner } from './runner/in_memory_runner.js';
|
|
97
|
-
export { Runner, isRunner } from './runner/runner.js';
|
|
107
|
+
export { Runner, determineAgentForResumption, findEventByLastFunctionResponseId, isRoutableLlmAgent, isRunner, } from './runner/runner.js';
|
|
98
108
|
export type { RunnerConfig } from './runner/runner.js';
|
|
99
109
|
export { BaseSessionService } from './sessions/base_session_service.js';
|
|
100
110
|
export type { AppendEventRequest, CreateSessionRequest, DeleteSessionRequest, GetSessionConfig, GetSessionRequest, ListSessionsRequest, ListSessionsResponse, } from './sessions/base_session_service.js';
|
|
101
111
|
export { InMemorySessionService } from './sessions/in_memory_session_service.js';
|
|
102
112
|
export { createSession } from './sessions/session.js';
|
|
103
|
-
export type { Session } from './sessions/session.js';
|
|
113
|
+
export type { CompositeSessionKey, Session } from './sessions/session.js';
|
|
104
114
|
export { State } from './sessions/state.js';
|
|
105
115
|
export { AgentTool, isAgentTool } from './tools/agent_tool.js';
|
|
106
116
|
export type { AgentToolConfig } from './tools/agent_tool.js';
|
|
@@ -108,6 +118,9 @@ export { BaseTool, isBaseTool } from './tools/base_tool.js';
|
|
|
108
118
|
export type { BaseToolParams, RunAsyncToolRequest, ToolProcessLlmRequest, } from './tools/base_tool.js';
|
|
109
119
|
export { BaseToolset, isBaseToolset } from './tools/base_toolset.js';
|
|
110
120
|
export type { ToolPredicate } from './tools/base_toolset.js';
|
|
121
|
+
export { ConsolidateContextTool } from './tools/consolidate_context_tool.js';
|
|
122
|
+
export { ENTERPRISE_WEB_SEARCH, EnterpriseWebSearchTool, } from './tools/enterprise_web_search_tool.js';
|
|
123
|
+
export { ExampleTool } from './tools/example_tool.js';
|
|
111
124
|
export { EXIT_LOOP, ExitLoopTool } from './tools/exit_loop_tool.js';
|
|
112
125
|
export { FunctionTool, isFunctionTool } from './tools/function_tool.js';
|
|
113
126
|
export type { ToolExecuteArgument, ToolExecuteFunction, ToolInputParameters, ToolOptions, } from './tools/function_tool.js';
|
|
@@ -115,6 +128,8 @@ export { GOOGLE_MAPS_GROUNDING, GoogleMapsGroundingTool, } from './tools/google_
|
|
|
115
128
|
export { GOOGLE_SEARCH, GoogleSearchTool } from './tools/google_search_tool.js';
|
|
116
129
|
export { LOAD_ARTIFACTS, LoadArtifactsTool, } from './tools/load_artifacts_tool.js';
|
|
117
130
|
export { LOAD_MEMORY, LoadMemoryTool } from './tools/load_memory_tool.js';
|
|
131
|
+
export { LOAD_WEB_PAGE, loadWebPage } from './tools/load_web_page.js';
|
|
132
|
+
export type { LoadWebPageOptions } from './tools/load_web_page.js';
|
|
118
133
|
export { LongRunningFunctionTool } from './tools/long_running_tool.js';
|
|
119
134
|
export { PRELOAD_MEMORY, PreloadMemoryTool, } from './tools/preload_memory_tool.js';
|
|
120
135
|
export { ToolConfirmation } from './tools/tool_confirmation.js';
|
|
@@ -122,10 +137,13 @@ export { URL_CONTEXT, UrlContextTool } from './tools/url_context_tool.js';
|
|
|
122
137
|
export { VertexAiSearchTool } from './tools/vertex_ai_search_tool.js';
|
|
123
138
|
export type { DataStoreParams, SearchEngineParams, VertexAISearchConfig, VertexAISearchDataStoreSpec, VertexAiSearchToolParams, } from './tools/vertex_ai_search_tool.js';
|
|
124
139
|
export { VertexRagRetrievalTool } from './tools/vertex_rag_retrieval_tool.js';
|
|
140
|
+
export { getClientLabels, runWithClientLabel } from './utils/client_labels.js';
|
|
125
141
|
export { LogLevel, getLogger, setLogLevel, setLogger } from './utils/logger.js';
|
|
126
142
|
export type { Logger } from './utils/logger.js';
|
|
127
143
|
export { isGemini2OrAbove, isGemini3xFlashLive } from './utils/model_name.js';
|
|
128
144
|
export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
|
|
145
|
+
export { Task } from './utils/task.js';
|
|
146
|
+
export type { TaskExecutable } from './utils/task.js';
|
|
129
147
|
export { GoogleLLMVariant } from './utils/variant_utils.js';
|
|
130
148
|
export { version } from './version.js';
|
|
131
149
|
export { GCPSkillRegistry } from './skills/gcp_skill_registry.js';
|
|
@@ -138,6 +156,11 @@ export { LoadSkillResourceTool } from './tools/skill/load_skill_resource_tool.js
|
|
|
138
156
|
export { LoadSkillTool } from './tools/skill/load_skill_tool.js';
|
|
139
157
|
export { SearchSkillsTool } from './tools/skill/search_skills_tool.js';
|
|
140
158
|
export { SkillToolset } from './tools/skill/skill_toolset.js';
|
|
159
|
+
export * from './artifacts/base_artifact_service.js';
|
|
160
|
+
export * from './features/feature_registry.js';
|
|
161
|
+
export * from './memory/base_memory_service.js';
|
|
162
|
+
export * from './sessions/base_session_service.js';
|
|
163
|
+
export * from './tools/base_tool.js';
|
|
141
164
|
export { OpenApiSpecParser } from './tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js';
|
|
142
165
|
export type { OperationEndpoint, ParsedOperation, } from './tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js';
|
|
143
166
|
export { OperationParser } from './tools/openapi_tool/openapi_spec_parser/operation_parser.js';
|
|
@@ -146,6 +169,7 @@ export { ToolAuthHandler } from './tools/openapi_tool/openapi_spec_parser/tool_a
|
|
|
146
169
|
export type { AuthPreparationResult } from './tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js';
|
|
147
170
|
export { OpenAPIToolset } from './tools/openapi_tool/openapi_toolset.js';
|
|
148
171
|
export { RestApiTool, createRestApiTool, } from './tools/openapi_tool/rest_api_tool.js';
|
|
172
|
+
export * from './apps/app.js';
|
|
149
173
|
export * from './artifacts/base_artifact_service.js';
|
|
150
174
|
export * from './features/feature_registry.js';
|
|
151
175
|
export * from './memory/base_memory_service.js';
|
|
@@ -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 { ContextCompactionTrigger } from '../plugins/base_plugin.js';
|
|
8
|
+
import { BaseContextCompactor } from './base_context_compactor.js';
|
|
9
|
+
import { BaseSummarizer } from './summarizers/base_summarizer.js';
|
|
10
|
+
/**
|
|
11
|
+
* A context compactor that triggers compaction when the agent explicitly
|
|
12
|
+
* requests it via the `ConsolidateContextTool`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AgentControlledContextCompactor implements BaseContextCompactor {
|
|
15
|
+
readonly trigger = ContextCompactionTrigger.AgentControlled;
|
|
16
|
+
private readonly summarizer;
|
|
17
|
+
constructor(options: {
|
|
18
|
+
summarizer: BaseSummarizer;
|
|
19
|
+
});
|
|
20
|
+
shouldCompact(invocationContext: InvocationContext): boolean;
|
|
21
|
+
compact(invocationContext: InvocationContext): Promise<void>;
|
|
22
|
+
private clearFlags;
|
|
23
|
+
private getActiveEvents;
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 AnchoredContextCompactorOptions {
|
|
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 maintains a single persistent 'Scratchpad' or
|
|
22
|
+
* 'State Tracker' event at the top of the context history.
|
|
23
|
+
*
|
|
24
|
+
* When compaction is triggered, it merges new raw events into the existing
|
|
25
|
+
* Scratchpad event and discards them from the active history view.
|
|
26
|
+
*/
|
|
27
|
+
export declare class AnchoredContextCompactor implements BaseContextCompactor {
|
|
28
|
+
private readonly tokenThreshold;
|
|
29
|
+
private readonly eventRetentionSize;
|
|
30
|
+
private readonly summarizer;
|
|
31
|
+
constructor(options: AnchoredContextCompactorOptions);
|
|
32
|
+
private getActiveEvents;
|
|
33
|
+
shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
|
|
34
|
+
compact(invocationContext: InvocationContext): Promise<void>;
|
|
35
|
+
}
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { InvocationContext } from '../agents/invocation_context.js';
|
|
7
|
+
import { ContextCompactionTrigger } from '../plugins/base_plugin.js';
|
|
7
8
|
/**
|
|
8
9
|
* Interface for compacting the context history in an agent session.
|
|
9
10
|
*/
|
|
10
11
|
export interface BaseContextCompactor {
|
|
12
|
+
/** The trigger associated with this compactor. */
|
|
13
|
+
readonly trigger?: ContextCompactionTrigger;
|
|
11
14
|
/**
|
|
12
15
|
* Determines whether the context should be compacted.
|
|
13
16
|
*
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Event } from '../events/event.js';
|
|
7
|
+
/**
|
|
8
|
+
* Determines the baseline index to retain from active raw events,
|
|
9
|
+
* ensuring we don't split between a function call and its response.
|
|
10
|
+
*
|
|
11
|
+
* @param rawEvents The active raw events to consider for compaction.
|
|
12
|
+
* @param eventRetentionSize The minimum number of raw events to keep at the end of the session.
|
|
13
|
+
* @returns The index in `rawEvents` at which to split. Events before this index will be compacted.
|
|
14
|
+
*/
|
|
15
|
+
export declare function calculateRetainStartIndex(rawEvents: Event[], eventRetentionSize: number): number;
|
|
@@ -7,7 +7,12 @@ import { InvocationContext } from '../agents/invocation_context.js';
|
|
|
7
7
|
import { BaseContextCompactor } from './base_context_compactor.js';
|
|
8
8
|
import { BaseSummarizer } from './summarizers/base_summarizer.js';
|
|
9
9
|
export interface TokenBasedContextCompactorOptions {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Prompt-size threshold (in tokens) that triggers compaction. Compared
|
|
12
|
+
* against the most recently observed LLM request size
|
|
13
|
+
* (`usageMetadata.promptTokenCount`), falling back to a character-based
|
|
14
|
+
* estimate of the effective contents when no usage metadata is available.
|
|
15
|
+
*/
|
|
11
16
|
tokenThreshold: number;
|
|
12
17
|
/**
|
|
13
18
|
* The minimum number of raw events to keep at the end of the session.
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Options for TrajectoryThoughtPruningCompactor.
|
|
10
|
+
*/
|
|
11
|
+
export interface TrajectoryThoughtPruningCompactorOptions {
|
|
12
|
+
/**
|
|
13
|
+
* The minimum number of raw events to keep at the end of the session.
|
|
14
|
+
* Compaction will not affect these tail events.
|
|
15
|
+
*/
|
|
16
|
+
eventRetentionSize: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A context compactor that prunes thought parts from older events in the session history.
|
|
20
|
+
* Preserves the causal history (actions and observations) while reducing token usage.
|
|
21
|
+
*/
|
|
22
|
+
export declare class TrajectoryThoughtPruningCompactor implements BaseContextCompactor {
|
|
23
|
+
private readonly eventRetentionSize;
|
|
24
|
+
constructor(options: TrajectoryThoughtPruningCompactorOptions);
|
|
25
|
+
shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
|
|
26
|
+
compact(invocationContext: InvocationContext): void | Promise<void>;
|
|
27
|
+
}
|
|
@@ -25,9 +25,19 @@ export interface CompactedEvent extends Event {
|
|
|
25
25
|
* The summarized content of the compacted events.
|
|
26
26
|
*/
|
|
27
27
|
compactedContent: string;
|
|
28
|
+
/**
|
|
29
|
+
* Identifies this compacted event as the persistent context scratchpad.
|
|
30
|
+
*/
|
|
31
|
+
isScratchpad?: boolean;
|
|
28
32
|
}
|
|
29
33
|
/**
|
|
30
34
|
* Type guard to check if an event is a CompactedEvent.
|
|
31
35
|
*/
|
|
32
36
|
export declare function isCompactedEvent(event: Event): event is CompactedEvent;
|
|
37
|
+
/**
|
|
38
|
+
* Type guard to check if an event is a scratchpad CompactedEvent.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isScratchpadEvent(event: Event): event is CompactedEvent & {
|
|
41
|
+
isScratchpad: true;
|
|
42
|
+
};
|
|
33
43
|
export declare function createCompactedEvent(params?: Partial<CompactedEvent>): CompactedEvent;
|
|
@@ -67,6 +67,15 @@ export declare function isFinalResponse(event: Event): boolean;
|
|
|
67
67
|
* Returns the function calls in the event.
|
|
68
68
|
*/
|
|
69
69
|
export declare function getFunctionCalls(event: Event): FunctionCall[];
|
|
70
|
+
export declare const AF_FUNCTION_CALL_ID_PREFIX = "adk-";
|
|
71
|
+
export declare function generateClientFunctionCallId(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Populates client-side function call IDs.
|
|
74
|
+
*
|
|
75
|
+
* It iterates through all function calls in the event and assigns a
|
|
76
|
+
* unique client-side ID to each one that doesn't already have an ID.
|
|
77
|
+
*/
|
|
78
|
+
export declare function populateClientFunctionCallId(modelResponseEvent: Event): void;
|
|
70
79
|
/**
|
|
71
80
|
* Returns the function responses in the event.
|
|
72
81
|
*/
|
|
@@ -82,6 +91,18 @@ export declare function hasTrailingCodeExecutionResult(event: Event): boolean;
|
|
|
82
91
|
* @returns A single string with the combined text.
|
|
83
92
|
*/
|
|
84
93
|
export declare function stringifyContent(event: Event): string;
|
|
94
|
+
/**
|
|
95
|
+
* Estimates the number of tokens in the event based on usage metadata or characters.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getEventTokens(event: Event): number;
|
|
98
|
+
/**
|
|
99
|
+
* Returns whether the event contains any thought parts.
|
|
100
|
+
*/
|
|
101
|
+
export declare function hasThoughts(event: Event): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Returns a copy of the event with all thought parts removed.
|
|
104
|
+
*/
|
|
105
|
+
export declare function pruneThoughts(event: Event): Event;
|
|
85
106
|
/**
|
|
86
107
|
* Generates a new unique ID for the event.
|
|
87
108
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { getA2AAgentCard } from './a2a/agent_card.js';
|
|
|
9
9
|
export { A2AAgentExecutor } from './a2a/agent_executor.js';
|
|
10
10
|
export type { AfterEventCallback, AfterExecuteCallback, AgentExecutorConfig, BeforeExecuteCallback, RunnerOrRunnerConfig, } from './a2a/agent_executor.js';
|
|
11
11
|
export { toA2a } from './a2a/agent_to_a2a.js';
|
|
12
|
-
export type { ToA2aOptions } from './a2a/agent_to_a2a.js';
|
|
12
|
+
export type { A2aUserBuilder, ToA2aOptions } from './a2a/agent_to_a2a.js';
|
|
13
13
|
export type { ExecutorContext } from './a2a/executor_context.js';
|
|
14
14
|
export { InvocationContext } from './agents/invocation_context.js';
|
|
15
15
|
export { FileArtifactService } from './artifacts/file_artifact_service.js';
|
|
@@ -24,11 +24,12 @@ export { getSessionServiceFromUri } from './sessions/registry.js';
|
|
|
24
24
|
export { VertexAiSessionService } from './sessions/vertex_ai_session_service.js';
|
|
25
25
|
export type { VertexAiSessionServiceOptions } from './sessions/vertex_ai_session_service.js';
|
|
26
26
|
export { loadAllSkillsInDir, loadSkillFromDir, validateSkillDir, } from './skills/loader.js';
|
|
27
|
-
export { RunSkillInlineScriptTool } from './tools/skill/run_skill_inline_script_tool.js';
|
|
27
|
+
export { RunSkillInlineScriptErrorCode, RunSkillInlineScriptTool, } from './tools/skill/run_skill_inline_script_tool.js';
|
|
28
28
|
export { RunSkillScriptTool } from './tools/skill/run_skill_script_tool.js';
|
|
29
29
|
export * from './integrations/agent_registry/agent_registry.js';
|
|
30
30
|
export * from './telemetry/google_cloud.js';
|
|
31
31
|
export * from './telemetry/setup.js';
|
|
32
|
+
export * from './tools/mcp/load_mcp_resource_tool.js';
|
|
32
33
|
export * from './tools/mcp/mcp_session_manager.js';
|
|
33
34
|
export * from './tools/mcp/mcp_tool.js';
|
|
34
35
|
export * from './tools/mcp/mcp_toolset.js';
|
|
@@ -39,20 +39,33 @@ export interface GeminiParams {
|
|
|
39
39
|
* Headers to merge with internally crafted headers.
|
|
40
40
|
*/
|
|
41
41
|
headers?: Record<string, string>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to use the Interactions API for stateful conversations.
|
|
44
|
+
*/
|
|
45
|
+
useInteractionsApi?: boolean;
|
|
42
46
|
}
|
|
47
|
+
declare const GEMINI_MODEL_SYMBOL: unique symbol;
|
|
48
|
+
/**
|
|
49
|
+
* Type guard to check if an object is an instance of Gemini.
|
|
50
|
+
* @param obj The object to check.
|
|
51
|
+
* @returns True if the object is an instance of Gemini, false otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isGemini(obj: unknown): obj is Gemini;
|
|
43
54
|
/**
|
|
44
55
|
* Integration for Gemini models.
|
|
45
56
|
*/
|
|
46
57
|
export declare class Gemini extends BaseLlm {
|
|
58
|
+
readonly [GEMINI_MODEL_SYMBOL] = true;
|
|
47
59
|
private readonly apiKey?;
|
|
48
60
|
protected readonly vertexai: boolean;
|
|
49
61
|
private readonly project?;
|
|
50
62
|
private readonly location?;
|
|
51
63
|
private readonly headers?;
|
|
64
|
+
readonly useInteractionsApi: boolean;
|
|
52
65
|
/**
|
|
53
66
|
* @param params The parameters for creating a Gemini instance.
|
|
54
67
|
*/
|
|
55
|
-
constructor({ model, apiKey, vertexai, project, location, headers, }: GeminiParams);
|
|
68
|
+
constructor({ model, apiKey, vertexai, project, location, headers, useInteractionsApi, }: GeminiParams);
|
|
56
69
|
/**
|
|
57
70
|
* A list of model name patterns that are supported by this LLM.
|
|
58
71
|
*
|
|
@@ -88,3 +101,4 @@ export declare class Gemini extends BaseLlm {
|
|
|
88
101
|
private preprocessRequest;
|
|
89
102
|
}
|
|
90
103
|
export declare function geminiInitParams({ model, vertexai, project, location, apiKey, }: GeminiParams): GeminiParams;
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Content, GenerateContentConfig, GoogleGenAI, Interactions, Part } from '@google/genai';
|
|
7
|
+
import { LlmRequest } from './llm_request.js';
|
|
8
|
+
import { LlmResponse } from './llm_response.js';
|
|
9
|
+
export interface ExtendedInteraction extends Interactions.Interaction {
|
|
10
|
+
error?: {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface ExtendedInteractionStatusUpdate extends Omit<Interactions.InteractionStatusUpdate, 'error'> {
|
|
16
|
+
error?: {
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface ExtendedFunctionCallStep extends Interactions.FunctionCallStep {
|
|
22
|
+
signature?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface ExtendedInteractionSSEEvent extends Omit<Interactions.InteractionSSEEvent, 'error' | 'interaction_id' | 'status' | 'event_type'> {
|
|
25
|
+
event_type?: string;
|
|
26
|
+
eventType?: string;
|
|
27
|
+
delta?: {
|
|
28
|
+
type: string;
|
|
29
|
+
text?: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
id?: string;
|
|
32
|
+
arguments?: Record<string, unknown>;
|
|
33
|
+
thought_signature?: string;
|
|
34
|
+
signature?: string;
|
|
35
|
+
data?: string;
|
|
36
|
+
uri?: string;
|
|
37
|
+
mime_type: string;
|
|
38
|
+
};
|
|
39
|
+
status?: string;
|
|
40
|
+
error?: {
|
|
41
|
+
code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
code?: string;
|
|
45
|
+
message?: string;
|
|
46
|
+
interaction_id?: string;
|
|
47
|
+
interactionId?: string;
|
|
48
|
+
interaction?: {
|
|
49
|
+
id: string;
|
|
50
|
+
};
|
|
51
|
+
id?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Extracts the latest turn contents for interactions API.
|
|
55
|
+
*/
|
|
56
|
+
export declare function getLatestUserContents(contents: Content[]): Content[];
|
|
57
|
+
/**
|
|
58
|
+
* Convert a Content to a list of Steps.
|
|
59
|
+
*/
|
|
60
|
+
export declare function convertContentToSteps(content: Content): Interactions.Step[];
|
|
61
|
+
/**
|
|
62
|
+
* Convert a Step to a list of Parts.
|
|
63
|
+
*/
|
|
64
|
+
export declare function convertStepToParts(step: Interactions.Step): Part[];
|
|
65
|
+
/**
|
|
66
|
+
* Convert tools config to interactions format.
|
|
67
|
+
*/
|
|
68
|
+
export declare function convertToolsConfigToInteractionsFormat(config: GenerateContentConfig): Interactions.Tool[];
|
|
69
|
+
/**
|
|
70
|
+
* Extract the latest model generated parts from a list of steps.
|
|
71
|
+
*/
|
|
72
|
+
export declare function getLatestModelParts(steps: Interactions.Step[]): Part[];
|
|
73
|
+
/**
|
|
74
|
+
* Convert Interaction response to an LlmResponse.
|
|
75
|
+
*/
|
|
76
|
+
export declare function convertInteractionToLlmResponse(interaction: ExtendedInteraction): LlmResponse;
|
|
77
|
+
/**
|
|
78
|
+
* Convert InteractionSSEEvent to LlmResponse.
|
|
79
|
+
*/
|
|
80
|
+
export declare function convertInteractionEventToLlmResponse(event: ExtendedInteractionSSEEvent, aggregatedParts: Part[], interactionId?: string): LlmResponse | null;
|
|
81
|
+
/**
|
|
82
|
+
* Build generation config.
|
|
83
|
+
*/
|
|
84
|
+
export declare function buildGenerationConfig(config: GenerateContentConfig): Record<string, unknown>;
|
|
85
|
+
/**
|
|
86
|
+
* Extract system instruction.
|
|
87
|
+
*/
|
|
88
|
+
export declare function extractSystemInstruction(config: GenerateContentConfig): string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Generate content using the interactions API.
|
|
91
|
+
*/
|
|
92
|
+
export declare function generateContentViaInteractions(apiClient: GoogleGenAI, llmRequest: LlmRequest, stream: boolean): AsyncGenerator<LlmResponse, void, void>;
|
|
@@ -34,6 +34,10 @@ export interface LlmRequest {
|
|
|
34
34
|
* The set of allowed tools, populated by request processors.
|
|
35
35
|
*/
|
|
36
36
|
allowedTools?: string[];
|
|
37
|
+
/**
|
|
38
|
+
* The interaction ID from the previous turn, if any.
|
|
39
|
+
*/
|
|
40
|
+
previousInteractionId?: string;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* Appends instructions to the system instruction.
|