@jeffreycao/copilot-api 2.2.5 → 2.2.7
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 +1 -1
- package/dist/{server-9Fk9a6_A.js → server-DT2XCiFm.js} +38 -19
- package/dist/server-DT2XCiFm.js.map +1 -0
- package/dist/{start-CO8nU6_-.js → start-DgPGr019.js} +2 -2
- package/dist/{start-CO8nU6_-.js.map → start-DgPGr019.js.map} +1 -1
- package/package.json +1 -1
- package/dist/server-9Fk9a6_A.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -30,7 +30,7 @@ if (isMcpFastPath(process.argv)) {
|
|
|
30
30
|
const { auth } = await import("./auth-C-RWNXGU.js");
|
|
31
31
|
const { debug } = await import("./debug-41w6Whae.js");
|
|
32
32
|
const { mcp } = await import("./mcp-fpSlKZxK.js");
|
|
33
|
-
const { start } = await import("./start-
|
|
33
|
+
const { start } = await import("./start-DgPGr019.js");
|
|
34
34
|
await runMain(defineCommand({
|
|
35
35
|
meta: {
|
|
36
36
|
name: "copilot-api",
|
|
@@ -5956,37 +5956,43 @@ const sanitizeOversizedInputImages = (payload, maxPromptImageSize) => {
|
|
|
5956
5956
|
if (limit === void 0 || !Array.isArray(payload.input)) return 0;
|
|
5957
5957
|
return sanitizeInputImages(payload.input, (image) => image.decodedBytes > limit);
|
|
5958
5958
|
};
|
|
5959
|
+
const normalizeInputImageDetails = (payload) => {
|
|
5960
|
+
if (!Array.isArray(payload.input)) return 0;
|
|
5961
|
+
let normalizedCount = 0;
|
|
5962
|
+
for (const image of collectInputImages(payload.input)) {
|
|
5963
|
+
if (image.detail === void 0 || VALID_INPUT_IMAGE_DETAILS.has(image.detail)) continue;
|
|
5964
|
+
image.detail = "auto";
|
|
5965
|
+
normalizedCount += 1;
|
|
5966
|
+
}
|
|
5967
|
+
return normalizedCount;
|
|
5968
|
+
};
|
|
5959
5969
|
const sanitizeInputImages = (input, shouldReplace) => {
|
|
5960
5970
|
let count = 0;
|
|
5961
|
-
for (const
|
|
5971
|
+
for (const record of collectInputImages(input)) {
|
|
5972
|
+
const image = getInputImageDataUrl(record);
|
|
5973
|
+
if (!image) continue;
|
|
5962
5974
|
if (!shouldReplace(image)) continue;
|
|
5963
5975
|
replaceInputImageWithPlaceholder(image);
|
|
5964
5976
|
count += 1;
|
|
5965
5977
|
}
|
|
5966
5978
|
return count;
|
|
5967
5979
|
};
|
|
5968
|
-
const
|
|
5969
|
-
for (const item of input)
|
|
5980
|
+
const collectInputImages = (input, images = []) => {
|
|
5981
|
+
for (const item of input) if (isResponseInputMessage(item)) collectContentImages(item.content, images);
|
|
5982
|
+
else if (isResponseFunctionCallOutputItem(item)) collectContentImages(item.output, images);
|
|
5970
5983
|
return images;
|
|
5971
5984
|
};
|
|
5972
|
-
const
|
|
5973
|
-
if (isResponseInputMessage(item)) collectContentImageDataUrls(item.content, images);
|
|
5974
|
-
else if (isResponseFunctionCallOutputItem(item)) collectContentImageDataUrls(item.output, images);
|
|
5975
|
-
};
|
|
5976
|
-
const collectContentImageDataUrls = (content, images) => {
|
|
5985
|
+
const collectContentImages = (content, images) => {
|
|
5977
5986
|
if (!Array.isArray(content)) return;
|
|
5978
|
-
for (const block of content)
|
|
5979
|
-
const image = getInputImageDataUrl(block);
|
|
5980
|
-
if (image) images.push(image);
|
|
5981
|
-
}
|
|
5987
|
+
for (const block of content) if (isResponseInputImage(block)) images.push(block);
|
|
5982
5988
|
};
|
|
5983
|
-
const getInputImageDataUrl = (
|
|
5984
|
-
if (
|
|
5985
|
-
const imageUrl =
|
|
5989
|
+
const getInputImageDataUrl = (image) => {
|
|
5990
|
+
if (typeof image.image_url !== "string") return null;
|
|
5991
|
+
const imageUrl = image.image_url;
|
|
5986
5992
|
if (!imageUrl.startsWith(DATA_URL_PREFIX)) return null;
|
|
5987
5993
|
return {
|
|
5988
5994
|
decodedBytes: estimateDataUrlByteLength(imageUrl),
|
|
5989
|
-
record:
|
|
5995
|
+
record: image
|
|
5990
5996
|
};
|
|
5991
5997
|
};
|
|
5992
5998
|
const estimateDataUrlByteLength = (value) => {
|
|
@@ -5998,11 +6004,16 @@ const replaceInputImageWithPlaceholder = (image) => {
|
|
|
5998
6004
|
image.record.detail = "low";
|
|
5999
6005
|
delete image.record.file_id;
|
|
6000
6006
|
};
|
|
6007
|
+
const VALID_INPUT_IMAGE_DETAILS = new Set([
|
|
6008
|
+
"auto",
|
|
6009
|
+
"high",
|
|
6010
|
+
"low"
|
|
6011
|
+
]);
|
|
6001
6012
|
const isResponseInputMessage = (item) => {
|
|
6002
6013
|
return typeof item === "object" && item !== null && "role" in item && typeof item.role === "string";
|
|
6003
6014
|
};
|
|
6004
6015
|
const isResponseFunctionCallOutputItem = (item) => {
|
|
6005
|
-
return typeof item === "object" && item !== null && "type" in item && item.type === "function_call_output";
|
|
6016
|
+
return typeof item === "object" && item !== null && "type" in item && (item.type === "custom_tool_call_output" || item.type === "function_call_output");
|
|
6006
6017
|
};
|
|
6007
6018
|
const isResponseInputImage = (content) => {
|
|
6008
6019
|
return typeof content === "object" && content !== null && "type" in content && content.type === "input_image";
|
|
@@ -8868,7 +8879,13 @@ function translateToolResultContent(value, path) {
|
|
|
8868
8879
|
if (value === void 0 || value === null) return "";
|
|
8869
8880
|
if (typeof value === "string") return value;
|
|
8870
8881
|
if (!Array.isArray(value)) throw new ResponsesMessagesTranslationError(`${path} must be text or an array`);
|
|
8871
|
-
|
|
8882
|
+
const blocks = value.flatMap((part, index) => isEmptyTextContentPart(part) ? [] : [translateUserContentPart(part, `${path}[${index}]`)]);
|
|
8883
|
+
return blocks.length > 0 ? blocks : "";
|
|
8884
|
+
}
|
|
8885
|
+
function isEmptyTextContentPart(part) {
|
|
8886
|
+
if (!isRecord(part)) return false;
|
|
8887
|
+
const type = part.type;
|
|
8888
|
+
return (type === "input_text" || type === "output_text" || type === "text") && part.text === "";
|
|
8872
8889
|
}
|
|
8873
8890
|
function translateImagePart(part, path) {
|
|
8874
8891
|
const imageUrl = getStringField(part, "image_url");
|
|
@@ -10245,6 +10262,8 @@ const handleResponses = async (c) => {
|
|
|
10245
10262
|
});
|
|
10246
10263
|
const sanitizedUnsupportedFieldCount = sanitizeUnsupportedInputFields(payload);
|
|
10247
10264
|
if (sanitizedUnsupportedFieldCount > 0) logger$1.debug(`Removed ${sanitizedUnsupportedFieldCount} unsupported input field(s) before forwarding to Copilot Responses`);
|
|
10265
|
+
const normalizedImageDetailCount = normalizeInputImageDetails(payload);
|
|
10266
|
+
if (normalizedImageDetailCount > 0) logger$1.debug(`Normalized ${normalizedImageDetailCount} unsupported input image detail value(s) before forwarding to Copilot Responses`);
|
|
10248
10267
|
removeUnsupportedTools(payload);
|
|
10249
10268
|
fillEmptyNamespaceToolDescriptions(payload);
|
|
10250
10269
|
if (!responsesHandlerDependencies.isResponsesApiWebSearchEnabled()) removeWebSearchTool(payload);
|
|
@@ -10508,4 +10527,4 @@ server.route("/:provider/images", providerImageRoutes);
|
|
|
10508
10527
|
//#endregion
|
|
10509
10528
|
export { server };
|
|
10510
10529
|
|
|
10511
|
-
//# sourceMappingURL=server-
|
|
10530
|
+
//# sourceMappingURL=server-DT2XCiFm.js.map
|