summaryrefslogtreecommitdiff
path: root/internal/api/logs.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-08 21:03:50 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-08 21:03:50 +0000
commit632ea5a44731af94b6238f330a3b5440906c8ae7 (patch)
treed8c780412598d66b89ef390b5729e379fdfd9d5b /internal/api/logs.go
parent406247b14985ab57902e8e42898dc8cb8960290d (diff)
parent93a4c852bf726b00e8014d385165f847763fa214 (diff)
merge: pull latest from master and resolve conflicts
- Resolve conflicts in API server, CLI, and executor. - Maintain Gemini classification and assignment logic. - Update UI to use generic agent config and project_dir. - Fix ProjectDir/WorkingDir inconsistencies in Gemini runner. - All tests passing after merge.
Diffstat (limited to 'internal/api/logs.go')
-rw-r--r--internal/api/logs.go33
1 files changed, 18 insertions, 15 deletions
diff --git a/internal/api/logs.go b/internal/api/logs.go
index 1ba4b00..4e63489 100644
--- a/internal/api/logs.go
+++ b/internal/api/logs.go
@@ -36,9 +36,10 @@ var terminalStates = map[string]bool{
}
type logStreamMsg struct {
- Type string `json:"type"`
- Message *logAssistMsg `json:"message,omitempty"`
- CostUSD float64 `json:"cost_usd,omitempty"`
+ Type string `json:"type"`
+ Message *logAssistMsg `json:"message,omitempty"`
+ CostUSD float64 `json:"cost_usd,omitempty"`
+ TotalCostUSD float64 `json:"total_cost_usd,omitempty"`
}
type logAssistMsg struct {
@@ -258,29 +259,31 @@ func emitLogLine(w http.ResponseWriter, flusher http.Flusher, line []byte) {
return
}
for _, block := range msg.Message.Content {
- var event map[string]string
+ var data []byte
switch block.Type {
case "text":
- event = map[string]string{"type": "text", "content": block.Text}
+ data, _ = json.Marshal(map[string]string{"type": "text", "content": block.Text})
case "tool_use":
- summary := string(block.Input)
- if len(summary) > 80 {
- summary = summary[:80]
- }
- event = map[string]string{"type": "tool_use", "content": fmt.Sprintf("%s(%s)", block.Name, summary)}
+ data, _ = json.Marshal(struct {
+ Type string `json:"type"`
+ Name string `json:"name"`
+ Input json.RawMessage `json:"input,omitempty"`
+ }{Type: "tool_use", Name: block.Name, Input: block.Input})
default:
continue
}
- data, _ := json.Marshal(event)
fmt.Fprintf(w, "data: %s\n\n", data)
flusher.Flush()
}
case "result":
- event := map[string]string{
- "type": "cost",
- "content": fmt.Sprintf("%g", msg.CostUSD),
+ cost := msg.TotalCostUSD
+ if cost == 0 {
+ cost = msg.CostUSD
}
- data, _ := json.Marshal(event)
+ data, _ := json.Marshal(struct {
+ Type string `json:"type"`
+ TotalCost float64 `json:"total_cost"`
+ }{Type: "cost", TotalCost: cost})
fmt.Fprintf(w, "data: %s\n\n", data)
flusher.Flush()
}