@google/adk 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/cjs/a2a/a2a_event.js +317 -0
- package/dist/cjs/a2a/a2a_remote_agent.js +174 -0
- package/dist/cjs/a2a/a2a_remote_agent_run_processor.js +198 -0
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +165 -0
- package/dist/cjs/a2a/agent_card.js +380 -0
- package/dist/cjs/a2a/agent_executor.js +221 -0
- package/dist/cjs/a2a/agent_to_a2a.js +115 -0
- package/dist/cjs/a2a/event_converter_utils.js +201 -0
- package/dist/cjs/a2a/event_processor_utils.js +180 -0
- package/dist/cjs/a2a/executor_context.js +53 -0
- package/dist/cjs/a2a/metadata_converter_utils.js +126 -0
- package/dist/cjs/a2a/part_converter_utils.js +47 -34
- package/dist/cjs/agents/base_agent.js +3 -3
- package/dist/cjs/{tools/tool_context.js → agents/context.js} +70 -15
- package/dist/cjs/agents/functions.js +2 -2
- package/dist/cjs/agents/llm_agent.js +38 -674
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +132 -0
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +68 -0
- package/dist/cjs/agents/processors/code_execution_request_processor.js +389 -0
- package/dist/cjs/agents/{content_processor_utils.js → processors/content_processor_utils.js} +21 -2
- package/dist/cjs/agents/processors/content_request_processor.js +87 -0
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +61 -0
- package/dist/cjs/agents/processors/identity_llm_request_processor.js +54 -0
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +85 -0
- package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +165 -0
- package/dist/cjs/artifacts/file_artifact_service.js +35 -4
- package/dist/cjs/common.js +48 -7
- package/dist/cjs/context/base_context_compactor.js +27 -0
- package/dist/cjs/context/summarizers/base_summarizer.js +27 -0
- package/dist/cjs/context/summarizers/llm_summarizer.js +93 -0
- package/dist/cjs/context/token_based_context_compactor.js +135 -0
- package/dist/cjs/context/truncating_context_compactor.js +58 -0
- package/dist/cjs/events/compacted_event.js +53 -0
- package/dist/cjs/index.js +113 -53
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/memory/in_memory_memory_service.js +1 -1
- package/dist/cjs/models/llm_response.js +2 -0
- package/dist/cjs/plugins/base_plugin.js +1 -1
- package/dist/cjs/runner/runner.js +20 -11
- package/dist/cjs/sessions/database_session_service.js +4 -1
- package/dist/cjs/sessions/db/operations.js +25 -23
- package/dist/cjs/sessions/state.js +2 -2
- package/dist/cjs/tools/agent_tool.js +6 -5
- package/dist/cjs/tools/base_tool.js +3 -0
- package/dist/cjs/tools/base_toolset.js +13 -3
- package/dist/cjs/tools/exit_loop_tool.js +63 -0
- package/dist/cjs/tools/load_artifacts_tool.js +188 -0
- package/dist/cjs/tools/load_memory_tool.js +107 -0
- package/dist/cjs/tools/mcp/mcp_toolset.js +9 -5
- package/dist/cjs/tools/preload_memory_tool.js +109 -0
- package/dist/cjs/utils/logger.js +62 -54
- package/dist/cjs/version.js +1 -1
- package/dist/esm/a2a/a2a_event.js +269 -0
- package/dist/esm/a2a/a2a_remote_agent.js +148 -0
- package/dist/esm/a2a/a2a_remote_agent_run_processor.js +175 -0
- package/dist/esm/a2a/a2a_remote_agent_utils.js +131 -0
- package/dist/esm/a2a/agent_card.js +340 -0
- package/dist/esm/a2a/agent_executor.js +202 -0
- package/dist/esm/a2a/agent_to_a2a.js +80 -0
- package/dist/esm/a2a/event_converter_utils.js +187 -0
- package/dist/esm/a2a/event_processor_utils.js +159 -0
- package/dist/esm/a2a/executor_context.js +23 -0
- package/dist/esm/a2a/metadata_converter_utils.js +91 -0
- package/dist/esm/a2a/part_converter_utils.js +49 -34
- package/dist/esm/agents/base_agent.js +3 -3
- package/dist/{web/tools/tool_context.js → esm/agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +2 -2
- package/dist/esm/agents/llm_agent.js +31 -683
- package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +101 -0
- package/dist/esm/agents/processors/basic_llm_request_processor.js +37 -0
- package/dist/esm/agents/processors/code_execution_request_processor.js +363 -0
- package/dist/esm/agents/{content_processor_utils.js → processors/content_processor_utils.js} +23 -2
- package/dist/esm/agents/processors/content_request_processor.js +59 -0
- package/dist/esm/agents/processors/context_compactor_request_processor.js +31 -0
- package/dist/esm/agents/processors/identity_llm_request_processor.js +23 -0
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +54 -0
- package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +140 -0
- package/dist/esm/artifacts/file_artifact_service.js +30 -3
- package/dist/esm/common.js +44 -10
- package/dist/esm/context/base_context_compactor.js +5 -0
- package/dist/esm/context/summarizers/base_summarizer.js +5 -0
- package/dist/esm/context/summarizers/llm_summarizer.js +65 -0
- package/dist/esm/context/token_based_context_compactor.js +105 -0
- package/dist/esm/context/truncating_context_compactor.js +28 -0
- package/dist/esm/events/compacted_event.js +22 -0
- package/dist/esm/index.js +119 -18
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/memory/in_memory_memory_service.js +1 -1
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +18 -10
- package/dist/esm/sessions/database_session_service.js +4 -1
- package/dist/esm/sessions/db/operations.js +32 -18
- package/dist/esm/sessions/state.js +2 -2
- package/dist/esm/tools/agent_tool.js +6 -5
- package/dist/esm/tools/base_tool.js +3 -0
- package/dist/esm/tools/base_toolset.js +11 -2
- package/dist/esm/tools/exit_loop_tool.js +32 -0
- package/dist/esm/tools/load_artifacts_tool.js +159 -0
- package/dist/esm/tools/load_memory_tool.js +78 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +9 -5
- package/dist/esm/tools/preload_memory_tool.js +80 -0
- package/dist/esm/utils/logger.js +52 -54
- package/dist/esm/version.js +1 -1
- package/dist/types/a2a/a2a_event.d.ts +139 -0
- package/dist/types/a2a/a2a_remote_agent.d.ts +63 -0
- package/dist/types/a2a/a2a_remote_agent_run_processor.d.ts +31 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +38 -0
- package/dist/types/a2a/agent_card.d.ts +23 -0
- package/dist/types/a2a/agent_executor.d.ts +52 -0
- package/dist/types/a2a/agent_to_a2a.d.ts +45 -0
- package/dist/types/a2a/event_converter_utils.d.ts +20 -0
- package/dist/types/a2a/event_processor_utils.d.ts +24 -0
- package/dist/types/a2a/executor_context.d.ts +33 -0
- package/dist/types/a2a/metadata_converter_utils.d.ts +63 -0
- package/dist/types/a2a/part_converter_utils.d.ts +4 -3
- package/dist/types/agents/base_agent.d.ts +2 -2
- package/dist/types/{tools/tool_context.d.ts → agents/context.d.ts} +43 -8
- package/dist/types/agents/llm_agent.d.ts +14 -31
- package/dist/types/agents/loop_agent.d.ts +1 -1
- package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +18 -0
- package/dist/types/agents/{base_llm_processor.d.ts → processors/base_llm_processor.d.ts} +4 -4
- package/dist/types/agents/processors/basic_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/code_execution_request_processor.d.ts +34 -0
- package/dist/types/agents/{content_processor_utils.d.ts → processors/content_processor_utils.d.ts} +1 -1
- package/dist/types/agents/processors/content_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/context_compactor_request_processor.d.ts +22 -0
- package/dist/types/agents/processors/identity_llm_request_processor.d.ts +13 -0
- package/dist/types/agents/processors/instructions_llm_request_processor.d.ts +16 -0
- package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +13 -0
- package/dist/types/artifacts/file_artifact_service.d.ts +4 -0
- package/dist/types/auth/credential_service/base_credential_service.d.ts +3 -3
- package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +3 -3
- package/dist/types/common.d.ts +20 -5
- package/dist/types/context/base_context_compactor.d.ts +24 -0
- package/dist/types/context/summarizers/base_summarizer.d.ts +19 -0
- package/dist/types/context/summarizers/llm_summarizer.d.ts +23 -0
- package/dist/types/context/token_based_context_compactor.d.ts +33 -0
- package/dist/types/context/truncating_context_compactor.d.ts +24 -0
- package/dist/types/events/compacted_event.d.ts +33 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/models/llm_response.d.ts +5 -1
- package/dist/types/plugins/base_plugin.d.ts +12 -13
- package/dist/types/plugins/logging_plugin.d.ts +9 -10
- package/dist/types/plugins/plugin_manager.d.ts +9 -10
- package/dist/types/plugins/security_plugin.d.ts +2 -2
- package/dist/types/runner/runner.d.ts +13 -0
- package/dist/types/sessions/database_session_service.d.ts +2 -1
- package/dist/types/sessions/db/operations.d.ts +3 -4
- package/dist/types/tools/base_tool.d.ts +3 -3
- package/dist/types/tools/base_toolset.d.ts +12 -3
- package/dist/types/tools/exit_loop_tool.d.ts +24 -0
- package/dist/types/tools/forwarding_artifact_service.d.ts +2 -2
- package/dist/types/tools/function_tool.d.ts +2 -2
- package/dist/types/tools/load_artifacts_tool.d.ts +21 -0
- package/dist/types/tools/load_memory_tool.d.ts +22 -0
- package/dist/types/tools/mcp/mcp_toolset.d.ts +1 -1
- package/dist/types/tools/preload_memory_tool.d.ts +23 -0
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/a2a_event.js +269 -0
- package/dist/web/a2a/a2a_remote_agent.js +193 -0
- package/dist/web/a2a/a2a_remote_agent_run_processor.js +175 -0
- package/dist/web/a2a/a2a_remote_agent_utils.js +131 -0
- package/dist/web/a2a/agent_card.js +340 -0
- package/dist/web/a2a/agent_executor.js +216 -0
- package/dist/web/a2a/agent_to_a2a.js +80 -0
- package/dist/web/a2a/event_converter_utils.js +201 -0
- package/dist/web/a2a/event_processor_utils.js +168 -0
- package/dist/web/a2a/executor_context.js +23 -0
- package/dist/web/a2a/metadata_converter_utils.js +108 -0
- package/dist/web/a2a/part_converter_utils.js +49 -34
- package/dist/web/agents/base_agent.js +3 -3
- package/dist/{esm/tools/tool_context.js → web/agents/context.js} +66 -11
- package/dist/web/agents/functions.js +2 -2
- package/dist/web/agents/llm_agent.js +31 -661
- package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +100 -0
- package/dist/web/agents/processors/basic_llm_request_processor.js +71 -0
- package/dist/web/agents/processors/code_execution_request_processor.js +365 -0
- package/dist/web/agents/{content_processor_utils.js → processors/content_processor_utils.js} +22 -2
- package/dist/web/agents/processors/content_request_processor.js +77 -0
- package/dist/web/agents/processors/context_compactor_request_processor.js +49 -0
- package/dist/web/agents/processors/identity_llm_request_processor.js +41 -0
- package/dist/web/agents/processors/instructions_llm_request_processor.js +72 -0
- package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +158 -0
- package/dist/web/artifacts/file_artifact_service.js +30 -3
- package/dist/web/common.js +44 -10
- package/dist/web/context/base_context_compactor.js +5 -0
- package/dist/web/context/summarizers/base_summarizer.js +5 -0
- package/dist/web/context/summarizers/llm_summarizer.js +74 -0
- package/dist/web/context/token_based_context_compactor.js +105 -0
- package/dist/web/context/truncating_context_compactor.js +28 -0
- package/dist/web/events/compacted_event.js +40 -0
- package/dist/web/index.js +13 -18
- package/dist/web/index.js.map +7 -0
- package/dist/web/memory/in_memory_memory_service.js +1 -1
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +18 -10
- package/dist/web/sessions/database_session_service.js +4 -1
- package/dist/web/sessions/db/operations.js +32 -18
- package/dist/web/sessions/state.js +2 -2
- package/dist/web/tools/agent_tool.js +6 -5
- package/dist/web/tools/base_tool.js +3 -0
- package/dist/web/tools/base_toolset.js +11 -2
- package/dist/web/tools/exit_loop_tool.js +32 -0
- package/dist/web/tools/load_artifacts_tool.js +150 -0
- package/dist/web/tools/load_memory_tool.js +77 -0
- package/dist/web/tools/mcp/mcp_toolset.js +27 -5
- package/dist/web/tools/preload_memory_tool.js +75 -0
- package/dist/web/utils/logger.js +52 -54
- package/dist/web/version.js +1 -1
- package/package.json +7 -4
- package/dist/cjs/agents/callback_context.js +0 -101
- package/dist/esm/agents/callback_context.js +0 -71
- package/dist/types/agents/callback_context.d.ts +0 -42
- package/dist/web/agents/callback_context.js +0 -71
- /package/dist/cjs/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
- /package/dist/esm/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
- /package/dist/web/agents/{base_llm_processor.js → processors/base_llm_processor.js} +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { appendInstructions } from "../models/llm_request.js";
|
|
7
|
+
import { logger } from "../utils/logger.js";
|
|
8
|
+
import {
|
|
9
|
+
BaseTool
|
|
10
|
+
} from "./base_tool.js";
|
|
11
|
+
class PreloadMemoryTool extends BaseTool {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
// Name and description are not used because this tool only
|
|
15
|
+
// changes llm_request.
|
|
16
|
+
name: "preload_memory",
|
|
17
|
+
description: "preload_memory"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async runAsync({
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
args,
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
toolContext
|
|
25
|
+
}) {
|
|
26
|
+
throw new Error("PreloadMemoryTool should not be called by model");
|
|
27
|
+
}
|
|
28
|
+
async processLlmRequest(request) {
|
|
29
|
+
var _a, _b, _c;
|
|
30
|
+
await super.processLlmRequest(request);
|
|
31
|
+
const userContent = request.toolContext.userContent;
|
|
32
|
+
if (!userContent || !userContent.parts || !((_a = userContent.parts[0]) == null ? void 0 : _a.text)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const userQuery = userContent.parts[0].text;
|
|
36
|
+
let response;
|
|
37
|
+
try {
|
|
38
|
+
if (!request.toolContext.invocationContext.memoryService) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
response = await request.toolContext.searchMemory(userQuery);
|
|
42
|
+
} catch (_) {
|
|
43
|
+
logger.warn("Failed to preload memory for query: ".concat(userQuery));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!response.memories || response.memories.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const memoryTextLines = [];
|
|
50
|
+
for (const memory of response.memories) {
|
|
51
|
+
const timeStr = memory.timestamp ? "Time: ".concat(memory.timestamp) : "";
|
|
52
|
+
if (timeStr) memoryTextLines.push(timeStr);
|
|
53
|
+
const memoryText = (_c = (_b = memory.content.parts) == null ? void 0 : _b.map((p) => {
|
|
54
|
+
var _a2;
|
|
55
|
+
return (_a2 = p.text) != null ? _a2 : "";
|
|
56
|
+
}).join(" ")) != null ? _c : "";
|
|
57
|
+
if (memoryText) {
|
|
58
|
+
memoryTextLines.push(
|
|
59
|
+
memory.author ? "".concat(memory.author, ": ").concat(memoryText) : memoryText
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (memoryTextLines.length === 0) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const fullMemoryText = memoryTextLines.join("\n");
|
|
67
|
+
const si = "The following content is from your previous conversations with the user.\nThey may be useful for answering the user's current query.\n<PAST_CONVERSATIONS>\n".concat(fullMemoryText, "\n</PAST_CONVERSATIONS>\n");
|
|
68
|
+
appendInstructions(request.llmRequest, [si]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const PRELOAD_MEMORY = new PreloadMemoryTool();
|
|
72
|
+
export {
|
|
73
|
+
PRELOAD_MEMORY,
|
|
74
|
+
PreloadMemoryTool
|
|
75
|
+
};
|
package/dist/web/utils/logger.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import * as winston from "winston";
|
|
6
7
|
var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
7
8
|
LogLevel2[LogLevel2["DEBUG"] = 0] = "DEBUG";
|
|
8
9
|
LogLevel2[LogLevel2["INFO"] = 1] = "INFO";
|
|
@@ -10,58 +11,69 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
|
10
11
|
LogLevel2[LogLevel2["ERROR"] = 3] = "ERROR";
|
|
11
12
|
return LogLevel2;
|
|
12
13
|
})(LogLevel || {});
|
|
13
|
-
let logLevel = 1 /* INFO */;
|
|
14
|
-
function setLogLevel(level) {
|
|
15
|
-
logLevel = level;
|
|
16
|
-
}
|
|
17
14
|
class SimpleLogger {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
constructor() {
|
|
16
|
+
this.logLevel = 1 /* INFO */;
|
|
17
|
+
this.logger = winston.createLogger({
|
|
18
|
+
levels: {
|
|
19
|
+
"debug": 0 /* DEBUG */,
|
|
20
|
+
"info": 1 /* INFO */,
|
|
21
|
+
"warn": 2 /* WARN */,
|
|
22
|
+
"error": 3 /* ERROR */
|
|
23
|
+
},
|
|
24
|
+
level: "error",
|
|
25
|
+
format: winston.format.combine(
|
|
26
|
+
winston.format.label({ label: "ADK" }),
|
|
27
|
+
winston.format((info) => {
|
|
28
|
+
info.level = info.level.toUpperCase();
|
|
29
|
+
return info;
|
|
30
|
+
})(),
|
|
31
|
+
winston.format.colorize(),
|
|
32
|
+
winston.format.timestamp(),
|
|
33
|
+
winston.format.printf((info) => {
|
|
34
|
+
return "".concat(info.level, ": [").concat(info.label, "] ").concat(info.timestamp, " ").concat(info.message);
|
|
35
|
+
})
|
|
36
|
+
),
|
|
37
|
+
transports: [new winston.transports.Console()]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
setLogLevel(level) {
|
|
41
|
+
this.logLevel = level;
|
|
42
|
+
}
|
|
43
|
+
log(level, ...messages) {
|
|
44
|
+
if (this.logLevel > level) {
|
|
20
45
|
return;
|
|
21
46
|
}
|
|
22
|
-
|
|
23
|
-
case 0 /* DEBUG */:
|
|
24
|
-
this.debug(...args);
|
|
25
|
-
break;
|
|
26
|
-
case 1 /* INFO */:
|
|
27
|
-
this.info(...args);
|
|
28
|
-
break;
|
|
29
|
-
case 2 /* WARN */:
|
|
30
|
-
this.warn(...args);
|
|
31
|
-
break;
|
|
32
|
-
case 3 /* ERROR */:
|
|
33
|
-
this.error(...args);
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
throw new Error("Unsupported log level: ".concat(level));
|
|
37
|
-
}
|
|
47
|
+
this.logger.log(level.toString(), messages.join(" "));
|
|
38
48
|
}
|
|
39
|
-
debug(...
|
|
40
|
-
if (logLevel > 0 /* DEBUG */) {
|
|
49
|
+
debug(...messages) {
|
|
50
|
+
if (this.logLevel > 0 /* DEBUG */) {
|
|
41
51
|
return;
|
|
42
52
|
}
|
|
43
|
-
|
|
53
|
+
this.logger.debug(messages.join(" "));
|
|
44
54
|
}
|
|
45
|
-
info(...
|
|
46
|
-
if (logLevel > 1 /* INFO */) {
|
|
55
|
+
info(...messages) {
|
|
56
|
+
if (this.logLevel > 1 /* INFO */) {
|
|
47
57
|
return;
|
|
48
58
|
}
|
|
49
|
-
|
|
59
|
+
this.logger.info(messages.join(" "));
|
|
50
60
|
}
|
|
51
|
-
warn(...
|
|
52
|
-
if (logLevel > 2 /* WARN */) {
|
|
61
|
+
warn(...messages) {
|
|
62
|
+
if (this.logLevel > 2 /* WARN */) {
|
|
53
63
|
return;
|
|
54
64
|
}
|
|
55
|
-
|
|
65
|
+
this.logger.warn(messages.join(" "));
|
|
56
66
|
}
|
|
57
|
-
error(...
|
|
58
|
-
if (logLevel > 3 /* ERROR */) {
|
|
67
|
+
error(...messages) {
|
|
68
|
+
if (this.logLevel > 3 /* ERROR */) {
|
|
59
69
|
return;
|
|
60
70
|
}
|
|
61
|
-
|
|
71
|
+
this.logger.error(messages.join(" "));
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
class NoOpLogger {
|
|
75
|
+
setLogLevel(_level) {
|
|
76
|
+
}
|
|
65
77
|
log(_level, ..._args) {
|
|
66
78
|
}
|
|
67
79
|
debug(..._args) {
|
|
@@ -73,26 +85,6 @@ class NoOpLogger {
|
|
|
73
85
|
error(..._args) {
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
|
-
const LOG_LEVEL_STR = {
|
|
77
|
-
[0 /* DEBUG */]: "DEBUG",
|
|
78
|
-
[1 /* INFO */]: "INFO",
|
|
79
|
-
[2 /* WARN */]: "WARN",
|
|
80
|
-
[3 /* ERROR */]: "ERROR"
|
|
81
|
-
};
|
|
82
|
-
const CONSOLE_COLOR_MAP = {
|
|
83
|
-
[0 /* DEBUG */]: "\x1B[34m",
|
|
84
|
-
// Blue
|
|
85
|
-
[1 /* INFO */]: "\x1B[32m",
|
|
86
|
-
// Green
|
|
87
|
-
[2 /* WARN */]: "\x1B[33m",
|
|
88
|
-
// Yellow
|
|
89
|
-
[3 /* ERROR */]: "\x1B[31m"
|
|
90
|
-
// Red
|
|
91
|
-
};
|
|
92
|
-
const RESET_COLOR = "\x1B[0m";
|
|
93
|
-
function getColoredPrefix(level) {
|
|
94
|
-
return "".concat(CONSOLE_COLOR_MAP[level], "[ADK ").concat(LOG_LEVEL_STR[level], "]:").concat(RESET_COLOR);
|
|
95
|
-
}
|
|
96
88
|
let currentLogger = new SimpleLogger();
|
|
97
89
|
function setLogger(customLogger) {
|
|
98
90
|
currentLogger = customLogger != null ? customLogger : new NoOpLogger();
|
|
@@ -103,7 +95,13 @@ function getLogger() {
|
|
|
103
95
|
function resetLogger() {
|
|
104
96
|
currentLogger = new SimpleLogger();
|
|
105
97
|
}
|
|
98
|
+
function setLogLevel(level) {
|
|
99
|
+
logger.setLogLevel(level);
|
|
100
|
+
}
|
|
106
101
|
const logger = {
|
|
102
|
+
setLogLevel(level) {
|
|
103
|
+
currentLogger.setLogLevel(level);
|
|
104
|
+
},
|
|
107
105
|
log(level, ...args) {
|
|
108
106
|
currentLogger.log(level, ...args);
|
|
109
107
|
},
|
package/dist/web/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/adk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Google ADK JS",
|
|
5
5
|
"author": "Google",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "vitest",
|
|
38
38
|
"lint": "eslint 'src/**/*.ts'",
|
|
39
39
|
"format": "prettier --write 'src/**/*.ts'",
|
|
40
|
-
"prepublishOnly": "npm run build"
|
|
40
|
+
"prepublishOnly": "npm run build:bundle"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@a2a-js/sdk": "^0.3.10",
|
|
@@ -45,15 +45,18 @@
|
|
|
45
45
|
"@mikro-orm/core": "^6.6.6",
|
|
46
46
|
"@mikro-orm/reflection": "^6.6.6",
|
|
47
47
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
48
|
+
"express": "^4.22.1",
|
|
48
49
|
"google-auth-library": "^10.3.0",
|
|
49
50
|
"lodash-es": "^4.17.23",
|
|
51
|
+
"winston": "^3.19.0",
|
|
50
52
|
"zod": "^4.2.1",
|
|
51
53
|
"zod-to-json-schema": "^3.25.1"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
56
|
+
"@mikro-orm/sqlite": "^6.6.6",
|
|
57
|
+
"@types/express": "^4.17.25",
|
|
54
58
|
"@types/lodash-es": "^4.17.12",
|
|
55
|
-
"openapi-types": "^12.1.3"
|
|
56
|
-
"@mikro-orm/sqlite": "^6.6.6"
|
|
59
|
+
"openapi-types": "^12.1.3"
|
|
57
60
|
},
|
|
58
61
|
"peerDependencies": {
|
|
59
62
|
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
|
|
@@ -1,101 +0,0 @@
|
|
|
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 callback_context_exports = {};
|
|
26
|
-
__export(callback_context_exports, {
|
|
27
|
-
CallbackContext: () => CallbackContext
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(callback_context_exports);
|
|
30
|
-
var import_event_actions = require("../events/event_actions.js");
|
|
31
|
-
var import_state = require("../sessions/state.js");
|
|
32
|
-
var import_readonly_context = require("./readonly_context.js");
|
|
33
|
-
/**
|
|
34
|
-
* @license
|
|
35
|
-
* Copyright 2025 Google LLC
|
|
36
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
-
*/
|
|
38
|
-
class CallbackContext extends import_readonly_context.ReadonlyContext {
|
|
39
|
-
constructor({
|
|
40
|
-
invocationContext,
|
|
41
|
-
eventActions
|
|
42
|
-
}) {
|
|
43
|
-
super(invocationContext);
|
|
44
|
-
this.eventActions = eventActions || (0, import_event_actions.createEventActions)();
|
|
45
|
-
this._state = new import_state.State(
|
|
46
|
-
invocationContext.session.state,
|
|
47
|
-
this.eventActions.stateDelta
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The delta-aware state of the current session.
|
|
52
|
-
*/
|
|
53
|
-
get state() {
|
|
54
|
-
return this._state;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Loads an artifact attached to the current session.
|
|
58
|
-
*
|
|
59
|
-
* @param filename The filename of the artifact.
|
|
60
|
-
* @param version The version of the artifact. If not provided, the latest
|
|
61
|
-
* version will be used.
|
|
62
|
-
* @return A promise that resolves to the loaded artifact.
|
|
63
|
-
*/
|
|
64
|
-
loadArtifact(filename, version) {
|
|
65
|
-
if (!this.invocationContext.artifactService) {
|
|
66
|
-
throw new Error("Artifact service is not initialized.");
|
|
67
|
-
}
|
|
68
|
-
return this.invocationContext.artifactService.loadArtifact({
|
|
69
|
-
appName: this.invocationContext.appName,
|
|
70
|
-
userId: this.invocationContext.userId,
|
|
71
|
-
sessionId: this.invocationContext.session.id,
|
|
72
|
-
filename,
|
|
73
|
-
version
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Saves an artifact attached to the current session.
|
|
78
|
-
*
|
|
79
|
-
* @param filename The filename of the artifact.
|
|
80
|
-
* @param artifact The artifact to save.
|
|
81
|
-
* @return A promise that resolves to the version of the saved artifact.
|
|
82
|
-
*/
|
|
83
|
-
async saveArtifact(filename, artifact) {
|
|
84
|
-
if (!this.invocationContext.artifactService) {
|
|
85
|
-
throw new Error("Artifact service is not initialized.");
|
|
86
|
-
}
|
|
87
|
-
const version = await this.invocationContext.artifactService.saveArtifact({
|
|
88
|
-
appName: this.invocationContext.appName,
|
|
89
|
-
userId: this.invocationContext.userId,
|
|
90
|
-
sessionId: this.invocationContext.session.id,
|
|
91
|
-
filename,
|
|
92
|
-
artifact
|
|
93
|
-
});
|
|
94
|
-
this.eventActions.artifactDelta[filename] = version;
|
|
95
|
-
return version;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
99
|
-
0 && (module.exports = {
|
|
100
|
-
CallbackContext
|
|
101
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { createEventActions } from "../events/event_actions.js";
|
|
7
|
-
import { State } from "../sessions/state.js";
|
|
8
|
-
import { ReadonlyContext } from "./readonly_context.js";
|
|
9
|
-
class CallbackContext extends ReadonlyContext {
|
|
10
|
-
constructor({
|
|
11
|
-
invocationContext,
|
|
12
|
-
eventActions
|
|
13
|
-
}) {
|
|
14
|
-
super(invocationContext);
|
|
15
|
-
this.eventActions = eventActions || createEventActions();
|
|
16
|
-
this._state = new State(
|
|
17
|
-
invocationContext.session.state,
|
|
18
|
-
this.eventActions.stateDelta
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The delta-aware state of the current session.
|
|
23
|
-
*/
|
|
24
|
-
get state() {
|
|
25
|
-
return this._state;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Loads an artifact attached to the current session.
|
|
29
|
-
*
|
|
30
|
-
* @param filename The filename of the artifact.
|
|
31
|
-
* @param version The version of the artifact. If not provided, the latest
|
|
32
|
-
* version will be used.
|
|
33
|
-
* @return A promise that resolves to the loaded artifact.
|
|
34
|
-
*/
|
|
35
|
-
loadArtifact(filename, version) {
|
|
36
|
-
if (!this.invocationContext.artifactService) {
|
|
37
|
-
throw new Error("Artifact service is not initialized.");
|
|
38
|
-
}
|
|
39
|
-
return this.invocationContext.artifactService.loadArtifact({
|
|
40
|
-
appName: this.invocationContext.appName,
|
|
41
|
-
userId: this.invocationContext.userId,
|
|
42
|
-
sessionId: this.invocationContext.session.id,
|
|
43
|
-
filename,
|
|
44
|
-
version
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Saves an artifact attached to the current session.
|
|
49
|
-
*
|
|
50
|
-
* @param filename The filename of the artifact.
|
|
51
|
-
* @param artifact The artifact to save.
|
|
52
|
-
* @return A promise that resolves to the version of the saved artifact.
|
|
53
|
-
*/
|
|
54
|
-
async saveArtifact(filename, artifact) {
|
|
55
|
-
if (!this.invocationContext.artifactService) {
|
|
56
|
-
throw new Error("Artifact service is not initialized.");
|
|
57
|
-
}
|
|
58
|
-
const version = await this.invocationContext.artifactService.saveArtifact({
|
|
59
|
-
appName: this.invocationContext.appName,
|
|
60
|
-
userId: this.invocationContext.userId,
|
|
61
|
-
sessionId: this.invocationContext.session.id,
|
|
62
|
-
filename,
|
|
63
|
-
artifact
|
|
64
|
-
});
|
|
65
|
-
this.eventActions.artifactDelta[filename] = version;
|
|
66
|
-
return version;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
CallbackContext
|
|
71
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Part } from '@google/genai';
|
|
7
|
-
import { EventActions } from '../events/event_actions.js';
|
|
8
|
-
import { State } from '../sessions/state.js';
|
|
9
|
-
import { InvocationContext } from './invocation_context.js';
|
|
10
|
-
import { ReadonlyContext } from './readonly_context.js';
|
|
11
|
-
/**
|
|
12
|
-
* The context of various callbacks within an agent run.
|
|
13
|
-
*/
|
|
14
|
-
export declare class CallbackContext extends ReadonlyContext {
|
|
15
|
-
private readonly _state;
|
|
16
|
-
readonly eventActions: EventActions;
|
|
17
|
-
constructor({ invocationContext, eventActions, }: {
|
|
18
|
-
invocationContext: InvocationContext;
|
|
19
|
-
eventActions?: EventActions;
|
|
20
|
-
});
|
|
21
|
-
/**
|
|
22
|
-
* The delta-aware state of the current session.
|
|
23
|
-
*/
|
|
24
|
-
get state(): State;
|
|
25
|
-
/**
|
|
26
|
-
* Loads an artifact attached to the current session.
|
|
27
|
-
*
|
|
28
|
-
* @param filename The filename of the artifact.
|
|
29
|
-
* @param version The version of the artifact. If not provided, the latest
|
|
30
|
-
* version will be used.
|
|
31
|
-
* @return A promise that resolves to the loaded artifact.
|
|
32
|
-
*/
|
|
33
|
-
loadArtifact(filename: string, version?: number): Promise<Part | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Saves an artifact attached to the current session.
|
|
36
|
-
*
|
|
37
|
-
* @param filename The filename of the artifact.
|
|
38
|
-
* @param artifact The artifact to save.
|
|
39
|
-
* @return A promise that resolves to the version of the saved artifact.
|
|
40
|
-
*/
|
|
41
|
-
saveArtifact(filename: string, artifact: Part): Promise<number>;
|
|
42
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { createEventActions } from "../events/event_actions.js";
|
|
7
|
-
import { State } from "../sessions/state.js";
|
|
8
|
-
import { ReadonlyContext } from "./readonly_context.js";
|
|
9
|
-
class CallbackContext extends ReadonlyContext {
|
|
10
|
-
constructor({
|
|
11
|
-
invocationContext,
|
|
12
|
-
eventActions
|
|
13
|
-
}) {
|
|
14
|
-
super(invocationContext);
|
|
15
|
-
this.eventActions = eventActions || createEventActions();
|
|
16
|
-
this._state = new State(
|
|
17
|
-
invocationContext.session.state,
|
|
18
|
-
this.eventActions.stateDelta
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The delta-aware state of the current session.
|
|
23
|
-
*/
|
|
24
|
-
get state() {
|
|
25
|
-
return this._state;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Loads an artifact attached to the current session.
|
|
29
|
-
*
|
|
30
|
-
* @param filename The filename of the artifact.
|
|
31
|
-
* @param version The version of the artifact. If not provided, the latest
|
|
32
|
-
* version will be used.
|
|
33
|
-
* @return A promise that resolves to the loaded artifact.
|
|
34
|
-
*/
|
|
35
|
-
loadArtifact(filename, version) {
|
|
36
|
-
if (!this.invocationContext.artifactService) {
|
|
37
|
-
throw new Error("Artifact service is not initialized.");
|
|
38
|
-
}
|
|
39
|
-
return this.invocationContext.artifactService.loadArtifact({
|
|
40
|
-
appName: this.invocationContext.appName,
|
|
41
|
-
userId: this.invocationContext.userId,
|
|
42
|
-
sessionId: this.invocationContext.session.id,
|
|
43
|
-
filename,
|
|
44
|
-
version
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Saves an artifact attached to the current session.
|
|
49
|
-
*
|
|
50
|
-
* @param filename The filename of the artifact.
|
|
51
|
-
* @param artifact The artifact to save.
|
|
52
|
-
* @return A promise that resolves to the version of the saved artifact.
|
|
53
|
-
*/
|
|
54
|
-
async saveArtifact(filename, artifact) {
|
|
55
|
-
if (!this.invocationContext.artifactService) {
|
|
56
|
-
throw new Error("Artifact service is not initialized.");
|
|
57
|
-
}
|
|
58
|
-
const version = await this.invocationContext.artifactService.saveArtifact({
|
|
59
|
-
appName: this.invocationContext.appName,
|
|
60
|
-
userId: this.invocationContext.userId,
|
|
61
|
-
sessionId: this.invocationContext.session.id,
|
|
62
|
-
filename,
|
|
63
|
-
artifact
|
|
64
|
-
});
|
|
65
|
-
this.eventActions.artifactDelta[filename] = version;
|
|
66
|
-
return version;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export {
|
|
70
|
-
CallbackContext
|
|
71
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|