summaryrefslogtreecommitdiffhomepage
path: root/internal/message/content.go
diff options
context:
space:
mode:
authorKujtim Hoxha <[email protected]>2025-04-12 02:01:45 +0200
committerKujtim Hoxha <[email protected]>2025-04-21 13:38:42 +0200
commit8d874b839db169906e18e4277cd198504018e022 (patch)
tree658a1adbee42a0ca2249252827fb37f7469f3667 /internal/message/content.go
parent08bd75bb6e1fde0427dfd37204ee9a3c43bb1e5b (diff)
downloadopencode-8d874b839db169906e18e4277cd198504018e022.tar.gz
opencode-8d874b839db169906e18e4277cd198504018e022.zip
add initial message handling
Diffstat (limited to 'internal/message/content.go')
-rw-r--r--internal/message/content.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/internal/message/content.go b/internal/message/content.go
index 2604cd68a..cd263798b 100644
--- a/internal/message/content.go
+++ b/internal/message/content.go
@@ -2,6 +2,7 @@ package message
import (
"encoding/base64"
+ "time"
)
type MessageRole string
@@ -64,6 +65,7 @@ type ToolCall struct {
Name string `json:"name"`
Input string `json:"input"`
Type string `json:"type"`
+ Metadata any `json:"metadata"`
Finished bool `json:"finished"`
}
@@ -80,6 +82,7 @@ func (ToolResult) isPart() {}
type Finish struct {
Reason string `json:"reason"`
+ Time int64 `json:"time"`
}
func (Finish) isPart() {}
@@ -161,6 +164,15 @@ func (m *Message) IsFinished() bool {
return false
}
+func (m *Message) FinishPart() *Finish {
+ for _, part := range m.Parts {
+ if c, ok := part.(Finish); ok {
+ return &c
+ }
+ }
+ return nil
+}
+
func (m *Message) FinishReason() string {
for _, part := range m.Parts {
if c, ok := part.(Finish); ok {
@@ -232,7 +244,7 @@ func (m *Message) SetToolResults(tr []ToolResult) {
}
func (m *Message) AddFinish(reason string) {
- m.Parts = append(m.Parts, Finish{Reason: reason})
+ m.Parts = append(m.Parts, Finish{Reason: reason, Time: time.Now().Unix()})
}
func (m *Message) AddImageURL(url, detail string) {