@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
|
@@ -41,6 +41,7 @@ function createLlmResponse(response) {
|
|
|
41
41
|
return {
|
|
42
42
|
content: candidate.content,
|
|
43
43
|
groundingMetadata: candidate.groundingMetadata,
|
|
44
|
+
citationMetadata: candidate.citationMetadata,
|
|
44
45
|
usageMetadata,
|
|
45
46
|
finishReason: candidate.finishReason
|
|
46
47
|
};
|
|
@@ -49,6 +50,7 @@ function createLlmResponse(response) {
|
|
|
49
50
|
errorCode: candidate.finishReason,
|
|
50
51
|
errorMessage: candidate.finishMessage,
|
|
51
52
|
usageMetadata,
|
|
53
|
+
citationMetadata: candidate.citationMetadata,
|
|
52
54
|
finishReason: candidate.finishReason
|
|
53
55
|
};
|
|
54
56
|
}
|
|
@@ -227,7 +227,7 @@ class BasePlugin {
|
|
|
227
227
|
* Callback executed when a tool call encounters an error.
|
|
228
228
|
tool: BaseTool;
|
|
229
229
|
toolArgs: Record<string, unknown>;
|
|
230
|
-
toolContext:
|
|
230
|
+
toolContext: Context;
|
|
231
231
|
result: Record<string, unknown>;
|
|
232
232
|
}): Promise<Record<string, unknown> | undefined> {
|
|
233
233
|
return;
|
|
@@ -264,7 +264,7 @@ class Runner {
|
|
|
264
264
|
return rootAgent.findAgent(event.author) || rootAgent;
|
|
265
265
|
}
|
|
266
266
|
for (let i = session.events.length - 1; i >= 0; i--) {
|
|
267
|
-
import_logger.logger.info("event:
|
|
267
|
+
import_logger.logger.info("event:", JSON.stringify(session.events[i]));
|
|
268
268
|
const event2 = session.events[i];
|
|
269
269
|
if (event2.author === "user" || !event2.author) {
|
|
270
270
|
continue;
|
|
@@ -51,7 +51,7 @@ class DatabaseSessionService extends import_base_session_service.BaseSessionServ
|
|
|
51
51
|
super();
|
|
52
52
|
this.initialized = false;
|
|
53
53
|
if (typeof connectionStringOrOptions === "string") {
|
|
54
|
-
this.
|
|
54
|
+
this.connectionString = connectionStringOrOptions;
|
|
55
55
|
} else {
|
|
56
56
|
if (!connectionStringOrOptions.driver) {
|
|
57
57
|
throw new Error("Driver is required when passing options object.");
|
|
@@ -66,6 +66,9 @@ class DatabaseSessionService extends import_base_session_service.BaseSessionServ
|
|
|
66
66
|
if (this.initialized) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
+
if (this.connectionString && (!this.options || !this.options.driver)) {
|
|
70
|
+
this.options = await (0, import_operations.getConnectionOptionsFromUri)(this.connectionString);
|
|
71
|
+
}
|
|
69
72
|
this.orm = await import_core.MikroORM.init(this.options);
|
|
70
73
|
await (0, import_operations.ensureDatabaseCreated)(this.orm);
|
|
71
74
|
await (0, import_operations.validateDatabaseSchemaVersion)(this.orm);
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
14
|
var __export = (target, all) => {
|
|
13
15
|
for (var name in all)
|
|
@@ -21,6 +23,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
23
|
}
|
|
22
24
|
return to;
|
|
23
25
|
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
24
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
35
|
var operations_exports = {};
|
|
26
36
|
__export(operations_exports, {
|
|
@@ -30,29 +40,29 @@ __export(operations_exports, {
|
|
|
30
40
|
});
|
|
31
41
|
module.exports = __toCommonJS(operations_exports);
|
|
32
42
|
var import_core = require("@mikro-orm/core");
|
|
33
|
-
var import_mariadb = require("@mikro-orm/mariadb");
|
|
34
|
-
var import_mssql = require("@mikro-orm/mssql");
|
|
35
|
-
var import_mysql = require("@mikro-orm/mysql");
|
|
36
|
-
var import_postgresql = require("@mikro-orm/postgresql");
|
|
37
|
-
var import_sqlite = require("@mikro-orm/sqlite");
|
|
38
43
|
var import_schema = require("./schema.js");
|
|
39
44
|
/**
|
|
40
45
|
* @license
|
|
41
46
|
* Copyright 2026 Google LLC
|
|
42
47
|
* SPDX-License-Identifier: Apache-2.0
|
|
43
48
|
*/
|
|
44
|
-
function getConnectionOptionsFromUri(uri) {
|
|
49
|
+
async function getConnectionOptionsFromUri(uri) {
|
|
45
50
|
let driver;
|
|
46
51
|
if (uri.startsWith("postgres://") || uri.startsWith("postgresql://")) {
|
|
47
|
-
|
|
52
|
+
const { PostgreSqlDriver } = await Promise.resolve().then(() => __toESM(require("@mikro-orm/postgresql"), 1));
|
|
53
|
+
driver = PostgreSqlDriver;
|
|
48
54
|
} else if (uri.startsWith("mysql://")) {
|
|
49
|
-
|
|
55
|
+
const { MySqlDriver } = await Promise.resolve().then(() => __toESM(require("@mikro-orm/mysql"), 1));
|
|
56
|
+
driver = MySqlDriver;
|
|
50
57
|
} else if (uri.startsWith("mariadb://")) {
|
|
51
|
-
|
|
58
|
+
const { MariaDbDriver } = await Promise.resolve().then(() => __toESM(require("@mikro-orm/mariadb"), 1));
|
|
59
|
+
driver = MariaDbDriver;
|
|
52
60
|
} else if (uri.startsWith("sqlite://")) {
|
|
53
|
-
|
|
61
|
+
const { SqliteDriver } = await Promise.resolve().then(() => __toESM(require("@mikro-orm/sqlite"), 1));
|
|
62
|
+
driver = SqliteDriver;
|
|
54
63
|
} else if (uri.startsWith("mssql://")) {
|
|
55
|
-
|
|
64
|
+
const { MsSqlDriver } = await Promise.resolve().then(() => __toESM(require("@mikro-orm/mssql"), 1));
|
|
65
|
+
driver = MsSqlDriver;
|
|
56
66
|
} else {
|
|
57
67
|
throw new Error(`Unsupported database URI: ${uri}`);
|
|
58
68
|
}
|
|
@@ -80,7 +90,9 @@ async function ensureDatabaseCreated(ormOrUrlOrOptions) {
|
|
|
80
90
|
if (ormOrUrlOrOptions instanceof import_core.MikroORM) {
|
|
81
91
|
orm = ormOrUrlOrOptions;
|
|
82
92
|
} else if (typeof ormOrUrlOrOptions === "string") {
|
|
83
|
-
orm = await import_core.MikroORM.init(
|
|
93
|
+
orm = await import_core.MikroORM.init(
|
|
94
|
+
await getConnectionOptionsFromUri(ormOrUrlOrOptions)
|
|
95
|
+
);
|
|
84
96
|
} else {
|
|
85
97
|
orm = await import_core.MikroORM.init(ormOrUrlOrOptions);
|
|
86
98
|
}
|
|
@@ -84,6 +84,9 @@ class BaseTool {
|
|
|
84
84
|
if (!functionDeclaration) {
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
+
if (this.name in llmRequest.toolsDict) {
|
|
88
|
+
throw new Error(`Duplicate tool name: ${this.name}`);
|
|
89
|
+
}
|
|
87
90
|
llmRequest.toolsDict[this.name] = this;
|
|
88
91
|
const tool = findToolWithFunctionDeclarations(llmRequest);
|
|
89
92
|
if (tool) {
|
|
@@ -24,7 +24,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
24
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
25
|
var base_toolset_exports = {};
|
|
26
26
|
__export(base_toolset_exports, {
|
|
27
|
-
BaseToolset: () => BaseToolset
|
|
27
|
+
BaseToolset: () => BaseToolset,
|
|
28
|
+
isBaseToolset: () => isBaseToolset
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(base_toolset_exports);
|
|
30
31
|
/**
|
|
@@ -32,9 +33,17 @@ module.exports = __toCommonJS(base_toolset_exports);
|
|
|
32
33
|
* Copyright 2025 Google LLC
|
|
33
34
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
35
|
*/
|
|
36
|
+
var _a;
|
|
37
|
+
const BASE_TOOLSET_SIGNATURE_SYMBOL = Symbol.for("google.adk.baseToolset");
|
|
38
|
+
function isBaseToolset(obj) {
|
|
39
|
+
return typeof obj === "object" && obj !== null && BASE_TOOLSET_SIGNATURE_SYMBOL in obj && obj[BASE_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
40
|
+
}
|
|
41
|
+
_a = BASE_TOOLSET_SIGNATURE_SYMBOL;
|
|
35
42
|
class BaseToolset {
|
|
36
|
-
constructor(toolFilter) {
|
|
43
|
+
constructor(toolFilter, prefix) {
|
|
37
44
|
this.toolFilter = toolFilter;
|
|
45
|
+
this.prefix = prefix;
|
|
46
|
+
this[_a] = true;
|
|
38
47
|
}
|
|
39
48
|
/**
|
|
40
49
|
* Returns whether the tool should be exposed to LLM.
|
|
@@ -72,5 +81,6 @@ class BaseToolset {
|
|
|
72
81
|
}
|
|
73
82
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
83
|
0 && (module.exports = {
|
|
75
|
-
BaseToolset
|
|
84
|
+
BaseToolset,
|
|
85
|
+
isBaseToolset
|
|
76
86
|
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __export = (target, all) => {
|
|
13
|
+
for (var name in all)
|
|
14
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var exit_loop_tool_exports = {};
|
|
26
|
+
__export(exit_loop_tool_exports, {
|
|
27
|
+
EXIT_LOOP: () => EXIT_LOOP,
|
|
28
|
+
ExitLoopTool: () => ExitLoopTool
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(exit_loop_tool_exports);
|
|
31
|
+
var import_base_tool = require("./base_tool.js");
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2026 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
class ExitLoopTool extends import_base_tool.BaseTool {
|
|
38
|
+
constructor() {
|
|
39
|
+
super({
|
|
40
|
+
name: "exit_loop",
|
|
41
|
+
description: "Exits the loop.\n\nCall this function only when you are instructed to do so."
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
_getDeclaration() {
|
|
45
|
+
return {
|
|
46
|
+
name: this.name,
|
|
47
|
+
description: this.description
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
async runAsync({
|
|
51
|
+
toolContext
|
|
52
|
+
}) {
|
|
53
|
+
toolContext.actions.escalate = true;
|
|
54
|
+
toolContext.actions.skipSummarization = true;
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const EXIT_LOOP = new ExitLoopTool();
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
EXIT_LOOP,
|
|
62
|
+
ExitLoopTool
|
|
63
|
+
});
|
|
@@ -37,8 +37,8 @@ var import_mcp_tool = require("./mcp_tool.js");
|
|
|
37
37
|
* SPDX-License-Identifier: Apache-2.0
|
|
38
38
|
*/
|
|
39
39
|
class MCPToolset extends import_base_toolset.BaseToolset {
|
|
40
|
-
constructor(connectionParams, toolFilter = []) {
|
|
41
|
-
super(toolFilter);
|
|
40
|
+
constructor(connectionParams, toolFilter = [], prefix) {
|
|
41
|
+
super(toolFilter, prefix);
|
|
42
42
|
this.mcpSessionManager = new import_mcp_session_manager.MCPSessionManager(connectionParams);
|
|
43
43
|
}
|
|
44
44
|
async getTools() {
|
|
@@ -48,9 +48,13 @@ class MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
48
48
|
for (const tool of listResult.tools) {
|
|
49
49
|
import_logger.logger.debug(`tool: ${tool.name}`);
|
|
50
50
|
}
|
|
51
|
-
return listResult.tools.map(
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
return listResult.tools.map((tool) => {
|
|
52
|
+
const toolWithPrefix = {
|
|
53
|
+
...tool,
|
|
54
|
+
name: this.prefix ? `${this.prefix}_${tool.name}` : tool.name
|
|
55
|
+
};
|
|
56
|
+
return new import_mcp_tool.MCPTool(toolWithPrefix, this.mcpSessionManager);
|
|
57
|
+
});
|
|
54
58
|
}
|
|
55
59
|
async close() {
|
|
56
60
|
}
|
package/dist/cjs/utils/logger.js
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
8
|
+
var __create = Object.create;
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
9
10
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
11
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
14
|
var __export = (target, all) => {
|
|
13
15
|
for (var name in all)
|
|
@@ -21,6 +23,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
23
|
}
|
|
22
24
|
return to;
|
|
23
25
|
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
24
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
35
|
var logger_exports = {};
|
|
26
36
|
__export(logger_exports, {
|
|
@@ -32,6 +42,7 @@ __export(logger_exports, {
|
|
|
32
42
|
setLogger: () => setLogger
|
|
33
43
|
});
|
|
34
44
|
module.exports = __toCommonJS(logger_exports);
|
|
45
|
+
var winston = __toESM(require("winston"), 1);
|
|
35
46
|
/**
|
|
36
47
|
* @license
|
|
37
48
|
* Copyright 2025 Google LLC
|
|
@@ -44,58 +55,68 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
|
44
55
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
45
56
|
return LogLevel2;
|
|
46
57
|
})(LogLevel || {});
|
|
47
|
-
let logLevel = 1 /* INFO */;
|
|
48
|
-
function setLogLevel(level) {
|
|
49
|
-
logLevel = level;
|
|
50
|
-
}
|
|
51
58
|
class SimpleLogger {
|
|
52
|
-
|
|
53
|
-
|
|
59
|
+
constructor() {
|
|
60
|
+
this.logLevel = 1 /* INFO */;
|
|
61
|
+
this.logger = winston.createLogger({
|
|
62
|
+
levels: {
|
|
63
|
+
"debug": 0 /* DEBUG */,
|
|
64
|
+
"info": 1 /* INFO */,
|
|
65
|
+
"warn": 2 /* WARN */,
|
|
66
|
+
"error": 3 /* ERROR */
|
|
67
|
+
},
|
|
68
|
+
format: winston.format.combine(
|
|
69
|
+
winston.format.label({ label: "ADK" }),
|
|
70
|
+
winston.format((info) => {
|
|
71
|
+
info.level = info.level.toUpperCase();
|
|
72
|
+
return info;
|
|
73
|
+
})(),
|
|
74
|
+
winston.format.colorize(),
|
|
75
|
+
winston.format.timestamp(),
|
|
76
|
+
winston.format.printf((info) => {
|
|
77
|
+
return `${info.level}: [${info.label}] ${info.timestamp} ${info.message}`;
|
|
78
|
+
})
|
|
79
|
+
),
|
|
80
|
+
transports: [new winston.transports.Console()]
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
setLogLevel(level) {
|
|
84
|
+
this.logLevel = level;
|
|
85
|
+
}
|
|
86
|
+
log(level, ...messages) {
|
|
87
|
+
if (this.logLevel > level) {
|
|
54
88
|
return;
|
|
55
89
|
}
|
|
56
|
-
|
|
57
|
-
case 0 /* DEBUG */:
|
|
58
|
-
this.debug(...args);
|
|
59
|
-
break;
|
|
60
|
-
case 1 /* INFO */:
|
|
61
|
-
this.info(...args);
|
|
62
|
-
break;
|
|
63
|
-
case 2 /* WARN */:
|
|
64
|
-
this.warn(...args);
|
|
65
|
-
break;
|
|
66
|
-
case 3 /* ERROR */:
|
|
67
|
-
this.error(...args);
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
throw new Error(`Unsupported log level: ${level}`);
|
|
71
|
-
}
|
|
90
|
+
this.logger.log(level.toString(), messages.join(" "));
|
|
72
91
|
}
|
|
73
|
-
debug(...
|
|
74
|
-
if (logLevel > 0 /* DEBUG */) {
|
|
92
|
+
debug(...messages) {
|
|
93
|
+
if (this.logLevel > 0 /* DEBUG */) {
|
|
75
94
|
return;
|
|
76
95
|
}
|
|
77
|
-
|
|
96
|
+
this.logger.debug(messages.join(" "));
|
|
78
97
|
}
|
|
79
|
-
info(...
|
|
80
|
-
if (logLevel > 1 /* INFO */) {
|
|
98
|
+
info(...messages) {
|
|
99
|
+
if (this.logLevel > 1 /* INFO */) {
|
|
81
100
|
return;
|
|
82
101
|
}
|
|
83
|
-
|
|
102
|
+
this.logger.info(messages.join(" "));
|
|
84
103
|
}
|
|
85
|
-
warn(...
|
|
86
|
-
if (logLevel > 2 /* WARN */) {
|
|
104
|
+
warn(...messages) {
|
|
105
|
+
if (this.logLevel > 2 /* WARN */) {
|
|
87
106
|
return;
|
|
88
107
|
}
|
|
89
|
-
|
|
108
|
+
this.logger.warn(messages.join(" "));
|
|
90
109
|
}
|
|
91
|
-
error(...
|
|
92
|
-
if (logLevel > 3 /* ERROR */) {
|
|
110
|
+
error(...messages) {
|
|
111
|
+
if (this.logLevel > 3 /* ERROR */) {
|
|
93
112
|
return;
|
|
94
113
|
}
|
|
95
|
-
|
|
114
|
+
this.logger.error(messages.join(" "));
|
|
96
115
|
}
|
|
97
116
|
}
|
|
98
117
|
class NoOpLogger {
|
|
118
|
+
setLogLevel(_level) {
|
|
119
|
+
}
|
|
99
120
|
log(_level, ..._args) {
|
|
100
121
|
}
|
|
101
122
|
debug(..._args) {
|
|
@@ -107,26 +128,6 @@ class NoOpLogger {
|
|
|
107
128
|
error(..._args) {
|
|
108
129
|
}
|
|
109
130
|
}
|
|
110
|
-
const LOG_LEVEL_STR = {
|
|
111
|
-
[0 /* DEBUG */]: "DEBUG",
|
|
112
|
-
[1 /* INFO */]: "INFO",
|
|
113
|
-
[2 /* WARN */]: "WARN",
|
|
114
|
-
[3 /* ERROR */]: "ERROR"
|
|
115
|
-
};
|
|
116
|
-
const CONSOLE_COLOR_MAP = {
|
|
117
|
-
[0 /* DEBUG */]: "\x1B[34m",
|
|
118
|
-
// Blue
|
|
119
|
-
[1 /* INFO */]: "\x1B[32m",
|
|
120
|
-
// Green
|
|
121
|
-
[2 /* WARN */]: "\x1B[33m",
|
|
122
|
-
// Yellow
|
|
123
|
-
[3 /* ERROR */]: "\x1B[31m"
|
|
124
|
-
// Red
|
|
125
|
-
};
|
|
126
|
-
const RESET_COLOR = "\x1B[0m";
|
|
127
|
-
function getColoredPrefix(level) {
|
|
128
|
-
return `${CONSOLE_COLOR_MAP[level]}[ADK ${LOG_LEVEL_STR[level]}]:${RESET_COLOR}`;
|
|
129
|
-
}
|
|
130
131
|
let currentLogger = new SimpleLogger();
|
|
131
132
|
function setLogger(customLogger) {
|
|
132
133
|
currentLogger = customLogger != null ? customLogger : new NoOpLogger();
|
|
@@ -137,7 +138,13 @@ function getLogger() {
|
|
|
137
138
|
function resetLogger() {
|
|
138
139
|
currentLogger = new SimpleLogger();
|
|
139
140
|
}
|
|
141
|
+
function setLogLevel(level) {
|
|
142
|
+
logger.setLogLevel(level);
|
|
143
|
+
}
|
|
140
144
|
const logger = {
|
|
145
|
+
setLogLevel(level) {
|
|
146
|
+
currentLogger.setLogLevel(level);
|
|
147
|
+
},
|
|
141
148
|
log(level, ...args) {
|
|
142
149
|
currentLogger.log(level, ...args);
|
|
143
150
|
},
|
package/dist/cjs/version.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(version_exports);
|
|
|
32
32
|
* Copyright 2025 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
34
|
*/
|
|
35
|
-
const version = "0.
|
|
35
|
+
const version = "0.5.0";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|