@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/cli.meta.json +2 -2
- package/dist/index.js +208 -390
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +16 -11
- package/dist/server.js +208 -390
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/plugin/command-data.d.ts +2 -248
- package/dist/src/plugin/command-data.d.ts.map +1 -1
- package/dist/src/plugin/command-data.js +4 -397
- package/dist/src/plugin/command-data.js.map +1 -1
- package/dist/src/plugin/gemini-dump.d.ts +0 -22
- package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/src/plugin/gemini-dump.js +0 -39
- package/dist/src/plugin/gemini-dump.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +10 -417
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.js +4 -4
- package/dist/types/src/plugin/command-data.d.ts +2 -248
- package/dist/types/src/plugin/command-data.d.ts.map +1 -1
- package/dist/types/src/plugin/gemini-dump.d.ts +0 -22
- package/dist/types/src/plugin/gemini-dump.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/plugin/command-data.ts +5 -683
package/dist/index.js
CHANGED
|
@@ -20435,11 +20435,11 @@ var AccountManager = class _AccountManager {
|
|
|
20435
20435
|
usage: () => this.requestSaveToDisk(),
|
|
20436
20436
|
stale: (account, label) => this.ignoreStale(account, label)
|
|
20437
20437
|
},
|
|
20438
|
-
// A repository-backed manager gets its own new trackers
|
|
20439
|
-
// manager
|
|
20440
|
-
// (`getHealthTracker`, `getTokenTracker`)
|
|
20441
|
-
healthTracker: options.healthTracker ?? (repositoryBacked ? new HealthScoreTracker() : getHealthTracker),
|
|
20442
|
-
tokenTracker: options.tokenTracker ?? (repositoryBacked ? new TokenBucketTracker() : getTokenTracker),
|
|
20438
|
+
// A repository-backed manager gets its own new trackers, which run on
|
|
20439
|
+
// this manager's clock. A pool-file manager without supplied trackers
|
|
20440
|
+
// shares the process-wide ones (`getHealthTracker`, `getTokenTracker`).
|
|
20441
|
+
healthTracker: options.healthTracker ?? (repositoryBacked ? new HealthScoreTracker({}, this.now) : getHealthTracker),
|
|
20442
|
+
tokenTracker: options.tokenTracker ?? (repositoryBacked ? new TokenBucketTracker({}, this.now) : getTokenTracker),
|
|
20443
20443
|
now: this.now,
|
|
20444
20444
|
random: options.random ?? (() => Math.random()),
|
|
20445
20445
|
pid: options.pid ?? process.pid,
|
|
@@ -24235,29 +24235,29 @@ function appendClaudeThinkingHint(payload, hint = CLAUDE_INTERLEAVED_THINKING_HI
|
|
|
24235
24235
|
}
|
|
24236
24236
|
|
|
24237
24237
|
// ../core/dist/transform/gemini.js
|
|
24238
|
-
var
|
|
24239
|
-
"
|
|
24240
|
-
"
|
|
24241
|
-
"
|
|
24242
|
-
"
|
|
24243
|
-
"
|
|
24244
|
-
"
|
|
24245
|
-
"
|
|
24246
|
-
"
|
|
24247
|
-
"
|
|
24248
|
-
"
|
|
24249
|
-
"
|
|
24250
|
-
"
|
|
24251
|
-
"
|
|
24252
|
-
"
|
|
24253
|
-
"
|
|
24254
|
-
"
|
|
24255
|
-
"
|
|
24256
|
-
"
|
|
24257
|
-
"
|
|
24258
|
-
"
|
|
24259
|
-
"
|
|
24260
|
-
"
|
|
24238
|
+
var ALLOWED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
24239
|
+
"type",
|
|
24240
|
+
"properties",
|
|
24241
|
+
"items",
|
|
24242
|
+
"required",
|
|
24243
|
+
"description",
|
|
24244
|
+
"format",
|
|
24245
|
+
"pattern",
|
|
24246
|
+
"title",
|
|
24247
|
+
"nullable",
|
|
24248
|
+
"propertyOrdering",
|
|
24249
|
+
"example",
|
|
24250
|
+
"default",
|
|
24251
|
+
"enum",
|
|
24252
|
+
"anyOf",
|
|
24253
|
+
"minimum",
|
|
24254
|
+
"maximum",
|
|
24255
|
+
"minLength",
|
|
24256
|
+
"maxLength",
|
|
24257
|
+
"minItems",
|
|
24258
|
+
"maxItems",
|
|
24259
|
+
"minProperties",
|
|
24260
|
+
"maxProperties"
|
|
24261
24261
|
]);
|
|
24262
24262
|
var NUMERIC_SCHEMA_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
24263
24263
|
"minLength",
|
|
@@ -24272,13 +24272,121 @@ var NUMERIC_SCHEMA_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
|
24272
24272
|
"exclusiveMaximum",
|
|
24273
24273
|
"multipleOf"
|
|
24274
24274
|
]);
|
|
24275
|
+
function isSchemaObject(value) {
|
|
24276
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
24277
|
+
}
|
|
24278
|
+
function describeValue(value) {
|
|
24279
|
+
return JSON.stringify(value) ?? String(value);
|
|
24280
|
+
}
|
|
24281
|
+
function sameSchemaValue(left, right) {
|
|
24282
|
+
if (left === right)
|
|
24283
|
+
return true;
|
|
24284
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
24285
|
+
return left.length === right.length && left.every((value, index) => sameSchemaValue(value, right[index]));
|
|
24286
|
+
}
|
|
24287
|
+
if (!isSchemaObject(left) || !isSchemaObject(right))
|
|
24288
|
+
return false;
|
|
24289
|
+
const keys = Object.keys(left);
|
|
24290
|
+
return keys.length === Object.keys(right).length && keys.every((key) => Object.hasOwn(right, key) && sameSchemaValue(left[key], right[key]));
|
|
24291
|
+
}
|
|
24292
|
+
function mergeSchemaAllOf(schema, hints) {
|
|
24293
|
+
if (!Array.isArray(schema.allOf))
|
|
24294
|
+
return schema;
|
|
24295
|
+
const { allOf, ...base } = schema;
|
|
24296
|
+
const branches = [base, ...allOf];
|
|
24297
|
+
const properties = {};
|
|
24298
|
+
const required2 = /* @__PURE__ */ new Set();
|
|
24299
|
+
const descriptions = [];
|
|
24300
|
+
const metadata = {};
|
|
24301
|
+
let unambiguous = allOf.length > 0;
|
|
24302
|
+
for (const branch of branches) {
|
|
24303
|
+
if (!isSchemaObject(branch) || branch.type !== void 0 && String(branch.type).toUpperCase() !== "OBJECT" || branch.properties !== void 0 && !isSchemaObject(branch.properties)) {
|
|
24304
|
+
unambiguous = false;
|
|
24305
|
+
break;
|
|
24306
|
+
}
|
|
24307
|
+
for (const [key, value] of Object.entries(branch)) {
|
|
24308
|
+
if (!["properties", "required", "description"].includes(key) && !Object.hasOwn(metadata, key))
|
|
24309
|
+
metadata[key] = value;
|
|
24310
|
+
}
|
|
24311
|
+
if (typeof branch.description === "string")
|
|
24312
|
+
descriptions.push(branch.description);
|
|
24313
|
+
for (const [name, property] of Object.entries(branch.properties ?? {})) {
|
|
24314
|
+
if (Object.hasOwn(properties, name) && !sameSchemaValue(properties[name], property))
|
|
24315
|
+
unambiguous = false;
|
|
24316
|
+
properties[name] = property;
|
|
24317
|
+
}
|
|
24318
|
+
if (Array.isArray(branch.required)) {
|
|
24319
|
+
for (const name of branch.required) {
|
|
24320
|
+
if (typeof name === "string")
|
|
24321
|
+
required2.add(name);
|
|
24322
|
+
}
|
|
24323
|
+
}
|
|
24324
|
+
}
|
|
24325
|
+
if (unambiguous) {
|
|
24326
|
+
return {
|
|
24327
|
+
...metadata,
|
|
24328
|
+
type: "object",
|
|
24329
|
+
properties,
|
|
24330
|
+
...required2.size ? { required: [...required2] } : {},
|
|
24331
|
+
...descriptions.length ? { description: descriptions.join(" ") } : {}
|
|
24332
|
+
};
|
|
24333
|
+
}
|
|
24334
|
+
hints.push("allOf: using the first branch; other intersection constraints omitted.");
|
|
24335
|
+
const first = isSchemaObject(allOf[0]) ? allOf[0] : {};
|
|
24336
|
+
return {
|
|
24337
|
+
...base,
|
|
24338
|
+
...first,
|
|
24339
|
+
...base.description ? { description: base.description } : {}
|
|
24340
|
+
};
|
|
24341
|
+
}
|
|
24342
|
+
var CLAUDE_VALIDATED_HINT_FIELDS = /* @__PURE__ */ new Set([
|
|
24343
|
+
"minLength",
|
|
24344
|
+
"maxLength",
|
|
24345
|
+
"minItems",
|
|
24346
|
+
"maxItems",
|
|
24347
|
+
"pattern",
|
|
24348
|
+
"format",
|
|
24349
|
+
"default"
|
|
24350
|
+
]);
|
|
24351
|
+
function flattenClaudeUnion(schema, hints) {
|
|
24352
|
+
if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0)
|
|
24353
|
+
return schema;
|
|
24354
|
+
const { anyOf, ...base } = schema;
|
|
24355
|
+
const branches = anyOf.filter(isSchemaObject);
|
|
24356
|
+
if (!branches.length)
|
|
24357
|
+
return base;
|
|
24358
|
+
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)) {
|
|
24359
|
+
return {
|
|
24360
|
+
...base,
|
|
24361
|
+
type: "STRING",
|
|
24362
|
+
enum: [...new Set(branches.flatMap((branch) => branch.enum))]
|
|
24363
|
+
};
|
|
24364
|
+
}
|
|
24365
|
+
const typeName = (branch) => branch.properties ? "object" : branch.items ? "array" : String(branch.type ?? "null").toLowerCase();
|
|
24366
|
+
const score = (branch) => {
|
|
24367
|
+
const type = typeName(branch);
|
|
24368
|
+
return type === "object" ? 3 : type === "array" ? 2 : type === "null" ? 0 : 1;
|
|
24369
|
+
};
|
|
24370
|
+
let selected = branches[0];
|
|
24371
|
+
for (const branch of branches.slice(1)) {
|
|
24372
|
+
if (score(branch) > score(selected))
|
|
24373
|
+
selected = branch;
|
|
24374
|
+
}
|
|
24375
|
+
const result = { ...base, ...selected };
|
|
24376
|
+
if (typeof base.description === "string" && base.description) {
|
|
24377
|
+
result.description = typeof selected.description === "string" && selected.description && selected.description !== base.description ? `${base.description} (${selected.description})` : base.description;
|
|
24378
|
+
}
|
|
24379
|
+
if (branches.length > 1)
|
|
24380
|
+
hints.push(`Accepts: ${[...new Set(branches.map(typeName))].join(" | ")}`);
|
|
24381
|
+
return result;
|
|
24382
|
+
}
|
|
24275
24383
|
function toGeminiSchema(schema, options = {}) {
|
|
24276
24384
|
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
24277
24385
|
return schema;
|
|
24278
24386
|
}
|
|
24279
|
-
const inputSchema = schema;
|
|
24280
|
-
const result = {};
|
|
24281
24387
|
const numericConstraintHints = [];
|
|
24388
|
+
const inputSchema = mergeSchemaAllOf(schema, numericConstraintHints);
|
|
24389
|
+
let result = {};
|
|
24282
24390
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
24283
24391
|
if (inputSchema.properties && typeof inputSchema.properties === "object") {
|
|
24284
24392
|
for (const propName of Object.keys(inputSchema.properties)) {
|
|
@@ -24286,9 +24394,51 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
24286
24394
|
}
|
|
24287
24395
|
}
|
|
24288
24396
|
for (const [key, value] of Object.entries(inputSchema)) {
|
|
24289
|
-
if (
|
|
24397
|
+
if (options.claudeValidated) {
|
|
24398
|
+
if (key === "title")
|
|
24399
|
+
continue;
|
|
24400
|
+
if (key === "additionalProperties" && value === false)
|
|
24401
|
+
numericConstraintHints.push("No extra properties allowed");
|
|
24402
|
+
if (CLAUDE_VALIDATED_HINT_FIELDS.has(key)) {
|
|
24403
|
+
if (value !== void 0 && typeof value !== "object")
|
|
24404
|
+
numericConstraintHints.push(`${key}: ${value}`);
|
|
24405
|
+
continue;
|
|
24406
|
+
}
|
|
24407
|
+
}
|
|
24408
|
+
if (key === "const") {
|
|
24409
|
+
if (typeof value === "string")
|
|
24410
|
+
result.enum = [value];
|
|
24411
|
+
else
|
|
24412
|
+
numericConstraintHints.push(`Must be ${describeValue(value)}.`);
|
|
24290
24413
|
continue;
|
|
24291
24414
|
}
|
|
24415
|
+
if (NUMERIC_SCHEMA_CONSTRAINTS.has(key)) {
|
|
24416
|
+
const exclusive = key === "exclusiveMinimum" || key === "exclusiveMaximum";
|
|
24417
|
+
if (exclusive && !options.moveNumericConstraintsToDescription && String(inputSchema.type).toUpperCase() === "INTEGER" && typeof value === "number" && Number.isFinite(value)) {
|
|
24418
|
+
const lower = key === "exclusiveMinimum";
|
|
24419
|
+
const bound = lower ? Math.floor(value) + 1 : Math.ceil(value) - 1;
|
|
24420
|
+
const inclusiveKey = lower ? "minimum" : "maximum";
|
|
24421
|
+
const existing = inputSchema[inclusiveKey];
|
|
24422
|
+
if (Number.isSafeInteger(bound)) {
|
|
24423
|
+
result[inclusiveKey] = typeof existing === "number" ? lower ? Math.max(existing, bound) : Math.min(existing, bound) : bound;
|
|
24424
|
+
continue;
|
|
24425
|
+
}
|
|
24426
|
+
}
|
|
24427
|
+
if (options.moveNumericConstraintsToDescription || exclusive || key === "multipleOf") {
|
|
24428
|
+
if (["string", "number", "boolean"].includes(typeof value))
|
|
24429
|
+
numericConstraintHints.push(`${key}: ${value}`);
|
|
24430
|
+
continue;
|
|
24431
|
+
}
|
|
24432
|
+
}
|
|
24433
|
+
if (key === "oneOf" && Array.isArray(value)) {
|
|
24434
|
+
if (!Array.isArray(inputSchema.anyOf))
|
|
24435
|
+
result.anyOf = value.map((item) => toGeminiSchema(item, options));
|
|
24436
|
+
else
|
|
24437
|
+
numericConstraintHints.push("oneOf: additional union constraints omitted.");
|
|
24438
|
+
continue;
|
|
24439
|
+
}
|
|
24440
|
+
if (!ALLOWED_SCHEMA_FIELDS.has(key))
|
|
24441
|
+
continue;
|
|
24292
24442
|
if (key === "type" && typeof value === "string") {
|
|
24293
24443
|
result[key] = value.toUpperCase();
|
|
24294
24444
|
} else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
@@ -24299,16 +24449,15 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
24299
24449
|
result[key] = props;
|
|
24300
24450
|
} else if (key === "items" && typeof value === "object") {
|
|
24301
24451
|
result[key] = toGeminiSchema(value, options);
|
|
24302
|
-
} else if (
|
|
24452
|
+
} else if (key === "anyOf" && Array.isArray(value)) {
|
|
24303
24453
|
result[key] = value.map((item) => toGeminiSchema(item, options));
|
|
24304
24454
|
} else if (key === "enum" && Array.isArray(value)) {
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24455
|
+
if (value.every((item) => typeof item === "string")) {
|
|
24456
|
+
if (typeof inputSchema.const !== "string")
|
|
24457
|
+
result.enum = value;
|
|
24458
|
+
} else {
|
|
24459
|
+
numericConstraintHints.push(`Allowed values: ${value.map(describeValue).join(", ")}.`);
|
|
24309
24460
|
}
|
|
24310
|
-
} else if (key === "default" || key === "examples") {
|
|
24311
|
-
result[key] = value;
|
|
24312
24461
|
} else if (key === "required" && Array.isArray(value)) {
|
|
24313
24462
|
if (propertyNames.size > 0) {
|
|
24314
24463
|
const validRequired = value.filter((prop) => typeof prop === "string" && propertyNames.has(prop));
|
|
@@ -24318,10 +24467,23 @@ function toGeminiSchema(schema, options = {}) {
|
|
|
24318
24467
|
} else {
|
|
24319
24468
|
result[key] = value;
|
|
24320
24469
|
}
|
|
24470
|
+
} else if ((key === "minimum" || key === "maximum") && typeof result[key] === "number" && typeof value === "number") {
|
|
24471
|
+
result[key] = key === "minimum" ? Math.max(result[key], value) : Math.min(result[key], value);
|
|
24321
24472
|
} else {
|
|
24322
24473
|
result[key] = value;
|
|
24323
24474
|
}
|
|
24324
24475
|
}
|
|
24476
|
+
if (options.claudeValidated) {
|
|
24477
|
+
result = flattenClaudeUnion(result, numericConstraintHints);
|
|
24478
|
+
if (isSchemaObject(result.properties) && Array.isArray(result.required)) {
|
|
24479
|
+
const properties = result.properties;
|
|
24480
|
+
const required2 = result.required.filter((name) => typeof name === "string" && Object.hasOwn(properties, name));
|
|
24481
|
+
if (required2.length)
|
|
24482
|
+
result.required = required2;
|
|
24483
|
+
else
|
|
24484
|
+
delete result.required;
|
|
24485
|
+
}
|
|
24486
|
+
}
|
|
24325
24487
|
if (numericConstraintHints.length > 0) {
|
|
24326
24488
|
const hint = numericConstraintHints.join(", ");
|
|
24327
24489
|
result.description = typeof result.description === "string" && result.description ? `${result.description} (${hint})` : hint;
|
|
@@ -36301,10 +36463,6 @@ import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync7, writeFileSy
|
|
|
36301
36463
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
36302
36464
|
import { join as join23 } from "node:path";
|
|
36303
36465
|
var DUMP_STATUS_TITLE = "## Gemini Dump Status";
|
|
36304
|
-
var DUMP_ENABLED_TITLE = "## Gemini Dump Enabled";
|
|
36305
|
-
var DUMP_DISABLED_TITLE = "## Gemini Dump Disabled";
|
|
36306
|
-
var DUMP_USAGE_TITLE = "## Gemini Dump Usage";
|
|
36307
|
-
var DUMP_USAGE = "Usage: `/gemini-dump`, `/gemini-dump on`, or `/gemini-dump off`.";
|
|
36308
36466
|
var DUMP_DIR_ENV = "OPENCODE_ANTIGRAVITY_GEMINI_DUMP_DIR";
|
|
36309
36467
|
var DEFAULT_DUMP_DIR = join23(tmpdir4(), "opencode-antigravity-gemini-dumps");
|
|
36310
36468
|
var DUMP_DIR_MODE = 448;
|
|
@@ -36321,8 +36479,7 @@ function createGeminiDumpState(options = {}) {
|
|
|
36321
36479
|
enabled = next;
|
|
36322
36480
|
},
|
|
36323
36481
|
dumpRequest: (input2) => enabled ? writeGeminiDump(input2) : null,
|
|
36324
|
-
buildStatusSummary: (input2) => renderGeminiDumpStatus(input2?.enabled ?? enabled)
|
|
36325
|
-
executeCommand: (input2) => renderGeminiDumpCommand(input2.argumentsText, input2.enabled ?? enabled)
|
|
36482
|
+
buildStatusSummary: (input2) => renderGeminiDumpStatus(input2?.enabled ?? enabled)
|
|
36326
36483
|
};
|
|
36327
36484
|
}
|
|
36328
36485
|
var legacyDumpState = createGeminiDumpState();
|
|
@@ -36335,15 +36492,6 @@ function setGeminiDumpEnabled(enabled) {
|
|
|
36335
36492
|
function getGeminiDumpDirectory() {
|
|
36336
36493
|
return process.env[DUMP_DIR_ENV] || DEFAULT_DUMP_DIR;
|
|
36337
36494
|
}
|
|
36338
|
-
function parseGeminiDumpCommandAction(argumentsText) {
|
|
36339
|
-
const normalized = argumentsText.trim().split(/\s+/).filter(Boolean);
|
|
36340
|
-
if (normalized.length === 0) return { type: "status" };
|
|
36341
|
-
if (normalized.length === 1 && normalized[0] === "on")
|
|
36342
|
-
return { type: "enable" };
|
|
36343
|
-
if (normalized.length === 1 && normalized[0] === "off")
|
|
36344
|
-
return { type: "disable" };
|
|
36345
|
-
return { type: "usage" };
|
|
36346
|
-
}
|
|
36347
36495
|
function renderGeminiDumpStatus(enabled) {
|
|
36348
36496
|
return [
|
|
36349
36497
|
DUMP_STATUS_TITLE,
|
|
@@ -36354,23 +36502,6 @@ function renderGeminiDumpStatus(enabled) {
|
|
|
36354
36502
|
"- Warning: dumps contain prompt/session content; turn this off after debugging"
|
|
36355
36503
|
].join("\n");
|
|
36356
36504
|
}
|
|
36357
|
-
function renderGeminiDumpCommand(argumentsText, enabled) {
|
|
36358
|
-
const action = parseGeminiDumpCommandAction(argumentsText);
|
|
36359
|
-
if (action.type === "status") return renderGeminiDumpStatus(enabled);
|
|
36360
|
-
if (action.type === "enable") {
|
|
36361
|
-
return [DUMP_ENABLED_TITLE, "", renderGeminiDumpStatus(true)].join("\n");
|
|
36362
|
-
}
|
|
36363
|
-
if (action.type === "disable") {
|
|
36364
|
-
return [DUMP_DISABLED_TITLE, "", renderGeminiDumpStatus(false)].join("\n");
|
|
36365
|
-
}
|
|
36366
|
-
return [
|
|
36367
|
-
DUMP_USAGE_TITLE,
|
|
36368
|
-
"",
|
|
36369
|
-
DUMP_USAGE,
|
|
36370
|
-
"",
|
|
36371
|
-
renderGeminiDumpStatus(enabled)
|
|
36372
|
-
].join("\n");
|
|
36373
|
-
}
|
|
36374
36505
|
function hashText2(value) {
|
|
36375
36506
|
return createHash15("sha256").update(value).digest("hex");
|
|
36376
36507
|
}
|
|
@@ -37035,31 +37166,6 @@ function createSessionRecoveryHook(ctx, config) {
|
|
|
37035
37166
|
// src/plugin/request-helpers.ts
|
|
37036
37167
|
var log10 = createLogger4("request-helpers");
|
|
37037
37168
|
var ANTIGRAVITY_PREVIEW_LINK = "https://goo.gle/enable-preview-features";
|
|
37038
|
-
var UNSUPPORTED_CONSTRAINTS = [
|
|
37039
|
-
"minLength",
|
|
37040
|
-
"maxLength",
|
|
37041
|
-
"exclusiveMinimum",
|
|
37042
|
-
"exclusiveMaximum",
|
|
37043
|
-
"pattern",
|
|
37044
|
-
"minItems",
|
|
37045
|
-
"maxItems",
|
|
37046
|
-
"format",
|
|
37047
|
-
"default",
|
|
37048
|
-
"examples"
|
|
37049
|
-
];
|
|
37050
|
-
var UNSUPPORTED_KEYWORDS = [
|
|
37051
|
-
...UNSUPPORTED_CONSTRAINTS,
|
|
37052
|
-
"$schema",
|
|
37053
|
-
"$defs",
|
|
37054
|
-
"definitions",
|
|
37055
|
-
"const",
|
|
37056
|
-
"$ref",
|
|
37057
|
-
"additionalProperties",
|
|
37058
|
-
"propertyNames",
|
|
37059
|
-
"title",
|
|
37060
|
-
"$id",
|
|
37061
|
-
"$comment"
|
|
37062
|
-
];
|
|
37063
37169
|
function appendDescriptionHint(schema, hint) {
|
|
37064
37170
|
if (!schema || typeof schema !== "object") {
|
|
37065
37171
|
return schema;
|
|
@@ -37089,23 +37195,6 @@ function convertRefsToHints(schema) {
|
|
|
37089
37195
|
}
|
|
37090
37196
|
return result;
|
|
37091
37197
|
}
|
|
37092
|
-
function convertConstToEnum(schema) {
|
|
37093
|
-
if (!schema || typeof schema !== "object") {
|
|
37094
|
-
return schema;
|
|
37095
|
-
}
|
|
37096
|
-
if (Array.isArray(schema)) {
|
|
37097
|
-
return schema.map((item) => convertConstToEnum(item));
|
|
37098
|
-
}
|
|
37099
|
-
const result = {};
|
|
37100
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
37101
|
-
if (key === "const" && !schema.enum) {
|
|
37102
|
-
result.enum = [value];
|
|
37103
|
-
} else {
|
|
37104
|
-
result[key] = convertConstToEnum(value);
|
|
37105
|
-
}
|
|
37106
|
-
}
|
|
37107
|
-
return result;
|
|
37108
|
-
}
|
|
37109
37198
|
function addEnumHints(schema) {
|
|
37110
37199
|
if (!schema || typeof schema !== "object") {
|
|
37111
37200
|
return schema;
|
|
@@ -37114,7 +37203,7 @@ function addEnumHints(schema) {
|
|
|
37114
37203
|
return schema.map((item) => addEnumHints(item));
|
|
37115
37204
|
}
|
|
37116
37205
|
let result = { ...schema };
|
|
37117
|
-
if (Array.isArray(result.enum) && result.enum.length > 1 && result.enum.length <= 10) {
|
|
37206
|
+
if (Array.isArray(result.enum) && result.enum.every((value) => typeof value === "string") && result.enum.length > 1 && result.enum.length <= 10) {
|
|
37118
37207
|
const vals = result.enum.map((v) => String(v)).join(", ");
|
|
37119
37208
|
result = appendDescriptionHint(result, `Allowed: ${vals}`);
|
|
37120
37209
|
}
|
|
@@ -37125,213 +37214,6 @@ function addEnumHints(schema) {
|
|
|
37125
37214
|
}
|
|
37126
37215
|
return result;
|
|
37127
37216
|
}
|
|
37128
|
-
function addAdditionalPropertiesHints(schema) {
|
|
37129
|
-
if (!schema || typeof schema !== "object") {
|
|
37130
|
-
return schema;
|
|
37131
|
-
}
|
|
37132
|
-
if (Array.isArray(schema)) {
|
|
37133
|
-
return schema.map((item) => addAdditionalPropertiesHints(item));
|
|
37134
|
-
}
|
|
37135
|
-
let result = { ...schema };
|
|
37136
|
-
if (result.additionalProperties === false) {
|
|
37137
|
-
result = appendDescriptionHint(result, "No extra properties allowed");
|
|
37138
|
-
}
|
|
37139
|
-
for (const [key, value] of Object.entries(result)) {
|
|
37140
|
-
if (key !== "additionalProperties" && typeof value === "object" && value !== null) {
|
|
37141
|
-
result[key] = addAdditionalPropertiesHints(value);
|
|
37142
|
-
}
|
|
37143
|
-
}
|
|
37144
|
-
return result;
|
|
37145
|
-
}
|
|
37146
|
-
function moveConstraintsToDescription(schema) {
|
|
37147
|
-
if (!schema || typeof schema !== "object") {
|
|
37148
|
-
return schema;
|
|
37149
|
-
}
|
|
37150
|
-
if (Array.isArray(schema)) {
|
|
37151
|
-
return schema.map((item) => moveConstraintsToDescription(item));
|
|
37152
|
-
}
|
|
37153
|
-
let result = { ...schema };
|
|
37154
|
-
for (const constraint of UNSUPPORTED_CONSTRAINTS) {
|
|
37155
|
-
if (result[constraint] !== void 0 && typeof result[constraint] !== "object") {
|
|
37156
|
-
result = appendDescriptionHint(
|
|
37157
|
-
result,
|
|
37158
|
-
`${constraint}: ${result[constraint]}`
|
|
37159
|
-
);
|
|
37160
|
-
}
|
|
37161
|
-
}
|
|
37162
|
-
for (const [key, value] of Object.entries(result)) {
|
|
37163
|
-
if (typeof value === "object" && value !== null) {
|
|
37164
|
-
result[key] = moveConstraintsToDescription(value);
|
|
37165
|
-
}
|
|
37166
|
-
}
|
|
37167
|
-
return result;
|
|
37168
|
-
}
|
|
37169
|
-
function mergeAllOf(schema) {
|
|
37170
|
-
if (!schema || typeof schema !== "object") {
|
|
37171
|
-
return schema;
|
|
37172
|
-
}
|
|
37173
|
-
if (Array.isArray(schema)) {
|
|
37174
|
-
return schema.map((item) => mergeAllOf(item));
|
|
37175
|
-
}
|
|
37176
|
-
const result = { ...schema };
|
|
37177
|
-
if (Array.isArray(result.allOf)) {
|
|
37178
|
-
const merged = {};
|
|
37179
|
-
const mergedRequired = [];
|
|
37180
|
-
for (const item of result.allOf) {
|
|
37181
|
-
if (!item || typeof item !== "object") continue;
|
|
37182
|
-
if (item.properties && typeof item.properties === "object") {
|
|
37183
|
-
merged.properties = { ...merged.properties, ...item.properties };
|
|
37184
|
-
}
|
|
37185
|
-
if (Array.isArray(item.required)) {
|
|
37186
|
-
for (const req of item.required) {
|
|
37187
|
-
if (!mergedRequired.includes(req)) {
|
|
37188
|
-
mergedRequired.push(req);
|
|
37189
|
-
}
|
|
37190
|
-
}
|
|
37191
|
-
}
|
|
37192
|
-
for (const [key, value] of Object.entries(item)) {
|
|
37193
|
-
if (key !== "properties" && key !== "required" && merged[key] === void 0) {
|
|
37194
|
-
merged[key] = value;
|
|
37195
|
-
}
|
|
37196
|
-
}
|
|
37197
|
-
}
|
|
37198
|
-
if (merged.properties) {
|
|
37199
|
-
result.properties = { ...result.properties, ...merged.properties };
|
|
37200
|
-
}
|
|
37201
|
-
if (mergedRequired.length > 0) {
|
|
37202
|
-
const existingRequired = Array.isArray(result.required) ? result.required : [];
|
|
37203
|
-
result.required = Array.from(
|
|
37204
|
-
/* @__PURE__ */ new Set([...existingRequired, ...mergedRequired])
|
|
37205
|
-
);
|
|
37206
|
-
}
|
|
37207
|
-
for (const [key, value] of Object.entries(merged)) {
|
|
37208
|
-
if (key !== "properties" && key !== "required" && result[key] === void 0) {
|
|
37209
|
-
result[key] = value;
|
|
37210
|
-
}
|
|
37211
|
-
}
|
|
37212
|
-
delete result.allOf;
|
|
37213
|
-
}
|
|
37214
|
-
for (const [key, value] of Object.entries(result)) {
|
|
37215
|
-
if (typeof value === "object" && value !== null) {
|
|
37216
|
-
result[key] = mergeAllOf(value);
|
|
37217
|
-
}
|
|
37218
|
-
}
|
|
37219
|
-
return result;
|
|
37220
|
-
}
|
|
37221
|
-
function scoreSchemaOption(schema) {
|
|
37222
|
-
if (!schema || typeof schema !== "object") {
|
|
37223
|
-
return { score: 0, typeName: "unknown" };
|
|
37224
|
-
}
|
|
37225
|
-
const type = schema.type;
|
|
37226
|
-
if (type === "object" || schema.properties) {
|
|
37227
|
-
return { score: 3, typeName: "object" };
|
|
37228
|
-
}
|
|
37229
|
-
if (type === "array" || schema.items) {
|
|
37230
|
-
return { score: 2, typeName: "array" };
|
|
37231
|
-
}
|
|
37232
|
-
if (type && type !== "null") {
|
|
37233
|
-
return { score: 1, typeName: type };
|
|
37234
|
-
}
|
|
37235
|
-
return { score: 0, typeName: type || "null" };
|
|
37236
|
-
}
|
|
37237
|
-
function tryMergeEnumFromUnion(options) {
|
|
37238
|
-
if (!Array.isArray(options) || options.length === 0) {
|
|
37239
|
-
return null;
|
|
37240
|
-
}
|
|
37241
|
-
const enumValues = [];
|
|
37242
|
-
for (const option of options) {
|
|
37243
|
-
if (!option || typeof option !== "object") {
|
|
37244
|
-
return null;
|
|
37245
|
-
}
|
|
37246
|
-
if (option.const !== void 0) {
|
|
37247
|
-
enumValues.push(String(option.const));
|
|
37248
|
-
continue;
|
|
37249
|
-
}
|
|
37250
|
-
if (Array.isArray(option.enum) && option.enum.length === 1) {
|
|
37251
|
-
enumValues.push(String(option.enum[0]));
|
|
37252
|
-
continue;
|
|
37253
|
-
}
|
|
37254
|
-
if (Array.isArray(option.enum) && option.enum.length > 0) {
|
|
37255
|
-
for (const val of option.enum) {
|
|
37256
|
-
enumValues.push(String(val));
|
|
37257
|
-
}
|
|
37258
|
-
continue;
|
|
37259
|
-
}
|
|
37260
|
-
if (option.properties || option.items || option.anyOf || option.oneOf || option.allOf) {
|
|
37261
|
-
return null;
|
|
37262
|
-
}
|
|
37263
|
-
if (option.type && !option.const && !option.enum) {
|
|
37264
|
-
return null;
|
|
37265
|
-
}
|
|
37266
|
-
}
|
|
37267
|
-
return enumValues.length > 0 ? enumValues : null;
|
|
37268
|
-
}
|
|
37269
|
-
function flattenAnyOfOneOf(schema) {
|
|
37270
|
-
if (!schema || typeof schema !== "object") {
|
|
37271
|
-
return schema;
|
|
37272
|
-
}
|
|
37273
|
-
if (Array.isArray(schema)) {
|
|
37274
|
-
return schema.map((item) => flattenAnyOfOneOf(item));
|
|
37275
|
-
}
|
|
37276
|
-
let result = { ...schema };
|
|
37277
|
-
for (const unionKey of ["anyOf", "oneOf"]) {
|
|
37278
|
-
if (Array.isArray(result[unionKey]) && result[unionKey].length > 0) {
|
|
37279
|
-
const options = result[unionKey];
|
|
37280
|
-
const parentDesc = typeof result.description === "string" ? result.description : "";
|
|
37281
|
-
const mergedEnum = tryMergeEnumFromUnion(options);
|
|
37282
|
-
if (mergedEnum !== null) {
|
|
37283
|
-
const { [unionKey]: _2, ...rest2 } = result;
|
|
37284
|
-
result = {
|
|
37285
|
-
...rest2,
|
|
37286
|
-
type: "string",
|
|
37287
|
-
enum: mergedEnum
|
|
37288
|
-
};
|
|
37289
|
-
if (parentDesc) {
|
|
37290
|
-
result.description = parentDesc;
|
|
37291
|
-
}
|
|
37292
|
-
continue;
|
|
37293
|
-
}
|
|
37294
|
-
let bestIdx = 0;
|
|
37295
|
-
let bestScore = -1;
|
|
37296
|
-
const allTypes = [];
|
|
37297
|
-
for (let i = 0; i < options.length; i++) {
|
|
37298
|
-
const { score, typeName } = scoreSchemaOption(options[i]);
|
|
37299
|
-
if (typeName) {
|
|
37300
|
-
allTypes.push(typeName);
|
|
37301
|
-
}
|
|
37302
|
-
if (score > bestScore) {
|
|
37303
|
-
bestScore = score;
|
|
37304
|
-
bestIdx = i;
|
|
37305
|
-
}
|
|
37306
|
-
}
|
|
37307
|
-
let selected = flattenAnyOfOneOf(options[bestIdx]) || { type: "string" };
|
|
37308
|
-
if (parentDesc) {
|
|
37309
|
-
const childDesc = typeof selected.description === "string" ? selected.description : "";
|
|
37310
|
-
if (childDesc && childDesc !== parentDesc) {
|
|
37311
|
-
selected = {
|
|
37312
|
-
...selected,
|
|
37313
|
-
description: `${parentDesc} (${childDesc})`
|
|
37314
|
-
};
|
|
37315
|
-
} else if (!childDesc) {
|
|
37316
|
-
selected = { ...selected, description: parentDesc };
|
|
37317
|
-
}
|
|
37318
|
-
}
|
|
37319
|
-
if (allTypes.length > 1) {
|
|
37320
|
-
const uniqueTypes = Array.from(new Set(allTypes));
|
|
37321
|
-
const hint = `Accepts: ${uniqueTypes.join(" | ")}`;
|
|
37322
|
-
selected = appendDescriptionHint(selected, hint);
|
|
37323
|
-
}
|
|
37324
|
-
const { [unionKey]: _, description: __, ...rest } = result;
|
|
37325
|
-
result = { ...rest, ...selected };
|
|
37326
|
-
}
|
|
37327
|
-
}
|
|
37328
|
-
for (const [key, value] of Object.entries(result)) {
|
|
37329
|
-
if (typeof value === "object" && value !== null) {
|
|
37330
|
-
result[key] = flattenAnyOfOneOf(value);
|
|
37331
|
-
}
|
|
37332
|
-
}
|
|
37333
|
-
return result;
|
|
37334
|
-
}
|
|
37335
37217
|
function flattenTypeArrays(schema, nullableFields, currentPath) {
|
|
37336
37218
|
if (!schema || typeof schema !== "object") {
|
|
37337
37219
|
return schema;
|
|
@@ -37400,62 +37282,6 @@ function flattenTypeArrays(schema, nullableFields, currentPath) {
|
|
|
37400
37282
|
}
|
|
37401
37283
|
return result;
|
|
37402
37284
|
}
|
|
37403
|
-
function removeUnsupportedKeywords(schema, insideProperties = false) {
|
|
37404
|
-
if (!schema || typeof schema !== "object") {
|
|
37405
|
-
return schema;
|
|
37406
|
-
}
|
|
37407
|
-
if (Array.isArray(schema)) {
|
|
37408
|
-
return schema.map((item) => removeUnsupportedKeywords(item, false));
|
|
37409
|
-
}
|
|
37410
|
-
const result = {};
|
|
37411
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
37412
|
-
if (!insideProperties && UNSUPPORTED_KEYWORDS.includes(key)) {
|
|
37413
|
-
continue;
|
|
37414
|
-
}
|
|
37415
|
-
if (typeof value === "object" && value !== null) {
|
|
37416
|
-
if (key === "properties") {
|
|
37417
|
-
const propertiesResult = {};
|
|
37418
|
-
for (const [propName, propSchema] of Object.entries(value)) {
|
|
37419
|
-
propertiesResult[propName] = removeUnsupportedKeywords(
|
|
37420
|
-
propSchema,
|
|
37421
|
-
false
|
|
37422
|
-
);
|
|
37423
|
-
}
|
|
37424
|
-
result[key] = propertiesResult;
|
|
37425
|
-
} else {
|
|
37426
|
-
result[key] = removeUnsupportedKeywords(value, false);
|
|
37427
|
-
}
|
|
37428
|
-
} else {
|
|
37429
|
-
result[key] = value;
|
|
37430
|
-
}
|
|
37431
|
-
}
|
|
37432
|
-
return result;
|
|
37433
|
-
}
|
|
37434
|
-
function cleanupRequiredFields(schema) {
|
|
37435
|
-
if (!schema || typeof schema !== "object") {
|
|
37436
|
-
return schema;
|
|
37437
|
-
}
|
|
37438
|
-
if (Array.isArray(schema)) {
|
|
37439
|
-
return schema.map((item) => cleanupRequiredFields(item));
|
|
37440
|
-
}
|
|
37441
|
-
const result = { ...schema };
|
|
37442
|
-
if (Array.isArray(result.required) && result.properties && typeof result.properties === "object") {
|
|
37443
|
-
const validRequired = result.required.filter(
|
|
37444
|
-
(req) => Object.hasOwn(result.properties, req)
|
|
37445
|
-
);
|
|
37446
|
-
if (validRequired.length === 0) {
|
|
37447
|
-
delete result.required;
|
|
37448
|
-
} else if (validRequired.length !== result.required.length) {
|
|
37449
|
-
result.required = validRequired;
|
|
37450
|
-
}
|
|
37451
|
-
}
|
|
37452
|
-
for (const [key, value] of Object.entries(result)) {
|
|
37453
|
-
if (typeof value === "object" && value !== null) {
|
|
37454
|
-
result[key] = cleanupRequiredFields(value);
|
|
37455
|
-
}
|
|
37456
|
-
}
|
|
37457
|
-
return result;
|
|
37458
|
-
}
|
|
37459
37285
|
function addEmptySchemaPlaceholder(schema) {
|
|
37460
37286
|
if (!schema || typeof schema !== "object") {
|
|
37461
37287
|
return schema;
|
|
@@ -37488,19 +37314,11 @@ function cleanJSONSchemaForAntigravity(schema) {
|
|
|
37488
37314
|
if (!schema || typeof schema !== "object") {
|
|
37489
37315
|
return schema;
|
|
37490
37316
|
}
|
|
37491
|
-
let result = schema;
|
|
37492
|
-
result = convertRefsToHints(result);
|
|
37493
|
-
result = convertConstToEnum(result);
|
|
37317
|
+
let result = convertRefsToHints(schema);
|
|
37494
37318
|
result = addEnumHints(result);
|
|
37495
|
-
result = addAdditionalPropertiesHints(result);
|
|
37496
|
-
result = moveConstraintsToDescription(result);
|
|
37497
|
-
result = mergeAllOf(result);
|
|
37498
|
-
result = flattenAnyOfOneOf(result);
|
|
37499
37319
|
result = flattenTypeArrays(result);
|
|
37500
|
-
result = removeUnsupportedKeywords(result);
|
|
37501
|
-
result = cleanupRequiredFields(result);
|
|
37502
37320
|
result = addEmptySchemaPlaceholder(result);
|
|
37503
|
-
return result;
|
|
37321
|
+
return toGeminiSchema(result, { claudeValidated: true });
|
|
37504
37322
|
}
|
|
37505
37323
|
var DEFAULT_THINKING_BUDGET = 16e3;
|
|
37506
37324
|
function isThinkingCapableModel2(modelName) {
|
|
@@ -40196,10 +40014,10 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
40196
40014
|
const normalizeSchema = (schema) => {
|
|
40197
40015
|
const createPlaceholderSchema = (base = {}) => ({
|
|
40198
40016
|
...base,
|
|
40199
|
-
type: "
|
|
40017
|
+
type: "OBJECT",
|
|
40200
40018
|
properties: {
|
|
40201
40019
|
[EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
|
|
40202
|
-
type: "
|
|
40020
|
+
type: "BOOLEAN",
|
|
40203
40021
|
description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION
|
|
40204
40022
|
}
|
|
40205
40023
|
},
|
|
@@ -40215,11 +40033,11 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
|
|
|
40215
40033
|
return createPlaceholderSchema();
|
|
40216
40034
|
}
|
|
40217
40035
|
const hasProperties = cleaned.properties && typeof cleaned.properties === "object" && Object.keys(cleaned.properties).length > 0;
|
|
40218
|
-
cleaned.type = "
|
|
40036
|
+
cleaned.type = "OBJECT";
|
|
40219
40037
|
if (!hasProperties) {
|
|
40220
40038
|
cleaned.properties = {
|
|
40221
40039
|
[EMPTY_SCHEMA_PLACEHOLDER_NAME]: {
|
|
40222
|
-
type: "
|
|
40040
|
+
type: "BOOLEAN",
|
|
40223
40041
|
description: EMPTY_SCHEMA_PLACEHOLDER_DESCRIPTION
|
|
40224
40042
|
}
|
|
40225
40043
|
};
|