@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,107 @@
|
|
|
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 load_memory_tool_exports = {};
|
|
26
|
+
__export(load_memory_tool_exports, {
|
|
27
|
+
LOAD_MEMORY: () => LOAD_MEMORY,
|
|
28
|
+
LoadMemoryTool: () => LoadMemoryTool
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(load_memory_tool_exports);
|
|
31
|
+
var import_genai = require("@google/genai");
|
|
32
|
+
var import_llm_request = require("../models/llm_request.js");
|
|
33
|
+
var import_base_tool = require("./base_tool.js");
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2026 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
38
|
+
*/
|
|
39
|
+
class LoadMemoryTool extends import_base_tool.BaseTool {
|
|
40
|
+
constructor() {
|
|
41
|
+
super({
|
|
42
|
+
name: "load_memory",
|
|
43
|
+
description: "Loads the memory for the current user.\n\nNOTE: Currently this tool only uses text part from the memory."
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
_getDeclaration() {
|
|
47
|
+
return {
|
|
48
|
+
name: this.name,
|
|
49
|
+
description: this.description,
|
|
50
|
+
parameters: {
|
|
51
|
+
type: import_genai.Type.OBJECT,
|
|
52
|
+
properties: {
|
|
53
|
+
query: {
|
|
54
|
+
type: import_genai.Type.STRING,
|
|
55
|
+
description: "The query to load the memory for."
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
required: ["query"]
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async runAsync({
|
|
63
|
+
args,
|
|
64
|
+
toolContext
|
|
65
|
+
}) {
|
|
66
|
+
try {
|
|
67
|
+
const query = args["query"];
|
|
68
|
+
if (!toolContext.invocationContext.memoryService) {
|
|
69
|
+
throw new Error("Memory service is not initialized.");
|
|
70
|
+
}
|
|
71
|
+
const searchMemoryResponse = await toolContext.searchMemory(query);
|
|
72
|
+
return {
|
|
73
|
+
memories: searchMemoryResponse.memories.map((m) => {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
return {
|
|
76
|
+
// Join all text parts by a space, or empty string if no text parts
|
|
77
|
+
content: (_b = (_a = m.content.parts) == null ? void 0 : _a.map((p) => {
|
|
78
|
+
var _a2;
|
|
79
|
+
return (_a2 = p.text) != null ? _a2 : "";
|
|
80
|
+
}).join(" ")) != null ? _b : "",
|
|
81
|
+
author: m.author,
|
|
82
|
+
timestamp: m.timestamp
|
|
83
|
+
};
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
} catch (e) {
|
|
87
|
+
console.error("ERROR in LoadMemoryTool runAsync:", e);
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async processLlmRequest(request) {
|
|
92
|
+
await super.processLlmRequest(request);
|
|
93
|
+
if (!request.toolContext.invocationContext.memoryService) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
(0, import_llm_request.appendInstructions)(request.llmRequest, [
|
|
97
|
+
`You have memory. You can use it to answer questions. If any questions need
|
|
98
|
+
you to look up the memory, you should call load_memory function with a query.`
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const LOAD_MEMORY = new LoadMemoryTool();
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
LOAD_MEMORY,
|
|
106
|
+
LoadMemoryTool
|
|
107
|
+
});
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 preload_memory_tool_exports = {};
|
|
26
|
+
__export(preload_memory_tool_exports, {
|
|
27
|
+
PRELOAD_MEMORY: () => PRELOAD_MEMORY,
|
|
28
|
+
PreloadMemoryTool: () => PreloadMemoryTool
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(preload_memory_tool_exports);
|
|
31
|
+
var import_llm_request = require("../models/llm_request.js");
|
|
32
|
+
var import_logger = require("../utils/logger.js");
|
|
33
|
+
var import_base_tool = require("./base_tool.js");
|
|
34
|
+
/**
|
|
35
|
+
* @license
|
|
36
|
+
* Copyright 2026 Google LLC
|
|
37
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
38
|
+
*/
|
|
39
|
+
class PreloadMemoryTool extends import_base_tool.BaseTool {
|
|
40
|
+
constructor() {
|
|
41
|
+
super({
|
|
42
|
+
// Name and description are not used because this tool only
|
|
43
|
+
// changes llm_request.
|
|
44
|
+
name: "preload_memory",
|
|
45
|
+
description: "preload_memory"
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
async runAsync({
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
|
+
args,
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
52
|
+
toolContext
|
|
53
|
+
}) {
|
|
54
|
+
throw new Error("PreloadMemoryTool should not be called by model");
|
|
55
|
+
}
|
|
56
|
+
async processLlmRequest(request) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
await super.processLlmRequest(request);
|
|
59
|
+
const userContent = request.toolContext.userContent;
|
|
60
|
+
if (!userContent || !userContent.parts || !((_a = userContent.parts[0]) == null ? void 0 : _a.text)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const userQuery = userContent.parts[0].text;
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
if (!request.toolContext.invocationContext.memoryService) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
response = await request.toolContext.searchMemory(userQuery);
|
|
70
|
+
} catch (_) {
|
|
71
|
+
import_logger.logger.warn(`Failed to preload memory for query: ${userQuery}`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (!response.memories || response.memories.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const memoryTextLines = [];
|
|
78
|
+
for (const memory of response.memories) {
|
|
79
|
+
const timeStr = memory.timestamp ? `Time: ${memory.timestamp}` : "";
|
|
80
|
+
if (timeStr) memoryTextLines.push(timeStr);
|
|
81
|
+
const memoryText = (_c = (_b = memory.content.parts) == null ? void 0 : _b.map((p) => {
|
|
82
|
+
var _a2;
|
|
83
|
+
return (_a2 = p.text) != null ? _a2 : "";
|
|
84
|
+
}).join(" ")) != null ? _c : "";
|
|
85
|
+
if (memoryText) {
|
|
86
|
+
memoryTextLines.push(
|
|
87
|
+
memory.author ? `${memory.author}: ${memoryText}` : memoryText
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (memoryTextLines.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const fullMemoryText = memoryTextLines.join("\n");
|
|
95
|
+
const si = `The following content is from your previous conversations with the user.
|
|
96
|
+
They may be useful for answering the user's current query.
|
|
97
|
+
<PAST_CONVERSATIONS>
|
|
98
|
+
${fullMemoryText}
|
|
99
|
+
</PAST_CONVERSATIONS>
|
|
100
|
+
`;
|
|
101
|
+
(0, import_llm_request.appendInstructions)(request.llmRequest, [si]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const PRELOAD_MEMORY = new PreloadMemoryTool();
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
PRELOAD_MEMORY,
|
|
108
|
+
PreloadMemoryTool
|
|
109
|
+
});
|
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,69 @@ 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
|
+
level: "error",
|
|
69
|
+
format: winston.format.combine(
|
|
70
|
+
winston.format.label({ label: "ADK" }),
|
|
71
|
+
winston.format((info) => {
|
|
72
|
+
info.level = info.level.toUpperCase();
|
|
73
|
+
return info;
|
|
74
|
+
})(),
|
|
75
|
+
winston.format.colorize(),
|
|
76
|
+
winston.format.timestamp(),
|
|
77
|
+
winston.format.printf((info) => {
|
|
78
|
+
return `${info.level}: [${info.label}] ${info.timestamp} ${info.message}`;
|
|
79
|
+
})
|
|
80
|
+
),
|
|
81
|
+
transports: [new winston.transports.Console()]
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
setLogLevel(level) {
|
|
85
|
+
this.logLevel = level;
|
|
86
|
+
}
|
|
87
|
+
log(level, ...messages) {
|
|
88
|
+
if (this.logLevel > level) {
|
|
54
89
|
return;
|
|
55
90
|
}
|
|
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
|
-
}
|
|
91
|
+
this.logger.log(level.toString(), messages.join(" "));
|
|
72
92
|
}
|
|
73
|
-
debug(...
|
|
74
|
-
if (logLevel > 0 /* DEBUG */) {
|
|
93
|
+
debug(...messages) {
|
|
94
|
+
if (this.logLevel > 0 /* DEBUG */) {
|
|
75
95
|
return;
|
|
76
96
|
}
|
|
77
|
-
|
|
97
|
+
this.logger.debug(messages.join(" "));
|
|
78
98
|
}
|
|
79
|
-
info(...
|
|
80
|
-
if (logLevel > 1 /* INFO */) {
|
|
99
|
+
info(...messages) {
|
|
100
|
+
if (this.logLevel > 1 /* INFO */) {
|
|
81
101
|
return;
|
|
82
102
|
}
|
|
83
|
-
|
|
103
|
+
this.logger.info(messages.join(" "));
|
|
84
104
|
}
|
|
85
|
-
warn(...
|
|
86
|
-
if (logLevel > 2 /* WARN */) {
|
|
105
|
+
warn(...messages) {
|
|
106
|
+
if (this.logLevel > 2 /* WARN */) {
|
|
87
107
|
return;
|
|
88
108
|
}
|
|
89
|
-
|
|
109
|
+
this.logger.warn(messages.join(" "));
|
|
90
110
|
}
|
|
91
|
-
error(...
|
|
92
|
-
if (logLevel > 3 /* ERROR */) {
|
|
111
|
+
error(...messages) {
|
|
112
|
+
if (this.logLevel > 3 /* ERROR */) {
|
|
93
113
|
return;
|
|
94
114
|
}
|
|
95
|
-
|
|
115
|
+
this.logger.error(messages.join(" "));
|
|
96
116
|
}
|
|
97
117
|
}
|
|
98
118
|
class NoOpLogger {
|
|
119
|
+
setLogLevel(_level) {
|
|
120
|
+
}
|
|
99
121
|
log(_level, ..._args) {
|
|
100
122
|
}
|
|
101
123
|
debug(..._args) {
|
|
@@ -107,26 +129,6 @@ class NoOpLogger {
|
|
|
107
129
|
error(..._args) {
|
|
108
130
|
}
|
|
109
131
|
}
|
|
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
132
|
let currentLogger = new SimpleLogger();
|
|
131
133
|
function setLogger(customLogger) {
|
|
132
134
|
currentLogger = customLogger != null ? customLogger : new NoOpLogger();
|
|
@@ -137,7 +139,13 @@ function getLogger() {
|
|
|
137
139
|
function resetLogger() {
|
|
138
140
|
currentLogger = new SimpleLogger();
|
|
139
141
|
}
|
|
142
|
+
function setLogLevel(level) {
|
|
143
|
+
logger.setLogLevel(level);
|
|
144
|
+
}
|
|
140
145
|
const logger = {
|
|
146
|
+
setLogLevel(level) {
|
|
147
|
+
currentLogger.setLogLevel(level);
|
|
148
|
+
},
|
|
141
149
|
log(level, ...args) {
|
|
142
150
|
currentLogger.log(level, ...args);
|
|
143
151
|
},
|
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.6.0";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|
|
@@ -0,0 +1,269 @@
|
|
|
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
|
+
var TaskState = /* @__PURE__ */ ((TaskState2) => {
|
|
13
|
+
TaskState2["SUBMITTED"] = "submitted";
|
|
14
|
+
TaskState2["WORKING"] = "working";
|
|
15
|
+
TaskState2["COMPLETED"] = "completed";
|
|
16
|
+
TaskState2["FAILED"] = "failed";
|
|
17
|
+
TaskState2["CANCELED"] = "canceled";
|
|
18
|
+
TaskState2["REJECTED"] = "rejected";
|
|
19
|
+
TaskState2["INPUT_REQUIRED"] = "input-required";
|
|
20
|
+
return TaskState2;
|
|
21
|
+
})(TaskState || {});
|
|
22
|
+
function isTaskStatusUpdateEvent(event) {
|
|
23
|
+
return (event == null ? void 0 : event.kind) === "status-update";
|
|
24
|
+
}
|
|
25
|
+
function isTaskArtifactUpdateEvent(event) {
|
|
26
|
+
return (event == null ? void 0 : event.kind) === "artifact-update";
|
|
27
|
+
}
|
|
28
|
+
function isMessage(event) {
|
|
29
|
+
return (event == null ? void 0 : event.kind) === "message";
|
|
30
|
+
}
|
|
31
|
+
function isTask(event) {
|
|
32
|
+
return (event == null ? void 0 : event.kind) === "task";
|
|
33
|
+
}
|
|
34
|
+
function getEventMetadata(event) {
|
|
35
|
+
if (isTaskArtifactUpdateEvent(event)) {
|
|
36
|
+
return event.artifact.metadata || {};
|
|
37
|
+
}
|
|
38
|
+
if (isTaskStatusUpdateEvent(event) || isTask(event) || isMessage(event)) {
|
|
39
|
+
return event.metadata || {};
|
|
40
|
+
}
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
function isFailedTaskStatusUpdateEvent(event) {
|
|
44
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && event.status.state === "failed" /* FAILED */;
|
|
45
|
+
}
|
|
46
|
+
function isTerminalTaskStatusUpdateEvent(event) {
|
|
47
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && [
|
|
48
|
+
"completed" /* COMPLETED */,
|
|
49
|
+
"failed" /* FAILED */,
|
|
50
|
+
"canceled" /* CANCELED */,
|
|
51
|
+
"rejected" /* REJECTED */
|
|
52
|
+
].includes(event.status.state);
|
|
53
|
+
}
|
|
54
|
+
function isInputRequiredTaskStatusUpdateEvent(event) {
|
|
55
|
+
return (isTaskStatusUpdateEvent(event) || isTask(event)) && event.status.state === "input-required" /* INPUT_REQUIRED */;
|
|
56
|
+
}
|
|
57
|
+
function getFailedTaskStatusUpdateEventError(event) {
|
|
58
|
+
var _a;
|
|
59
|
+
if (!isFailedTaskStatusUpdateEvent(event)) {
|
|
60
|
+
return void 0;
|
|
61
|
+
}
|
|
62
|
+
const parts = ((_a = event.status.message) == null ? void 0 : _a.parts) || [];
|
|
63
|
+
if (parts.length === 0) {
|
|
64
|
+
return void 0;
|
|
65
|
+
}
|
|
66
|
+
if (parts[0].kind !== "text") {
|
|
67
|
+
return void 0;
|
|
68
|
+
}
|
|
69
|
+
return parts[0].text;
|
|
70
|
+
}
|
|
71
|
+
function createTaskSubmittedEvent({
|
|
72
|
+
taskId,
|
|
73
|
+
contextId,
|
|
74
|
+
message,
|
|
75
|
+
metadata
|
|
76
|
+
}) {
|
|
77
|
+
return {
|
|
78
|
+
kind: "status-update",
|
|
79
|
+
taskId,
|
|
80
|
+
contextId,
|
|
81
|
+
final: false,
|
|
82
|
+
status: {
|
|
83
|
+
state: "submitted" /* SUBMITTED */,
|
|
84
|
+
message,
|
|
85
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
86
|
+
},
|
|
87
|
+
metadata
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function createTask({
|
|
91
|
+
contextId,
|
|
92
|
+
message,
|
|
93
|
+
taskId,
|
|
94
|
+
metadata
|
|
95
|
+
}) {
|
|
96
|
+
return {
|
|
97
|
+
kind: "task",
|
|
98
|
+
id: taskId || randomUUID(),
|
|
99
|
+
contextId,
|
|
100
|
+
history: [message],
|
|
101
|
+
status: {
|
|
102
|
+
state: "submitted" /* SUBMITTED */,
|
|
103
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
104
|
+
},
|
|
105
|
+
metadata
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function createTaskWorkingEvent({
|
|
109
|
+
taskId,
|
|
110
|
+
contextId,
|
|
111
|
+
message,
|
|
112
|
+
metadata
|
|
113
|
+
}) {
|
|
114
|
+
return {
|
|
115
|
+
kind: "status-update",
|
|
116
|
+
taskId,
|
|
117
|
+
contextId,
|
|
118
|
+
final: false,
|
|
119
|
+
status: {
|
|
120
|
+
state: "working" /* WORKING */,
|
|
121
|
+
message,
|
|
122
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
123
|
+
},
|
|
124
|
+
metadata
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
function createTaskCompletedEvent({
|
|
128
|
+
taskId,
|
|
129
|
+
contextId,
|
|
130
|
+
metadata
|
|
131
|
+
}) {
|
|
132
|
+
return {
|
|
133
|
+
kind: "status-update",
|
|
134
|
+
taskId,
|
|
135
|
+
contextId,
|
|
136
|
+
final: true,
|
|
137
|
+
status: {
|
|
138
|
+
state: "completed" /* COMPLETED */,
|
|
139
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
140
|
+
},
|
|
141
|
+
metadata
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function createTaskArtifactUpdateEvent({
|
|
145
|
+
taskId,
|
|
146
|
+
contextId,
|
|
147
|
+
artifactId,
|
|
148
|
+
parts = [],
|
|
149
|
+
metadata,
|
|
150
|
+
append,
|
|
151
|
+
lastChunk
|
|
152
|
+
}) {
|
|
153
|
+
return {
|
|
154
|
+
kind: "artifact-update",
|
|
155
|
+
taskId,
|
|
156
|
+
contextId,
|
|
157
|
+
append,
|
|
158
|
+
lastChunk,
|
|
159
|
+
artifact: {
|
|
160
|
+
artifactId: artifactId || randomUUID(),
|
|
161
|
+
parts
|
|
162
|
+
},
|
|
163
|
+
metadata
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function createTaskFailedEvent({
|
|
167
|
+
taskId,
|
|
168
|
+
contextId,
|
|
169
|
+
error,
|
|
170
|
+
metadata
|
|
171
|
+
}) {
|
|
172
|
+
return {
|
|
173
|
+
kind: "status-update",
|
|
174
|
+
taskId,
|
|
175
|
+
contextId,
|
|
176
|
+
final: true,
|
|
177
|
+
status: {
|
|
178
|
+
state: "failed" /* FAILED */,
|
|
179
|
+
message: {
|
|
180
|
+
kind: "message",
|
|
181
|
+
messageId: randomUUID(),
|
|
182
|
+
role: "agent",
|
|
183
|
+
taskId,
|
|
184
|
+
contextId,
|
|
185
|
+
parts: [
|
|
186
|
+
{
|
|
187
|
+
kind: "text",
|
|
188
|
+
text: error.message
|
|
189
|
+
}
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
193
|
+
},
|
|
194
|
+
metadata
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function createTaskInputRequiredEvent({
|
|
198
|
+
taskId,
|
|
199
|
+
contextId,
|
|
200
|
+
parts,
|
|
201
|
+
metadata
|
|
202
|
+
}) {
|
|
203
|
+
return {
|
|
204
|
+
kind: "status-update",
|
|
205
|
+
taskId,
|
|
206
|
+
contextId,
|
|
207
|
+
final: true,
|
|
208
|
+
status: {
|
|
209
|
+
state: "input-required" /* INPUT_REQUIRED */,
|
|
210
|
+
message: {
|
|
211
|
+
kind: "message",
|
|
212
|
+
messageId: randomUUID(),
|
|
213
|
+
role: "agent",
|
|
214
|
+
taskId,
|
|
215
|
+
contextId,
|
|
216
|
+
parts
|
|
217
|
+
},
|
|
218
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
219
|
+
},
|
|
220
|
+
metadata
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function createInputMissingErrorEvent({
|
|
224
|
+
taskId,
|
|
225
|
+
contextId,
|
|
226
|
+
parts,
|
|
227
|
+
metadata
|
|
228
|
+
}) {
|
|
229
|
+
return {
|
|
230
|
+
kind: "status-update",
|
|
231
|
+
taskId,
|
|
232
|
+
contextId,
|
|
233
|
+
final: true,
|
|
234
|
+
status: {
|
|
235
|
+
state: "input-required" /* INPUT_REQUIRED */,
|
|
236
|
+
message: {
|
|
237
|
+
kind: "message",
|
|
238
|
+
messageId: randomUUID(),
|
|
239
|
+
role: "agent",
|
|
240
|
+
taskId,
|
|
241
|
+
contextId,
|
|
242
|
+
parts
|
|
243
|
+
},
|
|
244
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
245
|
+
},
|
|
246
|
+
metadata
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
export {
|
|
250
|
+
MessageRole,
|
|
251
|
+
TaskState,
|
|
252
|
+
createInputMissingErrorEvent,
|
|
253
|
+
createTask,
|
|
254
|
+
createTaskArtifactUpdateEvent,
|
|
255
|
+
createTaskCompletedEvent,
|
|
256
|
+
createTaskFailedEvent,
|
|
257
|
+
createTaskInputRequiredEvent,
|
|
258
|
+
createTaskSubmittedEvent,
|
|
259
|
+
createTaskWorkingEvent,
|
|
260
|
+
getEventMetadata,
|
|
261
|
+
getFailedTaskStatusUpdateEventError,
|
|
262
|
+
isFailedTaskStatusUpdateEvent,
|
|
263
|
+
isInputRequiredTaskStatusUpdateEvent,
|
|
264
|
+
isMessage,
|
|
265
|
+
isTask,
|
|
266
|
+
isTaskArtifactUpdateEvent,
|
|
267
|
+
isTaskStatusUpdateEvent,
|
|
268
|
+
isTerminalTaskStatusUpdateEvent
|
|
269
|
+
};
|