@google/adk 0.3.0 → 0.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/a2a/part_converter_utils.js +210 -0
- package/dist/cjs/agents/active_streaming_tool.js +1 -1
- package/dist/cjs/agents/base_agent.js +3 -3
- package/dist/cjs/agents/base_llm_processor.js +1 -1
- package/dist/cjs/agents/callback_context.js +1 -1
- package/dist/cjs/agents/content_processor_utils.js +1 -1
- package/dist/cjs/agents/functions.js +2 -1
- 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 +58 -40
- package/dist/cjs/agents/loop_agent.js +1 -1
- package/dist/cjs/agents/parallel_agent.js +1 -1
- 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 +14 -1
- 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 +54 -83
- 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 +1 -1
- package/dist/cjs/models/registry.js +3 -1
- package/dist/cjs/plugins/base_plugin.js +1 -1
- 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 +32 -1
- package/dist/cjs/sessions/base_session_service.js +53 -3
- package/dist/cjs/sessions/database_session_service.js +364 -0
- package/dist/cjs/sessions/db/operations.js +114 -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 +1 -1
- package/dist/cjs/tools/base_toolset.js +1 -1
- 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 +1 -1
- package/dist/cjs/tools/tool_confirmation.js +1 -1
- package/dist/cjs/tools/tool_context.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 +1 -1
- 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/part_converter_utils.js +171 -0
- package/dist/esm/agents/base_agent.js +2 -2
- package/dist/esm/agents/functions.js +1 -0
- package/dist/esm/agents/llm_agent.js +58 -40
- 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 +9 -1
- 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 +18 -88
- package/dist/esm/models/apigee_llm.js +152 -0
- package/dist/esm/models/google_llm.js +67 -49
- package/dist/esm/models/registry.js +2 -0
- package/dist/esm/runner/runner.js +31 -0
- package/dist/esm/sessions/base_session_service.js +49 -1
- package/dist/esm/sessions/database_session_service.js +350 -0
- package/dist/esm/sessions/db/operations.js +87 -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/forwarding_artifact_service.js +16 -0
- package/dist/esm/utils/env_aware_utils.js +8 -0
- 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/part_converter_utils.d.ts +47 -0
- package/dist/types/agents/llm_agent.d.ts +11 -11
- 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/common.d.ts +11 -2
- 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/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 +31 -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/forwarding_artifact_service.d.ts +3 -1
- package/dist/types/utils/env_aware_utils.d.ts +7 -0
- package/dist/types/utils/object_notation_utils.d.ts +21 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/web/a2a/part_converter_utils.js +171 -0
- package/dist/web/agents/base_agent.js +2 -2
- package/dist/web/agents/functions.js +1 -0
- package/dist/web/agents/llm_agent.js +79 -59
- 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 +9 -1
- 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 +18 -8
- package/dist/web/models/apigee_llm.js +219 -0
- package/dist/web/models/google_llm.js +67 -46
- package/dist/web/models/registry.js +2 -0
- package/dist/web/runner/runner.js +33 -0
- package/dist/web/sessions/base_session_service.js +49 -1
- package/dist/web/sessions/database_session_service.js +368 -0
- package/dist/web/sessions/db/operations.js +87 -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/forwarding_artifact_service.js +16 -0
- package/dist/web/utils/env_aware_utils.js +8 -0
- 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 -4
- package/dist/cjs/index.js.map +0 -7
- package/dist/esm/index.js.map +0 -7
- package/dist/web/index.js.map +0 -7
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
+
if (decorator = decorators[i])
|
|
7
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
+
if (kind && result) __defProp(target, key, result);
|
|
9
|
+
return result;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright 2026 Google LLC
|
|
14
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
15
|
+
*/
|
|
16
|
+
import { Entity, JsonType, PrimaryKey, Property } from "@mikro-orm/core";
|
|
17
|
+
import {
|
|
18
|
+
transformToCamelCaseEvent,
|
|
19
|
+
transformToSnakeCaseEvent
|
|
20
|
+
} from "../../events/event.js";
|
|
21
|
+
const SCHEMA_VERSION_KEY = "schema_version";
|
|
22
|
+
const SCHEMA_VERSION_1_JSON = "1";
|
|
23
|
+
class CamelCaseToSnakeCaseJsonType extends JsonType {
|
|
24
|
+
convertToDatabaseValue(value) {
|
|
25
|
+
return JSON.stringify(transformToSnakeCaseEvent(value));
|
|
26
|
+
}
|
|
27
|
+
convertToJSValue(value) {
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
return transformToCamelCaseEvent(JSON.parse(value));
|
|
30
|
+
}
|
|
31
|
+
return transformToCamelCaseEvent(value);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
let StorageMetadata = class {
|
|
35
|
+
};
|
|
36
|
+
__decorateClass([
|
|
37
|
+
PrimaryKey({ type: "string" })
|
|
38
|
+
], StorageMetadata.prototype, "key", 2);
|
|
39
|
+
__decorateClass([
|
|
40
|
+
Property({ type: "string" })
|
|
41
|
+
], StorageMetadata.prototype, "value", 2);
|
|
42
|
+
StorageMetadata = __decorateClass([
|
|
43
|
+
Entity({ tableName: "adk_internal_metadata" })
|
|
44
|
+
], StorageMetadata);
|
|
45
|
+
let StorageAppState = class {
|
|
46
|
+
constructor() {
|
|
47
|
+
this.updateTime = /* @__PURE__ */ new Date();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
__decorateClass([
|
|
51
|
+
PrimaryKey({ type: "string", fieldName: "app_name" })
|
|
52
|
+
], StorageAppState.prototype, "appName", 2);
|
|
53
|
+
__decorateClass([
|
|
54
|
+
Property({ type: "json" })
|
|
55
|
+
], StorageAppState.prototype, "state", 2);
|
|
56
|
+
__decorateClass([
|
|
57
|
+
Property({
|
|
58
|
+
type: "datetime",
|
|
59
|
+
fieldName: "update_time",
|
|
60
|
+
onCreate: () => /* @__PURE__ */ new Date(),
|
|
61
|
+
onUpdate: () => /* @__PURE__ */ new Date()
|
|
62
|
+
})
|
|
63
|
+
], StorageAppState.prototype, "updateTime", 2);
|
|
64
|
+
StorageAppState = __decorateClass([
|
|
65
|
+
Entity({ tableName: "app_states" })
|
|
66
|
+
], StorageAppState);
|
|
67
|
+
PrimaryKey.name;
|
|
68
|
+
let StorageUserState = class {
|
|
69
|
+
constructor() {
|
|
70
|
+
this.updateTime = /* @__PURE__ */ new Date();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
__decorateClass([
|
|
74
|
+
PrimaryKey({ type: "string", fieldName: "app_name" })
|
|
75
|
+
], StorageUserState.prototype, "appName", 2);
|
|
76
|
+
__decorateClass([
|
|
77
|
+
PrimaryKey({ type: "string", fieldName: "user_id" })
|
|
78
|
+
], StorageUserState.prototype, "userId", 2);
|
|
79
|
+
__decorateClass([
|
|
80
|
+
Property({ type: "json" })
|
|
81
|
+
], StorageUserState.prototype, "state", 2);
|
|
82
|
+
__decorateClass([
|
|
83
|
+
Property({
|
|
84
|
+
type: "datetime",
|
|
85
|
+
fieldName: "update_time",
|
|
86
|
+
onCreate: () => /* @__PURE__ */ new Date(),
|
|
87
|
+
onUpdate: () => /* @__PURE__ */ new Date()
|
|
88
|
+
})
|
|
89
|
+
], StorageUserState.prototype, "updateTime", 2);
|
|
90
|
+
StorageUserState = __decorateClass([
|
|
91
|
+
Entity({ tableName: "user_states" })
|
|
92
|
+
], StorageUserState);
|
|
93
|
+
PrimaryKey.name;
|
|
94
|
+
let StorageSession = class {
|
|
95
|
+
constructor() {
|
|
96
|
+
this.createTime = /* @__PURE__ */ new Date();
|
|
97
|
+
this.updateTime = /* @__PURE__ */ new Date();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
__decorateClass([
|
|
101
|
+
PrimaryKey({ type: "string" })
|
|
102
|
+
], StorageSession.prototype, "id", 2);
|
|
103
|
+
__decorateClass([
|
|
104
|
+
PrimaryKey({ type: "string", fieldName: "app_name" })
|
|
105
|
+
], StorageSession.prototype, "appName", 2);
|
|
106
|
+
__decorateClass([
|
|
107
|
+
PrimaryKey({ type: "string", fieldName: "user_id" })
|
|
108
|
+
], StorageSession.prototype, "userId", 2);
|
|
109
|
+
__decorateClass([
|
|
110
|
+
Property({ type: "json" })
|
|
111
|
+
], StorageSession.prototype, "state", 2);
|
|
112
|
+
__decorateClass([
|
|
113
|
+
Property({
|
|
114
|
+
type: "datetime",
|
|
115
|
+
fieldName: "create_time",
|
|
116
|
+
onCreate: () => /* @__PURE__ */ new Date()
|
|
117
|
+
})
|
|
118
|
+
], StorageSession.prototype, "createTime", 2);
|
|
119
|
+
__decorateClass([
|
|
120
|
+
Property({
|
|
121
|
+
type: "datetime",
|
|
122
|
+
fieldName: "update_time",
|
|
123
|
+
onCreate: () => /* @__PURE__ */ new Date()
|
|
124
|
+
})
|
|
125
|
+
], StorageSession.prototype, "updateTime", 2);
|
|
126
|
+
StorageSession = __decorateClass([
|
|
127
|
+
Entity({ tableName: "sessions" })
|
|
128
|
+
], StorageSession);
|
|
129
|
+
PrimaryKey.name;
|
|
130
|
+
let StorageEvent = class {
|
|
131
|
+
};
|
|
132
|
+
__decorateClass([
|
|
133
|
+
PrimaryKey({ type: "string" })
|
|
134
|
+
], StorageEvent.prototype, "id", 2);
|
|
135
|
+
__decorateClass([
|
|
136
|
+
PrimaryKey({ type: "string", fieldName: "app_name" })
|
|
137
|
+
], StorageEvent.prototype, "appName", 2);
|
|
138
|
+
__decorateClass([
|
|
139
|
+
PrimaryKey({ type: "string", fieldName: "user_id" })
|
|
140
|
+
], StorageEvent.prototype, "userId", 2);
|
|
141
|
+
__decorateClass([
|
|
142
|
+
PrimaryKey({ type: "string", fieldName: "session_id" })
|
|
143
|
+
], StorageEvent.prototype, "sessionId", 2);
|
|
144
|
+
__decorateClass([
|
|
145
|
+
Property({ type: "string", fieldName: "invocation_id" })
|
|
146
|
+
], StorageEvent.prototype, "invocationId", 2);
|
|
147
|
+
__decorateClass([
|
|
148
|
+
Property({ type: "datetime" })
|
|
149
|
+
], StorageEvent.prototype, "timestamp", 2);
|
|
150
|
+
__decorateClass([
|
|
151
|
+
Property({ type: CamelCaseToSnakeCaseJsonType, fieldName: "event_data" })
|
|
152
|
+
], StorageEvent.prototype, "eventData", 2);
|
|
153
|
+
StorageEvent = __decorateClass([
|
|
154
|
+
Entity({ tableName: "events" })
|
|
155
|
+
], StorageEvent);
|
|
156
|
+
const ENTITIES = [
|
|
157
|
+
StorageMetadata,
|
|
158
|
+
StorageAppState,
|
|
159
|
+
StorageUserState,
|
|
160
|
+
StorageSession,
|
|
161
|
+
StorageEvent
|
|
162
|
+
];
|
|
163
|
+
export {
|
|
164
|
+
ENTITIES,
|
|
165
|
+
SCHEMA_VERSION_1_JSON,
|
|
166
|
+
SCHEMA_VERSION_KEY,
|
|
167
|
+
StorageAppState,
|
|
168
|
+
StorageEvent,
|
|
169
|
+
StorageMetadata,
|
|
170
|
+
StorageSession,
|
|
171
|
+
StorageUserState
|
|
172
|
+
};
|
|
@@ -7,10 +7,14 @@ import { cloneDeep } from "lodash-es";
|
|
|
7
7
|
import { randomUUID } from "../utils/env_aware_utils.js";
|
|
8
8
|
import { logger } from "../utils/logger.js";
|
|
9
9
|
import {
|
|
10
|
-
BaseSessionService
|
|
10
|
+
BaseSessionService,
|
|
11
|
+
mergeStates
|
|
11
12
|
} from "./base_session_service.js";
|
|
12
13
|
import { createSession } from "./session.js";
|
|
13
14
|
import { State } from "./state.js";
|
|
15
|
+
function isInMemoryConnectionString(uri) {
|
|
16
|
+
return uri === "memory://";
|
|
17
|
+
}
|
|
14
18
|
class InMemorySessionService extends BaseSessionService {
|
|
15
19
|
constructor() {
|
|
16
20
|
super(...arguments);
|
|
@@ -28,12 +32,13 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
28
32
|
*/
|
|
29
33
|
this.appState = {};
|
|
30
34
|
}
|
|
31
|
-
createSession({
|
|
35
|
+
async createSession({
|
|
32
36
|
appName,
|
|
33
37
|
userId,
|
|
34
38
|
state,
|
|
35
39
|
sessionId
|
|
36
40
|
}) {
|
|
41
|
+
var _a;
|
|
37
42
|
const session = createSession({
|
|
38
43
|
id: sessionId || randomUUID(),
|
|
39
44
|
appName,
|
|
@@ -49,16 +54,21 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
49
54
|
this.sessions[appName][userId] = {};
|
|
50
55
|
}
|
|
51
56
|
this.sessions[appName][userId][session.id] = session;
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
const copiedSession = cloneDeep(session);
|
|
58
|
+
copiedSession.state = mergeStates(
|
|
59
|
+
this.appState[appName],
|
|
60
|
+
(_a = this.userState[appName]) == null ? void 0 : _a[userId],
|
|
61
|
+
copiedSession.state
|
|
54
62
|
);
|
|
63
|
+
return copiedSession;
|
|
55
64
|
}
|
|
56
|
-
getSession({
|
|
65
|
+
async getSession({
|
|
57
66
|
appName,
|
|
58
67
|
userId,
|
|
59
68
|
sessionId,
|
|
60
69
|
config
|
|
61
70
|
}) {
|
|
71
|
+
var _a;
|
|
62
72
|
if (!this.sessions[appName] || !this.sessions[appName][userId] || !this.sessions[appName][userId][sessionId]) {
|
|
63
73
|
return Promise.resolve(void 0);
|
|
64
74
|
}
|
|
@@ -83,7 +93,12 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
83
93
|
}
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
|
-
|
|
96
|
+
copiedSession.state = mergeStates(
|
|
97
|
+
this.appState[appName],
|
|
98
|
+
(_a = this.userState[appName]) == null ? void 0 : _a[userId],
|
|
99
|
+
copiedSession.state
|
|
100
|
+
);
|
|
101
|
+
return copiedSession;
|
|
87
102
|
}
|
|
88
103
|
listSessions({
|
|
89
104
|
appName,
|
|
@@ -160,21 +175,8 @@ class InMemorySessionService extends BaseSessionService {
|
|
|
160
175
|
storageSession.lastUpdateTime = event.timestamp;
|
|
161
176
|
return event;
|
|
162
177
|
}
|
|
163
|
-
mergeState(appName, userId, copiedSession) {
|
|
164
|
-
if (this.appState[appName]) {
|
|
165
|
-
for (const key of Object.keys(this.appState[appName])) {
|
|
166
|
-
copiedSession.state[State.APP_PREFIX + key] = this.appState[appName][key];
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if (!this.userState[appName] || !this.userState[appName][userId]) {
|
|
170
|
-
return copiedSession;
|
|
171
|
-
}
|
|
172
|
-
for (const key of Object.keys(this.userState[appName][userId])) {
|
|
173
|
-
copiedSession.state[State.USER_PREFIX + key] = this.userState[appName][userId][key];
|
|
174
|
-
}
|
|
175
|
-
return copiedSession;
|
|
176
|
-
}
|
|
177
178
|
}
|
|
178
179
|
export {
|
|
179
|
-
InMemorySessionService
|
|
180
|
+
InMemorySessionService,
|
|
181
|
+
isInMemoryConnectionString
|
|
180
182
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import {
|
|
7
|
+
DatabaseSessionService,
|
|
8
|
+
isDatabaseConnectionString
|
|
9
|
+
} from "./database_session_service.js";
|
|
10
|
+
import {
|
|
11
|
+
InMemorySessionService,
|
|
12
|
+
isInMemoryConnectionString
|
|
13
|
+
} from "./in_memory_session_service.js";
|
|
14
|
+
function getSessionServiceFromUri(uri) {
|
|
15
|
+
if (isInMemoryConnectionString(uri)) {
|
|
16
|
+
return new InMemorySessionService();
|
|
17
|
+
}
|
|
18
|
+
if (isDatabaseConnectionString(uri)) {
|
|
19
|
+
return new DatabaseSessionService(uri);
|
|
20
|
+
}
|
|
21
|
+
throw new Error("Unsupported session service URI: ".concat(uri));
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
getSessionServiceFromUri
|
|
25
|
+
};
|
|
@@ -35,6 +35,22 @@ class ForwardingArtifactService {
|
|
|
35
35
|
request
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
|
+
listArtifactVersions(request) {
|
|
39
|
+
if (!this.toolContext.invocationContext.artifactService) {
|
|
40
|
+
throw new Error("Artifact service is not initialized.");
|
|
41
|
+
}
|
|
42
|
+
return this.toolContext.invocationContext.artifactService.listArtifactVersions(
|
|
43
|
+
request
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
getArtifactVersion(request) {
|
|
47
|
+
if (!this.toolContext.invocationContext.artifactService) {
|
|
48
|
+
throw new Error("Artifact service is not initialized.");
|
|
49
|
+
}
|
|
50
|
+
return this.toolContext.invocationContext.artifactService.getArtifactVersion(
|
|
51
|
+
request
|
|
52
|
+
);
|
|
53
|
+
}
|
|
38
54
|
}
|
|
39
55
|
export {
|
|
40
56
|
ForwardingArtifactService
|
|
@@ -40,9 +40,17 @@ function isBase64Encoded(data) {
|
|
|
40
40
|
return false;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
function getBooleanEnvVar(envVar) {
|
|
44
|
+
if (!process.env) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
48
|
+
return ["true", "1"].includes(envVarValue);
|
|
49
|
+
}
|
|
43
50
|
export {
|
|
44
51
|
base64Decode,
|
|
45
52
|
base64Encode,
|
|
53
|
+
getBooleanEnvVar,
|
|
46
54
|
isBase64Encoded,
|
|
47
55
|
isBrowser,
|
|
48
56
|
randomUUID
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
function toCamelCase(obj, preserveKeys = []) {
|
|
7
|
+
return toNotation(obj, toCamelCaseKey, "", preserveKeys);
|
|
8
|
+
}
|
|
9
|
+
function toSnakeCase(obj, preserveKeys = []) {
|
|
10
|
+
return toNotation(obj, toSnakeCaseKey, "", preserveKeys);
|
|
11
|
+
}
|
|
12
|
+
const toCamelCaseKey = (key) => key.replace(
|
|
13
|
+
/_([a-z])/g,
|
|
14
|
+
(_match, letter) => letter.toUpperCase()
|
|
15
|
+
);
|
|
16
|
+
const toSnakeCaseKey = (key) => key.replace(/[A-Z]/g, (g) => "_" + g.toLowerCase());
|
|
17
|
+
function toNotation(obj, converter, parentKey = "", preserveKeys = []) {
|
|
18
|
+
if (Array.isArray(obj)) {
|
|
19
|
+
return obj.map(
|
|
20
|
+
(item) => toNotation(item, converter, parentKey, preserveKeys)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === "object" && obj !== null) {
|
|
24
|
+
const source = obj;
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const key of Object.keys(source)) {
|
|
27
|
+
const convertedKey = converter(key);
|
|
28
|
+
const fullPath = parentKey !== "" ? parentKey + "." + key : key;
|
|
29
|
+
if (preserveKeys.includes(fullPath)) {
|
|
30
|
+
result[convertedKey] = source[key];
|
|
31
|
+
} else {
|
|
32
|
+
result[convertedKey] = toNotation(
|
|
33
|
+
source[key],
|
|
34
|
+
converter,
|
|
35
|
+
fullPath,
|
|
36
|
+
preserveKeys
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
toCamelCase,
|
|
46
|
+
toSnakeCase
|
|
47
|
+
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2025 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
+
import { getBooleanEnvVar } from "./env_aware_utils.js";
|
|
6
7
|
var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
7
8
|
GoogleLLMVariant2["VERTEX_AI"] = "VERTEX_AI";
|
|
8
9
|
GoogleLLMVariant2["GEMINI_API"] = "GEMINI_API";
|
|
@@ -11,13 +12,6 @@ var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
|
|
|
11
12
|
function getGoogleLlmVariant() {
|
|
12
13
|
return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
|
|
13
14
|
}
|
|
14
|
-
function getBooleanEnvVar(envVar) {
|
|
15
|
-
if (!process.env) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const envVarValue = (process.env[envVar] || "").toLowerCase();
|
|
19
|
-
return ["true", "1"].includes(envVarValue);
|
|
20
|
-
}
|
|
21
15
|
export {
|
|
22
16
|
GoogleLLMVariant,
|
|
23
17
|
getGoogleLlmVariant
|
package/dist/web/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/adk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Google ADK JS",
|
|
5
5
|
"author": "Google",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,11 +37,14 @@
|
|
|
37
37
|
"test": "vitest",
|
|
38
38
|
"lint": "eslint 'src/**/*.ts'",
|
|
39
39
|
"format": "prettier --write 'src/**/*.ts'",
|
|
40
|
-
"prepublishOnly": "npm run build
|
|
40
|
+
"prepublishOnly": "npm run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@a2a-js/sdk": "^0.3.10",
|
|
43
44
|
"@google/genai": "^1.37.0",
|
|
44
|
-
"@
|
|
45
|
+
"@mikro-orm/core": "^6.6.6",
|
|
46
|
+
"@mikro-orm/reflection": "^6.6.6",
|
|
47
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
45
48
|
"google-auth-library": "^10.3.0",
|
|
46
49
|
"lodash-es": "^4.17.23",
|
|
47
50
|
"zod": "^4.2.1",
|
|
@@ -49,12 +52,18 @@
|
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@types/lodash-es": "^4.17.12",
|
|
52
|
-
"openapi-types": "^12.1.3"
|
|
55
|
+
"openapi-types": "^12.1.3",
|
|
56
|
+
"@mikro-orm/sqlite": "^6.6.6"
|
|
53
57
|
},
|
|
54
58
|
"peerDependencies": {
|
|
55
59
|
"@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
|
|
56
60
|
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
|
|
57
61
|
"@google-cloud/storage": "^7.17.1",
|
|
62
|
+
"@mikro-orm/mariadb": "^6.6.6",
|
|
63
|
+
"@mikro-orm/mssql": "^6.6.6",
|
|
64
|
+
"@mikro-orm/mysql": "^6.6.6",
|
|
65
|
+
"@mikro-orm/postgresql": "^6.6.6",
|
|
66
|
+
"@mikro-orm/sqlite": "^6.6.6",
|
|
58
67
|
"@opentelemetry/api": "1.9.0",
|
|
59
68
|
"@opentelemetry/api-logs": "^0.205.0",
|
|
60
69
|
"@opentelemetry/exporter-logs-otlp-http": "^0.205.0",
|