copilot-api-plus 1.0.22 → 1.0.23
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/main.js +87 -12
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1293,19 +1293,56 @@ function parseBase64Image(url) {
|
|
|
1293
1293
|
};
|
|
1294
1294
|
}
|
|
1295
1295
|
/**
|
|
1296
|
+
* Clean and convert JSON schema to Gemini format
|
|
1297
|
+
* - Removes unsupported fields like $schema, additionalProperties
|
|
1298
|
+
* - Converts type values to uppercase (string -> STRING)
|
|
1299
|
+
*/
|
|
1300
|
+
function cleanJsonSchema$1(schema) {
|
|
1301
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
1302
|
+
if (Array.isArray(schema)) return schema.map((item) => cleanJsonSchema$1(item));
|
|
1303
|
+
const obj = schema;
|
|
1304
|
+
const cleaned = {};
|
|
1305
|
+
const unsupportedFields = new Set([
|
|
1306
|
+
"$schema",
|
|
1307
|
+
"$id",
|
|
1308
|
+
"$ref",
|
|
1309
|
+
"additionalProperties",
|
|
1310
|
+
"default",
|
|
1311
|
+
"examples",
|
|
1312
|
+
"minItems",
|
|
1313
|
+
"maxItems",
|
|
1314
|
+
"minLength",
|
|
1315
|
+
"maxLength",
|
|
1316
|
+
"minimum",
|
|
1317
|
+
"maximum",
|
|
1318
|
+
"pattern",
|
|
1319
|
+
"format"
|
|
1320
|
+
]);
|
|
1321
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1322
|
+
if (unsupportedFields.has(key)) continue;
|
|
1323
|
+
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1324
|
+
else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema$1(value);
|
|
1325
|
+
else cleaned[key] = value;
|
|
1326
|
+
}
|
|
1327
|
+
return cleaned;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1296
1330
|
* Convert tools to Antigravity format
|
|
1331
|
+
* All tools should be in a single object with functionDeclarations array
|
|
1297
1332
|
*/
|
|
1298
1333
|
function convertTools$1(tools) {
|
|
1299
1334
|
if (!tools || tools.length === 0) return void 0;
|
|
1300
|
-
|
|
1335
|
+
const functionDeclarations = [];
|
|
1336
|
+
for (const tool of tools) {
|
|
1301
1337
|
const t = tool;
|
|
1302
|
-
if (t.type === "function" && t.function)
|
|
1338
|
+
if (t.type === "function" && t.function) functionDeclarations.push({
|
|
1303
1339
|
name: t.function.name,
|
|
1304
1340
|
description: t.function.description || "",
|
|
1305
|
-
parameters: t.function.parameters || {}
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1341
|
+
parameters: cleanJsonSchema$1(t.function.parameters) || {}
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
if (functionDeclarations.length === 0) return void 0;
|
|
1345
|
+
return [{ functionDeclarations }];
|
|
1309
1346
|
}
|
|
1310
1347
|
/**
|
|
1311
1348
|
* Build standard Gemini API request body (for API Key authentication)
|
|
@@ -1802,18 +1839,55 @@ function buildParts(content) {
|
|
|
1802
1839
|
return parts;
|
|
1803
1840
|
}
|
|
1804
1841
|
/**
|
|
1842
|
+
* Clean and convert JSON schema to Gemini format
|
|
1843
|
+
* - Removes unsupported fields like $schema, additionalProperties
|
|
1844
|
+
* - Converts type values to uppercase (string -> STRING)
|
|
1845
|
+
*/
|
|
1846
|
+
function cleanJsonSchema(schema) {
|
|
1847
|
+
if (!schema || typeof schema !== "object") return schema;
|
|
1848
|
+
if (Array.isArray(schema)) return schema.map((item) => cleanJsonSchema(item));
|
|
1849
|
+
const obj = schema;
|
|
1850
|
+
const cleaned = {};
|
|
1851
|
+
const unsupportedFields = new Set([
|
|
1852
|
+
"$schema",
|
|
1853
|
+
"$id",
|
|
1854
|
+
"$ref",
|
|
1855
|
+
"additionalProperties",
|
|
1856
|
+
"default",
|
|
1857
|
+
"examples",
|
|
1858
|
+
"minItems",
|
|
1859
|
+
"maxItems",
|
|
1860
|
+
"minLength",
|
|
1861
|
+
"maxLength",
|
|
1862
|
+
"minimum",
|
|
1863
|
+
"maximum",
|
|
1864
|
+
"pattern",
|
|
1865
|
+
"format"
|
|
1866
|
+
]);
|
|
1867
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
1868
|
+
if (unsupportedFields.has(key)) continue;
|
|
1869
|
+
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1870
|
+
else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema(value);
|
|
1871
|
+
else cleaned[key] = value;
|
|
1872
|
+
}
|
|
1873
|
+
return cleaned;
|
|
1874
|
+
}
|
|
1875
|
+
/**
|
|
1805
1876
|
* Convert tools to Antigravity format
|
|
1877
|
+
* All tools should be in a single object with functionDeclarations array
|
|
1806
1878
|
*/
|
|
1807
1879
|
function convertTools(tools) {
|
|
1808
1880
|
if (!tools || tools.length === 0) return void 0;
|
|
1809
|
-
|
|
1881
|
+
const functionDeclarations = [];
|
|
1882
|
+
for (const tool of tools) {
|
|
1810
1883
|
const t = tool;
|
|
1811
|
-
|
|
1884
|
+
functionDeclarations.push({
|
|
1812
1885
|
name: t.name,
|
|
1813
1886
|
description: t.description || "",
|
|
1814
|
-
parameters: t.input_schema || {}
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1887
|
+
parameters: cleanJsonSchema(t.input_schema) || {}
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
return [{ functionDeclarations }];
|
|
1817
1891
|
}
|
|
1818
1892
|
/**
|
|
1819
1893
|
* Build Antigravity request body
|
|
@@ -1997,7 +2071,8 @@ async function processStream(reader, decoder, state$1, controller) {
|
|
|
1997
2071
|
* Transform Antigravity non-stream response to Anthropic format
|
|
1998
2072
|
*/
|
|
1999
2073
|
async function transformNonStreamResponse(response, model) {
|
|
2000
|
-
const
|
|
2074
|
+
const rawData = await response.json();
|
|
2075
|
+
const data = rawData.response ?? rawData;
|
|
2001
2076
|
const parts = (data.candidates?.[0])?.content?.parts ?? [];
|
|
2002
2077
|
const content = buildNonStreamContent(parts);
|
|
2003
2078
|
const anthropicResponse = {
|