@google/adk 0.3.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 +212 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +6 -6
- package/dist/cjs/agents/content_processor_utils.js +1 -1
- package/dist/cjs/{tools/tool_context.js → agents/context.js} +71 -16
- package/dist/cjs/agents/functions.js +4 -3
- package/dist/cjs/agents/instructions.js +1 -1
- package/dist/cjs/agents/invocation_context.js +1 -1
- package/dist/cjs/agents/live_request_queue.js +1 -1
- package/dist/cjs/agents/llm_agent.js +76 -711
- package/dist/cjs/agents/loop_agent.js +1 -1
- package/dist/cjs/agents/parallel_agent.js +1 -1
- package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +132 -0
- package/dist/cjs/agents/{base_llm_processor.js → processors/base_llm_processor.js} +1 -1
- 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/agents/readonly_context.js +13 -1
- package/dist/cjs/agents/run_config.js +2 -1
- package/dist/cjs/agents/sequential_agent.js +1 -1
- package/dist/cjs/agents/transcription_entry.js +1 -1
- package/dist/cjs/artifacts/base_artifact_service.js +1 -1
- package/dist/cjs/artifacts/file_artifact_service.js +491 -0
- package/dist/cjs/artifacts/gcs_artifact_service.js +127 -48
- package/dist/cjs/artifacts/in_memory_artifact_service.js +54 -6
- package/dist/cjs/artifacts/registry.js +55 -0
- package/dist/cjs/auth/auth_credential.js +1 -1
- package/dist/cjs/auth/auth_handler.js +1 -1
- package/dist/cjs/auth/auth_schemes.js +1 -1
- package/dist/cjs/auth/auth_tool.js +1 -1
- package/dist/cjs/auth/credential_service/base_credential_service.js +1 -1
- package/dist/cjs/auth/credential_service/in_memory_credential_service.js +1 -1
- package/dist/cjs/auth/exchanger/base_credential_exchanger.js +1 -1
- package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +1 -1
- package/dist/cjs/code_executors/base_code_executor.js +1 -1
- package/dist/cjs/code_executors/built_in_code_executor.js +1 -1
- package/dist/cjs/code_executors/code_execution_utils.js +1 -1
- package/dist/cjs/code_executors/code_executor_context.js +1 -1
- package/dist/cjs/common.js +25 -8
- package/dist/cjs/events/event.js +33 -4
- package/dist/cjs/events/event_actions.js +2 -2
- package/dist/cjs/events/structured_events.js +105 -0
- package/dist/cjs/examples/base_example_provider.js +1 -1
- package/dist/cjs/examples/example.js +1 -1
- package/dist/cjs/examples/example_util.js +1 -1
- package/dist/cjs/index.js +24 -17
- package/dist/cjs/index.js.map +4 -4
- package/dist/cjs/index_web.js +1 -1
- package/dist/cjs/memory/base_memory_service.js +1 -1
- package/dist/cjs/memory/in_memory_memory_service.js +1 -1
- package/dist/cjs/memory/memory_entry.js +1 -1
- package/dist/cjs/models/apigee_llm.js +182 -0
- package/dist/cjs/models/base_llm.js +1 -1
- package/dist/cjs/models/base_llm_connection.js +1 -1
- package/dist/cjs/models/gemini_llm_connection.js +1 -1
- package/dist/cjs/models/google_llm.js +70 -51
- package/dist/cjs/models/llm_request.js +1 -1
- package/dist/cjs/models/llm_response.js +3 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +2 -2
- package/dist/cjs/plugins/logging_plugin.js +1 -1
- package/dist/cjs/plugins/plugin_manager.js +1 -1
- package/dist/cjs/plugins/security_plugin.js +1 -1
- package/dist/cjs/runner/in_memory_runner.js +1 -1
- package/dist/cjs/runner/runner.js +33 -2
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +367 -0
- package/dist/cjs/sessions/db/operations.js +126 -0
- package/dist/cjs/sessions/db/schema.js +204 -0
- package/dist/cjs/sessions/in_memory_session_service.js +24 -22
- package/dist/cjs/sessions/registry.js +49 -0
- package/dist/cjs/sessions/session.js +1 -1
- package/dist/cjs/sessions/state.js +1 -1
- package/dist/cjs/telemetry/google_cloud.js +1 -1
- package/dist/cjs/telemetry/setup.js +1 -1
- package/dist/cjs/telemetry/tracing.js +1 -1
- package/dist/cjs/tools/agent_tool.js +1 -1
- package/dist/cjs/tools/base_tool.js +4 -1
- package/dist/cjs/tools/base_toolset.js +14 -4
- package/dist/cjs/tools/exit_loop_tool.js +63 -0
- package/dist/cjs/tools/forwarding_artifact_service.js +17 -1
- package/dist/cjs/tools/function_tool.js +1 -1
- package/dist/cjs/tools/google_search_tool.js +1 -1
- package/dist/cjs/tools/long_running_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_session_manager.js +1 -1
- package/dist/cjs/tools/mcp/mcp_tool.js +1 -1
- package/dist/cjs/tools/mcp/mcp_toolset.js +10 -6
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/utils/client_labels.js +1 -1
- package/dist/cjs/utils/env_aware_utils.js +10 -1
- package/dist/cjs/utils/gemini_schema_util.js +1 -1
- package/dist/cjs/utils/logger.js +62 -55
- package/dist/cjs/utils/model_name.js +1 -1
- package/dist/cjs/utils/object_notation_utils.js +78 -0
- package/dist/cjs/utils/simple_zod_to_json.js +1 -1
- package/dist/cjs/utils/variant_utils.js +3 -9
- package/dist/cjs/version.js +2 -2
- 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 +175 -0
- package/dist/esm/agents/base_agent.js +5 -5
- package/dist/esm/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/esm/agents/functions.js +3 -2
- package/dist/esm/agents/llm_agent.js +69 -720
- 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/agents/readonly_context.js +12 -0
- package/dist/esm/agents/run_config.js +1 -0
- package/dist/esm/artifacts/file_artifact_service.js +451 -0
- package/dist/esm/artifacts/gcs_artifact_service.js +126 -47
- package/dist/esm/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/esm/artifacts/registry.js +28 -0
- package/dist/esm/common.js +20 -10
- package/dist/esm/events/event.js +29 -2
- package/dist/esm/events/event_actions.js +1 -1
- package/dist/esm/events/structured_events.js +74 -0
- package/dist/esm/index.js +24 -17
- package/dist/esm/index.js.map +4 -4
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/google_llm.js +67 -49
- package/dist/esm/models/llm_response.js +2 -0
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/plugins/base_plugin.js +1 -1
- package/dist/esm/runner/runner.js +32 -1
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +353 -0
- package/dist/esm/sessions/db/operations.js +111 -0
- package/dist/esm/sessions/db/schema.js +172 -0
- package/dist/esm/sessions/in_memory_session_service.js +23 -21
- package/dist/esm/sessions/registry.js +25 -0
- 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/forwarding_artifact_service.js +16 -0
- package/dist/esm/tools/mcp/mcp_toolset.js +9 -5
- package/dist/esm/utils/env_aware_utils.js +8 -0
- package/dist/esm/utils/logger.js +51 -54
- package/dist/esm/utils/object_notation_utils.js +47 -0
- package/dist/esm/utils/variant_utils.js +1 -7
- 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 +48 -0
- 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 +19 -42
- 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/agents/readonly_context.d.ts +8 -0
- package/dist/types/agents/run_config.d.ts +6 -0
- package/dist/types/artifacts/base_artifact_service.d.ts +31 -0
- package/dist/types/artifacts/file_artifact_service.d.ts +43 -0
- package/dist/types/artifacts/gcs_artifact_service.d.ts +3 -1
- package/dist/types/artifacts/in_memory_artifact_service.d.ts +5 -2
- package/dist/types/artifacts/registry.d.ts +7 -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 +15 -6
- package/dist/types/events/event.d.ts +15 -1
- package/dist/types/events/event_actions.d.ts +1 -1
- package/dist/types/events/structured_events.d.ts +106 -0
- package/dist/types/index.d.ts +5 -1
- package/dist/types/models/apigee_llm.d.ts +59 -0
- package/dist/types/models/google_llm.d.ts +5 -2
- 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 +15 -0
- package/dist/types/sessions/base_session_service.d.ts +20 -0
- package/dist/types/sessions/database_session_service.d.ts +32 -0
- package/dist/types/sessions/db/operations.d.ts +29 -0
- package/dist/types/sessions/db/schema.d.ts +45 -0
- package/dist/types/sessions/in_memory_session_service.d.ts +4 -1
- package/dist/types/sessions/registry.d.ts +7 -0
- 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 +5 -3
- 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/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/logger.d.ts +5 -9
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- 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 +175 -0
- package/dist/web/agents/base_agent.js +5 -5
- package/dist/web/{tools/tool_context.js → agents/context.js} +66 -11
- package/dist/web/agents/functions.js +3 -2
- package/dist/web/agents/llm_agent.js +90 -717
- 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/agents/readonly_context.js +12 -0
- package/dist/web/agents/run_config.js +2 -1
- package/dist/web/artifacts/file_artifact_service.js +506 -0
- package/dist/web/artifacts/gcs_artifact_service.js +123 -46
- package/dist/web/artifacts/in_memory_artifact_service.js +51 -4
- package/dist/web/artifacts/registry.js +28 -0
- package/dist/web/common.js +20 -10
- package/dist/web/events/event.js +29 -2
- package/dist/web/events/event_actions.js +1 -1
- package/dist/web/events/structured_events.js +74 -0
- package/dist/web/index.js +7 -2
- package/dist/web/index.js.map +4 -4
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/google_llm.js +67 -46
- package/dist/web/models/llm_response.js +2 -0
- package/dist/web/models/registry.js +2 -0
- package/dist/web/plugins/base_plugin.js +1 -1
- package/dist/web/runner/runner.js +34 -1
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +371 -0
- package/dist/web/sessions/db/operations.js +111 -0
- package/dist/web/sessions/db/schema.js +172 -0
- package/dist/web/sessions/in_memory_session_service.js +23 -21
- package/dist/web/sessions/registry.js +25 -0
- 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/forwarding_artifact_service.js +16 -0
- package/dist/web/tools/mcp/mcp_toolset.js +27 -5
- package/dist/web/utils/env_aware_utils.js +8 -0
- package/dist/web/utils/logger.js +51 -54
- package/dist/web/utils/object_notation_utils.js +47 -0
- package/dist/web/utils/variant_utils.js +1 -7
- package/dist/web/version.js +1 -1
- package/package.json +13 -3
- 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/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
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -49,6 +49,18 @@ class ReadonlyContext {
|
|
|
49
49
|
get invocationId() {
|
|
50
50
|
return this.invocationContext.invocationId;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* The user ID of the current session.
|
|
54
|
+
*/
|
|
55
|
+
get userId() {
|
|
56
|
+
return this.invocationContext.userId;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The ID of the current session.
|
|
60
|
+
*/
|
|
61
|
+
get sessionId() {
|
|
62
|
+
return this.invocationContext.session.id;
|
|
63
|
+
}
|
|
52
64
|
/**
|
|
53
65
|
* The current agent name.
|
|
54
66
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -47,6 +47,7 @@ function createRunConfig(params = {}) {
|
|
|
47
47
|
enableAffectiveDialog: false,
|
|
48
48
|
streamingMode: "none" /* NONE */,
|
|
49
49
|
maxLlmCalls: validateMaxLlmCalls(params.maxLlmCalls || 500),
|
|
50
|
+
pauseOnToolCalls: false,
|
|
50
51
|
...params
|
|
51
52
|
};
|
|
52
53
|
}
|