@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
|
@@ -0,0 +1,54 @@
|
|
|
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 identity_llm_request_processor_exports = {};
|
|
26
|
+
__export(identity_llm_request_processor_exports, {
|
|
27
|
+
IDENTITY_LLM_REQUEST_PROCESSOR: () => IDENTITY_LLM_REQUEST_PROCESSOR,
|
|
28
|
+
IdentityLlmRequestProcessor: () => IdentityLlmRequestProcessor
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(identity_llm_request_processor_exports);
|
|
31
|
+
var import_llm_request = require("../../models/llm_request.js");
|
|
32
|
+
var import_base_llm_processor = require("./base_llm_processor.js");
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2025 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
*/
|
|
38
|
+
class IdentityLlmRequestProcessor extends import_base_llm_processor.BaseLlmRequestProcessor {
|
|
39
|
+
// eslint-disable-next-line require-yield
|
|
40
|
+
async *runAsync(invocationContext, llmRequest) {
|
|
41
|
+
const agent = invocationContext.agent;
|
|
42
|
+
const si = [`You are an agent. Your internal name is "${agent.name}".`];
|
|
43
|
+
if (agent.description) {
|
|
44
|
+
si.push(`The description about you is "${agent.description}"`);
|
|
45
|
+
}
|
|
46
|
+
(0, import_llm_request.appendInstructions)(llmRequest, si);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const IDENTITY_LLM_REQUEST_PROCESSOR = new IdentityLlmRequestProcessor();
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
IDENTITY_LLM_REQUEST_PROCESSOR,
|
|
53
|
+
IdentityLlmRequestProcessor
|
|
54
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
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 instructions_llm_request_processor_exports = {};
|
|
26
|
+
__export(instructions_llm_request_processor_exports, {
|
|
27
|
+
INSTRUCTIONS_LLM_REQUEST_PROCESSOR: () => INSTRUCTIONS_LLM_REQUEST_PROCESSOR,
|
|
28
|
+
InstructionsLlmRequestProcessor: () => InstructionsLlmRequestProcessor
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(instructions_llm_request_processor_exports);
|
|
31
|
+
var import_llm_request = require("../../models/llm_request.js");
|
|
32
|
+
var import_instructions = require("../instructions.js");
|
|
33
|
+
var import_llm_agent = require("../llm_agent.js");
|
|
34
|
+
var import_readonly_context = require("../readonly_context.js");
|
|
35
|
+
var import_base_llm_processor = require("./base_llm_processor.js");
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2025 Google LLC
|
|
39
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
40
|
+
*/
|
|
41
|
+
class InstructionsLlmRequestProcessor extends import_base_llm_processor.BaseLlmRequestProcessor {
|
|
42
|
+
/**
|
|
43
|
+
* Handles instructions and global instructions for LLM flow.
|
|
44
|
+
*/
|
|
45
|
+
// eslint-disable-next-line require-yield
|
|
46
|
+
async *runAsync(invocationContext, llmRequest) {
|
|
47
|
+
const agent = invocationContext.agent;
|
|
48
|
+
if (!(0, import_llm_agent.isLlmAgent)(agent) || !(0, import_llm_agent.isLlmAgent)(agent.rootAgent)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const rootAgent = agent.rootAgent;
|
|
52
|
+
if ((0, import_llm_agent.isLlmAgent)(rootAgent) && rootAgent.globalInstruction) {
|
|
53
|
+
const { instruction, requireStateInjection } = await rootAgent.canonicalGlobalInstruction(
|
|
54
|
+
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
55
|
+
);
|
|
56
|
+
let instructionWithState = instruction;
|
|
57
|
+
if (requireStateInjection) {
|
|
58
|
+
instructionWithState = await (0, import_instructions.injectSessionState)(
|
|
59
|
+
instruction,
|
|
60
|
+
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
(0, import_llm_request.appendInstructions)(llmRequest, [instructionWithState]);
|
|
64
|
+
}
|
|
65
|
+
if (agent.instruction) {
|
|
66
|
+
const { instruction, requireStateInjection } = await agent.canonicalInstruction(
|
|
67
|
+
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
68
|
+
);
|
|
69
|
+
let instructionWithState = instruction;
|
|
70
|
+
if (requireStateInjection) {
|
|
71
|
+
instructionWithState = await (0, import_instructions.injectSessionState)(
|
|
72
|
+
instruction,
|
|
73
|
+
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
(0, import_llm_request.appendInstructions)(llmRequest, [instructionWithState]);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const INSTRUCTIONS_LLM_REQUEST_PROCESSOR = new InstructionsLlmRequestProcessor();
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
INSTRUCTIONS_LLM_REQUEST_PROCESSOR,
|
|
84
|
+
InstructionsLlmRequestProcessor
|
|
85
|
+
});
|
|
@@ -0,0 +1,165 @@
|
|
|
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 request_confirmation_llm_request_processor_exports = {};
|
|
26
|
+
__export(request_confirmation_llm_request_processor_exports, {
|
|
27
|
+
REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR: () => REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
|
|
28
|
+
RequestConfirmationLlmRequestProcessor: () => RequestConfirmationLlmRequestProcessor
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(request_confirmation_llm_request_processor_exports);
|
|
31
|
+
var import_event = require("../../events/event.js");
|
|
32
|
+
var import_tool_confirmation = require("../../tools/tool_confirmation.js");
|
|
33
|
+
var import_functions = require("../functions.js");
|
|
34
|
+
var import_llm_agent = require("../llm_agent.js");
|
|
35
|
+
var import_readonly_context = require("../readonly_context.js");
|
|
36
|
+
var import_base_llm_processor = require("./base_llm_processor.js");
|
|
37
|
+
/**
|
|
38
|
+
* @license
|
|
39
|
+
* Copyright 2025 Google LLC
|
|
40
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
41
|
+
*/
|
|
42
|
+
class RequestConfirmationLlmRequestProcessor extends import_base_llm_processor.BaseLlmRequestProcessor {
|
|
43
|
+
/** Handles tool confirmation information to build the LLM request. */
|
|
44
|
+
async *runAsync(invocationContext) {
|
|
45
|
+
const agent = invocationContext.agent;
|
|
46
|
+
if (!(0, import_llm_agent.isLlmAgent)(agent)) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const events = invocationContext.session.events;
|
|
50
|
+
if (!events || events.length === 0) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const requestConfirmationFunctionResponses = {};
|
|
54
|
+
let confirmationEventIndex = -1;
|
|
55
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
56
|
+
const event = events[i];
|
|
57
|
+
if (event.author !== "user") {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const responses = (0, import_event.getFunctionResponses)(event);
|
|
61
|
+
if (!responses) {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
let foundConfirmation = false;
|
|
65
|
+
for (const functionResponse of responses) {
|
|
66
|
+
if (functionResponse.name !== import_functions.REQUEST_CONFIRMATION_FUNCTION_CALL_NAME) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
foundConfirmation = true;
|
|
70
|
+
let toolConfirmation = null;
|
|
71
|
+
if (functionResponse.response && Object.keys(functionResponse.response).length === 1 && "response" in functionResponse.response) {
|
|
72
|
+
toolConfirmation = JSON.parse(
|
|
73
|
+
functionResponse.response["response"]
|
|
74
|
+
);
|
|
75
|
+
} else if (functionResponse.response) {
|
|
76
|
+
toolConfirmation = new import_tool_confirmation.ToolConfirmation({
|
|
77
|
+
hint: functionResponse.response["hint"],
|
|
78
|
+
payload: functionResponse.response["payload"],
|
|
79
|
+
confirmed: functionResponse.response["confirmed"]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
if (functionResponse.id && toolConfirmation) {
|
|
83
|
+
requestConfirmationFunctionResponses[functionResponse.id] = toolConfirmation;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (foundConfirmation) {
|
|
87
|
+
confirmationEventIndex = i;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (Object.keys(requestConfirmationFunctionResponses).length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
for (let i = confirmationEventIndex - 1; i >= 0; i--) {
|
|
95
|
+
const event = events[i];
|
|
96
|
+
const functionCalls = (0, import_event.getFunctionCalls)(event);
|
|
97
|
+
if (!functionCalls) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const toolsToResumeWithConfirmation = {};
|
|
101
|
+
const toolsToResumeWithArgs = {};
|
|
102
|
+
for (const functionCall of functionCalls) {
|
|
103
|
+
if (!functionCall.id || !(functionCall.id in requestConfirmationFunctionResponses)) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const args = functionCall.args;
|
|
107
|
+
if (!args || !("originalFunctionCall" in args)) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const originalFunctionCall = args["originalFunctionCall"];
|
|
111
|
+
if (originalFunctionCall.id) {
|
|
112
|
+
toolsToResumeWithConfirmation[originalFunctionCall.id] = requestConfirmationFunctionResponses[functionCall.id];
|
|
113
|
+
toolsToResumeWithArgs[originalFunctionCall.id] = originalFunctionCall;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (Object.keys(toolsToResumeWithConfirmation).length === 0) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
for (let j = events.length - 1; j > confirmationEventIndex; j--) {
|
|
120
|
+
const eventToCheck = events[j];
|
|
121
|
+
const functionResponses = (0, import_event.getFunctionResponses)(eventToCheck);
|
|
122
|
+
if (!functionResponses) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
for (const fr of functionResponses) {
|
|
126
|
+
if (fr.id && fr.id in toolsToResumeWithConfirmation) {
|
|
127
|
+
delete toolsToResumeWithConfirmation[fr.id];
|
|
128
|
+
delete toolsToResumeWithArgs[fr.id];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (Object.keys(toolsToResumeWithConfirmation).length === 0) {
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (Object.keys(toolsToResumeWithConfirmation).length === 0) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const toolsList = await agent.canonicalTools(
|
|
139
|
+
new import_readonly_context.ReadonlyContext(invocationContext)
|
|
140
|
+
);
|
|
141
|
+
const toolsDict = Object.fromEntries(
|
|
142
|
+
toolsList.map((tool) => [tool.name, tool])
|
|
143
|
+
);
|
|
144
|
+
const functionResponseEvent = await (0, import_functions.handleFunctionCallList)({
|
|
145
|
+
invocationContext,
|
|
146
|
+
functionCalls: Object.values(toolsToResumeWithArgs),
|
|
147
|
+
toolsDict,
|
|
148
|
+
beforeToolCallbacks: agent.canonicalBeforeToolCallbacks,
|
|
149
|
+
afterToolCallbacks: agent.canonicalAfterToolCallbacks,
|
|
150
|
+
filters: new Set(Object.keys(toolsToResumeWithConfirmation)),
|
|
151
|
+
toolConfirmationDict: toolsToResumeWithConfirmation
|
|
152
|
+
});
|
|
153
|
+
if (functionResponseEvent) {
|
|
154
|
+
yield functionResponseEvent;
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR = new RequestConfirmationLlmRequestProcessor();
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
REQUEST_CONFIRMATION_LLM_REQUEST_PROCESSOR,
|
|
164
|
+
RequestConfirmationLlmRequestProcessor
|
|
165
|
+
});
|
package/dist/cjs/common.js
CHANGED
|
@@ -40,8 +40,10 @@ __export(common_exports, {
|
|
|
40
40
|
BaseTool: () => import_base_tool.BaseTool,
|
|
41
41
|
BaseToolset: () => import_base_toolset.BaseToolset,
|
|
42
42
|
BuiltInCodeExecutor: () => import_built_in_code_executor.BuiltInCodeExecutor,
|
|
43
|
-
|
|
43
|
+
Context: () => import_context.Context,
|
|
44
|
+
EXIT_LOOP: () => import_exit_loop_tool.EXIT_LOOP,
|
|
44
45
|
EventType: () => import_structured_events.EventType,
|
|
46
|
+
ExitLoopTool: () => import_exit_loop_tool.ExitLoopTool,
|
|
45
47
|
FunctionTool: () => import_function_tool.FunctionTool,
|
|
46
48
|
GOOGLE_SEARCH: () => import_google_search_tool.GOOGLE_SEARCH,
|
|
47
49
|
Gemini: () => import_google_llm.Gemini,
|
|
@@ -71,7 +73,6 @@ __export(common_exports, {
|
|
|
71
73
|
State: () => import_state.State,
|
|
72
74
|
StreamingMode: () => import_run_config.StreamingMode,
|
|
73
75
|
ToolConfirmation: () => import_tool_confirmation.ToolConfirmation,
|
|
74
|
-
ToolContext: () => import_tool_context.ToolContext,
|
|
75
76
|
createEvent: () => import_event.createEvent,
|
|
76
77
|
createEventActions: () => import_event_actions.createEventActions,
|
|
77
78
|
createSession: () => import_session.createSession,
|
|
@@ -87,6 +88,7 @@ __export(common_exports, {
|
|
|
87
88
|
isBaseExampleProvider: () => import_base_example_provider.isBaseExampleProvider,
|
|
88
89
|
isBaseLlm: () => import_base_llm.isBaseLlm,
|
|
89
90
|
isBaseTool: () => import_base_tool.isBaseTool,
|
|
91
|
+
isBaseToolset: () => import_base_toolset.isBaseToolset,
|
|
90
92
|
isFinalResponse: () => import_event.isFinalResponse,
|
|
91
93
|
isFunctionTool: () => import_function_tool.isFunctionTool,
|
|
92
94
|
isGemini2OrAbove: () => import_model_name.isGemini2OrAbove,
|
|
@@ -104,14 +106,14 @@ __export(common_exports, {
|
|
|
104
106
|
module.exports = __toCommonJS(common_exports);
|
|
105
107
|
var import_active_streaming_tool = require("./agents/active_streaming_tool.js");
|
|
106
108
|
var import_base_agent = require("./agents/base_agent.js");
|
|
107
|
-
var
|
|
108
|
-
var import_callback_context = require("./agents/callback_context.js");
|
|
109
|
+
var import_context = require("./agents/context.js");
|
|
109
110
|
var import_functions = require("./agents/functions.js");
|
|
110
111
|
var import_invocation_context = require("./agents/invocation_context.js");
|
|
111
112
|
var import_live_request_queue = require("./agents/live_request_queue.js");
|
|
112
113
|
var import_llm_agent = require("./agents/llm_agent.js");
|
|
113
114
|
var import_loop_agent = require("./agents/loop_agent.js");
|
|
114
115
|
var import_parallel_agent = require("./agents/parallel_agent.js");
|
|
116
|
+
var import_base_llm_processor = require("./agents/processors/base_llm_processor.js");
|
|
115
117
|
var import_readonly_context = require("./agents/readonly_context.js");
|
|
116
118
|
var import_run_config = require("./agents/run_config.js");
|
|
117
119
|
var import_sequential_agent = require("./agents/sequential_agent.js");
|
|
@@ -141,11 +143,11 @@ var import_state = require("./sessions/state.js");
|
|
|
141
143
|
var import_agent_tool = require("./tools/agent_tool.js");
|
|
142
144
|
var import_base_tool = require("./tools/base_tool.js");
|
|
143
145
|
var import_base_toolset = require("./tools/base_toolset.js");
|
|
146
|
+
var import_exit_loop_tool = require("./tools/exit_loop_tool.js");
|
|
144
147
|
var import_function_tool = require("./tools/function_tool.js");
|
|
145
148
|
var import_google_search_tool = require("./tools/google_search_tool.js");
|
|
146
149
|
var import_long_running_tool = require("./tools/long_running_tool.js");
|
|
147
150
|
var import_tool_confirmation = require("./tools/tool_confirmation.js");
|
|
148
|
-
var import_tool_context = require("./tools/tool_context.js");
|
|
149
151
|
var import_logger = require("./utils/logger.js");
|
|
150
152
|
var import_model_name = require("./utils/model_name.js");
|
|
151
153
|
var import_simple_zod_to_json = require("./utils/simple_zod_to_json.js");
|
|
@@ -177,8 +179,10 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
177
179
|
BaseTool,
|
|
178
180
|
BaseToolset,
|
|
179
181
|
BuiltInCodeExecutor,
|
|
180
|
-
|
|
182
|
+
Context,
|
|
183
|
+
EXIT_LOOP,
|
|
181
184
|
EventType,
|
|
185
|
+
ExitLoopTool,
|
|
182
186
|
FunctionTool,
|
|
183
187
|
GOOGLE_SEARCH,
|
|
184
188
|
Gemini,
|
|
@@ -208,7 +212,6 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
208
212
|
State,
|
|
209
213
|
StreamingMode,
|
|
210
214
|
ToolConfirmation,
|
|
211
|
-
ToolContext,
|
|
212
215
|
createEvent,
|
|
213
216
|
createEventActions,
|
|
214
217
|
createSession,
|
|
@@ -224,6 +227,7 @@ __reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
|
224
227
|
isBaseExampleProvider,
|
|
225
228
|
isBaseLlm,
|
|
226
229
|
isBaseTool,
|
|
230
|
+
isBaseToolset,
|
|
227
231
|
isFinalResponse,
|
|
228
232
|
isFunctionTool,
|
|
229
233
|
isGemini2OrAbove,
|