@benjamolina/pi-antigravity-guard 0.5.1 → 0.6.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,6 @@
1
+ import { EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION, EMPTY_SCHEMA_PLACEHOLDER_NAME, cleanJSONSchemaForAntigravity, toGeminiSchema, } from "@benjamolina/antigravity-guard-core";
1
2
  import { denseArray, fail, freeze, ownData, plainObject } from "./tool-contract.js";
3
+ export { cleanJSONSchemaForAntigravity, toGeminiSchema };
2
4
  const MAX_SCHEMA_DEPTH = 32;
3
5
  const MAX_SCHEMA_NODES = 2048;
4
6
  const MAX_SCHEMA_BYTES = 256 * 1024;
@@ -218,34 +220,26 @@ function isJsonObject(value) {
218
220
  function define(target, key, value) {
219
221
  Object.defineProperty(target, key, { value, enumerable: true, configurable: false, writable: false });
220
222
  }
221
- const CUSTOM_TOOL_SCHEMA_ALLOW = new Set([
222
- "type",
223
- "description",
224
- "properties",
225
- "required",
226
- "items",
227
- "enum",
228
- ]);
229
223
  export function normalizeCustomToolSchema(schema) {
230
224
  if (!schema || typeof schema !== "object" || Array.isArray(schema))
231
225
  return {};
232
- const out = {};
233
- for (const [key, value] of Object.entries(schema)) {
234
- if (!CUSTOM_TOOL_SCHEMA_ALLOW.has(key))
235
- continue;
236
- if (key === "properties" && value && typeof value === "object" && !Array.isArray(value)) {
237
- const props = {};
238
- for (const [propName, propSchema] of Object.entries(value)) {
239
- props[propName] = normalizeCustomToolSchema(propSchema);
240
- }
241
- out.properties = props;
242
- continue;
243
- }
244
- if (key === "items") {
245
- out.items = normalizeCustomToolSchema(value);
246
- continue;
247
- }
248
- out[key] = value;
226
+ const cleaned = cleanJSONSchemaForAntigravity(schema);
227
+ if (!cleaned || typeof cleaned !== "object" || Array.isArray(cleaned))
228
+ return {};
229
+ const hasProperties = cleaned.properties !== null &&
230
+ typeof cleaned.properties === "object" &&
231
+ !Array.isArray(cleaned.properties) &&
232
+ Object.keys(cleaned.properties).length > 0;
233
+ if (cleaned.type === "object" && !hasProperties) {
234
+ cleaned.properties = {
235
+ [EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
236
+ type: "boolean",
237
+ description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION,
238
+ },
239
+ };
240
+ cleaned.required = Array.isArray(cleaned.required)
241
+ ? Array.from(new Set([...cleaned.required, EMPTY_SCHEMA_PLACEHOLDER_NAME]))
242
+ : [EMPTY_SCHEMA_PLACEHOLDER_NAME];
249
243
  }
250
- return out;
244
+ return cleaned;
251
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@benjamolina/pi-antigravity-guard",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "Pi adapter for Antigravity Guard",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -29,7 +29,7 @@
29
29
  ]
30
30
  },
31
31
  "dependencies": {
32
- "@benjamolina/antigravity-guard-core": "0.2.0"
32
+ "@benjamolina/antigravity-guard-core": "0.3.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@earendil-works/pi-ai": "*",