summaryrefslogtreecommitdiffhomepage
path: root/packages/tui/sdk/session.go
diff options
context:
space:
mode:
authorDax <[email protected]>2025-07-18 13:42:50 -0400
committerGitHub <[email protected]>2025-07-18 13:42:50 -0400
commitd56dec4ba7867670d9a7dae2a535d38d59f24efb (patch)
treef10cde4e4aad0bc6d882266bdef96948251375f4 /packages/tui/sdk/session.go
parentc952e9ae3d74dcdda2a4fbdfef19b42c49096026 (diff)
downloadopencode-d56dec4ba7867670d9a7dae2a535d38d59f24efb.tar.gz
opencode-d56dec4ba7867670d9a7dae2a535d38d59f24efb.zip
wip: optional IDs in api (#1128)
Diffstat (limited to 'packages/tui/sdk/session.go')
-rw-r--r--packages/tui/sdk/session.go83
1 files changed, 53 insertions, 30 deletions
diff --git a/packages/tui/sdk/session.go b/packages/tui/sdk/session.go
index b62ade1f0..bfb2e2773 100644
--- a/packages/tui/sdk/session.go
+++ b/packages/tui/sdk/session.go
@@ -481,21 +481,33 @@ func (r FilePartType) IsKnown() bool {
return false
}
-type FilePartParam struct {
- ID param.Field[string] `json:"id,required"`
- MessageID param.Field[string] `json:"messageID,required"`
- Mime param.Field[string] `json:"mime,required"`
- SessionID param.Field[string] `json:"sessionID,required"`
- Type param.Field[FilePartType] `json:"type,required"`
- URL param.Field[string] `json:"url,required"`
- Filename param.Field[string] `json:"filename"`
+type FilePartInputParam struct {
+ Mime param.Field[string] `json:"mime,required"`
+ Type param.Field[FilePartInputType] `json:"type,required"`
+ URL param.Field[string] `json:"url,required"`
+ ID param.Field[string] `json:"id"`
+ Filename param.Field[string] `json:"filename"`
}
-func (r FilePartParam) MarshalJSON() (data []byte, err error) {
+func (r FilePartInputParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r FilePartParam) implementsSessionChatParamsPartUnion() {}
+func (r FilePartInputParam) implementsSessionChatParamsPartUnion() {}
+
+type FilePartInputType string
+
+const (
+ FilePartInputTypeFile FilePartInputType = "file"
+)
+
+func (r FilePartInputType) IsKnown() bool {
+ switch r {
+ case FilePartInputTypeFile:
+ return true
+ }
+ return false
+}
type Message struct {
ID string `json:"id,required"`
@@ -1076,28 +1088,40 @@ func (r textPartTimeJSON) RawJSON() string {
return r.raw
}
-type TextPartParam struct {
- ID param.Field[string] `json:"id,required"`
- MessageID param.Field[string] `json:"messageID,required"`
- SessionID param.Field[string] `json:"sessionID,required"`
- Text param.Field[string] `json:"text,required"`
- Type param.Field[TextPartType] `json:"type,required"`
- Synthetic param.Field[bool] `json:"synthetic"`
- Time param.Field[TextPartTimeParam] `json:"time"`
+type TextPartInputParam struct {
+ Text param.Field[string] `json:"text,required"`
+ Type param.Field[TextPartInputType] `json:"type,required"`
+ ID param.Field[string] `json:"id"`
+ Synthetic param.Field[bool] `json:"synthetic"`
+ Time param.Field[TextPartInputTimeParam] `json:"time"`
}
-func (r TextPartParam) MarshalJSON() (data []byte, err error) {
+func (r TextPartInputParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r TextPartParam) implementsSessionChatParamsPartUnion() {}
+func (r TextPartInputParam) implementsSessionChatParamsPartUnion() {}
+
+type TextPartInputType string
-type TextPartTimeParam struct {
+const (
+ TextPartInputTypeText TextPartInputType = "text"
+)
+
+func (r TextPartInputType) IsKnown() bool {
+ switch r {
+ case TextPartInputTypeText:
+ return true
+ }
+ return false
+}
+
+type TextPartInputTimeParam struct {
Start param.Field[float64] `json:"start,required"`
End param.Field[float64] `json:"end"`
}
-func (r TextPartTimeParam) MarshalJSON() (data []byte, err error) {
+func (r TextPartInputTimeParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
@@ -1574,11 +1598,11 @@ func (r sessionMessagesResponseJSON) RawJSON() string {
}
type SessionChatParams struct {
- MessageID param.Field[string] `json:"messageID,required"`
- Mode param.Field[string] `json:"mode,required"`
ModelID param.Field[string] `json:"modelID,required"`
Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"`
ProviderID param.Field[string] `json:"providerID,required"`
+ MessageID param.Field[string] `json:"messageID"`
+ Mode param.Field[string] `json:"mode"`
}
func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
@@ -1586,10 +1610,8 @@ func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
}
type SessionChatParamsPart struct {
- ID param.Field[string] `json:"id,required"`
- MessageID param.Field[string] `json:"messageID,required"`
- SessionID param.Field[string] `json:"sessionID,required"`
Type param.Field[SessionChatParamsPartsType] `json:"type,required"`
+ ID param.Field[string] `json:"id"`
Filename param.Field[string] `json:"filename"`
Mime param.Field[string] `json:"mime"`
Synthetic param.Field[bool] `json:"synthetic"`
@@ -1604,7 +1626,8 @@ func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
-// Satisfied by [FilePartParam], [TextPartParam], [SessionChatParamsPart].
+// Satisfied by [TextPartInputParam], [FilePartInputParam],
+// [SessionChatParamsPart].
type SessionChatParamsPartUnion interface {
implementsSessionChatParamsPartUnion()
}
@@ -1612,13 +1635,13 @@ type SessionChatParamsPartUnion interface {
type SessionChatParamsPartsType string
const (
- SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
+ SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
)
func (r SessionChatParamsPartsType) IsKnown() bool {
switch r {
- case SessionChatParamsPartsTypeFile, SessionChatParamsPartsTypeText:
+ case SessionChatParamsPartsTypeText, SessionChatParamsPartsTypeFile:
return true
}
return false