Unified · Split
| @@ -604,10 +604,22 @@ type kiroHistoryMessage struct { · 603 unmodified lines | |||
| 604 | AssistantResponseMessage *kiroAssistantResponseMessage `json:"assistantResponseMessage,omitempty"` | 604 | AssistantResponseMessage *kiroAssistantResponseMessage `json:"assistantResponseMessage,omitempty"` |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | // kiroImage represents an image in Kiro API format | ||
| 608 | type kiroImage struct { | ||
| 609 | Format string `json:"format"` | ||
| 610 | Source kiroImageSource `json:"source"` | ||
| 611 | } | ||
| 612 | |||
| 613 | // kiroImageSource contains the image data | ||
| 614 | type kiroImageSource struct { | ||
| 615 | Bytes string `json:"bytes"` // base64 encoded image data | ||
| 616 | } | ||
| 617 | |||
| 607 | type kiroUserInputMessage struct { | 618 | type kiroUserInputMessage struct { |
| 608 | Content string `json:"content"` | 619 | Content string `json:"content"` |
| 609 | ModelID string `json:"modelId"` | 620 | ModelID string `json:"modelId"` |
| 610 | Origin string `json:"origin"` | 621 | Origin string `json:"origin"` |
| 622 | Images []kiroImage `json:"images,omitempty"` | ||
| 611 | UserInputMessageContext *kiroUserInputMessageContext `json:"userInputMessageContext,omitempty"` | 623 | UserInputMessageContext *kiroUserInputMessageContext `json:"userInputMessageContext,omitempty"` |
| 612 | } | 624 | } |
| 613 | 625 | ||
| @@ -824,6 +836,7 @@ func (e *KiroExecutor) buildUserMessageStruct(msg gjson.Result, modelID, origin · 210 unmodified lines | |||
| 824 | content := msg.Get("content") | 836 | content := msg.Get("content") |
| 825 | var contentBuilder strings.Builder | 837 | var contentBuilder strings.Builder |
| 826 | var toolResults []kiroToolResult | 838 | var toolResults []kiroToolResult |
| 839 | var images []kiroImage | ||
| 827 | 840 | ||
| 828 | if content.IsArray() { | 841 | if content.IsArray() { |
| 829 | for _, part := range content.Array() { | 842 | for _, part := range content.Array() { |
| @@ -831,6 +844,25 @@ func (e *KiroExecutor) buildUserMessageStruct(msg gjson.Result, modelID, origin · 1 unmodified line | |||
| 831 | switch partType { | 844 | switch partType { |
| 832 | case "text": | 845 | case "text": |
| 833 | contentBuilder.WriteString(part.Get("text").String()) | 846 | contentBuilder.WriteString(part.Get("text").String()) |
| 847 | case "image": | ||
| 848 | // Extract image data from Claude API format | ||
| 849 | mediaType := part.Get("source.media_type").String() | ||
| 850 | data := part.Get("source.data").String() | ||
| 851 | |||
| 852 | // Extract format from media_type (e.g., "image/png" -> "png") | ||
| 853 | format := "" | ||
| 854 | if idx := strings.LastIndex(mediaType, "/"); idx != -1 { | ||
| 855 | format = mediaType[idx+1:] | ||
| 856 | } | ||
| 857 | |||
| 858 | if format != "" && data != "" { | ||
| 859 | images = append(images, kiroImage{ | ||
| 860 | Format: format, | ||
| 861 | Source: kiroImageSource{ | ||
| 862 | Bytes: data, | ||
| 863 | }, | ||
| 864 | }) | ||
| 865 | } | ||
| 834 | case "tool_result": | 866 | case "tool_result": |
| 835 | // Extract tool result for API | 867 | // Extract tool result for API |
| 836 | toolUseID := part.Get("tool_use_id").String() | 868 | toolUseID := part.Get("tool_use_id").String() |
| @@ -872,11 +904,18 @@ func (e *KiroExecutor) buildUserMessageStruct(msg gjson.Result, modelID, origin · 35 unmodified lines | |||
| 872 | contentBuilder.WriteString(content.String()) | 904 | contentBuilder.WriteString(content.String()) |
| 873 | } | 905 | } |
| 874 | 906 | ||
| 875 | return kiroUserInputMessage{ | 907 | userMsg := kiroUserInputMessage{ |
| 876 | Content: contentBuilder.String(), | 908 | Content: contentBuilder.String(), |
| 877 | ModelID: modelID, | 909 | ModelID: modelID, |
| 878 | Origin: origin, | 910 | Origin: origin, |
| 879 | }, toolResults | 911 | } |
| 912 | |||
| 913 | // Add images to message if present | ||
| 914 | if len(images) > 0 { | ||
| 915 | userMsg.Images = images | ||
| 916 | } | ||
| 917 | |||
| 918 | return userMsg, toolResults | ||
| 880 | } | 919 | } |
| 881 | 920 | ||
| 882 | // buildAssistantMessageStruct builds an assistant message with tool uses | 921 | // buildAssistantMessageStruct builds an assistant message with tool uses |