@google/adk 2.3.0 → 2.4.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/agents/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +28 -0
- package/dist/cjs/agents/instructions.js +2 -1
- package/dist/cjs/agents/llm_agent.js +19 -6
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- package/dist/cjs/cli/utils/logs.js +6 -6
- package/dist/cjs/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +9 -20
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/plugins/base_plugin.js +13 -23
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +53 -10
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +120 -42
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +163 -95
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +13 -9
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/failover_utils.js +1 -1
- package/dist/cjs/utils/gemini_schema_util.js +24 -6
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +28 -0
- package/dist/esm/agents/instructions.js +2 -1
- package/dist/esm/agents/llm_agent.js +19 -6
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- package/dist/esm/cli/utils/logs.js +4 -4
- package/dist/esm/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +10 -13
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/index.js +17 -3
- package/dist/esm/plugins/base_plugin.js +13 -23
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +57 -11
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +124 -42
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +163 -95
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +13 -9
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/failover_utils.js +1 -1
- package/dist/esm/utils/gemini_schema_util.js +23 -6
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/cli/utils/logs.d.ts +1 -1
- package/dist/types/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +5 -9
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/plugins/base_plugin.d.ts +0 -10
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/tracing.d.ts +17 -3
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +22 -8
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/gemini_schema_util.d.ts +8 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +74 -66
- package/dist/web/index_web.js.map +4 -4
- package/package.json +34 -27
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -70,6 +70,8 @@ let ContainerCodeExecutor = class extends import_base_code_executor.BaseCodeExec
|
|
|
70
70
|
constructor(options = {}) {
|
|
71
71
|
var _a, _b, _c;
|
|
72
72
|
super();
|
|
73
|
+
this.containers = /* @__PURE__ */ new Map();
|
|
74
|
+
this.initPromises = /* @__PURE__ */ new Map();
|
|
73
75
|
if (!options.image && !options.dockerPath) {
|
|
74
76
|
throw new Error(
|
|
75
77
|
"Either image or dockerPath must be set for ContainerCodeExecutor."
|
|
@@ -99,8 +101,9 @@ let ContainerCodeExecutor = class extends import_base_code_executor.BaseCodeExec
|
|
|
99
101
|
`Unsupported language for ContainerCodeExecutor: ${language}. Supported: ${Object.keys(LANGUAGE_RUNTIME_COMMAND_MAP).join(", ")}.`
|
|
100
102
|
);
|
|
101
103
|
}
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
+
const key = sessionKey(params.invocationContext);
|
|
105
|
+
const container = await this.ensureContainer(key);
|
|
106
|
+
const { stdout, stderr, exitCode } = await container.execute(
|
|
104
107
|
[...TIMEOUT_COMMAND, String(this.timeoutSeconds), ...command, code],
|
|
105
108
|
this.timeoutSeconds
|
|
106
109
|
);
|
|
@@ -132,32 +135,35 @@ ${message}` : message;
|
|
|
132
135
|
return stderr;
|
|
133
136
|
}
|
|
134
137
|
/**
|
|
135
|
-
* Stops and removes
|
|
136
|
-
* started; provided for deterministic teardown in tests and app
|
|
138
|
+
* Stops and removes every session's container. Safe to call when none has
|
|
139
|
+
* been started; provided for deterministic teardown in tests and app
|
|
140
|
+
* shutdown.
|
|
137
141
|
*/
|
|
138
142
|
async close() {
|
|
139
|
-
const
|
|
140
|
-
this.
|
|
141
|
-
this.
|
|
142
|
-
await (container
|
|
143
|
+
const containers = [...this.containers.values()];
|
|
144
|
+
this.containers.clear();
|
|
145
|
+
this.initPromises.clear();
|
|
146
|
+
await Promise.all(containers.map((container) => container.stop()));
|
|
143
147
|
}
|
|
144
|
-
/** Lazily builds/starts the container exactly once. */
|
|
145
|
-
ensureContainer() {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
/** Lazily builds/starts the given session's container exactly once. */
|
|
149
|
+
ensureContainer(key) {
|
|
150
|
+
let initPromise = this.initPromises.get(key);
|
|
151
|
+
if (!initPromise) {
|
|
152
|
+
initPromise = this.initContainer(key).catch((error) => {
|
|
153
|
+
this.initPromises.delete(key);
|
|
149
154
|
throw error;
|
|
150
155
|
});
|
|
156
|
+
this.initPromises.set(key, initPromise);
|
|
151
157
|
}
|
|
152
|
-
return this.
|
|
158
|
+
return initPromise.then(() => this.containers.get(key));
|
|
153
159
|
}
|
|
154
|
-
async initContainer() {
|
|
160
|
+
async initContainer(key) {
|
|
155
161
|
const container = new import_docker_container.DockerContainer(this.containerOptions);
|
|
156
162
|
if (this.dockerPath) {
|
|
157
163
|
await container.build(this.dockerPath);
|
|
158
164
|
}
|
|
159
165
|
await container.start();
|
|
160
|
-
this.
|
|
166
|
+
this.containers.set(key, container);
|
|
161
167
|
const { exitCode } = await container.execute(
|
|
162
168
|
["which", "python3"],
|
|
163
169
|
this.timeoutSeconds
|
|
@@ -171,6 +177,11 @@ __name(ContainerCodeExecutor, "ContainerCodeExecutor");
|
|
|
171
177
|
ContainerCodeExecutor = __decorateClass([
|
|
172
178
|
import_experimental.experimental
|
|
173
179
|
], ContainerCodeExecutor);
|
|
180
|
+
function sessionKey(invocationContext) {
|
|
181
|
+
const session = invocationContext.session;
|
|
182
|
+
return JSON.stringify([session.appName, session.userId, session.id]);
|
|
183
|
+
}
|
|
184
|
+
__name(sessionKey, "sessionKey");
|
|
174
185
|
function defineFrozenFalse(target, key) {
|
|
175
186
|
Object.defineProperty(target, key, {
|
|
176
187
|
value: false,
|
|
@@ -250,7 +250,12 @@ Code execution timed out after ${this.timeoutSeconds} seconds.`;
|
|
|
250
250
|
};
|
|
251
251
|
} finally {
|
|
252
252
|
if (tempDir) {
|
|
253
|
-
await fs.rm(tempDir, {
|
|
253
|
+
await fs.rm(tempDir, {
|
|
254
|
+
recursive: true,
|
|
255
|
+
force: true,
|
|
256
|
+
maxRetries: 10,
|
|
257
|
+
retryDelay: 500
|
|
258
|
+
});
|
|
254
259
|
}
|
|
255
260
|
}
|
|
256
261
|
}
|
package/dist/cjs/common.js
CHANGED
|
@@ -73,7 +73,6 @@ __export(common_exports, {
|
|
|
73
73
|
ContextCompactorRequestProcessor: () => import_context_compactor_request_processor.ContextCompactorRequestProcessor,
|
|
74
74
|
CredentialExchangeError: () => import_base_credential_exchanger.CredentialExchangeError,
|
|
75
75
|
CredentialRefresherRegistry: () => import_credential_refresher_registry.CredentialRefresherRegistry,
|
|
76
|
-
CrewaiTool: () => import_crewai_tool.CrewaiTool,
|
|
77
76
|
DEFAULT_ROUTE: () => import_workflow.DEFAULT_ROUTE,
|
|
78
77
|
ENTERPRISE_WEB_SEARCH: () => import_enterprise_web_search_tool.ENTERPRISE_WEB_SEARCH,
|
|
79
78
|
EXIT_LOOP: () => import_exit_loop_tool.EXIT_LOOP,
|
|
@@ -115,7 +114,6 @@ __export(common_exports, {
|
|
|
115
114
|
LOAD_ARTIFACTS: () => import_load_artifacts_tool.LOAD_ARTIFACTS,
|
|
116
115
|
LOAD_MEMORY: () => import_load_memory_tool.LOAD_MEMORY,
|
|
117
116
|
LangGraphAgent: () => import_langgraph_agent.LangGraphAgent,
|
|
118
|
-
LangchainTool: () => import_langchain_tool.LangchainTool,
|
|
119
117
|
ListSkillsTool: () => import_list_skills_tool.ListSkillsTool,
|
|
120
118
|
LiveRequestQueue: () => import_live_request_queue.LiveRequestQueue,
|
|
121
119
|
LlamaIndexRetrieval: () => import_llama_index_retrieval.LlamaIndexRetrieval,
|
|
@@ -155,7 +153,6 @@ __export(common_exports, {
|
|
|
155
153
|
ReadonlyContext: () => import_readonly_context.ReadonlyContext,
|
|
156
154
|
ReflectAndRetryModelPlugin: () => import_reflect_retry_model_plugin.ReflectAndRetryModelPlugin,
|
|
157
155
|
ReflectAndRetryToolPlugin: () => import_reflect_retry_tool_plugin.ReflectAndRetryToolPlugin,
|
|
158
|
-
RemoteAgent: () => import_remote_agent.RemoteAgent,
|
|
159
156
|
RequestInput: () => import_workflow.RequestInput,
|
|
160
157
|
RoutedAgent: () => import_routed_agent.RoutedAgent,
|
|
161
158
|
RoutedLlm: () => import_routed_llm.RoutedLlm,
|
|
@@ -180,7 +177,7 @@ __export(common_exports, {
|
|
|
180
177
|
ToolErrorType: () => import_tool_execution_error.ToolErrorType,
|
|
181
178
|
ToolExecutionError: () => import_tool_execution_error.ToolExecutionError,
|
|
182
179
|
ToolNode: () => import_workflow.ToolNode,
|
|
183
|
-
|
|
180
|
+
ToolboxToolset: () => import_toolbox_toolset.ToolboxToolset,
|
|
184
181
|
TrackingScope: () => import_reflect_retry_utils.TrackingScope,
|
|
185
182
|
TrajectoryThoughtPruningCompactor: () => import_trajectory_thought_pruning_compactor.TrajectoryThoughtPruningCompactor,
|
|
186
183
|
TruncatingContextCompactor: () => import_truncating_context_compactor.TruncatingContextCompactor,
|
|
@@ -244,7 +241,6 @@ __export(common_exports, {
|
|
|
244
241
|
isBaseToolset: () => import_base_toolset.isBaseToolset,
|
|
245
242
|
isBuiltInPlanner: () => import_built_in_planner.isBuiltInPlanner,
|
|
246
243
|
isCompactedEvent: () => import_compacted_event.isCompactedEvent,
|
|
247
|
-
isCrewaiTool: () => import_crewai_tool.isCrewaiTool,
|
|
248
244
|
isFinalResponse: () => import_event.isFinalResponse,
|
|
249
245
|
isFunctionTool: () => import_function_tool.isFunctionTool,
|
|
250
246
|
isGemini2OrAbove: () => import_model_name.isGemini2OrAbove,
|
|
@@ -253,7 +249,6 @@ __export(common_exports, {
|
|
|
253
249
|
isGemini3xLive: () => import_model_name.isGemini3xLive,
|
|
254
250
|
isIntentMismatchError: () => import_tool_confirmation.isIntentMismatchError,
|
|
255
251
|
isLangGraphAgent: () => import_langgraph_agent.isLangGraphAgent,
|
|
256
|
-
isLangchainTool: () => import_langchain_tool.isLangchainTool,
|
|
257
252
|
isLlmAgent: () => import_llm_agent.isLlmAgent,
|
|
258
253
|
isLlmCallsLimitExceededError: () => import_invocation_context.isLlmCallsLimitExceededError,
|
|
259
254
|
isLoopAgent: () => import_loop_agent.isLoopAgent,
|
|
@@ -263,7 +258,6 @@ __export(common_exports, {
|
|
|
263
258
|
isNodeState: () => import_workflow.isNodeState,
|
|
264
259
|
isNodeTimeoutError: () => import_workflow.isNodeTimeoutError,
|
|
265
260
|
isParallelAgent: () => import_parallel_agent.isParallelAgent,
|
|
266
|
-
isRemoteAgent: () => import_remote_agent.isRemoteAgent,
|
|
267
261
|
isRequestInput: () => import_workflow.isRequestInput,
|
|
268
262
|
isRoutableLlmAgent: () => import_runner.isRoutableLlmAgent,
|
|
269
263
|
isRoutedAgent: () => import_routed_agent.isRoutedAgent,
|
|
@@ -274,9 +268,11 @@ __export(common_exports, {
|
|
|
274
268
|
isSessionArtifactService: () => import_session_artifact_service.isSessionArtifactService,
|
|
275
269
|
isStateSchemaError: () => import_state.isStateSchemaError,
|
|
276
270
|
isToolNotFound: () => import_functions.isToolNotFound,
|
|
277
|
-
|
|
271
|
+
isToolboxToolset: () => import_toolbox_toolset.isToolboxToolset,
|
|
278
272
|
isWebMCPSupported: () => import_webmcp_types.isWebMCPSupported,
|
|
279
273
|
isWorkflow: () => import_workflow.isWorkflow,
|
|
274
|
+
isZodObject: () => import_simple_zod_to_json.isZodObject,
|
|
275
|
+
isZodSchema: () => import_simple_zod_to_json.isZodSchema,
|
|
280
276
|
logger: () => import_logger.logger,
|
|
281
277
|
markRestored: () => import_internal_metadata.markRestored,
|
|
282
278
|
node: () => import_workflow.node,
|
|
@@ -324,7 +320,6 @@ var import_content_request_processor = require("./agents/processors/content_requ
|
|
|
324
320
|
var import_context_compactor_request_processor = require("./agents/processors/context_compactor_request_processor.js");
|
|
325
321
|
var import_interactions_request_processor = require("./agents/processors/interactions_request_processor.js");
|
|
326
322
|
var import_readonly_context = require("./agents/readonly_context.js");
|
|
327
|
-
var import_remote_agent = require("./agents/remote_agent.js");
|
|
328
323
|
var import_routed_agent = require("./agents/routed_agent.js");
|
|
329
324
|
var import_run_config = require("./agents/run_config.js");
|
|
330
325
|
var import_sequential_agent = require("./agents/sequential_agent.js");
|
|
@@ -450,11 +445,9 @@ __reExport(common_exports, require("./memory/base_memory_service.js"), module.ex
|
|
|
450
445
|
__reExport(common_exports, require("./sessions/base_session_service.js"), module.exports);
|
|
451
446
|
__reExport(common_exports, require("./tools/base_tool.js"), module.exports);
|
|
452
447
|
var import_evals = require("./cli/utils/evals.js");
|
|
453
|
-
var import_crewai_tool = require("./tools/crewai_tool.js");
|
|
454
448
|
var import_function_tool2 = require("./tools/function_tool.js");
|
|
455
|
-
var import_langchain_tool = require("./tools/langchain_tool.js");
|
|
456
449
|
var import_base_retrieval_tool2 = require("./tools/retrieval/base_retrieval_tool.js");
|
|
457
|
-
var
|
|
450
|
+
var import_toolbox_toolset = require("./tools/toolbox_toolset.js");
|
|
458
451
|
/**
|
|
459
452
|
* @license
|
|
460
453
|
* Copyright 2025 Google LLC
|
|
@@ -510,7 +503,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
510
503
|
ContextCompactorRequestProcessor,
|
|
511
504
|
CredentialExchangeError,
|
|
512
505
|
CredentialRefresherRegistry,
|
|
513
|
-
CrewaiTool,
|
|
514
506
|
DEFAULT_ROUTE,
|
|
515
507
|
ENTERPRISE_WEB_SEARCH,
|
|
516
508
|
EXIT_LOOP,
|
|
@@ -552,7 +544,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
552
544
|
LOAD_ARTIFACTS,
|
|
553
545
|
LOAD_MEMORY,
|
|
554
546
|
LangGraphAgent,
|
|
555
|
-
LangchainTool,
|
|
556
547
|
ListSkillsTool,
|
|
557
548
|
LiveRequestQueue,
|
|
558
549
|
LlamaIndexRetrieval,
|
|
@@ -592,7 +583,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
592
583
|
ReadonlyContext,
|
|
593
584
|
ReflectAndRetryModelPlugin,
|
|
594
585
|
ReflectAndRetryToolPlugin,
|
|
595
|
-
RemoteAgent,
|
|
596
586
|
RequestInput,
|
|
597
587
|
RoutedAgent,
|
|
598
588
|
RoutedLlm,
|
|
@@ -617,7 +607,7 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
617
607
|
ToolErrorType,
|
|
618
608
|
ToolExecutionError,
|
|
619
609
|
ToolNode,
|
|
620
|
-
|
|
610
|
+
ToolboxToolset,
|
|
621
611
|
TrackingScope,
|
|
622
612
|
TrajectoryThoughtPruningCompactor,
|
|
623
613
|
TruncatingContextCompactor,
|
|
@@ -681,7 +671,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
681
671
|
isBaseToolset,
|
|
682
672
|
isBuiltInPlanner,
|
|
683
673
|
isCompactedEvent,
|
|
684
|
-
isCrewaiTool,
|
|
685
674
|
isFinalResponse,
|
|
686
675
|
isFunctionTool,
|
|
687
676
|
isGemini2OrAbove,
|
|
@@ -690,7 +679,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
690
679
|
isGemini3xLive,
|
|
691
680
|
isIntentMismatchError,
|
|
692
681
|
isLangGraphAgent,
|
|
693
|
-
isLangchainTool,
|
|
694
682
|
isLlmAgent,
|
|
695
683
|
isLlmCallsLimitExceededError,
|
|
696
684
|
isLoopAgent,
|
|
@@ -700,7 +688,6 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
700
688
|
isNodeState,
|
|
701
689
|
isNodeTimeoutError,
|
|
702
690
|
isParallelAgent,
|
|
703
|
-
isRemoteAgent,
|
|
704
691
|
isRequestInput,
|
|
705
692
|
isRoutableLlmAgent,
|
|
706
693
|
isRoutedAgent,
|
|
@@ -711,9 +698,11 @@ var import_toolbox_tool = require("./tools/toolbox_tool.js");
|
|
|
711
698
|
isSessionArtifactService,
|
|
712
699
|
isStateSchemaError,
|
|
713
700
|
isToolNotFound,
|
|
714
|
-
|
|
701
|
+
isToolboxToolset,
|
|
715
702
|
isWebMCPSupported,
|
|
716
703
|
isWorkflow,
|
|
704
|
+
isZodObject,
|
|
705
|
+
isZodSchema,
|
|
717
706
|
logger,
|
|
718
707
|
markRestored,
|
|
719
708
|
node,
|
|
@@ -36,9 +36,10 @@ module.exports = __toCommonJS(input_validation_error_exports);
|
|
|
36
36
|
const _InputValidationError = class _InputValidationError extends Error {
|
|
37
37
|
/**
|
|
38
38
|
* @param message A message describing why the input is invalid.
|
|
39
|
+
* @param options Standard error options, e.g. `{cause}`.
|
|
39
40
|
*/
|
|
40
|
-
constructor(message = "Invalid input.") {
|
|
41
|
-
super(message);
|
|
41
|
+
constructor(message = "Invalid input.", options) {
|
|
42
|
+
super(message, options);
|
|
42
43
|
this.name = "InputValidationError";
|
|
43
44
|
}
|
|
44
45
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -47,6 +47,7 @@ __export(index_exports, {
|
|
|
47
47
|
GcsArtifactService: () => import_gcs_artifact_service.GcsArtifactService,
|
|
48
48
|
INTERNAL_AUTH_PREFIX: () => import_auth_helpers.INTERNAL_AUTH_PREFIX,
|
|
49
49
|
IntegrationClient: () => import_integration_client.IntegrationClient,
|
|
50
|
+
IntegrationConnectorTool: () => import_integration_connector_tool.IntegrationConnectorTool,
|
|
50
51
|
InvocationContext: () => import_invocation_context.InvocationContext,
|
|
51
52
|
LOAD_WEB_PAGE: () => import_load_web_page.LOAD_WEB_PAGE,
|
|
52
53
|
LOGGING_FORMAT: () => import_logs.LOGGING_FORMAT,
|
|
@@ -66,6 +67,7 @@ __export(index_exports, {
|
|
|
66
67
|
SecretManagerClient: () => import_secret_client.SecretManagerClient,
|
|
67
68
|
ServiceAccountCredentialExchanger: () => import_service_account_exchanger.ServiceAccountCredentialExchanger,
|
|
68
69
|
SkillToolset: () => import_skill_toolset.SkillToolset,
|
|
70
|
+
StaleSessionError: () => import_database_session_service.StaleSessionError,
|
|
69
71
|
TOOL_TRAJECTORY_SCORE_KEY: () => import_cli_eval.TOOL_TRAJECTORY_SCORE_KEY,
|
|
70
72
|
ToolAuthHandler: () => import_tool_auth_handler.ToolAuthHandler,
|
|
71
73
|
ToolContextCredentialStore: () => import_tool_auth_handler.ToolContextCredentialStore,
|
|
@@ -99,6 +101,7 @@ __export(index_exports, {
|
|
|
99
101
|
getSessionServiceFromUri: () => import_registry2.getSessionServiceFromUri,
|
|
100
102
|
getTypeHint: () => import_common.getTypeHint,
|
|
101
103
|
isDebugLoggingPlugin: () => import_debug_logging_plugin.isDebugLoggingPlugin,
|
|
104
|
+
isStaleSessionError: () => import_database_session_service.isStaleSessionError,
|
|
102
105
|
listOperation: () => import_connections_client.listOperation,
|
|
103
106
|
listOperationRequest: () => import_connections_client.listOperationRequest,
|
|
104
107
|
loadAllSkillsInDir: () => import_loader.loadAllSkillsInDir,
|
|
@@ -106,7 +109,6 @@ __export(index_exports, {
|
|
|
106
109
|
loadSkillFromDir: () => import_loader.loadSkillFromDir,
|
|
107
110
|
loadSkillFromZipBuffer: () => import_loader.loadSkillFromZipBuffer,
|
|
108
111
|
loadWebPage: () => import_load_web_page.loadWebPage,
|
|
109
|
-
logToStderr: () => import_logs.logToStderr,
|
|
110
112
|
logToTmpFolder: () => import_logs.logToTmpFolder,
|
|
111
113
|
openidDictToSchemeCredential: () => import_auth_helpers.openidDictToSchemeCredential,
|
|
112
114
|
openidUrlToSchemeCredential: () => import_auth_helpers.openidUrlToSchemeCredential,
|
|
@@ -114,6 +116,7 @@ __export(index_exports, {
|
|
|
114
116
|
runEvals: () => import_cli_eval.runEvals,
|
|
115
117
|
serviceAccountDictToSchemeCredential: () => import_auth_helpers.serviceAccountDictToSchemeCredential,
|
|
116
118
|
serviceAccountSchemeCredential: () => import_auth_helpers.serviceAccountSchemeCredential,
|
|
119
|
+
setupAdkLogger: () => import_logs.setupAdkLogger,
|
|
117
120
|
tokenToSchemeCredential: () => import_auth_helpers.tokenToSchemeCredential,
|
|
118
121
|
tryGetResetFunc: () => import_cli_eval.tryGetResetFunc,
|
|
119
122
|
updateOperation: () => import_connections_client.updateOperation,
|
|
@@ -148,6 +151,7 @@ var import_secret_client = require("./tools/apihub_tool/clients/secret_client.js
|
|
|
148
151
|
var import_application_integration_toolset = require("./tools/application_integration_tool/application_integration_toolset.js");
|
|
149
152
|
var import_connections_client = require("./tools/application_integration_tool/clients/connections_client.js");
|
|
150
153
|
var import_integration_client = require("./tools/application_integration_tool/clients/integration_client.js");
|
|
154
|
+
var import_integration_connector_tool = require("./tools/application_integration_tool/integration_connector_tool.js");
|
|
151
155
|
var import_load_web_page = require("./tools/load_web_page.js");
|
|
152
156
|
var import_auth_helpers = require("./tools/openapi_tool/auth/auth_helpers.js");
|
|
153
157
|
var import_auto_auth_credential_exchanger = require("./tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js");
|
|
@@ -203,6 +207,7 @@ __reExport(index_exports, require("./tools/mcp/index.js"), module.exports);
|
|
|
203
207
|
GcsArtifactService,
|
|
204
208
|
INTERNAL_AUTH_PREFIX,
|
|
205
209
|
IntegrationClient,
|
|
210
|
+
IntegrationConnectorTool,
|
|
206
211
|
InvocationContext,
|
|
207
212
|
LOAD_WEB_PAGE,
|
|
208
213
|
LOGGING_FORMAT,
|
|
@@ -222,6 +227,7 @@ __reExport(index_exports, require("./tools/mcp/index.js"), module.exports);
|
|
|
222
227
|
SecretManagerClient,
|
|
223
228
|
ServiceAccountCredentialExchanger,
|
|
224
229
|
SkillToolset,
|
|
230
|
+
StaleSessionError,
|
|
225
231
|
TOOL_TRAJECTORY_SCORE_KEY,
|
|
226
232
|
ToolAuthHandler,
|
|
227
233
|
ToolContextCredentialStore,
|
|
@@ -255,6 +261,7 @@ __reExport(index_exports, require("./tools/mcp/index.js"), module.exports);
|
|
|
255
261
|
getSessionServiceFromUri,
|
|
256
262
|
getTypeHint,
|
|
257
263
|
isDebugLoggingPlugin,
|
|
264
|
+
isStaleSessionError,
|
|
258
265
|
listOperation,
|
|
259
266
|
listOperationRequest,
|
|
260
267
|
loadAllSkillsInDir,
|
|
@@ -262,7 +269,6 @@ __reExport(index_exports, require("./tools/mcp/index.js"), module.exports);
|
|
|
262
269
|
loadSkillFromDir,
|
|
263
270
|
loadSkillFromZipBuffer,
|
|
264
271
|
loadWebPage,
|
|
265
|
-
logToStderr,
|
|
266
272
|
logToTmpFolder,
|
|
267
273
|
openidDictToSchemeCredential,
|
|
268
274
|
openidUrlToSchemeCredential,
|
|
@@ -270,6 +276,7 @@ __reExport(index_exports, require("./tools/mcp/index.js"), module.exports);
|
|
|
270
276
|
runEvals,
|
|
271
277
|
serviceAccountDictToSchemeCredential,
|
|
272
278
|
serviceAccountSchemeCredential,
|
|
279
|
+
setupAdkLogger,
|
|
273
280
|
tokenToSchemeCredential,
|
|
274
281
|
tryGetResetFunc,
|
|
275
282
|
updateOperation,
|
|
@@ -272,29 +272,19 @@ const _BasePlugin = class _BasePlugin {
|
|
|
272
272
|
return;
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
* potentially providing alternative responses or recovery mechanisms.
|
|
289
|
-
*
|
|
290
|
-
* @param _params.tool The tool instance that encountered an error.
|
|
291
|
-
* @param _params.toolArgs The arguments that were passed to the tool.
|
|
292
|
-
* @param _params.toolContext The context specific to the tool execution.
|
|
293
|
-
* @param _params.error The exception that was raised during tool execution.
|
|
294
|
-
* @returns An optional dictionary. If a dictionary is returned, it will be
|
|
295
|
-
* used as the tool response instead of propagating the error. Returning
|
|
296
|
-
* `undefined` allows the original error to be raised.
|
|
297
|
-
*/
|
|
275
|
+
* Callback executed when a tool call encounters an error.
|
|
276
|
+
*
|
|
277
|
+
* This callback provides an opportunity to handle tool errors gracefully,
|
|
278
|
+
* potentially providing alternative responses or recovery mechanisms.
|
|
279
|
+
*
|
|
280
|
+
* @param _params.tool The tool instance that encountered an error.
|
|
281
|
+
* @param _params.toolArgs The arguments that were passed to the tool.
|
|
282
|
+
* @param _params.toolContext The context specific to the tool execution.
|
|
283
|
+
* @param _params.error The exception that was raised during tool execution.
|
|
284
|
+
* @returns An optional dictionary. If a dictionary is returned, it will be
|
|
285
|
+
* used as the tool response instead of propagating the error. Returning
|
|
286
|
+
* `undefined` allows the original error to be raised.
|
|
287
|
+
*/
|
|
298
288
|
async onToolErrorCallback(_params) {
|
|
299
289
|
return;
|
|
300
290
|
}
|
|
@@ -28,7 +28,8 @@ __export(base_session_service_exports, {
|
|
|
28
28
|
BaseSessionService: () => BaseSessionService,
|
|
29
29
|
mergeStates: () => mergeStates,
|
|
30
30
|
trimTempDeltaState: () => trimTempDeltaState,
|
|
31
|
-
trimTempState: () => trimTempState
|
|
31
|
+
trimTempState: () => trimTempState,
|
|
32
|
+
upsertSessionEvent: () => upsertSessionEvent
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(base_session_service_exports);
|
|
34
35
|
var import_lodash_es = require("lodash-es");
|
|
@@ -72,12 +73,7 @@ const _BaseSessionService = class _BaseSessionService {
|
|
|
72
73
|
}
|
|
73
74
|
event = trimTempDeltaState(event);
|
|
74
75
|
this.updateSessionState({ session, event });
|
|
75
|
-
|
|
76
|
-
if (index >= 0) {
|
|
77
|
-
session.events[index] = event;
|
|
78
|
-
} else {
|
|
79
|
-
session.events.push(event);
|
|
80
|
-
}
|
|
76
|
+
upsertSessionEvent(session, event);
|
|
81
77
|
return event;
|
|
82
78
|
}
|
|
83
79
|
/**
|
|
@@ -107,6 +103,15 @@ const _BaseSessionService = class _BaseSessionService {
|
|
|
107
103
|
};
|
|
108
104
|
__name(_BaseSessionService, "BaseSessionService");
|
|
109
105
|
let BaseSessionService = _BaseSessionService;
|
|
106
|
+
function upsertSessionEvent(session, event) {
|
|
107
|
+
const index = session.events.findIndex((e) => e.id === event.id);
|
|
108
|
+
if (index >= 0) {
|
|
109
|
+
session.events[index] = event;
|
|
110
|
+
} else {
|
|
111
|
+
session.events.push(event);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
__name(upsertSessionEvent, "upsertSessionEvent");
|
|
110
115
|
function trimTempDeltaState(event) {
|
|
111
116
|
if (!event.actions || !event.actions.stateDelta) {
|
|
112
117
|
return event;
|
|
@@ -149,5 +154,6 @@ __name(mergeStates, "mergeStates");
|
|
|
149
154
|
BaseSessionService,
|
|
150
155
|
mergeStates,
|
|
151
156
|
trimTempDeltaState,
|
|
152
|
-
trimTempState
|
|
157
|
+
trimTempState,
|
|
158
|
+
upsertSessionEvent
|
|
153
159
|
});
|
|
@@ -36,13 +36,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
36
36
|
var database_session_service_exports = {};
|
|
37
37
|
__export(database_session_service_exports, {
|
|
38
38
|
DatabaseSessionService: () => DatabaseSessionService,
|
|
39
|
-
|
|
39
|
+
StaleSessionError: () => import_stale_session_error2.StaleSessionError,
|
|
40
|
+
isDatabaseConnectionString: () => isDatabaseConnectionString,
|
|
41
|
+
isStaleSessionError: () => import_stale_session_error2.isStaleSessionError
|
|
40
42
|
});
|
|
41
43
|
module.exports = __toCommonJS(database_session_service_exports);
|
|
42
44
|
var import_env_aware_utils = require("../utils/env_aware_utils.js");
|
|
45
|
+
var import_logger = require("../utils/logger.js");
|
|
43
46
|
var import_base_session_service = require("./base_session_service.js");
|
|
44
47
|
var import_session = require("./session.js");
|
|
48
|
+
var import_stale_session_error = require("./stale_session_error.js");
|
|
45
49
|
var import_state = require("./state.js");
|
|
50
|
+
var import_stale_session_error2 = require("./stale_session_error.js");
|
|
46
51
|
/**
|
|
47
52
|
* @license
|
|
48
53
|
* Copyright 2026 Google LLC
|
|
@@ -79,6 +84,11 @@ async function importMikroOrm() {
|
|
|
79
84
|
} = operations);
|
|
80
85
|
}
|
|
81
86
|
__name(importMikroOrm, "importMikroOrm");
|
|
87
|
+
function formatDateTime(dateOrEpochMs) {
|
|
88
|
+
const date = typeof dateOrEpochMs === "number" ? new Date(dateOrEpochMs) : dateOrEpochMs;
|
|
89
|
+
return date.toISOString().replace("T", " ").slice(0, 19);
|
|
90
|
+
}
|
|
91
|
+
__name(formatDateTime, "formatDateTime");
|
|
82
92
|
function isDatabaseConnectionString(uri) {
|
|
83
93
|
if (!uri) {
|
|
84
94
|
return false;
|
|
@@ -87,16 +97,20 @@ function isDatabaseConnectionString(uri) {
|
|
|
87
97
|
}
|
|
88
98
|
__name(isDatabaseConnectionString, "isDatabaseConnectionString");
|
|
89
99
|
const _DatabaseSessionService = class _DatabaseSessionService extends import_base_session_service.BaseSessionService {
|
|
90
|
-
constructor(connectionStringOrOptions) {
|
|
100
|
+
constructor(connectionStringOrOptions, options) {
|
|
101
|
+
var _a;
|
|
91
102
|
super();
|
|
92
103
|
this.initialized = false;
|
|
93
104
|
if (typeof connectionStringOrOptions === "string") {
|
|
94
105
|
this.connectionString = connectionStringOrOptions;
|
|
106
|
+
this.staleSession = (_a = options == null ? void 0 : options.staleSession) != null ? _a : "reject";
|
|
95
107
|
} else {
|
|
96
108
|
if (!connectionStringOrOptions.driver) {
|
|
97
109
|
throw new Error("Driver is required when passing options object.");
|
|
98
110
|
}
|
|
99
|
-
|
|
111
|
+
const { staleSession, ...mikroOptions } = connectionStringOrOptions;
|
|
112
|
+
this.options = mikroOptions;
|
|
113
|
+
this.staleSession = staleSession != null ? staleSession : "reject";
|
|
100
114
|
}
|
|
101
115
|
}
|
|
102
116
|
async init() {
|
|
@@ -342,6 +356,7 @@ const _DatabaseSessionService = class _DatabaseSessionService extends import_bas
|
|
|
342
356
|
return event;
|
|
343
357
|
}
|
|
344
358
|
const trimmedEvent = (0, import_base_session_service.trimTempDeltaState)(event);
|
|
359
|
+
let sessionWasStale = false;
|
|
345
360
|
await em.transactional(async (txEm) => {
|
|
346
361
|
const storageSession = await txEm.findOne(
|
|
347
362
|
StorageSession,
|
|
@@ -355,6 +370,14 @@ const _DatabaseSessionService = class _DatabaseSessionService extends import_bas
|
|
|
355
370
|
if (!storageSession) {
|
|
356
371
|
throw new Error(`Session ${session.id} not found for appendEvent`);
|
|
357
372
|
}
|
|
373
|
+
if (storageSession.updateTime.getTime() > session.lastUpdateTime) {
|
|
374
|
+
if (this.staleSession === "reject") {
|
|
375
|
+
throw new import_stale_session_error.StaleSessionError(
|
|
376
|
+
`The last_update_time provided in the session object ${formatDateTime(session.lastUpdateTime)} is earlier than the update_time in the storage_session ${formatDateTime(storageSession.updateTime)}. Please check if it is a stale session.`
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
sessionWasStale = true;
|
|
380
|
+
}
|
|
358
381
|
let appStateModel = await txEm.findOne(StorageAppState, {
|
|
359
382
|
appName: session.appName
|
|
360
383
|
});
|
|
@@ -378,24 +401,6 @@ const _DatabaseSessionService = class _DatabaseSessionService extends import_bas
|
|
|
378
401
|
});
|
|
379
402
|
txEm.persist(userStateModel);
|
|
380
403
|
}
|
|
381
|
-
if (storageSession.updateTime.getTime() > session.lastUpdateTime) {
|
|
382
|
-
const events = await txEm.find(
|
|
383
|
-
StorageEvent,
|
|
384
|
-
{
|
|
385
|
-
appName: session.appName,
|
|
386
|
-
userId: session.userId,
|
|
387
|
-
sessionId: session.id
|
|
388
|
-
},
|
|
389
|
-
{ orderBy: { timestamp: "ASC" } }
|
|
390
|
-
);
|
|
391
|
-
const mergedState = (0, import_base_session_service.mergeStates)(
|
|
392
|
-
appStateModel.state,
|
|
393
|
-
userStateModel.state,
|
|
394
|
-
storageSession.state
|
|
395
|
-
);
|
|
396
|
-
session.state = mergedState;
|
|
397
|
-
session.events = events.map((e) => e.eventData);
|
|
398
|
-
}
|
|
399
404
|
if (event.actions && event.actions.stateDelta) {
|
|
400
405
|
const appDelta = {};
|
|
401
406
|
const userDelta = {};
|
|
@@ -449,14 +454,29 @@ const _DatabaseSessionService = class _DatabaseSessionService extends import_bas
|
|
|
449
454
|
storageSession.state
|
|
450
455
|
);
|
|
451
456
|
session.state = newMergedState;
|
|
452
|
-
|
|
453
|
-
if (index >= 0) {
|
|
454
|
-
session.events[index] = event;
|
|
455
|
-
} else {
|
|
456
|
-
session.events.push(event);
|
|
457
|
-
}
|
|
457
|
+
(0, import_base_session_service.upsertSessionEvent)(session, event);
|
|
458
458
|
session.lastUpdateTime = storageSession.updateTime.getTime();
|
|
459
459
|
});
|
|
460
|
+
if (sessionWasStale) {
|
|
461
|
+
try {
|
|
462
|
+
const storageEvents = await em.find(
|
|
463
|
+
StorageEvent,
|
|
464
|
+
{
|
|
465
|
+
appName: session.appName,
|
|
466
|
+
userId: session.userId,
|
|
467
|
+
sessionId: session.id
|
|
468
|
+
},
|
|
469
|
+
{ orderBy: { timestamp: "ASC" } }
|
|
470
|
+
);
|
|
471
|
+
session.events = storageEvents.map((se) => se.eventData);
|
|
472
|
+
(0, import_base_session_service.upsertSessionEvent)(session, event);
|
|
473
|
+
} catch (e) {
|
|
474
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
475
|
+
import_logger.logger.warn(
|
|
476
|
+
`Failed to reload events for stale session ${session.id} after appendEvent; the event was persisted but session.events may be missing concurrent appends: ${message}`
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
460
480
|
return event;
|
|
461
481
|
}
|
|
462
482
|
};
|
|
@@ -465,5 +485,7 @@ let DatabaseSessionService = _DatabaseSessionService;
|
|
|
465
485
|
// Annotate the CommonJS export names for ESM import in node:
|
|
466
486
|
0 && (module.exports = {
|
|
467
487
|
DatabaseSessionService,
|
|
468
|
-
|
|
488
|
+
StaleSessionError,
|
|
489
|
+
isDatabaseConnectionString,
|
|
490
|
+
isStaleSessionError
|
|
469
491
|
});
|
|
@@ -0,0 +1,59 @@
|
|
|
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 __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var stale_session_error_exports = {};
|
|
27
|
+
__export(stale_session_error_exports, {
|
|
28
|
+
StaleSessionError: () => StaleSessionError,
|
|
29
|
+
isStaleSessionError: () => isStaleSessionError
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(stale_session_error_exports);
|
|
32
|
+
/**
|
|
33
|
+
* @license
|
|
34
|
+
* Copyright 2026 Google LLC
|
|
35
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
36
|
+
*/
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const STALE_SESSION_ERROR_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
39
|
+
"google.adk.staleSessionError"
|
|
40
|
+
);
|
|
41
|
+
const _StaleSessionError = class _StaleSessionError extends (_b = Error, _a = STALE_SESSION_ERROR_SIGNATURE_SYMBOL, _b) {
|
|
42
|
+
constructor(message) {
|
|
43
|
+
super(message);
|
|
44
|
+
this[_a] = true;
|
|
45
|
+
this.name = "StaleSessionError";
|
|
46
|
+
Object.setPrototypeOf(this, _StaleSessionError.prototype);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
__name(_StaleSessionError, "StaleSessionError");
|
|
50
|
+
let StaleSessionError = _StaleSessionError;
|
|
51
|
+
function isStaleSessionError(obj) {
|
|
52
|
+
return typeof obj === "object" && obj !== null && (STALE_SESSION_ERROR_SIGNATURE_SYMBOL in obj || obj instanceof Error && obj.name === "StaleSessionError");
|
|
53
|
+
}
|
|
54
|
+
__name(isStaleSessionError, "isStaleSessionError");
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
StaleSessionError,
|
|
58
|
+
isStaleSessionError
|
|
59
|
+
});
|