copilot-api-plus 1.0.26 → 1.0.28
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
|
@@ -1313,7 +1313,7 @@ function convertMessages$1(messages) {
|
|
|
1313
1313
|
*/
|
|
1314
1314
|
function buildSystemInstruction(content) {
|
|
1315
1315
|
return {
|
|
1316
|
-
role: "
|
|
1316
|
+
role: "system",
|
|
1317
1317
|
parts: [{ text: typeof content === "string" ? content : content.map((c) => c.text || "").join("") }]
|
|
1318
1318
|
};
|
|
1319
1319
|
}
|
|
@@ -1346,6 +1346,7 @@ function parseBase64Image(url) {
|
|
|
1346
1346
|
* Clean and convert JSON schema to Gemini format
|
|
1347
1347
|
* - Removes unsupported fields like $schema, additionalProperties
|
|
1348
1348
|
* - Converts type values to uppercase (string -> STRING)
|
|
1349
|
+
* - Ensures properties format is correct for Google API
|
|
1349
1350
|
*/
|
|
1350
1351
|
function cleanJsonSchema$1(schema) {
|
|
1351
1352
|
if (!schema || typeof schema !== "object") return schema;
|
|
@@ -1366,12 +1367,31 @@ function cleanJsonSchema$1(schema) {
|
|
|
1366
1367
|
"minimum",
|
|
1367
1368
|
"maximum",
|
|
1368
1369
|
"pattern",
|
|
1369
|
-
"format"
|
|
1370
|
+
"format",
|
|
1371
|
+
"const",
|
|
1372
|
+
"allOf",
|
|
1373
|
+
"anyOf",
|
|
1374
|
+
"oneOf",
|
|
1375
|
+
"not"
|
|
1376
|
+
]);
|
|
1377
|
+
const allowedFields = new Set([
|
|
1378
|
+
"type",
|
|
1379
|
+
"description",
|
|
1380
|
+
"properties",
|
|
1381
|
+
"required",
|
|
1382
|
+
"items",
|
|
1383
|
+
"enum"
|
|
1370
1384
|
]);
|
|
1371
1385
|
for (const [key, value] of Object.entries(obj)) {
|
|
1372
1386
|
if (unsupportedFields.has(key)) continue;
|
|
1387
|
+
if (!allowedFields.has(key)) continue;
|
|
1373
1388
|
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1374
|
-
else if (typeof value === "object" && value !== null)
|
|
1389
|
+
else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
1390
|
+
const props = value;
|
|
1391
|
+
const cleanedProps = {};
|
|
1392
|
+
for (const [propKey, propValue] of Object.entries(props)) cleanedProps[propKey] = cleanJsonSchema$1(propValue);
|
|
1393
|
+
cleaned[key] = cleanedProps;
|
|
1394
|
+
} else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema$1(value);
|
|
1375
1395
|
else cleaned[key] = value;
|
|
1376
1396
|
}
|
|
1377
1397
|
return cleaned;
|
|
@@ -1859,7 +1879,7 @@ function convertMessages(messages, system) {
|
|
|
1859
1879
|
const contents = [];
|
|
1860
1880
|
let systemInstruction;
|
|
1861
1881
|
if (system) systemInstruction = {
|
|
1862
|
-
role: "
|
|
1882
|
+
role: "system",
|
|
1863
1883
|
parts: [{ text: system }]
|
|
1864
1884
|
};
|
|
1865
1885
|
for (const message of messages) {
|
|
@@ -1892,6 +1912,7 @@ function buildParts(content) {
|
|
|
1892
1912
|
* Clean and convert JSON schema to Gemini format
|
|
1893
1913
|
* - Removes unsupported fields like $schema, additionalProperties
|
|
1894
1914
|
* - Converts type values to uppercase (string -> STRING)
|
|
1915
|
+
* - Ensures properties format is correct for Google API
|
|
1895
1916
|
*/
|
|
1896
1917
|
function cleanJsonSchema(schema) {
|
|
1897
1918
|
if (!schema || typeof schema !== "object") return schema;
|
|
@@ -1912,12 +1933,31 @@ function cleanJsonSchema(schema) {
|
|
|
1912
1933
|
"minimum",
|
|
1913
1934
|
"maximum",
|
|
1914
1935
|
"pattern",
|
|
1915
|
-
"format"
|
|
1936
|
+
"format",
|
|
1937
|
+
"const",
|
|
1938
|
+
"allOf",
|
|
1939
|
+
"anyOf",
|
|
1940
|
+
"oneOf",
|
|
1941
|
+
"not"
|
|
1942
|
+
]);
|
|
1943
|
+
const allowedFields = new Set([
|
|
1944
|
+
"type",
|
|
1945
|
+
"description",
|
|
1946
|
+
"properties",
|
|
1947
|
+
"required",
|
|
1948
|
+
"items",
|
|
1949
|
+
"enum"
|
|
1916
1950
|
]);
|
|
1917
1951
|
for (const [key, value] of Object.entries(obj)) {
|
|
1918
1952
|
if (unsupportedFields.has(key)) continue;
|
|
1953
|
+
if (!allowedFields.has(key)) continue;
|
|
1919
1954
|
if (key === "type" && typeof value === "string") cleaned[key] = value.toUpperCase();
|
|
1920
|
-
else if (typeof value === "object" && value !== null)
|
|
1955
|
+
else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
1956
|
+
const props = value;
|
|
1957
|
+
const cleanedProps = {};
|
|
1958
|
+
for (const [propKey, propValue] of Object.entries(props)) cleanedProps[propKey] = cleanJsonSchema(propValue);
|
|
1959
|
+
cleaned[key] = cleanedProps;
|
|
1960
|
+
} else if (typeof value === "object" && value !== null) cleaned[key] = cleanJsonSchema(value);
|
|
1921
1961
|
else cleaned[key] = value;
|
|
1922
1962
|
}
|
|
1923
1963
|
return cleaned;
|