@cortexkit/opencode-antigravity-auth 3.0.2 → 3.0.3

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/server.js CHANGED
@@ -20437,11 +20437,11 @@ var AccountManager = class _AccountManager {
20437
20437
  usage: () => this.requestSaveToDisk(),
20438
20438
  stale: (account, label) => this.ignoreStale(account, label)
20439
20439
  },
20440
- // A repository-backed manager gets its own new trackers. A pool-file
20441
- // manager without supplied trackers shares the process-wide ones
20442
- // (`getHealthTracker`, `getTokenTracker`), as it always has.
20443
- healthTracker: options.healthTracker ?? (repositoryBacked ? new HealthScoreTracker() : getHealthTracker),
20444
- tokenTracker: options.tokenTracker ?? (repositoryBacked ? new TokenBucketTracker() : getTokenTracker),
20440
+ // A repository-backed manager gets its own new trackers, which run on
20441
+ // this manager's clock. A pool-file manager without supplied trackers
20442
+ // shares the process-wide ones (`getHealthTracker`, `getTokenTracker`).
20443
+ healthTracker: options.healthTracker ?? (repositoryBacked ? new HealthScoreTracker({}, this.now) : getHealthTracker),
20444
+ tokenTracker: options.tokenTracker ?? (repositoryBacked ? new TokenBucketTracker({}, this.now) : getTokenTracker),
20445
20445
  now: this.now,
20446
20446
  random: options.random ?? (() => Math.random()),
20447
20447
  pid: options.pid ?? process.pid,
@@ -24237,29 +24237,29 @@ function appendClaudeThinkingHint(payload, hint = CLAUDE_INTERLEAVED_THINKING_HI
24237
24237
  }
24238
24238
 
24239
24239
  // ../core/dist/transform/gemini.js
24240
- var UNSUPPORTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
24241
- "additionalProperties",
24242
- "$schema",
24243
- "$id",
24244
- "$comment",
24245
- "$ref",
24246
- "$defs",
24247
- "definitions",
24248
- "const",
24249
- "contentMediaType",
24250
- "contentEncoding",
24251
- "if",
24252
- "then",
24253
- "else",
24254
- "not",
24255
- "patternProperties",
24256
- "unevaluatedProperties",
24257
- "unevaluatedItems",
24258
- "dependentRequired",
24259
- "dependentSchemas",
24260
- "propertyNames",
24261
- "minContains",
24262
- "maxContains"
24240
+ var ALLOWED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
24241
+ "type",
24242
+ "properties",
24243
+ "items",
24244
+ "required",
24245
+ "description",
24246
+ "format",
24247
+ "pattern",
24248
+ "title",
24249
+ "nullable",
24250
+ "propertyOrdering",
24251
+ "example",
24252
+ "default",
24253
+ "enum",
24254
+ "anyOf",
24255
+ "minimum",
24256
+ "maximum",
24257
+ "minLength",
24258
+ "maxLength",
24259
+ "minItems",
24260
+ "maxItems",
24261
+ "minProperties",
24262
+ "maxProperties"
24263
24263
  ]);
24264
24264
  var NUMERIC_SCHEMA_CONSTRAINTS = /* @__PURE__ */ new Set([
24265
24265
  "minLength",
@@ -24274,13 +24274,121 @@ var NUMERIC_SCHEMA_CONSTRAINTS = /* @__PURE__ */ new Set([
24274
24274
  "exclusiveMaximum",
24275
24275
  "multipleOf"
24276
24276
  ]);
24277
+ function isSchemaObject(value) {
24278
+ return value !== null && typeof value === "object" && !Array.isArray(value);
24279
+ }
24280
+ function describeValue(value) {
24281
+ return JSON.stringify(value) ?? String(value);
24282
+ }
24283
+ function sameSchemaValue(left, right) {
24284
+ if (left === right)
24285
+ return true;
24286
+ if (Array.isArray(left) && Array.isArray(right)) {
24287
+ return left.length === right.length && left.every((value, index) => sameSchemaValue(value, right[index]));
24288
+ }
24289
+ if (!isSchemaObject(left) || !isSchemaObject(right))
24290
+ return false;
24291
+ const keys = Object.keys(left);
24292
+ return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && sameSchemaValue(left[key], right[key]));
24293
+ }
24294
+ function mergeSchemaAllOf(schema, hints) {
24295
+ if (!Array.isArray(schema.allOf))
24296
+ return schema;
24297
+ const { allOf, ...base } = schema;
24298
+ const branches = [base, ...allOf];
24299
+ const properties = {};
24300
+ const required2 = /* @__PURE__ */ new Set();
24301
+ const descriptions = [];
24302
+ const metadata = {};
24303
+ let unambiguous = allOf.length > 0;
24304
+ for (const branch of branches) {
24305
+ if (!isSchemaObject(branch) || branch.type !== void 0 && String(branch.type).toUpperCase() !== "OBJECT" || branch.properties !== void 0 && !isSchemaObject(branch.properties)) {
24306
+ unambiguous = false;
24307
+ break;
24308
+ }
24309
+ for (const [key, value] of Object.entries(branch)) {
24310
+ if (!["properties", "required", "description"].includes(key) && !Object.hasOwn(metadata, key))
24311
+ metadata[key] = value;
24312
+ }
24313
+ if (typeof branch.description === "string")
24314
+ descriptions.push(branch.description);
24315
+ for (const [name, property] of Object.entries(branch.properties ?? {})) {
24316
+ if (Object.hasOwn(properties, name) && !sameSchemaValue(properties[name], property))
24317
+ unambiguous = false;
24318
+ properties[name] = property;
24319
+ }
24320
+ if (Array.isArray(branch.required)) {
24321
+ for (const name of branch.required) {
24322
+ if (typeof name === "string")
24323
+ required2.add(name);
24324
+ }
24325
+ }
24326
+ }
24327
+ if (unambiguous) {
24328
+ return {
24329
+ ...metadata,
24330
+ type: "object",
24331
+ properties,
24332
+ ...required2.size ? { required: [...required2] } : {},
24333
+ ...descriptions.length ? { description: descriptions.join(" ") } : {}
24334
+ };
24335
+ }
24336
+ hints.push("allOf: using the first branch; other intersection constraints omitted.");
24337
+ const first = isSchemaObject(allOf[0]) ? allOf[0] : {};
24338
+ return {
24339
+ ...base,
24340
+ ...first,
24341
+ ...base.description ? { description: base.description } : {}
24342
+ };
24343
+ }
24344
+ var CLAUDE_VALIDATED_HINT_FIELDS = /* @__PURE__ */ new Set([
24345
+ "minLength",
24346
+ "maxLength",
24347
+ "minItems",
24348
+ "maxItems",
24349
+ "pattern",
24350
+ "format",
24351
+ "default"
24352
+ ]);
24353
+ function flattenClaudeUnion(schema, hints) {
24354
+ if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0)
24355
+ return schema;
24356
+ const { anyOf, ...base } = schema;
24357
+ const branches = anyOf.filter(isSchemaObject);
24358
+ if (!branches.length)
24359
+ return base;
24360
+ if (branches.length === anyOf.length && branches.every((branch) => Array.isArray(branch.enum) && branch.enum.length > 0 && branch.enum.every((value) => typeof value === "string") && (branch.type === void 0 || branch.type === "STRING") && !branch.properties && !branch.items)) {
24361
+ return {
24362
+ ...base,
24363
+ type: "STRING",
24364
+ enum: [...new Set(branches.flatMap((branch) => branch.enum))]
24365
+ };
24366
+ }
24367
+ const typeName = (branch) => branch.properties ? "object" : branch.items ? "array" : String(branch.type ?? "null").toLowerCase();
24368
+ const score = (branch) => {
24369
+ const type = typeName(branch);
24370
+ return type === "object" ? 3 : type === "array" ? 2 : type === "null" ? 0 : 1;
24371
+ };
24372
+ let selected = branches[0];
24373
+ for (const branch of branches.slice(1)) {
24374
+ if (score(branch) > score(selected))
24375
+ selected = branch;
24376
+ }
24377
+ const result = { ...base, ...selected };
24378
+ if (typeof base.description === "string" && base.description) {
24379
+ result.description = typeof selected.description === "string" && selected.description && selected.description !== base.description ? `${base.description} (${selected.description})` : base.description;
24380
+ }
24381
+ if (branches.length > 1)
24382
+ hints.push(`Accepts: ${[...new Set(branches.map(typeName))].join(" | ")}`);
24383
+ return result;
24384
+ }
24277
24385
  function toGeminiSchema(schema, options = {}) {
24278
24386
  if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
24279
24387
  return schema;
24280
24388
  }
24281
- const inputSchema = schema;
24282
- const result = {};
24283
24389
  const numericConstraintHints = [];
24390
+ const inputSchema = mergeSchemaAllOf(schema, numericConstraintHints);
24391
+ let result = {};
24284
24392
  const propertyNames = /* @__PURE__ */ new Set();
24285
24393
  if (inputSchema.properties && typeof inputSchema.properties === "object") {
24286
24394
  for (const propName of Object.keys(inputSchema.properties)) {
@@ -24288,9 +24396,51 @@ function toGeminiSchema(schema, options = {}) {
24288
24396
  }
24289
24397
  }
24290
24398
  for (const [key, value] of Object.entries(inputSchema)) {
24291
- if (UNSUPPORTED_SCHEMA_FIELDS.has(key)) {
24399
+ if (options.claudeValidated) {
24400
+ if (key === "title")
24401
+ continue;
24402
+ if (key === "additionalProperties" && value === false)
24403
+ numericConstraintHints.push("No extra properties allowed");
24404
+ if (CLAUDE_VALIDATED_HINT_FIELDS.has(key)) {
24405
+ if (value !== void 0 && typeof value !== "object")
24406
+ numericConstraintHints.push(`${key}: ${value}`);
24407
+ continue;
24408
+ }
24409
+ }
24410
+ if (key === "const") {
24411
+ if (typeof value === "string")
24412
+ result.enum = [value];
24413
+ else
24414
+ numericConstraintHints.push(`Must be ${describeValue(value)}.`);
24292
24415
  continue;
24293
24416
  }
24417
+ if (NUMERIC_SCHEMA_CONSTRAINTS.has(key)) {
24418
+ const exclusive = key === "exclusiveMinimum" || key === "exclusiveMaximum";
24419
+ if (exclusive && !options.moveNumericConstraintsToDescription && String(inputSchema.type).toUpperCase() === "INTEGER" && typeof value === "number" && Number.isFinite(value)) {
24420
+ const lower = key === "exclusiveMinimum";
24421
+ const bound = lower ? Math.floor(value) + 1 : Math.ceil(value) - 1;
24422
+ const inclusiveKey = lower ? "minimum" : "maximum";
24423
+ const existing = inputSchema[inclusiveKey];
24424
+ if (Number.isSafeInteger(bound)) {
24425
+ result[inclusiveKey] = typeof existing === "number" ? lower ? Math.max(existing, bound) : Math.min(existing, bound) : bound;
24426
+ continue;
24427
+ }
24428
+ }
24429
+ if (options.moveNumericConstraintsToDescription || exclusive || key === "multipleOf") {
24430
+ if (["string", "number", "boolean"].includes(typeof value))
24431
+ numericConstraintHints.push(`${key}: ${value}`);
24432
+ continue;
24433
+ }
24434
+ }
24435
+ if (key === "oneOf" && Array.isArray(value)) {
24436
+ if (!Array.isArray(inputSchema.anyOf))
24437
+ result.anyOf = value.map((item) => toGeminiSchema(item, options));
24438
+ else
24439
+ numericConstraintHints.push("oneOf: additional union constraints omitted.");
24440
+ continue;
24441
+ }
24442
+ if (!ALLOWED_SCHEMA_FIELDS.has(key))
24443
+ continue;
24294
24444
  if (key === "type" && typeof value === "string") {
24295
24445
  result[key] = value.toUpperCase();
24296
24446
  } else if (key === "properties" && typeof value === "object" && value !== null) {
@@ -24301,16 +24451,15 @@ function toGeminiSchema(schema, options = {}) {
24301
24451
  result[key] = props;
24302
24452
  } else if (key === "items" && typeof value === "object") {
24303
24453
  result[key] = toGeminiSchema(value, options);
24304
- } else if ((key === "anyOf" || key === "oneOf" || key === "allOf") && Array.isArray(value)) {
24454
+ } else if (key === "anyOf" && Array.isArray(value)) {
24305
24455
  result[key] = value.map((item) => toGeminiSchema(item, options));
24306
24456
  } else if (key === "enum" && Array.isArray(value)) {
24307
- result[key] = value;
24308
- } else if (options.moveNumericConstraintsToDescription && NUMERIC_SCHEMA_CONSTRAINTS.has(key)) {
24309
- if (typeof value === "string" || typeof value === "number") {
24310
- numericConstraintHints.push(`${key}: ${value}`);
24457
+ if (value.every((item) => typeof item === "string")) {
24458
+ if (typeof inputSchema.const !== "string")
24459
+ result.enum = value;
24460
+ } else {
24461
+ numericConstraintHints.push(`Allowed values: ${value.map(describeValue).join(", ")}.`);
24311
24462
  }
24312
- } else if (key === "default" || key === "examples") {
24313
- result[key] = value;
24314
24463
  } else if (key === "required" && Array.isArray(value)) {
24315
24464
  if (propertyNames.size > 0) {
24316
24465
  const validRequired = value.filter((prop) => typeof prop === "string" && propertyNames.has(prop));
@@ -24320,10 +24469,23 @@ function toGeminiSchema(schema, options = {}) {
24320
24469
  } else {
24321
24470
  result[key] = value;
24322
24471
  }
24472
+ } else if ((key === "minimum" || key === "maximum") && typeof result[key] === "number" && typeof value === "number") {
24473
+ result[key] = key === "minimum" ? Math.max(result[key], value) : Math.min(result[key], value);
24323
24474
  } else {
24324
24475
  result[key] = value;
24325
24476
  }
24326
24477
  }
24478
+ if (options.claudeValidated) {
24479
+ result = flattenClaudeUnion(result, numericConstraintHints);
24480
+ if (isSchemaObject(result.properties) && Array.isArray(result.required)) {
24481
+ const properties = result.properties;
24482
+ const required2 = result.required.filter((name) => typeof name === "string" && Object.hasOwn(properties, name));
24483
+ if (required2.length)
24484
+ result.required = required2;
24485
+ else
24486
+ delete result.required;
24487
+ }
24488
+ }
24327
24489
  if (numericConstraintHints.length > 0) {
24328
24490
  const hint = numericConstraintHints.join(", ");
24329
24491
  result.description = typeof result.description === "string" && result.description ? `${result.description} (${hint})` : hint;
@@ -31570,10 +31732,6 @@ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync6, writeFileSy
31570
31732
  import { tmpdir as tmpdir3 } from "node:os";
31571
31733
  import { join as join16 } from "node:path";
31572
31734
  var DUMP_STATUS_TITLE = "## Gemini Dump Status";
31573
- var DUMP_ENABLED_TITLE = "## Gemini Dump Enabled";
31574
- var DUMP_DISABLED_TITLE = "## Gemini Dump Disabled";
31575
- var DUMP_USAGE_TITLE = "## Gemini Dump Usage";
31576
- var DUMP_USAGE = "Usage: `/gemini-dump`, `/gemini-dump on`, or `/gemini-dump off`.";
31577
31735
  var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
31578
31736
  var DEFAULT_DUMP_DIR = join16(tmpdir3(), "opencode-antigravity-gemini-dumps");
31579
31737
  var DUMP_DIR_MODE = 448;
@@ -31590,8 +31748,7 @@ function createGeminiDumpState(options = {}) {
31590
31748
  enabled = next;
31591
31749
  },
31592
31750
  dumpRequest: (input2) => enabled ? writeGeminiDump(input2) : null,
31593
- buildStatusSummary: (input2) => renderGeminiDumpStatus(input2?.enabled ?? enabled),
31594
- executeCommand: (input2) => renderGeminiDumpCommand(input2.argumentsText, input2.enabled ?? enabled)
31751
+ buildStatusSummary: (input2) => renderGeminiDumpStatus(input2?.enabled ?? enabled)
31595
31752
  };
31596
31753
  }
31597
31754
  var legacyDumpState = createGeminiDumpState();
@@ -31604,15 +31761,6 @@ function setGeminiDumpEnabled(enabled) {
31604
31761
  function getGeminiDumpDirectory() {
31605
31762
  return process.env[DUMP_DIR_ENV] || DEFAULT_DUMP_DIR;
31606
31763
  }
31607
- function parseGeminiDumpCommandAction(argumentsText) {
31608
- const normalized = argumentsText.trim().split(/\s+/).filter(Boolean);
31609
- if (normalized.length === 0) return { type: "status" };
31610
- if (normalized.length === 1 && normalized[0] === "on")
31611
- return { type: "enable" };
31612
- if (normalized.length === 1 && normalized[0] === "off")
31613
- return { type: "disable" };
31614
- return { type: "usage" };
31615
- }
31616
31764
  function renderGeminiDumpStatus(enabled) {
31617
31765
  return [
31618
31766
  DUMP_STATUS_TITLE,
@@ -31623,23 +31771,6 @@ function renderGeminiDumpStatus(enabled) {
31623
31771
  "- Warning: dumps contain prompt/session content; turn this off after debugging"
31624
31772
  ].join("\n");
31625
31773
  }
31626
- function renderGeminiDumpCommand(argumentsText, enabled) {
31627
- const action = parseGeminiDumpCommandAction(argumentsText);
31628
- if (action.type === "status") return renderGeminiDumpStatus(enabled);
31629
- if (action.type === "enable") {
31630
- return [DUMP_ENABLED_TITLE, "", renderGeminiDumpStatus(true)].join("\n");
31631
- }
31632
- if (action.type === "disable") {
31633
- return [DUMP_DISABLED_TITLE, "", renderGeminiDumpStatus(false)].join("\n");
31634
- }
31635
- return [
31636
- DUMP_USAGE_TITLE,
31637
- "",
31638
- DUMP_USAGE,
31639
- "",
31640
- renderGeminiDumpStatus(enabled)
31641
- ].join("\n");
31642
- }
31643
31774
  function hashText2(value) {
31644
31775
  return createHash14("sha256").update(value).digest("hex");
31645
31776
  }
@@ -32304,31 +32435,6 @@ function createSessionRecoveryHook(ctx, config) {
32304
32435
  // src/plugin/request-helpers.ts
32305
32436
  var log8 = createLogger4("request-helpers");
32306
32437
  var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
32307
- var UNSUPPORTED_CONSTRAINTS = [
32308
- "minLength",
32309
- "maxLength",
32310
- "exclusiveMinimum",
32311
- "exclusiveMaximum",
32312
- "pattern",
32313
- "minItems",
32314
- "maxItems",
32315
- "format",
32316
- "default",
32317
- "examples"
32318
- ];
32319
- var UNSUPPORTED_KEYWORDS = [
32320
- ...UNSUPPORTED_CONSTRAINTS,
32321
- "$schema",
32322
- "$defs",
32323
- "definitions",
32324
- "const",
32325
- "$ref",
32326
- "additionalProperties",
32327
- "propertyNames",
32328
- "title",
32329
- "$id",
32330
- "$comment"
32331
- ];
32332
32438
  function appendDescriptionHint(schema, hint) {
32333
32439
  if (!schema || typeof schema !== "object") {
32334
32440
  return schema;
@@ -32358,23 +32464,6 @@ function convertRefsToHints(schema) {
32358
32464
  }
32359
32465
  return result;
32360
32466
  }
32361
- function convertConstToEnum(schema) {
32362
- if (!schema || typeof schema !== "object") {
32363
- return schema;
32364
- }
32365
- if (Array.isArray(schema)) {
32366
- return schema.map((item) => convertConstToEnum(item));
32367
- }
32368
- const result = {};
32369
- for (const [key, value] of Object.entries(schema)) {
32370
- if (key === "const" && !schema.enum) {
32371
- result.enum = [value];
32372
- } else {
32373
- result[key] = convertConstToEnum(value);
32374
- }
32375
- }
32376
- return result;
32377
- }
32378
32467
  function addEnumHints(schema) {
32379
32468
  if (!schema || typeof schema !== "object") {
32380
32469
  return schema;
@@ -32383,7 +32472,7 @@ function addEnumHints(schema) {
32383
32472
  return schema.map((item) => addEnumHints(item));
32384
32473
  }
32385
32474
  let result = { ...schema };
32386
- if (Array.isArray(result.enum) && result.enum.length > 1 && result.enum.length <= 10) {
32475
+ if (Array.isArray(result.enum) && result.enum.every((value) => typeof value === "string") && result.enum.length > 1 && result.enum.length <= 10) {
32387
32476
  const vals = result.enum.map((v) => String(v)).join(", ");
32388
32477
  result = appendDescriptionHint(result, `Allowed: ${vals}`);
32389
32478
  }
@@ -32394,213 +32483,6 @@ function addEnumHints(schema) {
32394
32483
  }
32395
32484
  return result;
32396
32485
  }
32397
- function addAdditionalPropertiesHints(schema) {
32398
- if (!schema || typeof schema !== "object") {
32399
- return schema;
32400
- }
32401
- if (Array.isArray(schema)) {
32402
- return schema.map((item) => addAdditionalPropertiesHints(item));
32403
- }
32404
- let result = { ...schema };
32405
- if (result.additionalProperties === false) {
32406
- result = appendDescriptionHint(result, "No extra properties allowed");
32407
- }
32408
- for (const [key, value] of Object.entries(result)) {
32409
- if (key !== "additionalProperties" && typeof value === "object" && value !== null) {
32410
- result[key] = addAdditionalPropertiesHints(value);
32411
- }
32412
- }
32413
- return result;
32414
- }
32415
- function moveConstraintsToDescription(schema) {
32416
- if (!schema || typeof schema !== "object") {
32417
- return schema;
32418
- }
32419
- if (Array.isArray(schema)) {
32420
- return schema.map((item) => moveConstraintsToDescription(item));
32421
- }
32422
- let result = { ...schema };
32423
- for (const constraint of UNSUPPORTED_CONSTRAINTS) {
32424
- if (result[constraint] !== void 0 && typeof result[constraint] !== "object") {
32425
- result = appendDescriptionHint(
32426
- result,
32427
- `${constraint}: ${result[constraint]}`
32428
- );
32429
- }
32430
- }
32431
- for (const [key, value] of Object.entries(result)) {
32432
- if (typeof value === "object" && value !== null) {
32433
- result[key] = moveConstraintsToDescription(value);
32434
- }
32435
- }
32436
- return result;
32437
- }
32438
- function mergeAllOf(schema) {
32439
- if (!schema || typeof schema !== "object") {
32440
- return schema;
32441
- }
32442
- if (Array.isArray(schema)) {
32443
- return schema.map((item) => mergeAllOf(item));
32444
- }
32445
- const result = { ...schema };
32446
- if (Array.isArray(result.allOf)) {
32447
- const merged = {};
32448
- const mergedRequired = [];
32449
- for (const item of result.allOf) {
32450
- if (!item || typeof item !== "object") continue;
32451
- if (item.properties && typeof item.properties === "object") {
32452
- merged.properties = { ...merged.properties, ...item.properties };
32453
- }
32454
- if (Array.isArray(item.required)) {
32455
- for (const req of item.required) {
32456
- if (!mergedRequired.includes(req)) {
32457
- mergedRequired.push(req);
32458
- }
32459
- }
32460
- }
32461
- for (const [key, value] of Object.entries(item)) {
32462
- if (key !== "properties" && key !== "required" && merged[key] === void 0) {
32463
- merged[key] = value;
32464
- }
32465
- }
32466
- }
32467
- if (merged.properties) {
32468
- result.properties = { ...result.properties, ...merged.properties };
32469
- }
32470
- if (mergedRequired.length > 0) {
32471
- const existingRequired = Array.isArray(result.required) ? result.required : [];
32472
- result.required = Array.from(
32473
- /* @__PURE__ */ new Set([...existingRequired, ...mergedRequired])
32474
- );
32475
- }
32476
- for (const [key, value] of Object.entries(merged)) {
32477
- if (key !== "properties" && key !== "required" && result[key] === void 0) {
32478
- result[key] = value;
32479
- }
32480
- }
32481
- delete result.allOf;
32482
- }
32483
- for (const [key, value] of Object.entries(result)) {
32484
- if (typeof value === "object" && value !== null) {
32485
- result[key] = mergeAllOf(value);
32486
- }
32487
- }
32488
- return result;
32489
- }
32490
- function scoreSchemaOption(schema) {
32491
- if (!schema || typeof schema !== "object") {
32492
- return { score: 0, typeName: "unknown" };
32493
- }
32494
- const type = schema.type;
32495
- if (type === "object" || schema.properties) {
32496
- return { score: 3, typeName: "object" };
32497
- }
32498
- if (type === "array" || schema.items) {
32499
- return { score: 2, typeName: "array" };
32500
- }
32501
- if (type && type !== "null") {
32502
- return { score: 1, typeName: type };
32503
- }
32504
- return { score: 0, typeName: type || "null" };
32505
- }
32506
- function tryMergeEnumFromUnion(options) {
32507
- if (!Array.isArray(options) || options.length === 0) {
32508
- return null;
32509
- }
32510
- const enumValues = [];
32511
- for (const option of options) {
32512
- if (!option || typeof option !== "object") {
32513
- return null;
32514
- }
32515
- if (option.const !== void 0) {
32516
- enumValues.push(String(option.const));
32517
- continue;
32518
- }
32519
- if (Array.isArray(option.enum) && option.enum.length === 1) {
32520
- enumValues.push(String(option.enum[0]));
32521
- continue;
32522
- }
32523
- if (Array.isArray(option.enum) && option.enum.length > 0) {
32524
- for (const val of option.enum) {
32525
- enumValues.push(String(val));
32526
- }
32527
- continue;
32528
- }
32529
- if (option.properties || option.items || option.anyOf || option.oneOf || option.allOf) {
32530
- return null;
32531
- }
32532
- if (option.type && !option.const && !option.enum) {
32533
- return null;
32534
- }
32535
- }
32536
- return enumValues.length > 0 ? enumValues : null;
32537
- }
32538
- function flattenAnyOfOneOf(schema) {
32539
- if (!schema || typeof schema !== "object") {
32540
- return schema;
32541
- }
32542
- if (Array.isArray(schema)) {
32543
- return schema.map((item) => flattenAnyOfOneOf(item));
32544
- }
32545
- let result = { ...schema };
32546
- for (const unionKey of ["anyOf", "oneOf"]) {
32547
- if (Array.isArray(result[unionKey]) && result[unionKey].length > 0) {
32548
- const options = result[unionKey];
32549
- const parentDesc = typeof result.description === "string" ? result.description : "";
32550
- const mergedEnum = tryMergeEnumFromUnion(options);
32551
- if (mergedEnum !== null) {
32552
- const { [unionKey]: _2, ...rest2 } = result;
32553
- result = {
32554
- ...rest2,
32555
- type: "string",
32556
- enum: mergedEnum
32557
- };
32558
- if (parentDesc) {
32559
- result.description = parentDesc;
32560
- }
32561
- continue;
32562
- }
32563
- let bestIdx = 0;
32564
- let bestScore = -1;
32565
- const allTypes = [];
32566
- for (let i = 0; i < options.length; i++) {
32567
- const { score, typeName } = scoreSchemaOption(options[i]);
32568
- if (typeName) {
32569
- allTypes.push(typeName);
32570
- }
32571
- if (score > bestScore) {
32572
- bestScore = score;
32573
- bestIdx = i;
32574
- }
32575
- }
32576
- let selected = flattenAnyOfOneOf(options[bestIdx]) || { type: "string" };
32577
- if (parentDesc) {
32578
- const childDesc = typeof selected.description === "string" ? selected.description : "";
32579
- if (childDesc && childDesc !== parentDesc) {
32580
- selected = {
32581
- ...selected,
32582
- description: `${parentDesc} (${childDesc})`
32583
- };
32584
- } else if (!childDesc) {
32585
- selected = { ...selected, description: parentDesc };
32586
- }
32587
- }
32588
- if (allTypes.length > 1) {
32589
- const uniqueTypes = Array.from(new Set(allTypes));
32590
- const hint = `Accepts: ${uniqueTypes.join(" | ")}`;
32591
- selected = appendDescriptionHint(selected, hint);
32592
- }
32593
- const { [unionKey]: _, description: __, ...rest } = result;
32594
- result = { ...rest, ...selected };
32595
- }
32596
- }
32597
- for (const [key, value] of Object.entries(result)) {
32598
- if (typeof value === "object" && value !== null) {
32599
- result[key] = flattenAnyOfOneOf(value);
32600
- }
32601
- }
32602
- return result;
32603
- }
32604
32486
  function flattenTypeArrays(schema, nullableFields, currentPath) {
32605
32487
  if (!schema || typeof schema !== "object") {
32606
32488
  return schema;
@@ -32669,62 +32551,6 @@ function flattenTypeArrays(schema, nullableFields, currentPath) {
32669
32551
  }
32670
32552
  return result;
32671
32553
  }
32672
- function removeUnsupportedKeywords(schema, insideProperties = false) {
32673
- if (!schema || typeof schema !== "object") {
32674
- return schema;
32675
- }
32676
- if (Array.isArray(schema)) {
32677
- return schema.map((item) => removeUnsupportedKeywords(item, false));
32678
- }
32679
- const result = {};
32680
- for (const [key, value] of Object.entries(schema)) {
32681
- if (!insideProperties && UNSUPPORTED_KEYWORDS.includes(key)) {
32682
- continue;
32683
- }
32684
- if (typeof value === "object" && value !== null) {
32685
- if (key === "properties") {
32686
- const propertiesResult = {};
32687
- for (const [propName, propSchema] of Object.entries(value)) {
32688
- propertiesResult[propName] = removeUnsupportedKeywords(
32689
- propSchema,
32690
- false
32691
- );
32692
- }
32693
- result[key] = propertiesResult;
32694
- } else {
32695
- result[key] = removeUnsupportedKeywords(value, false);
32696
- }
32697
- } else {
32698
- result[key] = value;
32699
- }
32700
- }
32701
- return result;
32702
- }
32703
- function cleanupRequiredFields(schema) {
32704
- if (!schema || typeof schema !== "object") {
32705
- return schema;
32706
- }
32707
- if (Array.isArray(schema)) {
32708
- return schema.map((item) => cleanupRequiredFields(item));
32709
- }
32710
- const result = { ...schema };
32711
- if (Array.isArray(result.required) && result.properties && typeof result.properties === "object") {
32712
- const validRequired = result.required.filter(
32713
- (req) => Object.hasOwn(result.properties, req)
32714
- );
32715
- if (validRequired.length === 0) {
32716
- delete result.required;
32717
- } else if (validRequired.length !== result.required.length) {
32718
- result.required = validRequired;
32719
- }
32720
- }
32721
- for (const [key, value] of Object.entries(result)) {
32722
- if (typeof value === "object" && value !== null) {
32723
- result[key] = cleanupRequiredFields(value);
32724
- }
32725
- }
32726
- return result;
32727
- }
32728
32554
  function addEmptySchemaPlaceholder(schema) {
32729
32555
  if (!schema || typeof schema !== "object") {
32730
32556
  return schema;
@@ -32757,19 +32583,11 @@ function cleanJSONSchemaForAntigravity(schema) {
32757
32583
  if (!schema || typeof schema !== "object") {
32758
32584
  return schema;
32759
32585
  }
32760
- let result = schema;
32761
- result = convertRefsToHints(result);
32762
- result = convertConstToEnum(result);
32586
+ let result = convertRefsToHints(schema);
32763
32587
  result = addEnumHints(result);
32764
- result = addAdditionalPropertiesHints(result);
32765
- result = moveConstraintsToDescription(result);
32766
- result = mergeAllOf(result);
32767
- result = flattenAnyOfOneOf(result);
32768
32588
  result = flattenTypeArrays(result);
32769
- result = removeUnsupportedKeywords(result);
32770
- result = cleanupRequiredFields(result);
32771
32589
  result = addEmptySchemaPlaceholder(result);
32772
- return result;
32590
+ return toGeminiSchema(result, { claudeValidated: true });
32773
32591
  }
32774
32592
  var DEFAULT_THINKING_BUDGET = 16e3;
32775
32593
  function isThinkingCapableModel2(modelName) {
@@ -35465,10 +35283,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
35465
35283
  const normalizeSchema = (schema) => {
35466
35284
  const createPlaceholderSchema = (base = {}) => ({
35467
35285
  ...base,
35468
- type: "object",
35286
+ type: "OBJECT",
35469
35287
  properties: {
35470
35288
  [EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
35471
- type: "boolean",
35289
+ type: "BOOLEAN",
35472
35290
  description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION
35473
35291
  }
35474
35292
  },
@@ -35484,11 +35302,11 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
35484
35302
  return createPlaceholderSchema();
35485
35303
  }
35486
35304
  const hasProperties = cleaned.properties && typeof cleaned.properties === "object" && Object.keys(cleaned.properties).length > 0;
35487
- cleaned.type = "object";
35305
+ cleaned.type = "OBJECT";
35488
35306
  if (!hasProperties) {
35489
35307
  cleaned.properties = {
35490
35308
  [EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
35491
- type: "boolean",
35309
+ type: "BOOLEAN",
35492
35310
  description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION
35493
35311
  }
35494
35312
  };