Skip to content

Commit b3a285a

Browse files
committed
Update version to v1.0.7
1 parent b5b451e commit b3a285a

4 files changed

Lines changed: 61 additions & 14 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OpenAI-compatible proxy server for the CommandCode API. It exposes `/v1/chat/com
44

55
Repository: https://github.com/dev2k6/command-code-proxy-server
66

7-
Version: `v1.0.6`
7+
Version: `v1.0.7`
88

99
## Features
1010

@@ -219,7 +219,7 @@ https://api.github.com/repos/dev2k6/command-code-proxy-server/tags
219219
If the latest GitHub tag is newer than the current app version, the version line is displayed as:
220220

221221
```text
222-
v1.0.6 (latest: v1.x.x)
222+
v1.0.7 (latest: v1.x.x)
223223
```
224224

225225
## CommandCode version header

internal/api/commandcode.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@ package api
22

33
// CommandCode API types (internal)
44

5+
type CCToolOutput struct {
6+
Type string `json:"type"`
7+
Value string `json:"value"`
8+
}
9+
510
type CCContentPart struct {
6-
Type string `json:"type"`
7-
Text *string `json:"text,omitempty"`
8-
ID *string `json:"id,omitempty"`
9-
Name *string `json:"name,omitempty"`
10-
Input any `json:"input,omitempty"`
11-
ToolUseID *string `json:"tool_use_id,omitempty"`
12-
Content any `json:"content,omitempty"`
11+
Type string `json:"type"`
12+
Text *string `json:"text,omitempty"`
13+
ID *string `json:"id,omitempty"`
14+
Name *string `json:"name,omitempty"`
15+
Input any `json:"input,omitempty"`
16+
ToolCallID *string `json:"toolCallId,omitempty"`
17+
ToolName *string `json:"toolName,omitempty"`
18+
Output *CCToolOutput `json:"output,omitempty"`
19+
ToolUseID *string `json:"tool_use_id,omitempty"`
20+
Content any `json:"content,omitempty"`
1321
}
1422

1523
type CCMessage struct {

internal/proxy/convert.go

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,28 @@ func ConvertMessages(openAIMsgs []api.OpenAIMessage) []api.CCMessage {
2121
}
2222

2323
if m.Role == "tool" {
24+
toolName := m.Name
25+
if toolName == "" {
26+
toolName = toolNames[m.ToolCallID]
27+
}
28+
if toolName == "" {
29+
toolName = "unknown"
30+
}
31+
contentStr := contentToString(m.Content)
32+
outputType := "text"
33+
if strings.HasPrefix(contentStr, "Error:") {
34+
outputType = "error-text"
35+
}
2436
ccMsgs = append(ccMsgs, api.CCMessage{
2537
Role: "tool",
2638
Content: []api.CCContentPart{{
27-
Type: "tool_result",
28-
ToolUseID: strPtr(m.ToolCallID),
29-
Content: contentToString(m.Content),
39+
Type: "tool-result",
40+
ToolCallID: strPtr(m.ToolCallID),
41+
ToolName: strPtr(toolName),
42+
Output: &api.CCToolOutput{
43+
Type: outputType,
44+
Value: contentStr,
45+
},
3046
}},
3147
})
3248
continue
@@ -225,7 +241,30 @@ func parseContent(content interface{}, toolNames map[string]string) []api.CCCont
225241
if toolID == "" {
226242
toolID, _ = partMap["toolCallId"].(string)
227243
}
228-
parts = append(parts, api.CCContentPart{Type: "tool_result", ToolUseID: strPtr(toolID), Content: contentPartToString(partMap["content"])})
244+
toolName, _ := partMap["toolName"].(string)
245+
if toolName == "" {
246+
toolName = toolNames[toolID]
247+
}
248+
if toolName == "" {
249+
toolName = "unknown"
250+
}
251+
contentVal := contentPartToString(partMap["content"])
252+
if contentVal == "" {
253+
contentVal = contentPartToString(partMap["output"])
254+
}
255+
outputType := "text"
256+
if strings.HasPrefix(contentVal, "Error:") {
257+
outputType = "error-text"
258+
}
259+
parts = append(parts, api.CCContentPart{
260+
Type: "tool-result",
261+
ToolCallID: strPtr(toolID),
262+
ToolName: strPtr(toolName),
263+
Output: &api.CCToolOutput{
264+
Type: outputType,
265+
Value: contentVal,
266+
},
267+
})
229268
}
230269
}
231270
return parts

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/dev2k6/command-code-proxy-server/internal/update"
1010
)
1111

12-
const appVersion = "v1.0.6"
12+
const appVersion = "v1.0.7"
1313
const repositoryURL = "https://github.com/dev2k6/command-code-proxy-server"
1414
const debugLogging = false
1515

0 commit comments

Comments
 (0)