diff options
| author | Dax Raad <[email protected]> | 2025-07-14 14:44:47 -0400 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-07-14 15:29:08 -0400 |
| commit | b4e4c3f662fc262755b989cacc2e3845418b1d34 (patch) | |
| tree | ae5a1e09b46309fa5aee82ef9ff7eba831b97a7a /packages/tui/sdk | |
| parent | ba676e7ae095a6e2089b2b061a1ec8f3cffd4e42 (diff) | |
| download | opencode-b4e4c3f662fc262755b989cacc2e3845418b1d34.tar.gz opencode-b4e4c3f662fc262755b989cacc2e3845418b1d34.zip | |
wip: snapshot
Diffstat (limited to 'packages/tui/sdk')
| -rw-r--r-- | packages/tui/sdk/.stats.yml | 4 | ||||
| -rw-r--r-- | packages/tui/sdk/session.go | 86 |
2 files changed, 68 insertions, 22 deletions
diff --git a/packages/tui/sdk/.stats.yml b/packages/tui/sdk/.stats.yml index c2069e9c5..5aeba9efe 100644 --- a/packages/tui/sdk/.stats.yml +++ b/packages/tui/sdk/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 22 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-9bdc593eab163d2165321716af6a4c13253792ad409420790ed6196da4178d3a.yml -openapi_spec_hash: c687f53ada739d315e2e7056df93d999 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-05150c78e0e6e97b0ce97ed685ebcf1cb01dc839beccb99e9d3ead5b783cfd47.yml +openapi_spec_hash: 833a5b6d53d98dc2beac2c4c394b20d5 config_hash: 3695cfc829cfaae14490850b4a1ed282 diff --git a/packages/tui/sdk/session.go b/packages/tui/sdk/session.go index e76ab7f90..c91de85bd 100644 --- a/packages/tui/sdk/session.go +++ b/packages/tui/sdk/session.go @@ -605,6 +605,7 @@ type Part struct { Cost float64 `json:"cost"` Filename string `json:"filename"` Mime string `json:"mime"` + Snapshot string `json:"snapshot"` // This field can have the runtime type of [ToolPartState]. State interface{} `json:"state"` Synthetic bool `json:"synthetic"` @@ -629,6 +630,7 @@ type partJSON struct { Cost apijson.Field Filename apijson.Field Mime apijson.Field + Snapshot apijson.Field State apijson.Field Synthetic apijson.Field Text apijson.Field @@ -657,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]. +// [StepStartPart], [StepFinishPart], [PartObject]. func (r Part) AsUnion() PartUnion { return r.union } -// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart] or -// [StepFinishPart]. +// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart], +// [StepFinishPart] or [PartObject]. type PartUnion interface { implementsPart() } @@ -671,35 +673,78 @@ type PartUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*PartUnion)(nil)).Elem(), - "type", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TextPart{}), - DiscriminatorValue: "text", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TextPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FilePart{}), - DiscriminatorValue: "file", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(FilePart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolPart{}), - DiscriminatorValue: "tool", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(StepStartPart{}), - DiscriminatorValue: "step-start", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(StepStartPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(StepFinishPart{}), - DiscriminatorValue: "step-finish", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(StepFinishPart{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PartObject{}), }, ) } +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 ( @@ -708,11 +753,12 @@ const ( PartTypeTool PartType = "tool" PartTypeStepStart PartType = "step-start" PartTypeStepFinish PartType = "step-finish" + PartTypeSnapshot PartType = "snapshot" ) func (r PartType) IsKnown() bool { switch r { - case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish: + case PartTypeText, PartTypeFile, PartTypeTool, PartTypeStepStart, PartTypeStepFinish, PartTypeSnapshot: return true } return false |
