@google/adk 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_event.js +290 -0
- package/dist/cjs/a2a/event_converter_utils.js +201 -0
- package/dist/cjs/a2a/executor_context.js +53 -0
- package/dist/cjs/a2a/metadata_converter_utils.js +125 -0
- package/dist/cjs/a2a/part_converter_utils.js +23 -21
- 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 +21 -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/processors/content_request_processor.js +66 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +54 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +85 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +165 -0
- package/dist/cjs/common.js +11 -7
- package/dist/cjs/index.js +89 -53
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/models/llm_response.js +2 -0
- package/dist/cjs/plugins/base_plugin.js +1 -1
- package/dist/cjs/runner/runner.js +1 -1
- package/dist/cjs/sessions/database_session_service.js +4 -1
- package/dist/cjs/sessions/db/operations.js +24 -12
- 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/mcp/mcp_toolset.js +9 -5
- package/dist/cjs/utils/logger.js +61 -54
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_event.js +243 -0
- package/dist/esm/a2a/event_converter_utils.js +187 -0
- package/dist/esm/a2a/executor_context.js +23 -0
- package/dist/esm/a2a/metadata_converter_utils.js +90 -0
- package/dist/esm/a2a/part_converter_utils.js +25 -21
- package/dist/esm/agents/base_agent.js +3 -3
- package/dist/esm/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +2 -2
- package/dist/esm/agents/llm_agent.js +14 -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/processors/content_request_processor.js +38 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +23 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +54 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +140 -0
- package/dist/esm/common.js +11 -9
- package/dist/esm/index.js +95 -18
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +1 -1
- package/dist/esm/sessions/database_session_service.js +4 -1
- package/dist/esm/sessions/db/operations.js +31 -7
- 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/mcp/mcp_toolset.js +9 -5
- package/dist/esm/utils/logger.js +51 -54
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_event.d.ts +122 -0
- package/dist/types/a2a/event_converter_utils.d.ts +20 -0
- package/dist/types/a2a/executor_context.d.ts +33 -0
- package/dist/types/a2a/metadata_converter_utils.d.ts +62 -0
- package/dist/types/a2a/part_converter_utils.d.ts +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 +8 -31
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +18 -0
- package/dist/types/agents/{base_llm_processor.d.ts → processors/base_llm_processor.d.ts} +4 -4
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/code_execution_request_processor.d.ts +34 -0
- package/dist/types/agents/processors/content_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/instructions_llm_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +13 -0
- package/dist/types/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 +4 -4
- 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/sessions/database_session_service.d.ts +2 -1
- package/dist/types/sessions/db/operations.d.ts +1 -1
- 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/mcp/mcp_toolset.d.ts +1 -1
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_event.js +243 -0
- package/dist/web/a2a/event_converter_utils.js +201 -0
- package/dist/web/a2a/executor_context.js +23 -0
- package/dist/web/a2a/metadata_converter_utils.js +107 -0
- package/dist/web/a2a/part_converter_utils.js +25 -21
- package/dist/web/agents/base_agent.js +3 -3
- package/dist/web/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/web/agents/functions.js +2 -2
- package/dist/web/agents/llm_agent.js +14 -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/processors/content_request_processor.js +56 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +41 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +72 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +158 -0
- package/dist/web/common.js +11 -9
- package/dist/web/index.js +13 -18
- package/dist/web/index.js.map +7 -0
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +1 -1
- package/dist/web/sessions/database_session_service.js +4 -1
- package/dist/web/sessions/db/operations.js +31 -7
- 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/mcp/mcp_toolset.js +27 -5
- package/dist/web/utils/logger.js +51 -54
- package/dist/web/version.js +1 -1
- package/package.json +3 -2
- 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
|
@@ -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>;
|
|
@@ -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,7 +11,7 @@ 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
|
*
|
|
@@ -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
|
|
@@ -32,7 +32,7 @@ import { MCPConnectionParams } from './mcp_session_manager.js';
|
|
|
32
32
|
*/
|
|
33
33
|
export declare class MCPToolset extends BaseToolset {
|
|
34
34
|
private readonly mcpSessionManager;
|
|
35
|
-
constructor(connectionParams: MCPConnectionParams, toolFilter?: ToolPredicate | string[]);
|
|
35
|
+
constructor(connectionParams: MCPConnectionParams, toolFilter?: ToolPredicate | string[], prefix?: string);
|
|
36
36
|
getTools(): Promise<BaseTool[]>;
|
|
37
37
|
close(): Promise<void>;
|
|
38
38
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
1
|
/** Log levels for the logger. */
|
|
7
2
|
export declare enum LogLevel {
|
|
8
3
|
DEBUG = 0,
|
|
@@ -19,11 +14,8 @@ export interface Logger {
|
|
|
19
14
|
info(...args: unknown[]): void;
|
|
20
15
|
warn(...args: unknown[]): void;
|
|
21
16
|
error(...args: unknown[]): void;
|
|
17
|
+
setLogLevel(level: LogLevel): void;
|
|
22
18
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Sets the log level for the logger.
|
|
25
|
-
*/
|
|
26
|
-
export declare function setLogLevel(level: LogLevel): void;
|
|
27
19
|
/**
|
|
28
20
|
* Sets a custom logger for ADK, or null to disable logging.
|
|
29
21
|
*/
|
|
@@ -36,6 +28,10 @@ export declare function getLogger(): Logger;
|
|
|
36
28
|
* Resets the logger to the default SimpleLogger.
|
|
37
29
|
*/
|
|
38
30
|
export declare function resetLogger(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Sets the log level for the logger.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
39
35
|
/**
|
|
40
36
|
* The logger instance for ADK.
|
|
41
37
|
*/
|
package/dist/types/version.d.ts
CHANGED
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { randomUUID } from "../utils/env_aware_utils.js";
|
|
7
|
+
var MessageRole = /* @__PURE__ */ ((MessageRole2) => {
|
|
8
|
+
MessageRole2["USER"] = "user";
|
|
9
|
+
MessageRole2["AGENT"] = "agent";
|
|
10
|
+
return MessageRole2;
|
|
11
|
+
})(MessageRole || {});
|
|
12
|
+
function isTaskStatusUpdateEvent(event) {
|
|
13
|
+
return (event == null ? void 0 : event.kind) === "status-update";
|
|
14
|
+
}
|
|
15
|
+
function isTaskArtifactUpdateEvent(event) {
|
|
16
|
+
return (event == null ? void 0 : event.kind) === "artifact-update";
|
|
17
|
+
}
|
|
18
|
+
function isMessage(event) {
|
|
19
|
+
return (event == null ? void 0 : event.kind) === "message";
|
|
20
|
+
}
|
|
21
|
+
function isTask(event) {
|
|
22
|
+
return (event == null ? void 0 : event.kind) === "task";
|
|
23
|
+
}
|
|
24
|
+
function getEventMetadata(event) {
|
|
25
|
+
if (isTaskArtifactUpdateEvent(event)) {
|
|
26
|
+
return event.artifact.metadata || {};
|
|
27
|
+
}
|
|
28
|
+
if (isTaskStatusUpdateEvent(event) || isTask(event) || isMessage(event)) {
|
|
29
|
+
return event.metadata || {};
|
|
30
|
+
}
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
function isFailedTaskStatusUpdateEvent(event) {
|
|
34
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && event.status.state === "failed";
|
|
35
|
+
}
|
|
36
|
+
function isTerminalTaskStatusUpdateEvent(event) {
|
|
37
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && ["completed", "failed", "canceled", "rejected"].includes(event.status.state);
|
|
38
|
+
}
|
|
39
|
+
function isInputRequiredTaskStatusUpdateEvent(event) {
|
|
40
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && event.status.state === "input-required";
|
|
41
|
+
}
|
|
42
|
+
function getFailedTaskStatusUpdateEventError(event) {
|
|
43
|
+
var _a;
|
|
44
|
+
if (!isFailedTaskStatusUpdateEvent(event)) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
const parts = ((_a = event.status.message) == null ? void 0 : _a.parts) || [];
|
|
48
|
+
if (parts.length === 0) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
if (parts[0].kind !== "text") {
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
return parts[0].text;
|
|
55
|
+
}
|
|
56
|
+
function createTaskSubmittedEvent({
|
|
57
|
+
taskId,
|
|
58
|
+
contextId,
|
|
59
|
+
message
|
|
60
|
+
}) {
|
|
61
|
+
return {
|
|
62
|
+
kind: "status-update",
|
|
63
|
+
taskId,
|
|
64
|
+
contextId,
|
|
65
|
+
final: false,
|
|
66
|
+
status: {
|
|
67
|
+
state: "submitted",
|
|
68
|
+
message,
|
|
69
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function createTask({
|
|
74
|
+
contextId,
|
|
75
|
+
message,
|
|
76
|
+
taskId
|
|
77
|
+
}) {
|
|
78
|
+
return {
|
|
79
|
+
kind: "task",
|
|
80
|
+
id: taskId || randomUUID(),
|
|
81
|
+
contextId,
|
|
82
|
+
history: [message],
|
|
83
|
+
status: {
|
|
84
|
+
state: "submitted",
|
|
85
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createTaskWorkingEvent({
|
|
90
|
+
taskId,
|
|
91
|
+
contextId,
|
|
92
|
+
message
|
|
93
|
+
}) {
|
|
94
|
+
return {
|
|
95
|
+
kind: "status-update",
|
|
96
|
+
taskId,
|
|
97
|
+
contextId,
|
|
98
|
+
final: false,
|
|
99
|
+
status: {
|
|
100
|
+
state: "working",
|
|
101
|
+
message,
|
|
102
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function createTaskCompletedEvent({
|
|
107
|
+
taskId,
|
|
108
|
+
contextId,
|
|
109
|
+
metadata = {}
|
|
110
|
+
}) {
|
|
111
|
+
return {
|
|
112
|
+
kind: "status-update",
|
|
113
|
+
taskId,
|
|
114
|
+
contextId,
|
|
115
|
+
final: true,
|
|
116
|
+
status: {
|
|
117
|
+
state: "completed",
|
|
118
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
119
|
+
},
|
|
120
|
+
metadata
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function createTaskArtifactUpdateEvent({
|
|
124
|
+
taskId,
|
|
125
|
+
contextId,
|
|
126
|
+
artifactId,
|
|
127
|
+
parts = [],
|
|
128
|
+
metadata,
|
|
129
|
+
append,
|
|
130
|
+
lastChunk
|
|
131
|
+
}) {
|
|
132
|
+
return {
|
|
133
|
+
kind: "artifact-update",
|
|
134
|
+
taskId,
|
|
135
|
+
contextId,
|
|
136
|
+
append,
|
|
137
|
+
lastChunk,
|
|
138
|
+
artifact: {
|
|
139
|
+
artifactId: artifactId || randomUUID(),
|
|
140
|
+
parts,
|
|
141
|
+
metadata
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
function createTaskFailedEvent({
|
|
146
|
+
taskId,
|
|
147
|
+
contextId,
|
|
148
|
+
error,
|
|
149
|
+
metadata
|
|
150
|
+
}) {
|
|
151
|
+
return {
|
|
152
|
+
kind: "status-update",
|
|
153
|
+
taskId,
|
|
154
|
+
contextId,
|
|
155
|
+
status: {
|
|
156
|
+
state: "failed",
|
|
157
|
+
message: {
|
|
158
|
+
kind: "message",
|
|
159
|
+
messageId: randomUUID(),
|
|
160
|
+
role: "agent",
|
|
161
|
+
taskId,
|
|
162
|
+
contextId,
|
|
163
|
+
parts: [
|
|
164
|
+
{
|
|
165
|
+
kind: "text",
|
|
166
|
+
text: error.message
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
171
|
+
},
|
|
172
|
+
metadata,
|
|
173
|
+
final: true
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function createTaskInputRequiredEvent({
|
|
177
|
+
taskId,
|
|
178
|
+
contextId,
|
|
179
|
+
parts
|
|
180
|
+
}) {
|
|
181
|
+
return {
|
|
182
|
+
kind: "status-update",
|
|
183
|
+
taskId,
|
|
184
|
+
contextId,
|
|
185
|
+
final: true,
|
|
186
|
+
status: {
|
|
187
|
+
state: "input-required",
|
|
188
|
+
message: {
|
|
189
|
+
kind: "message",
|
|
190
|
+
messageId: randomUUID(),
|
|
191
|
+
role: "agent",
|
|
192
|
+
taskId,
|
|
193
|
+
contextId,
|
|
194
|
+
parts
|
|
195
|
+
},
|
|
196
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function createInputMissingErrorEvent({
|
|
201
|
+
taskId,
|
|
202
|
+
contextId,
|
|
203
|
+
parts
|
|
204
|
+
}) {
|
|
205
|
+
return {
|
|
206
|
+
kind: "status-update",
|
|
207
|
+
taskId,
|
|
208
|
+
contextId,
|
|
209
|
+
final: true,
|
|
210
|
+
status: {
|
|
211
|
+
state: "input-required",
|
|
212
|
+
message: {
|
|
213
|
+
kind: "message",
|
|
214
|
+
messageId: randomUUID(),
|
|
215
|
+
role: "agent",
|
|
216
|
+
taskId,
|
|
217
|
+
contextId,
|
|
218
|
+
parts
|
|
219
|
+
},
|
|
220
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export {
|
|
225
|
+
MessageRole,
|
|
226
|
+
createInputMissingErrorEvent,
|
|
227
|
+
createTask,
|
|
228
|
+
createTaskArtifactUpdateEvent,
|
|
229
|
+
createTaskCompletedEvent,
|
|
230
|
+
createTaskFailedEvent,
|
|
231
|
+
createTaskInputRequiredEvent,
|
|
232
|
+
createTaskSubmittedEvent,
|
|
233
|
+
createTaskWorkingEvent,
|
|
234
|
+
getEventMetadata,
|
|
235
|
+
getFailedTaskStatusUpdateEventError,
|
|
236
|
+
isFailedTaskStatusUpdateEvent,
|
|
237
|
+
isInputRequiredTaskStatusUpdateEvent,
|
|
238
|
+
isMessage,
|
|
239
|
+
isTask,
|
|
240
|
+
isTaskArtifactUpdateEvent,
|
|
241
|
+
isTaskStatusUpdateEvent,
|
|
242
|
+
isTerminalTaskStatusUpdateEvent
|
|
243
|
+
};
|