diff --git a/.stats.yml b/.stats.yml index 2827679..b50260b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 16 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-3c79948402e96d2aae6e46095db2cf80759750d1b042d6f91281a72c415b14de.yml openapi_spec_hash: f9c2fc5988f0a30397929995c2be2c85 -config_hash: 482f0765aa5f3dbc38c35bc576a4946e +config_hash: 21abc53de22a5eb43aa3b885ecf19491 diff --git a/aliases.go b/aliases.go index ecc91ef..84dd614 100644 --- a/aliases.go +++ b/aliases.go @@ -4,6 +4,31 @@ package opencode import ( "github.com/sst/opencode-sdk-go/internal/apierror" + "github.com/sst/opencode-sdk-go/shared" ) type Error = apierror.Error + +// This is an alias to an internal type. +type ProviderAuthError = shared.ProviderAuthError + +// This is an alias to an internal type. +type ProviderAuthErrorData = shared.ProviderAuthErrorData + +// This is an alias to an internal type. +type ProviderAuthErrorName = shared.ProviderAuthErrorName + +// This is an alias to an internal value. +const ProviderAuthErrorNameProviderAuthError = shared.ProviderAuthErrorNameProviderAuthError + +// This is an alias to an internal type. +type UnknownError = shared.UnknownError + +// This is an alias to an internal type. +type UnknownErrorData = shared.UnknownErrorData + +// This is an alias to an internal type. +type UnknownErrorName = shared.UnknownErrorName + +// This is an alias to an internal value. +const UnknownErrorNameUnknownError = shared.UnknownErrorNameUnknownError diff --git a/api.md b/api.md index 484cfc4..d77a957 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,8 @@ +# Shared Response Types + +- shared.ProviderAuthError +- shared.UnknownError + # Event Response Types: diff --git a/event.go b/event.go index b4a2307..63627d6 100644 --- a/event.go +++ b/event.go @@ -10,6 +10,7 @@ import ( "github.com/sst/opencode-sdk-go/internal/apijson" "github.com/sst/opencode-sdk-go/internal/requestconfig" "github.com/sst/opencode-sdk-go/option" + "github.com/sst/opencode-sdk-go/shared" "github.com/tidwall/gjson" ) @@ -722,10 +723,8 @@ func (r eventListResponseEventSessionErrorPropertiesJSON) RawJSON() string { } type EventListResponseEventSessionErrorPropertiesError struct { - // This field can have the runtime type of - // [EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorData], - // [EventListResponseEventSessionErrorPropertiesErrorUnknownErrorData], - // [interface{}]. + // This field can have the runtime type of [shared.ProviderAuthErrorData], + // [shared.UnknownErrorData], [interface{}]. Data interface{} `json:"data,required"` Name EventListResponseEventSessionErrorPropertiesErrorName `json:"name,required"` JSON eventListResponseEventSessionErrorPropertiesErrorJSON `json:"-"` @@ -757,20 +756,17 @@ func (r *EventListResponseEventSessionErrorPropertiesError) UnmarshalJSON(data [ // AsUnion returns a [EventListResponseEventSessionErrorPropertiesErrorUnion] // interface which you can cast to the specific types for more type safety. // -// Possible runtime types of the union are -// [EventListResponseEventSessionErrorPropertiesErrorProviderAuthError], -// [EventListResponseEventSessionErrorPropertiesErrorUnknownError], +// Possible runtime types of the union are [shared.ProviderAuthError], +// [shared.UnknownError], // [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError]. func (r EventListResponseEventSessionErrorPropertiesError) AsUnion() EventListResponseEventSessionErrorPropertiesErrorUnion { return r.union } -// Union satisfied by -// [EventListResponseEventSessionErrorPropertiesErrorProviderAuthError], -// [EventListResponseEventSessionErrorPropertiesErrorUnknownError] or +// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError] or // [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError]. type EventListResponseEventSessionErrorPropertiesErrorUnion interface { - implementsEventListResponseEventSessionErrorPropertiesError() + ImplementsEventListResponseEventSessionErrorPropertiesError() } func init() { @@ -779,12 +775,12 @@ func init() { "name", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionErrorPropertiesErrorProviderAuthError{}), + Type: reflect.TypeOf(shared.ProviderAuthError{}), DiscriminatorValue: "ProviderAuthError", }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionErrorPropertiesErrorUnknownError{}), + Type: reflect.TypeOf(shared.UnknownError{}), DiscriminatorValue: "UnknownError", }, apijson.UnionVariant{ @@ -795,134 +791,6 @@ func init() { ) } -type EventListResponseEventSessionErrorPropertiesErrorProviderAuthError struct { - Data EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorData `json:"data,required"` - Name EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorName `json:"name,required"` - JSON eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorJSON `json:"-"` -} - -// eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorJSON contains -// the JSON metadata for the struct -// [EventListResponseEventSessionErrorPropertiesErrorProviderAuthError] -type eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorJSON struct { - Data apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionErrorPropertiesErrorProviderAuthError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorJSON) RawJSON() string { - return r.raw -} - -func (r EventListResponseEventSessionErrorPropertiesErrorProviderAuthError) implementsEventListResponseEventSessionErrorPropertiesError() { -} - -type EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorData struct { - Message string `json:"message,required"` - ProviderID string `json:"providerID,required"` - JSON eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorDataJSON `json:"-"` -} - -// eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorDataJSON -// contains the JSON metadata for the struct -// [EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorData] -type eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorDataJSON struct { - Message apijson.Field - ProviderID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorDataJSON) RawJSON() string { - return r.raw -} - -type EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorName string - -const ( - EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorNameProviderAuthError EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorName = "ProviderAuthError" -) - -func (r EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorName) IsKnown() bool { - switch r { - case EventListResponseEventSessionErrorPropertiesErrorProviderAuthErrorNameProviderAuthError: - return true - } - return false -} - -type EventListResponseEventSessionErrorPropertiesErrorUnknownError struct { - Data EventListResponseEventSessionErrorPropertiesErrorUnknownErrorData `json:"data,required"` - Name EventListResponseEventSessionErrorPropertiesErrorUnknownErrorName `json:"name,required"` - JSON eventListResponseEventSessionErrorPropertiesErrorUnknownErrorJSON `json:"-"` -} - -// eventListResponseEventSessionErrorPropertiesErrorUnknownErrorJSON contains the -// JSON metadata for the struct -// [EventListResponseEventSessionErrorPropertiesErrorUnknownError] -type eventListResponseEventSessionErrorPropertiesErrorUnknownErrorJSON struct { - Data apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionErrorPropertiesErrorUnknownError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionErrorPropertiesErrorUnknownErrorJSON) RawJSON() string { - return r.raw -} - -func (r EventListResponseEventSessionErrorPropertiesErrorUnknownError) implementsEventListResponseEventSessionErrorPropertiesError() { -} - -type EventListResponseEventSessionErrorPropertiesErrorUnknownErrorData struct { - Message string `json:"message,required"` - JSON eventListResponseEventSessionErrorPropertiesErrorUnknownErrorDataJSON `json:"-"` -} - -// eventListResponseEventSessionErrorPropertiesErrorUnknownErrorDataJSON contains -// the JSON metadata for the struct -// [EventListResponseEventSessionErrorPropertiesErrorUnknownErrorData] -type eventListResponseEventSessionErrorPropertiesErrorUnknownErrorDataJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionErrorPropertiesErrorUnknownErrorData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionErrorPropertiesErrorUnknownErrorDataJSON) RawJSON() string { - return r.raw -} - -type EventListResponseEventSessionErrorPropertiesErrorUnknownErrorName string - -const ( - EventListResponseEventSessionErrorPropertiesErrorUnknownErrorNameUnknownError EventListResponseEventSessionErrorPropertiesErrorUnknownErrorName = "UnknownError" -) - -func (r EventListResponseEventSessionErrorPropertiesErrorUnknownErrorName) IsKnown() bool { - switch r { - case EventListResponseEventSessionErrorPropertiesErrorUnknownErrorNameUnknownError: - return true - } - return false -} - type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError struct { Data interface{} `json:"data,required"` Name EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName `json:"name,required"` @@ -947,7 +815,7 @@ func (r eventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErro return r.raw } -func (r EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError) implementsEventListResponseEventSessionErrorPropertiesError() { +func (r EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError) ImplementsEventListResponseEventSessionErrorPropertiesError() { } type EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthErrorName string diff --git a/session.go b/session.go index bf418b5..4476b2f 100644 --- a/session.go +++ b/session.go @@ -13,6 +13,7 @@ import ( "github.com/sst/opencode-sdk-go/internal/param" "github.com/sst/opencode-sdk-go/internal/requestconfig" "github.com/sst/opencode-sdk-go/option" + "github.com/sst/opencode-sdk-go/shared" "github.com/tidwall/gjson" ) @@ -433,9 +434,8 @@ func (r messageMetadataAssistantTokensCacheJSON) RawJSON() string { } type MessageMetadataError struct { - // This field can have the runtime type of - // [MessageMetadataErrorProviderAuthErrorData], - // [MessageMetadataErrorUnknownErrorData], [interface{}]. + // This field can have the runtime type of [shared.ProviderAuthErrorData], + // [shared.UnknownErrorData], [interface{}]. Data interface{} `json:"data,required"` Name MessageMetadataErrorName `json:"name,required"` JSON messageMetadataErrorJSON `json:"-"` @@ -467,18 +467,16 @@ func (r *MessageMetadataError) UnmarshalJSON(data []byte) (err error) { // AsUnion returns a [MessageMetadataErrorUnion] interface which you can cast to // the specific types for more type safety. // -// Possible runtime types of the union are [MessageMetadataErrorProviderAuthError], -// [MessageMetadataErrorUnknownError], -// [MessageMetadataErrorMessageOutputLengthError]. +// Possible runtime types of the union are [shared.ProviderAuthError], +// [shared.UnknownError], [MessageMetadataErrorMessageOutputLengthError]. func (r MessageMetadataError) AsUnion() MessageMetadataErrorUnion { return r.union } -// Union satisfied by [MessageMetadataErrorProviderAuthError], -// [MessageMetadataErrorUnknownError] or +// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError] or // [MessageMetadataErrorMessageOutputLengthError]. type MessageMetadataErrorUnion interface { - implementsMessageMetadataError() + ImplementsMessageMetadataError() } func init() { @@ -487,12 +485,12 @@ func init() { "name", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(MessageMetadataErrorProviderAuthError{}), + Type: reflect.TypeOf(shared.ProviderAuthError{}), DiscriminatorValue: "ProviderAuthError", }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(MessageMetadataErrorUnknownError{}), + Type: reflect.TypeOf(shared.UnknownError{}), DiscriminatorValue: "UnknownError", }, apijson.UnionVariant{ @@ -503,128 +501,6 @@ func init() { ) } -type MessageMetadataErrorProviderAuthError struct { - Data MessageMetadataErrorProviderAuthErrorData `json:"data,required"` - Name MessageMetadataErrorProviderAuthErrorName `json:"name,required"` - JSON messageMetadataErrorProviderAuthErrorJSON `json:"-"` -} - -// messageMetadataErrorProviderAuthErrorJSON contains the JSON metadata for the -// struct [MessageMetadataErrorProviderAuthError] -type messageMetadataErrorProviderAuthErrorJSON struct { - Data apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageMetadataErrorProviderAuthError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageMetadataErrorProviderAuthErrorJSON) RawJSON() string { - return r.raw -} - -func (r MessageMetadataErrorProviderAuthError) implementsMessageMetadataError() {} - -type MessageMetadataErrorProviderAuthErrorData struct { - Message string `json:"message,required"` - ProviderID string `json:"providerID,required"` - JSON messageMetadataErrorProviderAuthErrorDataJSON `json:"-"` -} - -// messageMetadataErrorProviderAuthErrorDataJSON contains the JSON metadata for the -// struct [MessageMetadataErrorProviderAuthErrorData] -type messageMetadataErrorProviderAuthErrorDataJSON struct { - Message apijson.Field - ProviderID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageMetadataErrorProviderAuthErrorData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageMetadataErrorProviderAuthErrorDataJSON) RawJSON() string { - return r.raw -} - -type MessageMetadataErrorProviderAuthErrorName string - -const ( - MessageMetadataErrorProviderAuthErrorNameProviderAuthError MessageMetadataErrorProviderAuthErrorName = "ProviderAuthError" -) - -func (r MessageMetadataErrorProviderAuthErrorName) IsKnown() bool { - switch r { - case MessageMetadataErrorProviderAuthErrorNameProviderAuthError: - return true - } - return false -} - -type MessageMetadataErrorUnknownError struct { - Data MessageMetadataErrorUnknownErrorData `json:"data,required"` - Name MessageMetadataErrorUnknownErrorName `json:"name,required"` - JSON messageMetadataErrorUnknownErrorJSON `json:"-"` -} - -// messageMetadataErrorUnknownErrorJSON contains the JSON metadata for the struct -// [MessageMetadataErrorUnknownError] -type messageMetadataErrorUnknownErrorJSON struct { - Data apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageMetadataErrorUnknownError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageMetadataErrorUnknownErrorJSON) RawJSON() string { - return r.raw -} - -func (r MessageMetadataErrorUnknownError) implementsMessageMetadataError() {} - -type MessageMetadataErrorUnknownErrorData struct { - Message string `json:"message,required"` - JSON messageMetadataErrorUnknownErrorDataJSON `json:"-"` -} - -// messageMetadataErrorUnknownErrorDataJSON contains the JSON metadata for the -// struct [MessageMetadataErrorUnknownErrorData] -type messageMetadataErrorUnknownErrorDataJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MessageMetadataErrorUnknownErrorData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r messageMetadataErrorUnknownErrorDataJSON) RawJSON() string { - return r.raw -} - -type MessageMetadataErrorUnknownErrorName string - -const ( - MessageMetadataErrorUnknownErrorNameUnknownError MessageMetadataErrorUnknownErrorName = "UnknownError" -) - -func (r MessageMetadataErrorUnknownErrorName) IsKnown() bool { - switch r { - case MessageMetadataErrorUnknownErrorNameUnknownError: - return true - } - return false -} - type MessageMetadataErrorMessageOutputLengthError struct { Data interface{} `json:"data,required"` Name MessageMetadataErrorMessageOutputLengthErrorName `json:"name,required"` @@ -648,7 +524,7 @@ func (r messageMetadataErrorMessageOutputLengthErrorJSON) RawJSON() string { return r.raw } -func (r MessageMetadataErrorMessageOutputLengthError) implementsMessageMetadataError() {} +func (r MessageMetadataErrorMessageOutputLengthError) ImplementsMessageMetadataError() {} type MessageMetadataErrorMessageOutputLengthErrorName string diff --git a/shared/shared.go b/shared/shared.go new file mode 100644 index 0000000..121f64a --- /dev/null +++ b/shared/shared.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package shared + +import ( + "github.com/sst/opencode-sdk-go/internal/apijson" +) + +type ProviderAuthError struct { + Data ProviderAuthErrorData `json:"data,required"` + Name ProviderAuthErrorName `json:"name,required"` + JSON providerAuthErrorJSON `json:"-"` +} + +// providerAuthErrorJSON contains the JSON metadata for the struct +// [ProviderAuthError] +type providerAuthErrorJSON struct { + Data apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProviderAuthError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r providerAuthErrorJSON) RawJSON() string { + return r.raw +} + +func (r ProviderAuthError) ImplementsEventListResponseEventSessionErrorPropertiesError() {} + +func (r ProviderAuthError) ImplementsMessageMetadataError() {} + +type ProviderAuthErrorData struct { + Message string `json:"message,required"` + ProviderID string `json:"providerID,required"` + JSON providerAuthErrorDataJSON `json:"-"` +} + +// providerAuthErrorDataJSON contains the JSON metadata for the struct +// [ProviderAuthErrorData] +type providerAuthErrorDataJSON struct { + Message apijson.Field + ProviderID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProviderAuthErrorData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r providerAuthErrorDataJSON) RawJSON() string { + return r.raw +} + +type ProviderAuthErrorName string + +const ( + ProviderAuthErrorNameProviderAuthError ProviderAuthErrorName = "ProviderAuthError" +) + +func (r ProviderAuthErrorName) IsKnown() bool { + switch r { + case ProviderAuthErrorNameProviderAuthError: + return true + } + return false +} + +type UnknownError struct { + Data UnknownErrorData `json:"data,required"` + Name UnknownErrorName `json:"name,required"` + JSON unknownErrorJSON `json:"-"` +} + +// unknownErrorJSON contains the JSON metadata for the struct [UnknownError] +type unknownErrorJSON struct { + Data apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UnknownError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r unknownErrorJSON) RawJSON() string { + return r.raw +} + +func (r UnknownError) ImplementsEventListResponseEventSessionErrorPropertiesError() {} + +func (r UnknownError) ImplementsMessageMetadataError() {} + +type UnknownErrorData struct { + Message string `json:"message,required"` + JSON unknownErrorDataJSON `json:"-"` +} + +// unknownErrorDataJSON contains the JSON metadata for the struct +// [UnknownErrorData] +type unknownErrorDataJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UnknownErrorData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r unknownErrorDataJSON) RawJSON() string { + return r.raw +} + +type UnknownErrorName string + +const ( + UnknownErrorNameUnknownError UnknownErrorName = "UnknownError" +) + +func (r UnknownErrorName) IsKnown() bool { + switch r { + case UnknownErrorNameUnknownError: + return true + } + return false +}