@composio/core 0.15.0 → 0.16.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.
@@ -1,4 +1,4 @@
1
- import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-Bhom9a2R.mjs";
1
+ import { a as CreateCustomToolkitParams, f as CustomToolkit, o as CustomTool, r as CreateCustomToolParams, t as AnyZodSchema } from "./customTool.types-cGHcIBX-.mjs";
2
2
  import { SessionCreateResponse } from "@composio/client/resources/tool-router/session/session.mjs";
3
3
  //#region src/models/CustomTool.d.ts
4
4
  /**
@@ -172,6 +172,74 @@ function dereferenceJsonSchema(schema, options) {
172
172
  return out;
173
173
  }
174
174
  /**
175
+ * Returns a deep-cloned JSON Schema in which every node that carries a
176
+ * `properties` keyword also carries `type: "object"` when it has no explicit
177
+ * `type`. OpenAI tolerates the omission, but Google Gemini enforces OpenAPI
178
+ * 3.0 strictly and rejects function declarations whose nested objects are
179
+ * missing the `type` (see https://github.com/ComposioHQ/composio/issues/4022).
180
+ *
181
+ * The function follows JSON Schema's schema-bearing keywords while keeping
182
+ * property maps and instance values as containers. Nodes that already declare
183
+ * a `type` are left untouched.
184
+ */
185
+ function ensureObjectTypeOnProperties(schema) {
186
+ const schemaKeywords = /* @__PURE__ */ new Set([
187
+ "additionalItems",
188
+ "additionalProperties",
189
+ "contains",
190
+ "contentSchema",
191
+ "else",
192
+ "if",
193
+ "not",
194
+ "propertyNames",
195
+ "then",
196
+ "unevaluatedItems",
197
+ "unevaluatedProperties"
198
+ ]);
199
+ const schemaArrayKeywords = /* @__PURE__ */ new Set([
200
+ "allOf",
201
+ "anyOf",
202
+ "oneOf",
203
+ "prefixItems"
204
+ ]);
205
+ const schemaMapKeywords = /* @__PURE__ */ new Set([
206
+ "$defs",
207
+ "definitions",
208
+ "dependentSchemas",
209
+ "patternProperties",
210
+ "properties"
211
+ ]);
212
+ function walk(value, mode, depth = 0) {
213
+ if (depth > MAX_NODE_DEPTH) throw new RangeError(`JSON Schema exceeds maximum nesting depth of ${MAX_NODE_DEPTH}`);
214
+ if (Array.isArray(value)) {
215
+ const itemMode = mode === "schema-array" ? "schema" : "value";
216
+ return value.map((item) => walk(item, itemMode, depth + 1));
217
+ }
218
+ if (!isPlainObject(value)) return value;
219
+ const clone = {};
220
+ for (const [key, child] of Object.entries(value)) {
221
+ let childMode = "value";
222
+ if (mode === "schema-map") childMode = "schema";
223
+ else if (mode === "dependencies-map") childMode = Array.isArray(child) ? "value" : "schema";
224
+ else if (mode === "schema") {
225
+ if (schemaMapKeywords.has(key)) childMode = "schema-map";
226
+ else if (schemaArrayKeywords.has(key) || key === "items" && Array.isArray(child)) childMode = "schema-array";
227
+ else if (schemaKeywords.has(key) || key === "items") childMode = "schema";
228
+ else if (key === "dependencies") childMode = "dependencies-map";
229
+ }
230
+ Object.defineProperty(clone, key, {
231
+ configurable: true,
232
+ enumerable: true,
233
+ value: walk(child, childMode, depth + 1),
234
+ writable: true
235
+ });
236
+ }
237
+ if (mode === "schema" && clone.properties !== void 0 && clone.type === void 0) clone.type = "object";
238
+ return clone;
239
+ }
240
+ return walk(schema, "schema");
241
+ }
242
+ /**
175
243
  * Returns a deep-cloned JSON Schema whose `required` arrays contain each entry
176
244
  * at most once. Duplicate entries are invalid in JSON Schema 2020-12 but do
177
245
  * not change the schema's meaning, so preserving the first occurrence is safe.
@@ -293,4 +361,4 @@ async function withCancellation(call, signal) {
293
361
  }
294
362
 
295
363
  //#endregion
296
- export { removeNonRequiredProperties as a, jsonSchemaToZodSchema as i, deduplicateJsonSchemaRequiredArrays as n, dereferenceJsonSchema as r, withCancellation as t };
364
+ export { jsonSchemaToZodSchema as a, ensureObjectTypeOnProperties as i, deduplicateJsonSchemaRequiredArrays as n, removeNonRequiredProperties as o, dereferenceJsonSchema as r, withCancellation as t };