copilot-api-plus 1.0.27 → 1.0.29
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 +46 -6
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1312,7 +1312,7 @@ function convertMessages$1(messages) {
|
|
|
1312
1312
|
* Build system instruction from content
|
|
1313
1313
|
*/
|
|
1314
1314
|
function buildSystemInstruction(content) {
|
|
1315
|
-
return { parts:
|
|
1315
|
+
return { parts: { text: typeof content === "string" ? content : content.map((c) => c.text || "").join("") } };
|
|
1316
1316
|
}
|
|
1317
1317
|
/**
|
|
1318
1318
|
* Build message parts from content
|
|
@@ -1343,6 +1343,7 @@ function parseBase64Image(url) {
|
|
|
1343
1343
|
* Clean and convert JSON schema to Gemini format
|
|
1344
1344
|
* - Removes unsupported fields like $schema, additionalProperties
|
|
1345
1345
|
* - Converts type values to uppercase (string -> STRING)
|
|
1346
|
+
* - Ensures properties format is correct for Google API
|
|
1346
1347
|
*/
|
|
1347
1348
|
function cleanJsonSchema$1(schema) {
|
|
1348
1349
|
if (!schema || typeof schema !== "object") return schema;
|
|
@@ -1363,12 +1364,31 @@ function cleanJsonSchema$1(schema) {
|
|
|
1363
1364
|
"minimum",
|
|
1364
1365
|
"maximum",
|
|
1365
1366
|
"pattern",
|
|
1366
|
-
"format"
|
|
1367
|
+
"format",
|
|
1368
|
+
"const",
|
|
1369
|
+
"allOf",
|
|
1370
|
+
"anyOf",
|
|
1371
|
+
"oneOf",
|
|
1372
|
+
"not"
|
|
1373
|
+
]);
|
|
1374
|
+
const allowedFields = new Set([
|
|
1375
|
+
"type",
|
|
1376
|
+
"description",
|
|
1377
|
+
"properties",
|
|
1378
|
+
"required",
|
|
1379
|
+
"items",
|
|
1380
|
+
"enum"
|
|
1367
1381
|
]);
|
|
1368
1382
|
for (const [key, value] of Object.entries(obj)) {
|
|
1369
1383
|
if (unsupportedFields.has(key)) continue;
|
|
1384
|
+
if (!allowedFields.has(key)) continue;
|
|
1370
1385
|
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1371
|
-
else if (typeof value === "object" && value !== null)
|
|
1386
|
+
else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
1387
|
+
const props = value;
|
|
1388
|
+
const cleanedProps = {};
|
|
1389
|
+
for (const [propKey, propValue] of Object.entries(props)) cleanedProps[propKey] = cleanJsonSchema$1(propValue);
|
|
1390
|
+
cleaned[key] = cleanedProps;
|
|
1391
|
+
} else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema$1(value);
|
|
1372
1392
|
else cleaned[key] = value;
|
|
1373
1393
|
}
|
|
1374
1394
|
return cleaned;
|
|
@@ -1855,7 +1875,7 @@ const ANTIGRAVITY_USER_AGENT = "antigravity/1.11.3 windows/amd64";
|
|
|
1855
1875
|
function convertMessages(messages, system) {
|
|
1856
1876
|
const contents = [];
|
|
1857
1877
|
let systemInstruction;
|
|
1858
|
-
if (system) systemInstruction = { parts:
|
|
1878
|
+
if (system) systemInstruction = { parts: { text: system } };
|
|
1859
1879
|
for (const message of messages) {
|
|
1860
1880
|
const role = message.role === "assistant" ? "model" : "user";
|
|
1861
1881
|
const parts = buildParts(message.content);
|
|
@@ -1886,6 +1906,7 @@ function buildParts(content) {
|
|
|
1886
1906
|
* Clean and convert JSON schema to Gemini format
|
|
1887
1907
|
* - Removes unsupported fields like $schema, additionalProperties
|
|
1888
1908
|
* - Converts type values to uppercase (string -> STRING)
|
|
1909
|
+
* - Ensures properties format is correct for Google API
|
|
1889
1910
|
*/
|
|
1890
1911
|
function cleanJsonSchema(schema) {
|
|
1891
1912
|
if (!schema || typeof schema !== "object") return schema;
|
|
@@ -1906,12 +1927,31 @@ function cleanJsonSchema(schema) {
|
|
|
1906
1927
|
"minimum",
|
|
1907
1928
|
"maximum",
|
|
1908
1929
|
"pattern",
|
|
1909
|
-
"format"
|
|
1930
|
+
"format",
|
|
1931
|
+
"const",
|
|
1932
|
+
"allOf",
|
|
1933
|
+
"anyOf",
|
|
1934
|
+
"oneOf",
|
|
1935
|
+
"not"
|
|
1936
|
+
]);
|
|
1937
|
+
const allowedFields = new Set([
|
|
1938
|
+
"type",
|
|
1939
|
+
"description",
|
|
1940
|
+
"properties",
|
|
1941
|
+
"required",
|
|
1942
|
+
"items",
|
|
1943
|
+
"enum"
|
|
1910
1944
|
]);
|
|
1911
1945
|
for (const [key, value] of Object.entries(obj)) {
|
|
1912
1946
|
if (unsupportedFields.has(key)) continue;
|
|
1947
|
+
if (!allowedFields.has(key)) continue;
|
|
1913
1948
|
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1914
|
-
else if (typeof value === "object" && value !== null)
|
|
1949
|
+
else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
1950
|
+
const props = value;
|
|
1951
|
+
const cleanedProps = {};
|
|
1952
|
+
for (const [propKey, propValue] of Object.entries(props)) cleanedProps[propKey] = cleanJsonSchema(propValue);
|
|
1953
|
+
cleaned[key] = cleanedProps;
|
|
1954
|
+
} else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema(value);
|
|
1915
1955
|
else cleaned[key] = value;
|
|
1916
1956
|
}
|
|
1917
1957
|
return cleaned;
|