@paean-ai/adk 0.2.13 → 0.2.15

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.
Files changed (254) hide show
  1. package/dist/cjs/index.js +11 -11
  2. package/dist/cjs/index.js.map +3 -3
  3. package/dist/esm/index.js +11 -11
  4. package/dist/esm/index.js.map +3 -3
  5. package/dist/types/agents/llm_agent.d.ts +4 -0
  6. package/dist/web/index.js +1 -1
  7. package/dist/web/index.js.map +3 -3
  8. package/package.json +3 -3
  9. package/dist/cjs/agents/active_streaming_tool.js +0 -44
  10. package/dist/cjs/agents/base_agent.js +0 -245
  11. package/dist/cjs/agents/base_llm_processor.js +0 -44
  12. package/dist/cjs/agents/callback_context.js +0 -98
  13. package/dist/cjs/agents/content_processor_utils.js +0 -346
  14. package/dist/cjs/agents/functions.js +0 -385
  15. package/dist/cjs/agents/instructions.js +0 -110
  16. package/dist/cjs/agents/invocation_context.js +0 -107
  17. package/dist/cjs/agents/live_request_queue.js +0 -136
  18. package/dist/cjs/agents/llm_agent.js +0 -1212
  19. package/dist/cjs/agents/loop_agent.js +0 -68
  20. package/dist/cjs/agents/parallel_agent.js +0 -78
  21. package/dist/cjs/agents/readonly_context.js +0 -68
  22. package/dist/cjs/agents/run_config.js +0 -70
  23. package/dist/cjs/agents/sequential_agent.js +0 -84
  24. package/dist/cjs/agents/transcription_entry.js +0 -27
  25. package/dist/cjs/artifacts/base_artifact_service.js +0 -27
  26. package/dist/cjs/artifacts/gcs_artifact_service.js +0 -140
  27. package/dist/cjs/artifacts/in_memory_artifact_service.js +0 -119
  28. package/dist/cjs/auth/auth_credential.js +0 -46
  29. package/dist/cjs/auth/auth_handler.js +0 -92
  30. package/dist/cjs/auth/auth_schemes.js +0 -62
  31. package/dist/cjs/auth/auth_tool.js +0 -27
  32. package/dist/cjs/auth/credential_service/base_credential_service.js +0 -27
  33. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +0 -63
  34. package/dist/cjs/auth/exchanger/base_credential_exchanger.js +0 -40
  35. package/dist/cjs/auth/exchanger/credential_exchanger_registry.js +0 -59
  36. package/dist/cjs/code_executors/base_code_executor.js +0 -76
  37. package/dist/cjs/code_executors/built_in_code_executor.js +0 -58
  38. package/dist/cjs/code_executors/code_execution_utils.js +0 -142
  39. package/dist/cjs/code_executors/code_executor_context.js +0 -198
  40. package/dist/cjs/common.js +0 -181
  41. package/dist/cjs/events/event.js +0 -119
  42. package/dist/cjs/events/event_actions.js +0 -83
  43. package/dist/cjs/examples/base_example_provider.js +0 -40
  44. package/dist/cjs/examples/example.js +0 -27
  45. package/dist/cjs/examples/example_util.js +0 -107
  46. package/dist/cjs/index_web.js +0 -33
  47. package/dist/cjs/memory/base_memory_service.js +0 -27
  48. package/dist/cjs/memory/in_memory_memory_service.js +0 -97
  49. package/dist/cjs/memory/memory_entry.js +0 -27
  50. package/dist/cjs/models/base_llm.js +0 -95
  51. package/dist/cjs/models/base_llm_connection.js +0 -27
  52. package/dist/cjs/models/gemini_llm_connection.js +0 -132
  53. package/dist/cjs/models/google_llm.js +0 -559
  54. package/dist/cjs/models/llm_request.js +0 -82
  55. package/dist/cjs/models/llm_response.js +0 -71
  56. package/dist/cjs/models/registry.js +0 -121
  57. package/dist/cjs/plugins/base_plugin.js +0 -236
  58. package/dist/cjs/plugins/logging_plugin.js +0 -222
  59. package/dist/cjs/plugins/plugin_manager.js +0 -239
  60. package/dist/cjs/plugins/security_plugin.js +0 -153
  61. package/dist/cjs/runner/in_memory_runner.js +0 -58
  62. package/dist/cjs/runner/runner.js +0 -277
  63. package/dist/cjs/sessions/base_session_service.js +0 -71
  64. package/dist/cjs/sessions/in_memory_session_service.js +0 -184
  65. package/dist/cjs/sessions/session.js +0 -48
  66. package/dist/cjs/sessions/state.js +0 -101
  67. package/dist/cjs/telemetry/google_cloud.js +0 -85
  68. package/dist/cjs/telemetry/setup.js +0 -97
  69. package/dist/cjs/telemetry/tracing.js +0 -231
  70. package/dist/cjs/tools/agent_tool.js +0 -134
  71. package/dist/cjs/tools/base_tool.js +0 -107
  72. package/dist/cjs/tools/base_toolset.js +0 -76
  73. package/dist/cjs/tools/forwarding_artifact_service.js +0 -71
  74. package/dist/cjs/tools/function_tool.js +0 -101
  75. package/dist/cjs/tools/google_search_tool.js +0 -76
  76. package/dist/cjs/tools/long_running_tool.js +0 -63
  77. package/dist/cjs/tools/mcp/mcp_session_manager.js +0 -65
  78. package/dist/cjs/tools/mcp/mcp_tool.js +0 -65
  79. package/dist/cjs/tools/mcp/mcp_toolset.js +0 -61
  80. package/dist/cjs/tools/tool_confirmation.js +0 -49
  81. package/dist/cjs/tools/tool_context.js +0 -129
  82. package/dist/cjs/utils/client_labels.js +0 -56
  83. package/dist/cjs/utils/deep_clone.js +0 -44
  84. package/dist/cjs/utils/env_aware_utils.js +0 -83
  85. package/dist/cjs/utils/gemini_schema_util.js +0 -88
  86. package/dist/cjs/utils/logger.js +0 -121
  87. package/dist/cjs/utils/model_name.js +0 -76
  88. package/dist/cjs/utils/simple_zod_to_json.js +0 -191
  89. package/dist/cjs/utils/variant_utils.js +0 -55
  90. package/dist/cjs/version.js +0 -39
  91. package/dist/esm/agents/active_streaming_tool.js +0 -14
  92. package/dist/esm/agents/base_agent.js +0 -214
  93. package/dist/esm/agents/base_llm_processor.js +0 -13
  94. package/dist/esm/agents/callback_context.js +0 -68
  95. package/dist/esm/agents/content_processor_utils.js +0 -315
  96. package/dist/esm/agents/functions.js +0 -344
  97. package/dist/esm/agents/instructions.js +0 -80
  98. package/dist/esm/agents/invocation_context.js +0 -76
  99. package/dist/esm/agents/live_request_queue.js +0 -106
  100. package/dist/esm/agents/llm_agent.js +0 -1180
  101. package/dist/esm/agents/loop_agent.js +0 -38
  102. package/dist/esm/agents/parallel_agent.js +0 -48
  103. package/dist/esm/agents/readonly_context.js +0 -38
  104. package/dist/esm/agents/run_config.js +0 -39
  105. package/dist/esm/agents/sequential_agent.js +0 -54
  106. package/dist/esm/agents/transcription_entry.js +0 -5
  107. package/dist/esm/artifacts/base_artifact_service.js +0 -5
  108. package/dist/esm/artifacts/gcs_artifact_service.js +0 -110
  109. package/dist/esm/artifacts/in_memory_artifact_service.js +0 -89
  110. package/dist/esm/auth/auth_credential.js +0 -16
  111. package/dist/esm/auth/auth_handler.js +0 -62
  112. package/dist/esm/auth/auth_schemes.js +0 -31
  113. package/dist/esm/auth/auth_tool.js +0 -5
  114. package/dist/esm/auth/credential_service/base_credential_service.js +0 -5
  115. package/dist/esm/auth/credential_service/in_memory_credential_service.js +0 -33
  116. package/dist/esm/auth/exchanger/base_credential_exchanger.js +0 -10
  117. package/dist/esm/auth/exchanger/credential_exchanger_registry.js +0 -29
  118. package/dist/esm/code_executors/base_code_executor.js +0 -46
  119. package/dist/esm/code_executors/built_in_code_executor.js +0 -28
  120. package/dist/esm/code_executors/code_execution_utils.js +0 -108
  121. package/dist/esm/code_executors/code_executor_context.js +0 -168
  122. package/dist/esm/common.js +0 -98
  123. package/dist/esm/events/event.js +0 -83
  124. package/dist/esm/events/event_actions.js +0 -52
  125. package/dist/esm/examples/base_example_provider.js +0 -10
  126. package/dist/esm/examples/example.js +0 -5
  127. package/dist/esm/examples/example_util.js +0 -76
  128. package/dist/esm/index_web.js +0 -6
  129. package/dist/esm/memory/base_memory_service.js +0 -5
  130. package/dist/esm/memory/in_memory_memory_service.js +0 -67
  131. package/dist/esm/memory/memory_entry.js +0 -5
  132. package/dist/esm/models/base_llm.js +0 -64
  133. package/dist/esm/models/base_llm_connection.js +0 -5
  134. package/dist/esm/models/gemini_llm_connection.js +0 -102
  135. package/dist/esm/models/google_llm.js +0 -533
  136. package/dist/esm/models/llm_request.js +0 -50
  137. package/dist/esm/models/llm_response.js +0 -41
  138. package/dist/esm/models/registry.js +0 -91
  139. package/dist/esm/plugins/base_plugin.js +0 -206
  140. package/dist/esm/plugins/logging_plugin.js +0 -192
  141. package/dist/esm/plugins/plugin_manager.js +0 -209
  142. package/dist/esm/plugins/security_plugin.js +0 -119
  143. package/dist/esm/runner/in_memory_runner.js +0 -28
  144. package/dist/esm/runner/runner.js +0 -247
  145. package/dist/esm/sessions/base_session_service.js +0 -41
  146. package/dist/esm/sessions/in_memory_session_service.js +0 -154
  147. package/dist/esm/sessions/session.js +0 -18
  148. package/dist/esm/sessions/state.js +0 -71
  149. package/dist/esm/telemetry/google_cloud.js +0 -54
  150. package/dist/esm/telemetry/setup.js +0 -67
  151. package/dist/esm/telemetry/tracing.js +0 -195
  152. package/dist/esm/tools/agent_tool.js +0 -104
  153. package/dist/esm/tools/base_tool.js +0 -77
  154. package/dist/esm/tools/base_toolset.js +0 -46
  155. package/dist/esm/tools/forwarding_artifact_service.js +0 -41
  156. package/dist/esm/tools/function_tool.js +0 -71
  157. package/dist/esm/tools/google_search_tool.js +0 -46
  158. package/dist/esm/tools/long_running_tool.js +0 -33
  159. package/dist/esm/tools/mcp/mcp_session_manager.js +0 -35
  160. package/dist/esm/tools/mcp/mcp_tool.js +0 -35
  161. package/dist/esm/tools/mcp/mcp_toolset.js +0 -31
  162. package/dist/esm/tools/tool_confirmation.js +0 -19
  163. package/dist/esm/tools/tool_context.js +0 -99
  164. package/dist/esm/utils/client_labels.js +0 -26
  165. package/dist/esm/utils/deep_clone.js +0 -14
  166. package/dist/esm/utils/env_aware_utils.js +0 -49
  167. package/dist/esm/utils/gemini_schema_util.js +0 -58
  168. package/dist/esm/utils/logger.js +0 -89
  169. package/dist/esm/utils/model_name.js +0 -41
  170. package/dist/esm/utils/simple_zod_to_json.js +0 -160
  171. package/dist/esm/utils/variant_utils.js +0 -24
  172. package/dist/esm/version.js +0 -9
  173. package/dist/web/agents/active_streaming_tool.js +0 -14
  174. package/dist/web/agents/base_agent.js +0 -265
  175. package/dist/web/agents/base_llm_processor.js +0 -13
  176. package/dist/web/agents/callback_context.js +0 -68
  177. package/dist/web/agents/content_processor_utils.js +0 -315
  178. package/dist/web/agents/functions.js +0 -344
  179. package/dist/web/agents/instructions.js +0 -80
  180. package/dist/web/agents/invocation_context.js +0 -76
  181. package/dist/web/agents/live_request_queue.js +0 -124
  182. package/dist/web/agents/llm_agent.js +0 -1310
  183. package/dist/web/agents/loop_agent.js +0 -71
  184. package/dist/web/agents/parallel_agent.js +0 -83
  185. package/dist/web/agents/readonly_context.js +0 -38
  186. package/dist/web/agents/run_config.js +0 -54
  187. package/dist/web/agents/sequential_agent.js +0 -99
  188. package/dist/web/agents/transcription_entry.js +0 -5
  189. package/dist/web/artifacts/base_artifact_service.js +0 -5
  190. package/dist/web/artifacts/gcs_artifact_service.js +0 -126
  191. package/dist/web/artifacts/in_memory_artifact_service.js +0 -89
  192. package/dist/web/auth/auth_credential.js +0 -16
  193. package/dist/web/auth/auth_handler.js +0 -62
  194. package/dist/web/auth/auth_schemes.js +0 -31
  195. package/dist/web/auth/auth_tool.js +0 -5
  196. package/dist/web/auth/credential_service/base_credential_service.js +0 -5
  197. package/dist/web/auth/credential_service/in_memory_credential_service.js +0 -33
  198. package/dist/web/auth/exchanger/base_credential_exchanger.js +0 -10
  199. package/dist/web/auth/exchanger/credential_exchanger_registry.js +0 -29
  200. package/dist/web/code_executors/base_code_executor.js +0 -46
  201. package/dist/web/code_executors/built_in_code_executor.js +0 -28
  202. package/dist/web/code_executors/code_execution_utils.js +0 -105
  203. package/dist/web/code_executors/code_executor_context.js +0 -168
  204. package/dist/web/common.js +0 -98
  205. package/dist/web/events/event.js +0 -101
  206. package/dist/web/events/event_actions.js +0 -67
  207. package/dist/web/examples/base_example_provider.js +0 -10
  208. package/dist/web/examples/example.js +0 -5
  209. package/dist/web/examples/example_util.js +0 -75
  210. package/dist/web/index_web.js +0 -6
  211. package/dist/web/memory/base_memory_service.js +0 -5
  212. package/dist/web/memory/in_memory_memory_service.js +0 -67
  213. package/dist/web/memory/memory_entry.js +0 -5
  214. package/dist/web/models/base_llm.js +0 -64
  215. package/dist/web/models/base_llm_connection.js +0 -5
  216. package/dist/web/models/gemini_llm_connection.js +0 -120
  217. package/dist/web/models/google_llm.js +0 -574
  218. package/dist/web/models/llm_request.js +0 -50
  219. package/dist/web/models/llm_response.js +0 -41
  220. package/dist/web/models/registry.js +0 -91
  221. package/dist/web/plugins/base_plugin.js +0 -206
  222. package/dist/web/plugins/logging_plugin.js +0 -192
  223. package/dist/web/plugins/plugin_manager.js +0 -209
  224. package/dist/web/plugins/security_plugin.js +0 -119
  225. package/dist/web/runner/in_memory_runner.js +0 -28
  226. package/dist/web/runner/runner.js +0 -278
  227. package/dist/web/sessions/base_session_service.js +0 -41
  228. package/dist/web/sessions/in_memory_session_service.js +0 -154
  229. package/dist/web/sessions/session.js +0 -18
  230. package/dist/web/sessions/state.js +0 -87
  231. package/dist/web/telemetry/google_cloud.js +0 -54
  232. package/dist/web/telemetry/setup.js +0 -67
  233. package/dist/web/telemetry/tracing.js +0 -210
  234. package/dist/web/tools/agent_tool.js +0 -118
  235. package/dist/web/tools/base_tool.js +0 -77
  236. package/dist/web/tools/base_toolset.js +0 -46
  237. package/dist/web/tools/forwarding_artifact_service.js +0 -41
  238. package/dist/web/tools/function_tool.js +0 -71
  239. package/dist/web/tools/google_search_tool.js +0 -46
  240. package/dist/web/tools/long_running_tool.js +0 -50
  241. package/dist/web/tools/mcp/mcp_session_manager.js +0 -35
  242. package/dist/web/tools/mcp/mcp_tool.js +0 -35
  243. package/dist/web/tools/mcp/mcp_toolset.js +0 -31
  244. package/dist/web/tools/tool_confirmation.js +0 -19
  245. package/dist/web/tools/tool_context.js +0 -99
  246. package/dist/web/utils/client_labels.js +0 -26
  247. package/dist/web/utils/deep_clone.js +0 -14
  248. package/dist/web/utils/env_aware_utils.js +0 -49
  249. package/dist/web/utils/gemini_schema_util.js +0 -58
  250. package/dist/web/utils/logger.js +0 -89
  251. package/dist/web/utils/model_name.js +0 -41
  252. package/dist/web/utils/simple_zod_to_json.js +0 -174
  253. package/dist/web/utils/variant_utils.js +0 -24
  254. package/dist/web/version.js +0 -9
@@ -1,160 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Type } from "@google/genai";
7
- import { z } from "zod";
8
- function isZodObject(obj) {
9
- var _a;
10
- return obj !== null && typeof obj === "object" && ((_a = obj._def) == null ? void 0 : _a.typeName) === "ZodObject";
11
- }
12
- function parseZodType(zodType) {
13
- const def = zodType._def;
14
- if (!def) {
15
- return {};
16
- }
17
- const description = def.description;
18
- const result = {};
19
- if (description) result.description = description;
20
- const returnResult = (result2) => {
21
- if (result2.description === void 0) {
22
- delete result2.description;
23
- }
24
- return result2;
25
- };
26
- switch (def.typeName) {
27
- case z.ZodFirstPartyTypeKind.ZodString:
28
- result.type = Type.STRING;
29
- for (const check of def.checks || []) {
30
- if (check.kind === "min")
31
- result.minLength = check.value.toString();
32
- else if (check.kind === "max")
33
- result.maxLength = check.value.toString();
34
- else if (check.kind === "email")
35
- result.format = "email";
36
- else if (check.kind === "uuid")
37
- result.format = "uuid";
38
- else if (check.kind === "url")
39
- result.format = "uri";
40
- else if (check.kind === "regex")
41
- result.pattern = check.regex.source;
42
- }
43
- return returnResult(result);
44
- case z.ZodFirstPartyTypeKind.ZodNumber:
45
- result.type = Type.NUMBER;
46
- for (const check of def.checks || []) {
47
- if (check.kind === "min")
48
- result.minimum = check.value;
49
- else if (check.kind === "max")
50
- result.maximum = check.value;
51
- else if (check.kind === "int")
52
- result.type = Type.INTEGER;
53
- }
54
- return returnResult(result);
55
- case z.ZodFirstPartyTypeKind.ZodBoolean:
56
- result.type = Type.BOOLEAN;
57
- return returnResult(result);
58
- case z.ZodFirstPartyTypeKind.ZodArray:
59
- result.type = Type.ARRAY;
60
- result.items = parseZodType(def.type);
61
- if (def.minLength) result.minItems = def.minLength.value.toString();
62
- if (def.maxLength) result.maxItems = def.maxLength.value.toString();
63
- return returnResult(result);
64
- case z.ZodFirstPartyTypeKind.ZodObject: {
65
- const nestedSchema = zodObjectToSchema(zodType);
66
- return nestedSchema;
67
- }
68
- case z.ZodFirstPartyTypeKind.ZodLiteral:
69
- const literalType = typeof def.value;
70
- result.enum = [def.value.toString()];
71
- if (literalType === "string") {
72
- result.type = Type.STRING;
73
- } else if (literalType === "number") {
74
- result.type = Type.NUMBER;
75
- } else if (literalType === "boolean") {
76
- result.type = Type.BOOLEAN;
77
- } else if (def.value === null) {
78
- result.type = Type.NULL;
79
- } else {
80
- throw new Error(`Unsupported ZodLiteral value type: ${literalType}`);
81
- }
82
- return returnResult(result);
83
- case z.ZodFirstPartyTypeKind.ZodEnum:
84
- result.type = Type.STRING;
85
- result.enum = def.values;
86
- return returnResult(result);
87
- case z.ZodFirstPartyTypeKind.ZodNativeEnum:
88
- result.type = Type.STRING;
89
- result.enum = Object.values(def.values);
90
- return returnResult(result);
91
- case z.ZodFirstPartyTypeKind.ZodUnion:
92
- result.anyOf = def.options.map(parseZodType);
93
- return returnResult(result);
94
- case z.ZodFirstPartyTypeKind.ZodOptional:
95
- return parseZodType(def.innerType);
96
- case z.ZodFirstPartyTypeKind.ZodNullable:
97
- const nullableInner = parseZodType(def.innerType);
98
- return nullableInner ? returnResult({
99
- anyOf: [nullableInner, { type: Type.NULL }],
100
- ...description && { description }
101
- }) : returnResult({ type: Type.NULL, ...description && { description } });
102
- case z.ZodFirstPartyTypeKind.ZodDefault:
103
- const defaultInner = parseZodType(def.innerType);
104
- if (defaultInner) defaultInner.default = def.defaultValue();
105
- return defaultInner;
106
- case z.ZodFirstPartyTypeKind.ZodBranded:
107
- return parseZodType(def.type);
108
- case z.ZodFirstPartyTypeKind.ZodReadonly:
109
- return parseZodType(def.innerType);
110
- case z.ZodFirstPartyTypeKind.ZodNull:
111
- result.type = Type.NULL;
112
- return returnResult(result);
113
- case z.ZodFirstPartyTypeKind.ZodAny:
114
- case z.ZodFirstPartyTypeKind.ZodUnknown:
115
- return returnResult({ ...description && { description } });
116
- default:
117
- throw new Error(`Unsupported Zod type: ${def.typeName}`);
118
- }
119
- }
120
- function zodObjectToSchema(schema) {
121
- if (schema._def.typeName !== z.ZodFirstPartyTypeKind.ZodObject) {
122
- throw new Error("Expected a ZodObject");
123
- }
124
- const shape = schema.shape;
125
- const properties = {};
126
- const required = [];
127
- for (const key in shape) {
128
- const fieldSchema = shape[key];
129
- const parsedField = parseZodType(fieldSchema);
130
- if (parsedField) {
131
- properties[key] = parsedField;
132
- }
133
- let currentSchema = fieldSchema;
134
- let isOptional = false;
135
- while (currentSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodOptional || currentSchema._def.typeName === z.ZodFirstPartyTypeKind.ZodDefault) {
136
- isOptional = true;
137
- currentSchema = currentSchema._def.innerType;
138
- }
139
- if (!isOptional) {
140
- required.push(key);
141
- }
142
- }
143
- const catchall = schema._def.catchall;
144
- let additionalProperties = false;
145
- if (catchall && catchall._def.typeName !== z.ZodFirstPartyTypeKind.ZodNever) {
146
- additionalProperties = parseZodType(catchall) || true;
147
- } else {
148
- additionalProperties = schema._def.unknownKeys === "passthrough";
149
- }
150
- return {
151
- type: Type.OBJECT,
152
- properties,
153
- required: required.length > 0 ? required : [],
154
- ...schema._def.description ? { description: schema._def.description } : {}
155
- };
156
- }
157
- export {
158
- isZodObject,
159
- zodObjectToSchema
160
- };
@@ -1,24 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- var GoogleLLMVariant = /* @__PURE__ */ ((GoogleLLMVariant2) => {
7
- GoogleLLMVariant2["VERTEX_AI"] = "VERTEX_AI";
8
- GoogleLLMVariant2["GEMINI_API"] = "GEMINI_API";
9
- return GoogleLLMVariant2;
10
- })(GoogleLLMVariant || {});
11
- function getGoogleLlmVariant() {
12
- return getBooleanEnvVar("GOOGLE_GENAI_USE_VERTEXAI") ? "VERTEX_AI" /* VERTEX_AI */ : "GEMINI_API" /* GEMINI_API */;
13
- }
14
- function getBooleanEnvVar(envVar) {
15
- if (!process.env) {
16
- return false;
17
- }
18
- const envVarValue = (process.env[envVar] || "").toLowerCase();
19
- return ["true", "1"].includes(envVar.toLowerCase());
20
- }
21
- export {
22
- GoogleLLMVariant,
23
- getGoogleLlmVariant
24
- };
@@ -1,9 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- const version = "0.2.4";
7
- export {
8
- version
9
- };
@@ -1,14 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- class ActiveStreamingTool {
7
- constructor(params = {}) {
8
- this.task = params.task;
9
- this.stream = params.stream;
10
- }
11
- }
12
- export {
13
- ActiveStreamingTool
14
- };
@@ -1,265 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __spreadValues = (a, b) => {
10
- for (var prop in b || (b = {}))
11
- if (__hasOwnProp.call(b, prop))
12
- __defNormalProp(a, prop, b[prop]);
13
- if (__getOwnPropSymbols)
14
- for (var prop of __getOwnPropSymbols(b)) {
15
- if (__propIsEnum.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __await = function(promise, isYieldStar) {
22
- this[0] = promise;
23
- this[1] = isYieldStar;
24
- };
25
- var __asyncGenerator = (__this, __arguments, generator) => {
26
- var resume = (k, v, yes, no) => {
27
- try {
28
- var x = generator[k](v), isAwait = (v = x.value) instanceof __await, done = x.done;
29
- Promise.resolve(isAwait ? v[0] : v).then((y) => isAwait ? resume(k === "return" ? k : "next", v[1] ? { done: y.done, value: y.value } : y, yes, no) : yes({ value: y, done })).catch((e) => resume("throw", e, yes, no));
30
- } catch (e) {
31
- no(e);
32
- }
33
- }, method = (k) => it[k] = (x) => new Promise((yes, no) => resume(k, x, yes, no)), it = {};
34
- return generator = generator.apply(__this, __arguments), it[__knownSymbol("asyncIterator")] = () => it, method("next"), method("throw"), method("return"), it;
35
- };
36
- var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")]) ? it.call(obj) : (obj = obj[__knownSymbol("iterator")](), it = {}, method = (key, fn) => (fn = obj[key]) && (it[key] = (arg) => new Promise((yes, no, done) => (arg = fn.call(obj, arg), done = arg.done, Promise.resolve(arg.value).then((value) => yes({ value, done }), no)))), method("next"), method("return"), it);
37
- /**
38
- * @license
39
- * Copyright 2025 Google LLC
40
- * SPDX-License-Identifier: Apache-2.0
41
- */
42
- import { trace } from "@opentelemetry/api";
43
- import { createEvent } from "../events/event.js";
44
- import { CallbackContext } from "./callback_context.js";
45
- import { InvocationContext } from "./invocation_context.js";
46
- class BaseAgent {
47
- constructor(config) {
48
- this.name = validateAgentName(config.name);
49
- this.description = config.description;
50
- this.parentAgent = config.parentAgent;
51
- this.subAgents = config.subAgents || [];
52
- this.rootAgent = getRootAgent(this);
53
- this.beforeAgentCallback = getCannonicalCallback(config.beforeAgentCallback);
54
- this.afterAgentCallback = getCannonicalCallback(config.afterAgentCallback);
55
- this.setParentAgentForSubAgents();
56
- }
57
- /**
58
- * Entry method to run an agent via text-based conversation.
59
- *
60
- * @param parentContext The invocation context of the parent agent.
61
- * @yields The events generated by the agent.
62
- * @returns An AsyncGenerator that yields the events generated by the agent.
63
- */
64
- runAsync(parentContext) {
65
- return __asyncGenerator(this, null, function* () {
66
- const span = trace.getTracer("gcp.vertex.agent").startSpan("agent_run [".concat(this.name, "]"));
67
- try {
68
- const context = this.createInvocationContext(parentContext);
69
- const beforeAgentCallbackEvent = yield new __await(this.handleBeforeAgentCallback(context));
70
- if (beforeAgentCallbackEvent) {
71
- yield beforeAgentCallbackEvent;
72
- }
73
- if (context.endInvocation) {
74
- return;
75
- }
76
- try {
77
- for (var iter = __forAwait(this.runAsyncImpl(context)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
78
- const event = temp.value;
79
- yield event;
80
- }
81
- } catch (temp) {
82
- error = [temp];
83
- } finally {
84
- try {
85
- more && (temp = iter.return) && (yield new __await(temp.call(iter)));
86
- } finally {
87
- if (error)
88
- throw error[0];
89
- }
90
- }
91
- if (context.endInvocation) {
92
- return;
93
- }
94
- const afterAgentCallbackEvent = yield new __await(this.handleAfterAgentCallback(context));
95
- if (afterAgentCallbackEvent) {
96
- yield afterAgentCallbackEvent;
97
- }
98
- } finally {
99
- span.end();
100
- }
101
- });
102
- }
103
- /**
104
- * Entry method to run an agent via video/audio-based conversation.
105
- *
106
- * @param parentContext The invocation context of the parent agent.
107
- * @yields The events generated by the agent.
108
- * @returns An AsyncGenerator that yields the events generated by the agent.
109
- */
110
- runLive(parentContext) {
111
- return __asyncGenerator(this, null, function* () {
112
- const span = trace.getTracer("gcp.vertex.agent").startSpan("agent_run [".concat(this.name, "]"));
113
- try {
114
- throw new Error("Live mode is not implemented yet.");
115
- } finally {
116
- span.end();
117
- }
118
- });
119
- }
120
- /**
121
- * Finds the agent with the given name in this agent and its descendants.
122
- *
123
- * @param name The name of the agent to find.
124
- * @return The agent with the given name, or undefined if not found.
125
- */
126
- findAgent(name) {
127
- if (this.name === name) {
128
- return this;
129
- }
130
- return this.findSubAgent(name);
131
- }
132
- /**
133
- * Finds the agent with the given name in this agent's descendants.
134
- *
135
- * @param name The name of the agent to find.
136
- * @return The agent with the given name, or undefined if not found.
137
- */
138
- findSubAgent(name) {
139
- for (const subAgent of this.subAgents) {
140
- const result = subAgent.findAgent(name);
141
- if (result) {
142
- return result;
143
- }
144
- }
145
- return void 0;
146
- }
147
- /**
148
- * Creates an invocation context for this agent.
149
- *
150
- * @param parentContext The invocation context of the parent agent.
151
- * @return The invocation context for this agent.
152
- */
153
- createInvocationContext(parentContext) {
154
- return new InvocationContext(__spreadProps(__spreadValues({}, parentContext), {
155
- agent: this
156
- }));
157
- }
158
- /**
159
- * Runs the before agent callback if it exists.
160
- *
161
- * @param invocationContext The invocation context of the agent.
162
- * @return The event to return to the user, or undefined if no event is
163
- * generated.
164
- */
165
- async handleBeforeAgentCallback(invocationContext) {
166
- if (this.beforeAgentCallback.length === 0) {
167
- return void 0;
168
- }
169
- const callbackContext = new CallbackContext({ invocationContext });
170
- for (const callback of this.beforeAgentCallback) {
171
- const content = await callback(callbackContext);
172
- if (content) {
173
- invocationContext.endInvocation = true;
174
- return createEvent({
175
- invocationId: invocationContext.invocationId,
176
- author: this.name,
177
- branch: invocationContext.branch,
178
- content,
179
- actions: callbackContext.eventActions
180
- });
181
- }
182
- }
183
- if (callbackContext.state.hasDelta()) {
184
- return createEvent({
185
- invocationId: invocationContext.invocationId,
186
- author: this.name,
187
- branch: invocationContext.branch,
188
- actions: callbackContext.eventActions
189
- });
190
- }
191
- return void 0;
192
- }
193
- /**
194
- * Runs the after agent callback if it exists.
195
- *
196
- * @param invocationContext The invocation context of the agent.
197
- * @return The event to return to the user, or undefined if no event is
198
- * generated.
199
- */
200
- async handleAfterAgentCallback(invocationContext) {
201
- if (this.afterAgentCallback.length === 0) {
202
- return void 0;
203
- }
204
- const callbackContext = new CallbackContext({ invocationContext });
205
- for (const callback of this.afterAgentCallback) {
206
- const content = await callback(callbackContext);
207
- if (content) {
208
- return createEvent({
209
- invocationId: invocationContext.invocationId,
210
- author: this.name,
211
- branch: invocationContext.branch,
212
- content,
213
- actions: callbackContext.eventActions
214
- });
215
- }
216
- }
217
- if (callbackContext.state.hasDelta()) {
218
- return createEvent({
219
- invocationId: invocationContext.invocationId,
220
- author: this.name,
221
- branch: invocationContext.branch,
222
- actions: callbackContext.eventActions
223
- });
224
- }
225
- return void 0;
226
- }
227
- setParentAgentForSubAgents() {
228
- for (const subAgent of this.subAgents) {
229
- if (subAgent.parentAgent) {
230
- throw new Error('Agent "'.concat(subAgent.name, '" already has a parent agent, current parent: "').concat(subAgent.parentAgent.name, '", trying to add: "').concat(this.name, '"'));
231
- }
232
- subAgent.parentAgent = this;
233
- }
234
- }
235
- }
236
- function validateAgentName(name) {
237
- if (!isIdentifier(name)) {
238
- throw new Error('Found invalid agent name: "'.concat(name, '". Agent name must be a valid identifier. It should start with a letter (a-z, A-Z) or an underscore (_), and can only contain letters, digits (0-9), and underscores.'));
239
- }
240
- if (name === "user") {
241
- throw new Error(
242
- "Agent name cannot be 'user'. 'user' is reserved for end-user's input."
243
- );
244
- }
245
- return name;
246
- }
247
- function isIdentifier(str) {
248
- return new RegExp("^[\\p{ID_Start}$_][\\p{ID_Continue}$_]*$", "u").test(str);
249
- }
250
- function getRootAgent(rootAgent) {
251
- while (rootAgent.parentAgent) {
252
- rootAgent = rootAgent.parentAgent;
253
- }
254
- return rootAgent;
255
- }
256
- function getCannonicalCallback(callbacks) {
257
- if (!callbacks) {
258
- return [];
259
- }
260
- return Array.isArray(callbacks) ? callbacks : [callbacks];
261
- }
262
- export {
263
- BaseAgent,
264
- getCannonicalCallback
265
- };
@@ -1,13 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- class BaseLlmRequestProcessor {
7
- }
8
- class BaseLlmResponseProcessor {
9
- }
10
- export {
11
- BaseLlmRequestProcessor,
12
- BaseLlmResponseProcessor
13
- };
@@ -1,68 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { createEventActions } from "../events/event_actions.js";
7
- import { State } from "../sessions/state.js";
8
- import { ReadonlyContext } from "./readonly_context.js";
9
- class CallbackContext extends ReadonlyContext {
10
- constructor({ invocationContext, eventActions }) {
11
- super(invocationContext);
12
- this.eventActions = eventActions || createEventActions();
13
- this._state = new State(
14
- invocationContext.session.state,
15
- this.eventActions.stateDelta
16
- );
17
- }
18
- /**
19
- * The delta-aware state of the current session.
20
- */
21
- get state() {
22
- return this._state;
23
- }
24
- /**
25
- * Loads an artifact attached to the current session.
26
- *
27
- * @param filename The filename of the artifact.
28
- * @param version The version of the artifact. If not provided, the latest
29
- * version will be used.
30
- * @return A promise that resolves to the loaded artifact.
31
- */
32
- loadArtifact(filename, version) {
33
- if (!this.invocationContext.artifactService) {
34
- throw new Error("Artifact service is not initialized.");
35
- }
36
- return this.invocationContext.artifactService.loadArtifact({
37
- appName: this.invocationContext.appName,
38
- userId: this.invocationContext.userId,
39
- sessionId: this.invocationContext.session.id,
40
- filename,
41
- version
42
- });
43
- }
44
- /**
45
- * Saves an artifact attached to the current session.
46
- *
47
- * @param filename The filename of the artifact.
48
- * @param artifact The artifact to save.
49
- * @return A promise that resolves to the version of the saved artifact.
50
- */
51
- async saveArtifact(filename, artifact) {
52
- if (!this.invocationContext.artifactService) {
53
- throw new Error("Artifact service is not initialized.");
54
- }
55
- const version = await this.invocationContext.artifactService.saveArtifact({
56
- appName: this.invocationContext.appName,
57
- userId: this.invocationContext.userId,
58
- sessionId: this.invocationContext.session.id,
59
- filename,
60
- artifact
61
- });
62
- this.eventActions.artifactDelta[filename] = version;
63
- return version;
64
- }
65
- }
66
- export {
67
- CallbackContext
68
- };