diff --git a/.stats.yml b/.stats.yml
index b87c540..6701b4a 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 22
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-05150c78e0e6e97b0ce97ed685ebcf1cb01dc839beccb99e9d3ead5b783cfd47.yml
-openapi_spec_hash: 833a5b6d53d98dc2beac2c4c394b20d5
-config_hash: bfc82d11ce9b808a15a860a9222ad78e
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-7270b9e4859010d6680bcc92afcd6f7c679d80a2645f65d7097d19ce2e8cdc5a.yml
+openapi_spec_hash: 5fcbfaedebfea62c17c74437a9728b04
+config_hash: 931828b5dd9393834a3c1703e02e02b0
diff --git a/api.md b/api.md
index a48e6d7..9d41e75 100644
--- a/api.md
+++ b/api.md
@@ -85,6 +85,7 @@ Response Types:
- opencode.Message
- opencode.Part
- opencode.Session
+- opencode.SnapshotPart
- opencode.StepFinishPart
- opencode.StepStartPart
- opencode.TextPart
diff --git a/session.go b/session.go
index c91de85..b62ade1 100644
--- a/session.go
+++ b/session.go
@@ -659,13 +659,13 @@ func (r *Part) UnmarshalJSON(data []byte) (err error) {
// for more type safety.
//
// Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
-// [StepStartPart], [StepFinishPart], [PartObject].
+// [StepStartPart], [StepFinishPart], [SnapshotPart].
func (r Part) AsUnion() PartUnion {
return r.union
}
// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
-// [StepFinishPart] or [PartObject].
+// [StepFinishPart] or [SnapshotPart].
type PartUnion interface {
implementsPart()
}
@@ -673,78 +673,40 @@ type PartUnion interface {
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*PartUnion)(nil)).Elem(),
- "",
+ "type",
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(TextPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(TextPart{}),
+ DiscriminatorValue: "text",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(FilePart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(FilePart{}),
+ DiscriminatorValue: "file",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolPart{}),
+ DiscriminatorValue: "tool",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(StepStartPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(StepStartPart{}),
+ DiscriminatorValue: "step-start",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(StepFinishPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(StepFinishPart{}),
+ DiscriminatorValue: "step-finish",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(PartObject{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(SnapshotPart{}),
+ DiscriminatorValue: "snapshot",
},
)
}
-type PartObject struct {
- ID string `json:"id,required"`
- MessageID string `json:"messageID,required"`
- SessionID string `json:"sessionID,required"`
- Snapshot string `json:"snapshot,required"`
- Type PartObjectType `json:"type,required"`
- JSON partObjectJSON `json:"-"`
-}
-
-// partObjectJSON contains the JSON metadata for the struct [PartObject]
-type partObjectJSON struct {
- ID apijson.Field
- MessageID apijson.Field
- SessionID apijson.Field
- Snapshot apijson.Field
- Type apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *PartObject) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r partObjectJSON) RawJSON() string {
- return r.raw
-}
-
-func (r PartObject) implementsPart() {}
-
-type PartObjectType string
-
-const (
- PartObjectTypeSnapshot PartObjectType = "snapshot"
-)
-
-func (r PartObjectType) IsKnown() bool {
- switch r {
- case PartObjectTypeSnapshot:
- return true
- }
- return false
-}
-
type PartType string
const (
@@ -862,6 +824,50 @@ func (r sessionShareJSON) RawJSON() string {
return r.raw
}
+type SnapshotPart struct {
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Snapshot string `json:"snapshot,required"`
+ Type SnapshotPartType `json:"type,required"`
+ JSON snapshotPartJSON `json:"-"`
+}
+
+// snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
+type snapshotPartJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
+ Snapshot apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r snapshotPartJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r SnapshotPart) implementsPart() {}
+
+type SnapshotPartType string
+
+const (
+ SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
+)
+
+func (r SnapshotPartType) IsKnown() bool {
+ switch r {
+ case SnapshotPartTypeSnapshot:
+ return true
+ }
+ return false
+}
+
type StepFinishPart struct {
ID string `json:"id,required"`
Cost float64 `json:"cost,required"`