@google/adk 0.6.0 → 0.6.1

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.
@@ -1,3 +1,34 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
1
32
  /**
2
33
  * @license
3
34
  * Copyright 2025 Google LLC
@@ -26,22 +57,50 @@ function toGeminiType(mcpType) {
26
57
  return Type.ARRAY;
27
58
  case "object":
28
59
  return Type.OBJECT;
60
+ case "null":
61
+ return Type.NULL;
29
62
  default:
30
63
  return Type.TYPE_UNSPECIFIED;
31
64
  }
32
65
  }
66
+ const getTypeFromArrayItem = (mcpType) => {
67
+ var _a, _b;
68
+ if (typeof mcpType === "string") {
69
+ return mcpType.toLowerCase();
70
+ }
71
+ return (_b = (_a = mcpType == null ? void 0 : mcpType.type) == null ? void 0 : _a.toLowerCase) == null ? void 0 : _b.call(_a);
72
+ };
33
73
  function toGeminiSchema(mcpSchema) {
34
74
  if (!mcpSchema) {
35
75
  return void 0;
36
76
  }
37
77
  function recursiveConvert(mcp) {
38
- if (!mcp.type && mcp.anyOf && Array.isArray(mcp.anyOf)) {
39
- const nonNullOption = mcp.anyOf.find((opt) => {
40
- const t = opt.type;
41
- return t !== "null" && t !== "NULL";
42
- });
43
- if (nonNullOption) {
44
- mcp = nonNullOption;
78
+ var _a;
79
+ const sourceType = (_a = mcp.anyOf) != null ? _a : mcp.type;
80
+ let isNullable = false;
81
+ let nonNullTypes;
82
+ if (Array.isArray(sourceType)) {
83
+ nonNullTypes = sourceType.filter(
84
+ (t) => getTypeFromArrayItem(t) !== "null"
85
+ );
86
+ isNullable = sourceType.some(
87
+ (t) => getTypeFromArrayItem(t) === "null"
88
+ );
89
+ if (nonNullTypes.length === 1) {
90
+ const nonNullType = nonNullTypes[0];
91
+ if (typeof nonNullType === "object") {
92
+ mcp = nonNullType;
93
+ } else {
94
+ const _b = mcp, { type: _removed, anyOf: _removedAnyOf } = _b, rest = __objRest(_b, ["type", "anyOf"]);
95
+ mcp = __spreadProps(__spreadValues({}, rest), { type: nonNullType });
96
+ }
97
+ } else if (nonNullTypes.length === 0 && isNullable) {
98
+ const _c = mcp, { type: _removed, anyOf: _removedAnyOf } = _c, rest = __objRest(_c, ["type", "anyOf"]);
99
+ mcp = __spreadProps(__spreadValues({}, rest), { type: "null" });
100
+ } else if (typeof mcp.anyOf === "undefined") {
101
+ const anyOfItems = mcp.type.map((t) => ({ type: t }));
102
+ const _d = mcp, { type: _removed } = _d, rest = __objRest(_d, ["type"]);
103
+ mcp = __spreadProps(__spreadValues({}, rest), { anyOf: anyOfItems });
45
104
  }
46
105
  }
47
106
  if (!mcp.type) {
@@ -49,13 +108,25 @@ function toGeminiSchema(mcpSchema) {
49
108
  mcp.type = "object";
50
109
  } else if (mcp.items) {
51
110
  mcp.type = "array";
111
+ } else if (isNullable) {
112
+ mcp.type = "null";
52
113
  }
53
114
  }
54
115
  const geminiType = toGeminiType(mcp.type);
55
- const geminiSchema = {
56
- type: geminiType,
57
- description: mcp.description
58
- };
116
+ const geminiSchema = {};
117
+ if (mcp.anyOf) {
118
+ geminiSchema.anyOf = mcp.anyOf.map(
119
+ (item) => recursiveConvert(item)
120
+ );
121
+ } else {
122
+ geminiSchema.type = geminiType;
123
+ }
124
+ if (mcp.description) {
125
+ geminiSchema.description = mcp.description;
126
+ }
127
+ if (isNullable && mcp.type !== "null") {
128
+ geminiSchema.nullable = true;
129
+ }
59
130
  if (geminiType === Type.OBJECT) {
60
131
  geminiSchema.properties = {};
61
132
  if (mcp.properties) {
@@ -65,7 +136,9 @@ function toGeminiSchema(mcpSchema) {
65
136
  );
66
137
  }
67
138
  }
68
- geminiSchema.required = mcp.required;
139
+ if (mcp.required) {
140
+ geminiSchema.required = mcp.required;
141
+ }
69
142
  } else if (geminiType === Type.ARRAY) {
70
143
  if (mcp.items) {
71
144
  geminiSchema.items = recursiveConvert(mcp.items);
@@ -3,7 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- const version = "0.6.0";
6
+ const version = "0.6.1";
7
7
  export {
8
8
  version
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/adk",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Google ADK JS",
5
5
  "author": "Google",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "dependencies": {
43
43
  "@a2a-js/sdk": "^0.3.10",
44
44
  "@google/genai": "^1.37.0",
45
- "@mikro-orm/core": "^6.6.6",
45
+ "@mikro-orm/core": "^6.6.10",
46
46
  "@mikro-orm/reflection": "^6.6.6",
47
47
  "@modelcontextprotocol/sdk": "^1.26.0",
48
48
  "express": "^4.22.1",