@kenkaiiii/gg-ai 4.5.0 → 4.6.0

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/index.cjs CHANGED
@@ -205,7 +205,7 @@ function finaliseBySource(source, message, requestId, hint) {
205
205
  headline: message,
206
206
  source,
207
207
  message: "",
208
- guidance: hint ?? "Only Kimi, Gemini, and MiniMax can analyze video. Switch with /model.",
208
+ guidance: hint ?? "Only Kimi, Gemini, MiniMax, and MiMo-V2.5 can analyze video. Switch with /model.",
209
209
  ...requestId ? { requestId } : {}
210
210
  };
211
211
  case "ggcoder":
@@ -848,13 +848,14 @@ function toOpenAIMessages(messages, options) {
848
848
  }
849
849
  if (msg.role === "tool") {
850
850
  const isMoonshot = options?.provider === "moonshot";
851
- const imageBlocks = [];
851
+ const followUpMediaBlocks = [];
852
+ let followUpHasVideo = false;
852
853
  for (const result of msg.content) {
853
854
  const text = toolResultText(result.content);
854
855
  const images = toolResultImages(result.content);
855
- const videos = isMoonshot ? toolResultVideos(result.content) : [];
856
+ const videos = toolResultVideos(result.content);
856
857
  const hasText = text.length > 0;
857
- if (videos.length > 0) {
858
+ if (isMoonshot && videos.length > 0) {
858
859
  const parts = [];
859
860
  if (hasText) parts.push({ type: "text", text });
860
861
  const videoParts = videos.map((v) => {
@@ -871,21 +872,31 @@ function toOpenAIMessages(messages, options) {
871
872
  out.push({
872
873
  role: "tool",
873
874
  tool_call_id: remapToolCallId(result.toolCallId, idMap),
874
- content: hasText ? text : "(see attached image)"
875
+ content: hasText ? text : "(see attached media)"
875
876
  });
876
877
  if (images.length > 0 && options?.supportsImages !== false) {
877
878
  for (const img of images) {
878
- imageBlocks.push({
879
+ followUpMediaBlocks.push({
879
880
  type: "image_url",
880
881
  image_url: { url: `data:${img.mediaType};base64,${img.data}` }
881
882
  });
882
883
  }
883
884
  }
885
+ if (!isMoonshot && videos.length > 0) {
886
+ for (const v of videos) {
887
+ followUpMediaBlocks.push({
888
+ type: "video_url",
889
+ video_url: { url: `data:${v.mediaType};base64,${v.data}` }
890
+ });
891
+ followUpHasVideo = true;
892
+ }
893
+ }
884
894
  }
885
- if (imageBlocks.length > 0) {
895
+ if (followUpMediaBlocks.length > 0) {
896
+ const label = followUpHasVideo ? "Attached media from tool result:" : "Attached image(s) from tool result:";
886
897
  out.push({
887
898
  role: "user",
888
- content: [{ type: "text", text: "Attached image(s) from tool result:" }, ...imageBlocks]
899
+ content: [{ type: "text", text: label }, ...followUpMediaBlocks]
889
900
  });
890
901
  }
891
902
  }