diff --git a/.stats.yml b/.stats.yml
index 1eef7bb..5aeba9e 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 20
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-15eeb028f79b9a065b4e54a6ea6a58631e9bd5004f97820f0c79d18e3f8bac84.yml
-openapi_spec_hash: 38c8bacb6c8e4c46852a3e81e3fb9fda
-config_hash: 348a85e725de595ca05a61f4333794ac
+configured_endpoints: 22
+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/aliases.go b/aliases.go
index 84dd614..6ab36d0 100644
--- a/aliases.go
+++ b/aliases.go
@@ -9,6 +9,15 @@ import (
type Error = apierror.Error
+// This is an alias to an internal type.
+type MessageAbortedError = shared.MessageAbortedError
+
+// This is an alias to an internal type.
+type MessageAbortedErrorName = shared.MessageAbortedErrorName
+
+// This is an alias to an internal value.
+const MessageAbortedErrorNameMessageAbortedError = shared.MessageAbortedErrorNameMessageAbortedError
+
// This is an alias to an internal type.
type ProviderAuthError = shared.ProviderAuthError
diff --git a/api.md b/api.md
index c9859d1..a48e6d7 100644
--- a/api.md
+++ b/api.md
@@ -1,5 +1,6 @@
# Shared Response Types
+- shared.MessageAbortedError
- shared.ProviderAuthError
- shared.UnknownError
@@ -18,36 +19,40 @@ Methods:
Response Types:
- opencode.App
+- opencode.LogLevel
+- opencode.Mode
Methods:
- client.App.Get(ctx context.Context) (opencode.App, error)
- client.App.Init(ctx context.Context) (bool, error)
+- client.App.Log(ctx context.Context, body opencode.AppLogParams) (bool, error)
+- client.App.Modes(ctx context.Context) ([]opencode.Mode, error)
# Find
Response Types:
-- opencode.FindSymbolsResponse
-- opencode.FindTextResponse
+- opencode.Match
+- opencode.Symbol
Methods:
- client.Find.Files(ctx context.Context, query opencode.FindFilesParams) ([]string, error)
-- client.Find.Symbols(ctx context.Context, query opencode.FindSymbolsParams) ([]opencode.FindSymbolsResponse, error)
-- client.Find.Text(ctx context.Context, query opencode.FindTextParams) ([]opencode.FindTextResponse, error)
+- client.Find.Symbols(ctx context.Context, query opencode.FindSymbolsParams) ([]opencode.Symbol, error)
+- client.Find.Text(ctx context.Context, query opencode.FindTextParams) ([]opencode.Match, error)
# File
Response Types:
+- opencode.File
- opencode.FileReadResponse
-- opencode.FileStatusResponse
Methods:
- client.File.Read(ctx context.Context, query opencode.FileReadParams) (opencode.FileReadResponse, error)
-- client.File.Status(ctx context.Context) ([]opencode.FileStatusResponse, error)
+- client.File.Status(ctx context.Context) ([]opencode.File, error)
# Config
@@ -72,15 +77,15 @@ Params Types:
- opencode.FilePartParam
- opencode.TextPartParam
-- opencode.UserMessagePartUnionParam
Response Types:
- opencode.AssistantMessage
-- opencode.AssistantMessagePart
- opencode.FilePart
- opencode.Message
+- opencode.Part
- opencode.Session
+- opencode.StepFinishPart
- opencode.StepStartPart
- opencode.TextPart
- opencode.ToolPart
@@ -88,7 +93,8 @@ Response Types:
- opencode.ToolStateError
- opencode.ToolStatePending
- opencode.ToolStateRunning
-- opencode.UserMessagePart
+- opencode.UserMessage
+- opencode.SessionMessagesResponse
Methods:
@@ -98,7 +104,7 @@ Methods:
- client.Session.Abort(ctx context.Context, id string) (bool, error)
- client.Session.Chat(ctx context.Context, id string, body opencode.SessionChatParams) (opencode.AssistantMessage, error)
- client.Session.Init(ctx context.Context, id string, body opencode.SessionInitParams) (bool, error)
-- client.Session.Messages(ctx context.Context, id string) ([]opencode.Message, error)
+- client.Session.Messages(ctx context.Context, id string) ([]opencode.SessionMessagesResponse, error)
- client.Session.Share(ctx context.Context, id string) (opencode.Session, error)
- client.Session.Summarize(ctx context.Context, id string, body opencode.SessionSummarizeParams) (bool, error)
- client.Session.Unshare(ctx context.Context, id string) (opencode.Session, error)
diff --git a/app.go b/app.go
index dc44a74..69414f2 100644
--- a/app.go
+++ b/app.go
@@ -7,6 +7,7 @@ import (
"net/http"
"github.com/sst/opencode-sdk-go/internal/apijson"
+ "github.com/sst/opencode-sdk-go/internal/param"
"github.com/sst/opencode-sdk-go/internal/requestconfig"
"github.com/sst/opencode-sdk-go/option"
)
@@ -46,12 +47,27 @@ func (r *AppService) Init(ctx context.Context, opts ...option.RequestOption) (re
return
}
+// Write a log entry to the server logs
+func (r *AppService) Log(ctx context.Context, body AppLogParams, opts ...option.RequestOption) (res *bool, err error) {
+ opts = append(r.Options[:], opts...)
+ path := "log"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return
+}
+
+// List all modes
+func (r *AppService) Modes(ctx context.Context, opts ...option.RequestOption) (res *[]Mode, err error) {
+ opts = append(r.Options[:], opts...)
+ path := "mode"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
+ return
+}
+
type App struct {
Git bool `json:"git,required"`
Hostname string `json:"hostname,required"`
Path AppPath `json:"path,required"`
Time AppTime `json:"time,required"`
- User string `json:"user,required"`
JSON appJSON `json:"-"`
}
@@ -61,7 +77,6 @@ type appJSON struct {
Hostname apijson.Field
Path apijson.Field
Time apijson.Field
- User apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -121,3 +136,102 @@ func (r *AppTime) UnmarshalJSON(data []byte) (err error) {
func (r appTimeJSON) RawJSON() string {
return r.raw
}
+
+// Log level
+type LogLevel string
+
+const (
+ LogLevelDebug LogLevel = "DEBUG"
+ LogLevelInfo LogLevel = "INFO"
+ LogLevelWarn LogLevel = "WARN"
+ LogLevelError LogLevel = "ERROR"
+)
+
+func (r LogLevel) IsKnown() bool {
+ switch r {
+ case LogLevelDebug, LogLevelInfo, LogLevelWarn, LogLevelError:
+ return true
+ }
+ return false
+}
+
+type Mode struct {
+ Name string `json:"name,required"`
+ Tools map[string]bool `json:"tools,required"`
+ Model ModeModel `json:"model"`
+ Prompt string `json:"prompt"`
+ JSON modeJSON `json:"-"`
+}
+
+// modeJSON contains the JSON metadata for the struct [Mode]
+type modeJSON struct {
+ Name apijson.Field
+ Tools apijson.Field
+ Model apijson.Field
+ Prompt apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Mode) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r modeJSON) RawJSON() string {
+ return r.raw
+}
+
+type ModeModel struct {
+ ModelID string `json:"modelID,required"`
+ ProviderID string `json:"providerID,required"`
+ JSON modeModelJSON `json:"-"`
+}
+
+// modeModelJSON contains the JSON metadata for the struct [ModeModel]
+type modeModelJSON struct {
+ ModelID apijson.Field
+ ProviderID apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ModeModel) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r modeModelJSON) RawJSON() string {
+ return r.raw
+}
+
+type AppLogParams struct {
+ // Log level
+ Level param.Field[AppLogParamsLevel] `json:"level,required"`
+ // Log message
+ Message param.Field[string] `json:"message,required"`
+ // Service name for the log entry
+ Service param.Field[string] `json:"service,required"`
+ // Additional metadata for the log entry
+ Extra param.Field[map[string]interface{}] `json:"extra"`
+}
+
+func (r AppLogParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+// Log level
+type AppLogParamsLevel string
+
+const (
+ AppLogParamsLevelDebug AppLogParamsLevel = "debug"
+ AppLogParamsLevelInfo AppLogParamsLevel = "info"
+ AppLogParamsLevelError AppLogParamsLevel = "error"
+ AppLogParamsLevelWarn AppLogParamsLevel = "warn"
+)
+
+func (r AppLogParamsLevel) IsKnown() bool {
+ switch r {
+ case AppLogParamsLevelDebug, AppLogParamsLevelInfo, AppLogParamsLevelError, AppLogParamsLevelWarn:
+ return true
+ }
+ return false
+}
diff --git a/app_test.go b/app_test.go
index f96495f..8028f2c 100644
--- a/app_test.go
+++ b/app_test.go
@@ -56,3 +56,54 @@ func TestAppInit(t *testing.T) {
t.Fatalf("err should be nil: %s", err.Error())
}
}
+
+func TestAppLogWithOptionalParams(t *testing.T) {
+ t.Skip("skipped: tests are disabled for the time being")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := opencode.NewClient(
+ option.WithBaseURL(baseURL),
+ )
+ _, err := client.App.Log(context.TODO(), opencode.AppLogParams{
+ Level: opencode.F(opencode.AppLogParamsLevelDebug),
+ Message: opencode.F("message"),
+ Service: opencode.F("service"),
+ Extra: opencode.F(map[string]interface{}{
+ "foo": "bar",
+ }),
+ })
+ if err != nil {
+ var apierr *opencode.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
+
+func TestAppModes(t *testing.T) {
+ t.Skip("skipped: tests are disabled for the time being")
+ baseURL := "http://localhost:4010"
+ if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
+ baseURL = envURL
+ }
+ if !testutil.CheckTestServer(t, baseURL) {
+ return
+ }
+ client := opencode.NewClient(
+ option.WithBaseURL(baseURL),
+ )
+ _, err := client.App.Modes(context.TODO())
+ if err != nil {
+ var apierr *opencode.Error
+ if errors.As(err, &apierr) {
+ t.Log(string(apierr.DumpRequest(true)))
+ }
+ t.Fatalf("err should be nil: %s", err.Error())
+ }
+}
diff --git a/config.go b/config.go
index 39da2f9..7c04cd1 100644
--- a/config.go
+++ b/config.go
@@ -51,7 +51,8 @@ func (r *ConfigService) Providers(ctx context.Context, opts ...option.RequestOpt
type Config struct {
// JSON schema reference for configuration validation
Schema string `json:"$schema"`
- // Share newly created sessions automatically
+ // @deprecated Use 'share' field instead. Share newly created sessions
+ // automatically
Autoshare bool `json:"autoshare"`
// Automatically update to the latest version
Autoupdate bool `json:"autoupdate"`
@@ -62,15 +63,23 @@ type Config struct {
Instructions []string `json:"instructions"`
// Custom keybind configurations
Keybinds Keybinds `json:"keybinds"`
+ // Minimum log level to write to log files
+ LogLevel LogLevel `json:"log_level"`
// MCP (Model Context Protocol) server configurations
- Mcp map[string]ConfigMcp `json:"mcp"`
+ Mcp map[string]ConfigMcp `json:"mcp"`
+ Mode ConfigMode `json:"mode"`
// Model to use in the format of provider/model, eg anthropic/claude-2
Model string `json:"model"`
// Custom provider configurations and model overrides
Provider map[string]ConfigProvider `json:"provider"`
+ // Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
+ // all sharing
+ Share ConfigShare `json:"share"`
// Theme name to use for the interface
- Theme string `json:"theme"`
- JSON configJSON `json:"-"`
+ Theme string `json:"theme"`
+ // Custom username to display in conversations instead of system username
+ Username string `json:"username"`
+ JSON configJSON `json:"-"`
}
// configJSON contains the JSON metadata for the struct [Config]
@@ -82,10 +91,14 @@ type configJSON struct {
Experimental apijson.Field
Instructions apijson.Field
Keybinds apijson.Field
+ LogLevel apijson.Field
Mcp apijson.Field
+ Mode apijson.Field
Model apijson.Field
Provider apijson.Field
+ Share apijson.Field
Theme apijson.Field
+ Username apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -273,6 +286,77 @@ func (r ConfigMcpType) IsKnown() bool {
return false
}
+type ConfigMode struct {
+ Build ConfigModeBuild `json:"build"`
+ Plan ConfigModePlan `json:"plan"`
+ ExtraFields map[string]ConfigMode `json:"-,extras"`
+ JSON configModeJSON `json:"-"`
+}
+
+// configModeJSON contains the JSON metadata for the struct [ConfigMode]
+type configModeJSON struct {
+ Build apijson.Field
+ Plan apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConfigMode) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r configModeJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConfigModeBuild struct {
+ Model string `json:"model"`
+ Prompt string `json:"prompt"`
+ Tools map[string]bool `json:"tools"`
+ JSON configModeBuildJSON `json:"-"`
+}
+
+// configModeBuildJSON contains the JSON metadata for the struct [ConfigModeBuild]
+type configModeBuildJSON struct {
+ Model apijson.Field
+ Prompt apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConfigModeBuild) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r configModeBuildJSON) RawJSON() string {
+ return r.raw
+}
+
+type ConfigModePlan struct {
+ Model string `json:"model"`
+ Prompt string `json:"prompt"`
+ Tools map[string]bool `json:"tools"`
+ JSON configModePlanJSON `json:"-"`
+}
+
+// configModePlanJSON contains the JSON metadata for the struct [ConfigModePlan]
+type configModePlanJSON struct {
+ Model apijson.Field
+ Prompt apijson.Field
+ Tools apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *ConfigModePlan) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r configModePlanJSON) RawJSON() string {
+ return r.raw
+}
+
type ConfigProvider struct {
Models map[string]ConfigProviderModel `json:"models,required"`
ID string `json:"id"`
@@ -394,84 +478,120 @@ func (r configProviderModelsLimitJSON) RawJSON() string {
return r.raw
}
+// Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
+// all sharing
+type ConfigShare string
+
+const (
+ ConfigShareAuto ConfigShare = "auto"
+ ConfigShareDisabled ConfigShare = "disabled"
+)
+
+func (r ConfigShare) IsKnown() bool {
+ switch r {
+ case ConfigShareAuto, ConfigShareDisabled:
+ return true
+ }
+ return false
+}
+
type Keybinds struct {
// Exit the application
- AppExit string `json:"app_exit"`
- // Open external editor
- EditorOpen string `json:"editor_open"`
+ AppExit string `json:"app_exit,required"`
// Show help dialog
- Help string `json:"help"`
- // Navigate to next history item
- HistoryNext string `json:"history_next"`
- // Navigate to previous history item
- HistoryPrevious string `json:"history_previous"`
+ AppHelp string `json:"app_help,required"`
+ // Open external editor
+ EditorOpen string `json:"editor_open,required"`
+ // Close file
+ FileClose string `json:"file_close,required"`
+ // Split/unified diff
+ FileDiffToggle string `json:"file_diff_toggle,required"`
+ // List files
+ FileList string `json:"file_list,required"`
+ // Search file
+ FileSearch string `json:"file_search,required"`
// Clear input field
- InputClear string `json:"input_clear"`
+ InputClear string `json:"input_clear,required"`
// Insert newline in input
- InputNewline string `json:"input_newline"`
+ InputNewline string `json:"input_newline,required"`
// Paste from clipboard
- InputPaste string `json:"input_paste"`
+ InputPaste string `json:"input_paste,required"`
// Submit input
- InputSubmit string `json:"input_submit"`
+ InputSubmit string `json:"input_submit,required"`
// Leader key for keybind combinations
- Leader string `json:"leader"`
+ Leader string `json:"leader,required"`
+ // Copy message
+ MessagesCopy string `json:"messages_copy,required"`
// Navigate to first message
- MessagesFirst string `json:"messages_first"`
+ MessagesFirst string `json:"messages_first,required"`
// Scroll messages down by half page
- MessagesHalfPageDown string `json:"messages_half_page_down"`
+ MessagesHalfPageDown string `json:"messages_half_page_down,required"`
// Scroll messages up by half page
- MessagesHalfPageUp string `json:"messages_half_page_up"`
+ MessagesHalfPageUp string `json:"messages_half_page_up,required"`
// Navigate to last message
- MessagesLast string `json:"messages_last"`
+ MessagesLast string `json:"messages_last,required"`
+ // Toggle layout
+ MessagesLayoutToggle string `json:"messages_layout_toggle,required"`
// Navigate to next message
- MessagesNext string `json:"messages_next"`
+ MessagesNext string `json:"messages_next,required"`
// Scroll messages down by one page
- MessagesPageDown string `json:"messages_page_down"`
+ MessagesPageDown string `json:"messages_page_down,required"`
// Scroll messages up by one page
- MessagesPageUp string `json:"messages_page_up"`
+ MessagesPageUp string `json:"messages_page_up,required"`
// Navigate to previous message
- MessagesPrevious string `json:"messages_previous"`
+ MessagesPrevious string `json:"messages_previous,required"`
+ // Revert message
+ MessagesRevert string `json:"messages_revert,required"`
// List available models
- ModelList string `json:"model_list"`
- // Initialize project configuration
- ProjectInit string `json:"project_init"`
- // Toggle compact mode for session
- SessionCompact string `json:"session_compact"`
+ ModelList string `json:"model_list,required"`
+ // Create/update AGENTS.md
+ ProjectInit string `json:"project_init,required"`
+ // Compact the session
+ SessionCompact string `json:"session_compact,required"`
// Interrupt current session
- SessionInterrupt string `json:"session_interrupt"`
+ SessionInterrupt string `json:"session_interrupt,required"`
// List all sessions
- SessionList string `json:"session_list"`
+ SessionList string `json:"session_list,required"`
// Create a new session
- SessionNew string `json:"session_new"`
+ SessionNew string `json:"session_new,required"`
// Share current session
- SessionShare string `json:"session_share"`
+ SessionShare string `json:"session_share,required"`
+ // Unshare current session
+ SessionUnshare string `json:"session_unshare,required"`
+ // Switch mode
+ SwitchMode string `json:"switch_mode,required"`
// List available themes
- ThemeList string `json:"theme_list"`
- // Show tool details
- ToolDetails string `json:"tool_details"`
+ ThemeList string `json:"theme_list,required"`
+ // Toggle tool details
+ ToolDetails string `json:"tool_details,required"`
JSON keybindsJSON `json:"-"`
}
// keybindsJSON contains the JSON metadata for the struct [Keybinds]
type keybindsJSON struct {
AppExit apijson.Field
+ AppHelp apijson.Field
EditorOpen apijson.Field
- Help apijson.Field
- HistoryNext apijson.Field
- HistoryPrevious apijson.Field
+ FileClose apijson.Field
+ FileDiffToggle apijson.Field
+ FileList apijson.Field
+ FileSearch apijson.Field
InputClear apijson.Field
InputNewline apijson.Field
InputPaste apijson.Field
InputSubmit apijson.Field
Leader apijson.Field
+ MessagesCopy apijson.Field
MessagesFirst apijson.Field
MessagesHalfPageDown apijson.Field
MessagesHalfPageUp apijson.Field
MessagesLast apijson.Field
+ MessagesLayoutToggle apijson.Field
MessagesNext apijson.Field
MessagesPageDown apijson.Field
MessagesPageUp apijson.Field
MessagesPrevious apijson.Field
+ MessagesRevert apijson.Field
ModelList apijson.Field
ProjectInit apijson.Field
SessionCompact apijson.Field
@@ -479,6 +599,8 @@ type keybindsJSON struct {
SessionList apijson.Field
SessionNew apijson.Field
SessionShare apijson.Field
+ SessionUnshare apijson.Field
+ SwitchMode apijson.Field
ThemeList apijson.Field
ToolDetails apijson.Field
raw string
diff --git a/event.go b/event.go
index 48eb129..9002d2a 100644
--- a/event.go
+++ b/event.go
@@ -52,10 +52,10 @@ type EventListResponse struct {
// [EventListResponseEventPermissionUpdatedProperties],
// [EventListResponseEventFileEditedProperties],
// [EventListResponseEventInstallationUpdatedProperties],
- // [EventListResponseEventStorageWriteProperties],
// [EventListResponseEventMessageUpdatedProperties],
// [EventListResponseEventMessageRemovedProperties],
// [EventListResponseEventMessagePartUpdatedProperties],
+ // [EventListResponseEventStorageWriteProperties],
// [EventListResponseEventSessionUpdatedProperties],
// [EventListResponseEventSessionDeletedProperties],
// [EventListResponseEventSessionIdleProperties],
@@ -96,11 +96,11 @@ func (r *EventListResponse) UnmarshalJSON(data []byte) (err error) {
// [EventListResponseEventLspClientDiagnostics],
// [EventListResponseEventPermissionUpdated], [EventListResponseEventFileEdited],
// [EventListResponseEventInstallationUpdated],
-// [EventListResponseEventStorageWrite], [EventListResponseEventMessageUpdated],
-// [EventListResponseEventMessageRemoved],
+// [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved],
// [EventListResponseEventMessagePartUpdated],
-// [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted],
-// [EventListResponseEventSessionIdle], [EventListResponseEventSessionError],
+// [EventListResponseEventStorageWrite], [EventListResponseEventSessionUpdated],
+// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle],
+// [EventListResponseEventSessionError],
// [EventListResponseEventFileWatcherUpdated].
func (r EventListResponse) AsUnion() EventListResponseUnion {
return r.union
@@ -109,11 +109,11 @@ func (r EventListResponse) AsUnion() EventListResponseUnion {
// Union satisfied by [EventListResponseEventLspClientDiagnostics],
// [EventListResponseEventPermissionUpdated], [EventListResponseEventFileEdited],
// [EventListResponseEventInstallationUpdated],
-// [EventListResponseEventStorageWrite], [EventListResponseEventMessageUpdated],
-// [EventListResponseEventMessageRemoved],
+// [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved],
// [EventListResponseEventMessagePartUpdated],
-// [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted],
-// [EventListResponseEventSessionIdle], [EventListResponseEventSessionError] or
+// [EventListResponseEventStorageWrite], [EventListResponseEventSessionUpdated],
+// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionIdle],
+// [EventListResponseEventSessionError] or
// [EventListResponseEventFileWatcherUpdated].
type EventListResponseUnion interface {
implementsEventListResponse()
@@ -143,11 +143,6 @@ func init() {
Type: reflect.TypeOf(EventListResponseEventInstallationUpdated{}),
DiscriminatorValue: "installation.updated",
},
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(EventListResponseEventStorageWrite{}),
- DiscriminatorValue: "storage.write",
- },
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventMessageUpdated{}),
@@ -163,6 +158,11 @@ func init() {
Type: reflect.TypeOf(EventListResponseEventMessagePartUpdated{}),
DiscriminatorValue: "message.part.updated",
},
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(EventListResponseEventStorageWrite{}),
+ DiscriminatorValue: "storage.write",
+ },
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}),
@@ -462,68 +462,6 @@ func (r EventListResponseEventInstallationUpdatedType) IsKnown() bool {
return false
}
-type EventListResponseEventStorageWrite struct {
- Properties EventListResponseEventStorageWriteProperties `json:"properties,required"`
- Type EventListResponseEventStorageWriteType `json:"type,required"`
- JSON eventListResponseEventStorageWriteJSON `json:"-"`
-}
-
-// eventListResponseEventStorageWriteJSON contains the JSON metadata for the struct
-// [EventListResponseEventStorageWrite]
-type eventListResponseEventStorageWriteJSON struct {
- Properties apijson.Field
- Type apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EventListResponseEventStorageWrite) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r eventListResponseEventStorageWriteJSON) RawJSON() string {
- return r.raw
-}
-
-func (r EventListResponseEventStorageWrite) implementsEventListResponse() {}
-
-type EventListResponseEventStorageWriteProperties struct {
- Key string `json:"key,required"`
- Content interface{} `json:"content"`
- JSON eventListResponseEventStorageWritePropertiesJSON `json:"-"`
-}
-
-// eventListResponseEventStorageWritePropertiesJSON contains the JSON metadata for
-// the struct [EventListResponseEventStorageWriteProperties]
-type eventListResponseEventStorageWritePropertiesJSON struct {
- Key apijson.Field
- Content apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *EventListResponseEventStorageWriteProperties) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r eventListResponseEventStorageWritePropertiesJSON) RawJSON() string {
- return r.raw
-}
-
-type EventListResponseEventStorageWriteType string
-
-const (
- EventListResponseEventStorageWriteTypeStorageWrite EventListResponseEventStorageWriteType = "storage.write"
-)
-
-func (r EventListResponseEventStorageWriteType) IsKnown() bool {
- switch r {
- case EventListResponseEventStorageWriteTypeStorageWrite:
- return true
- }
- return false
-}
-
type EventListResponseEventMessageUpdated struct {
Properties EventListResponseEventMessageUpdatedProperties `json:"properties,required"`
Type EventListResponseEventMessageUpdatedType `json:"type,required"`
@@ -672,18 +610,14 @@ func (r eventListResponseEventMessagePartUpdatedJSON) RawJSON() string {
func (r EventListResponseEventMessagePartUpdated) implementsEventListResponse() {}
type EventListResponseEventMessagePartUpdatedProperties struct {
- MessageID string `json:"messageID,required"`
- Part AssistantMessagePart `json:"part,required"`
- SessionID string `json:"sessionID,required"`
- JSON eventListResponseEventMessagePartUpdatedPropertiesJSON `json:"-"`
+ Part Part `json:"part,required"`
+ JSON eventListResponseEventMessagePartUpdatedPropertiesJSON `json:"-"`
}
// eventListResponseEventMessagePartUpdatedPropertiesJSON contains the JSON
// metadata for the struct [EventListResponseEventMessagePartUpdatedProperties]
type eventListResponseEventMessagePartUpdatedPropertiesJSON struct {
- MessageID apijson.Field
Part apijson.Field
- SessionID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -710,6 +644,68 @@ func (r EventListResponseEventMessagePartUpdatedType) IsKnown() bool {
return false
}
+type EventListResponseEventStorageWrite struct {
+ Properties EventListResponseEventStorageWriteProperties `json:"properties,required"`
+ Type EventListResponseEventStorageWriteType `json:"type,required"`
+ JSON eventListResponseEventStorageWriteJSON `json:"-"`
+}
+
+// eventListResponseEventStorageWriteJSON contains the JSON metadata for the struct
+// [EventListResponseEventStorageWrite]
+type eventListResponseEventStorageWriteJSON struct {
+ Properties apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EventListResponseEventStorageWrite) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r eventListResponseEventStorageWriteJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r EventListResponseEventStorageWrite) implementsEventListResponse() {}
+
+type EventListResponseEventStorageWriteProperties struct {
+ Key string `json:"key,required"`
+ Content interface{} `json:"content"`
+ JSON eventListResponseEventStorageWritePropertiesJSON `json:"-"`
+}
+
+// eventListResponseEventStorageWritePropertiesJSON contains the JSON metadata for
+// the struct [EventListResponseEventStorageWriteProperties]
+type eventListResponseEventStorageWritePropertiesJSON struct {
+ Key apijson.Field
+ Content apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *EventListResponseEventStorageWriteProperties) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r eventListResponseEventStorageWritePropertiesJSON) RawJSON() string {
+ return r.raw
+}
+
+type EventListResponseEventStorageWriteType string
+
+const (
+ EventListResponseEventStorageWriteTypeStorageWrite EventListResponseEventStorageWriteType = "storage.write"
+)
+
+func (r EventListResponseEventStorageWriteType) IsKnown() bool {
+ switch r {
+ case EventListResponseEventStorageWriteTypeStorageWrite:
+ return true
+ }
+ return false
+}
+
type EventListResponseEventSessionUpdated struct {
Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"`
Type EventListResponseEventSessionUpdatedType `json:"type,required"`
@@ -916,14 +912,16 @@ func (r eventListResponseEventSessionErrorJSON) RawJSON() string {
func (r EventListResponseEventSessionError) implementsEventListResponse() {}
type EventListResponseEventSessionErrorProperties struct {
- Error EventListResponseEventSessionErrorPropertiesError `json:"error"`
- JSON eventListResponseEventSessionErrorPropertiesJSON `json:"-"`
+ Error EventListResponseEventSessionErrorPropertiesError `json:"error"`
+ SessionID string `json:"sessionID"`
+ JSON eventListResponseEventSessionErrorPropertiesJSON `json:"-"`
}
// eventListResponseEventSessionErrorPropertiesJSON contains the JSON metadata for
// the struct [EventListResponseEventSessionErrorProperties]
type eventListResponseEventSessionErrorPropertiesJSON struct {
Error apijson.Field
+ SessionID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -972,13 +970,15 @@ func (r *EventListResponseEventSessionErrorPropertiesError) UnmarshalJSON(data [
//
// Possible runtime types of the union are [shared.ProviderAuthError],
// [shared.UnknownError],
-// [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError].
+// [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError],
+// [shared.MessageAbortedError].
func (r EventListResponseEventSessionErrorPropertiesError) AsUnion() EventListResponseEventSessionErrorPropertiesErrorUnion {
return r.union
}
-// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError] or
-// [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError].
+// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError],
+// [EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError] or
+// [shared.MessageAbortedError].
type EventListResponseEventSessionErrorPropertiesErrorUnion interface {
ImplementsEventListResponseEventSessionErrorPropertiesError()
}
@@ -1002,6 +1002,11 @@ func init() {
Type: reflect.TypeOf(EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError{}),
DiscriminatorValue: "MessageOutputLengthError",
},
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(shared.MessageAbortedError{}),
+ DiscriminatorValue: "MessageAbortedError",
+ },
)
}
@@ -1052,11 +1057,12 @@ const (
EventListResponseEventSessionErrorPropertiesErrorNameProviderAuthError EventListResponseEventSessionErrorPropertiesErrorName = "ProviderAuthError"
EventListResponseEventSessionErrorPropertiesErrorNameUnknownError EventListResponseEventSessionErrorPropertiesErrorName = "UnknownError"
EventListResponseEventSessionErrorPropertiesErrorNameMessageOutputLengthError EventListResponseEventSessionErrorPropertiesErrorName = "MessageOutputLengthError"
+ EventListResponseEventSessionErrorPropertiesErrorNameMessageAbortedError EventListResponseEventSessionErrorPropertiesErrorName = "MessageAbortedError"
)
func (r EventListResponseEventSessionErrorPropertiesErrorName) IsKnown() bool {
switch r {
- case EventListResponseEventSessionErrorPropertiesErrorNameProviderAuthError, EventListResponseEventSessionErrorPropertiesErrorNameUnknownError, EventListResponseEventSessionErrorPropertiesErrorNameMessageOutputLengthError:
+ case EventListResponseEventSessionErrorPropertiesErrorNameProviderAuthError, EventListResponseEventSessionErrorPropertiesErrorNameUnknownError, EventListResponseEventSessionErrorPropertiesErrorNameMessageOutputLengthError, EventListResponseEventSessionErrorPropertiesErrorNameMessageAbortedError:
return true
}
return false
@@ -1160,10 +1166,10 @@ const (
EventListResponseTypePermissionUpdated EventListResponseType = "permission.updated"
EventListResponseTypeFileEdited EventListResponseType = "file.edited"
EventListResponseTypeInstallationUpdated EventListResponseType = "installation.updated"
- EventListResponseTypeStorageWrite EventListResponseType = "storage.write"
EventListResponseTypeMessageUpdated EventListResponseType = "message.updated"
EventListResponseTypeMessageRemoved EventListResponseType = "message.removed"
EventListResponseTypeMessagePartUpdated EventListResponseType = "message.part.updated"
+ EventListResponseTypeStorageWrite EventListResponseType = "storage.write"
EventListResponseTypeSessionUpdated EventListResponseType = "session.updated"
EventListResponseTypeSessionDeleted EventListResponseType = "session.deleted"
EventListResponseTypeSessionIdle EventListResponseType = "session.idle"
@@ -1173,7 +1179,7 @@ const (
func (r EventListResponseType) IsKnown() bool {
switch r {
- case EventListResponseTypeLspClientDiagnostics, EventListResponseTypePermissionUpdated, EventListResponseTypeFileEdited, EventListResponseTypeInstallationUpdated, EventListResponseTypeStorageWrite, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeFileWatcherUpdated:
+ case EventListResponseTypeLspClientDiagnostics, EventListResponseTypePermissionUpdated, EventListResponseTypeFileEdited, EventListResponseTypeInstallationUpdated, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeStorageWrite, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeFileWatcherUpdated:
return true
}
return false
diff --git a/file.go b/file.go
index a9d6f01..0a8a4b2 100644
--- a/file.go
+++ b/file.go
@@ -42,13 +42,55 @@ func (r *FileService) Read(ctx context.Context, query FileReadParams, opts ...op
}
// Get file status
-func (r *FileService) Status(ctx context.Context, opts ...option.RequestOption) (res *[]FileStatusResponse, err error) {
+func (r *FileService) Status(ctx context.Context, opts ...option.RequestOption) (res *[]File, err error) {
opts = append(r.Options[:], opts...)
path := "file/status"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
return
}
+type File struct {
+ Added int64 `json:"added,required"`
+ Path string `json:"path,required"`
+ Removed int64 `json:"removed,required"`
+ Status FileStatus `json:"status,required"`
+ JSON fileJSON `json:"-"`
+}
+
+// fileJSON contains the JSON metadata for the struct [File]
+type fileJSON struct {
+ Added apijson.Field
+ Path apijson.Field
+ Removed apijson.Field
+ Status apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *File) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r fileJSON) RawJSON() string {
+ return r.raw
+}
+
+type FileStatus string
+
+const (
+ FileStatusAdded FileStatus = "added"
+ FileStatusDeleted FileStatus = "deleted"
+ FileStatusModified FileStatus = "modified"
+)
+
+func (r FileStatus) IsKnown() bool {
+ switch r {
+ case FileStatusAdded, FileStatusDeleted, FileStatusModified:
+ return true
+ }
+ return false
+}
+
type FileReadResponse struct {
Content string `json:"content,required"`
Type FileReadResponseType `json:"type,required"`
@@ -87,49 +129,6 @@ func (r FileReadResponseType) IsKnown() bool {
return false
}
-type FileStatusResponse struct {
- Added int64 `json:"added,required"`
- File string `json:"file,required"`
- Removed int64 `json:"removed,required"`
- Status FileStatusResponseStatus `json:"status,required"`
- JSON fileStatusResponseJSON `json:"-"`
-}
-
-// fileStatusResponseJSON contains the JSON metadata for the struct
-// [FileStatusResponse]
-type fileStatusResponseJSON struct {
- Added apijson.Field
- File apijson.Field
- Removed apijson.Field
- Status apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *FileStatusResponse) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r fileStatusResponseJSON) RawJSON() string {
- return r.raw
-}
-
-type FileStatusResponseStatus string
-
-const (
- FileStatusResponseStatusAdded FileStatusResponseStatus = "added"
- FileStatusResponseStatusDeleted FileStatusResponseStatus = "deleted"
- FileStatusResponseStatusModified FileStatusResponseStatus = "modified"
-)
-
-func (r FileStatusResponseStatus) IsKnown() bool {
- switch r {
- case FileStatusResponseStatusAdded, FileStatusResponseStatusDeleted, FileStatusResponseStatusModified:
- return true
- }
- return false
-}
-
type FileReadParams struct {
Path param.Field[string] `query:"path,required"`
}
diff --git a/find.go b/find.go
index bbd6b68..10f92fc 100644
--- a/find.go
+++ b/find.go
@@ -42,7 +42,7 @@ func (r *FindService) Files(ctx context.Context, query FindFilesParams, opts ...
}
// Find workspace symbols
-func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts ...option.RequestOption) (res *[]FindSymbolsResponse, err error) {
+func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts ...option.RequestOption) (res *[]Symbol, err error) {
opts = append(r.Options[:], opts...)
path := "find/symbol"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
@@ -50,27 +50,24 @@ func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts
}
// Find text in files
-func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]FindTextResponse, err error) {
+func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]Match, err error) {
opts = append(r.Options[:], opts...)
path := "find"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
return
}
-type FindSymbolsResponse = interface{}
-
-type FindTextResponse struct {
- AbsoluteOffset float64 `json:"absolute_offset,required"`
- LineNumber float64 `json:"line_number,required"`
- Lines FindTextResponseLines `json:"lines,required"`
- Path FindTextResponsePath `json:"path,required"`
- Submatches []FindTextResponseSubmatch `json:"submatches,required"`
- JSON findTextResponseJSON `json:"-"`
+type Match struct {
+ AbsoluteOffset float64 `json:"absolute_offset,required"`
+ LineNumber float64 `json:"line_number,required"`
+ Lines MatchLines `json:"lines,required"`
+ Path MatchPath `json:"path,required"`
+ Submatches []MatchSubmatch `json:"submatches,required"`
+ JSON matchJSON `json:"-"`
}
-// findTextResponseJSON contains the JSON metadata for the struct
-// [FindTextResponse]
-type findTextResponseJSON struct {
+// matchJSON contains the JSON metadata for the struct [Match]
+type matchJSON struct {
AbsoluteOffset apijson.Field
LineNumber apijson.Field
Lines apijson.Field
@@ -80,66 +77,63 @@ type findTextResponseJSON struct {
ExtraFields map[string]apijson.Field
}
-func (r *FindTextResponse) UnmarshalJSON(data []byte) (err error) {
+func (r *Match) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r findTextResponseJSON) RawJSON() string {
+func (r matchJSON) RawJSON() string {
return r.raw
}
-type FindTextResponseLines struct {
- Text string `json:"text,required"`
- JSON findTextResponseLinesJSON `json:"-"`
+type MatchLines struct {
+ Text string `json:"text,required"`
+ JSON matchLinesJSON `json:"-"`
}
-// findTextResponseLinesJSON contains the JSON metadata for the struct
-// [FindTextResponseLines]
-type findTextResponseLinesJSON struct {
+// matchLinesJSON contains the JSON metadata for the struct [MatchLines]
+type matchLinesJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *FindTextResponseLines) UnmarshalJSON(data []byte) (err error) {
+func (r *MatchLines) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r findTextResponseLinesJSON) RawJSON() string {
+func (r matchLinesJSON) RawJSON() string {
return r.raw
}
-type FindTextResponsePath struct {
- Text string `json:"text,required"`
- JSON findTextResponsePathJSON `json:"-"`
+type MatchPath struct {
+ Text string `json:"text,required"`
+ JSON matchPathJSON `json:"-"`
}
-// findTextResponsePathJSON contains the JSON metadata for the struct
-// [FindTextResponsePath]
-type findTextResponsePathJSON struct {
+// matchPathJSON contains the JSON metadata for the struct [MatchPath]
+type matchPathJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *FindTextResponsePath) UnmarshalJSON(data []byte) (err error) {
+func (r *MatchPath) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r findTextResponsePathJSON) RawJSON() string {
+func (r matchPathJSON) RawJSON() string {
return r.raw
}
-type FindTextResponseSubmatch struct {
- End float64 `json:"end,required"`
- Match FindTextResponseSubmatchesMatch `json:"match,required"`
- Start float64 `json:"start,required"`
- JSON findTextResponseSubmatchJSON `json:"-"`
+type MatchSubmatch struct {
+ End float64 `json:"end,required"`
+ Match MatchSubmatchesMatch `json:"match,required"`
+ Start float64 `json:"start,required"`
+ JSON matchSubmatchJSON `json:"-"`
}
-// findTextResponseSubmatchJSON contains the JSON metadata for the struct
-// [FindTextResponseSubmatch]
-type findTextResponseSubmatchJSON struct {
+// matchSubmatchJSON contains the JSON metadata for the struct [MatchSubmatch]
+type matchSubmatchJSON struct {
End apijson.Field
Match apijson.Field
Start apijson.Field
@@ -147,32 +141,147 @@ type findTextResponseSubmatchJSON struct {
ExtraFields map[string]apijson.Field
}
-func (r *FindTextResponseSubmatch) UnmarshalJSON(data []byte) (err error) {
+func (r *MatchSubmatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r findTextResponseSubmatchJSON) RawJSON() string {
+func (r matchSubmatchJSON) RawJSON() string {
return r.raw
}
-type FindTextResponseSubmatchesMatch struct {
- Text string `json:"text,required"`
- JSON findTextResponseSubmatchesMatchJSON `json:"-"`
+type MatchSubmatchesMatch struct {
+ Text string `json:"text,required"`
+ JSON matchSubmatchesMatchJSON `json:"-"`
}
-// findTextResponseSubmatchesMatchJSON contains the JSON metadata for the struct
-// [FindTextResponseSubmatchesMatch]
-type findTextResponseSubmatchesMatchJSON struct {
+// matchSubmatchesMatchJSON contains the JSON metadata for the struct
+// [MatchSubmatchesMatch]
+type matchSubmatchesMatchJSON struct {
Text apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r *FindTextResponseSubmatchesMatch) UnmarshalJSON(data []byte) (err error) {
+func (r *MatchSubmatchesMatch) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
-func (r findTextResponseSubmatchesMatchJSON) RawJSON() string {
+func (r matchSubmatchesMatchJSON) RawJSON() string {
+ return r.raw
+}
+
+type Symbol struct {
+ Kind float64 `json:"kind,required"`
+ Location SymbolLocation `json:"location,required"`
+ Name string `json:"name,required"`
+ JSON symbolJSON `json:"-"`
+}
+
+// symbolJSON contains the JSON metadata for the struct [Symbol]
+type symbolJSON struct {
+ Kind apijson.Field
+ Location apijson.Field
+ Name apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *Symbol) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r symbolJSON) RawJSON() string {
+ return r.raw
+}
+
+type SymbolLocation struct {
+ Range SymbolLocationRange `json:"range,required"`
+ Uri string `json:"uri,required"`
+ JSON symbolLocationJSON `json:"-"`
+}
+
+// symbolLocationJSON contains the JSON metadata for the struct [SymbolLocation]
+type symbolLocationJSON struct {
+ Range apijson.Field
+ Uri apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SymbolLocation) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r symbolLocationJSON) RawJSON() string {
+ return r.raw
+}
+
+type SymbolLocationRange struct {
+ End SymbolLocationRangeEnd `json:"end,required"`
+ Start SymbolLocationRangeStart `json:"start,required"`
+ JSON symbolLocationRangeJSON `json:"-"`
+}
+
+// symbolLocationRangeJSON contains the JSON metadata for the struct
+// [SymbolLocationRange]
+type symbolLocationRangeJSON struct {
+ End apijson.Field
+ Start apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SymbolLocationRange) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r symbolLocationRangeJSON) RawJSON() string {
+ return r.raw
+}
+
+type SymbolLocationRangeEnd struct {
+ Character float64 `json:"character,required"`
+ Line float64 `json:"line,required"`
+ JSON symbolLocationRangeEndJSON `json:"-"`
+}
+
+// symbolLocationRangeEndJSON contains the JSON metadata for the struct
+// [SymbolLocationRangeEnd]
+type symbolLocationRangeEndJSON struct {
+ Character apijson.Field
+ Line apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SymbolLocationRangeEnd) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r symbolLocationRangeEndJSON) RawJSON() string {
+ return r.raw
+}
+
+type SymbolLocationRangeStart struct {
+ Character float64 `json:"character,required"`
+ Line float64 `json:"line,required"`
+ JSON symbolLocationRangeStartJSON `json:"-"`
+}
+
+// symbolLocationRangeStartJSON contains the JSON metadata for the struct
+// [SymbolLocationRangeStart]
+type symbolLocationRangeStartJSON struct {
+ Character apijson.Field
+ Line apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SymbolLocationRangeStart) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r symbolLocationRangeStartJSON) RawJSON() string {
return r.raw
}
diff --git a/session.go b/session.go
index 8e0a9b3..c91de85 100644
--- a/session.go
+++ b/session.go
@@ -101,7 +101,7 @@ func (r *SessionService) Init(ctx context.Context, id string, body SessionInitPa
}
// List messages for a session
-func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]Message, err error) {
+func (r *SessionService) Messages(ctx context.Context, id string, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error) {
opts = append(r.Options[:], opts...)
if id == "" {
err = errors.New("missing required id parameter")
@@ -152,7 +152,6 @@ type AssistantMessage struct {
ID string `json:"id,required"`
Cost float64 `json:"cost,required"`
ModelID string `json:"modelID,required"`
- Parts []AssistantMessagePart `json:"parts,required"`
Path AssistantMessagePath `json:"path,required"`
ProviderID string `json:"providerID,required"`
Role AssistantMessageRole `json:"role,required"`
@@ -171,7 +170,6 @@ type assistantMessageJSON struct {
ID apijson.Field
Cost apijson.Field
ModelID apijson.Field
- Parts apijson.Field
Path apijson.Field
ProviderID apijson.Field
Role apijson.Field
@@ -340,13 +338,14 @@ func (r *AssistantMessageError) UnmarshalJSON(data []byte) (err error) {
// the specific types for more type safety.
//
// Possible runtime types of the union are [shared.ProviderAuthError],
-// [shared.UnknownError], [AssistantMessageErrorMessageOutputLengthError].
+// [shared.UnknownError], [AssistantMessageErrorMessageOutputLengthError],
+// [shared.MessageAbortedError].
func (r AssistantMessageError) AsUnion() AssistantMessageErrorUnion {
return r.union
}
-// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError] or
-// [AssistantMessageErrorMessageOutputLengthError].
+// Union satisfied by [shared.ProviderAuthError], [shared.UnknownError],
+// [AssistantMessageErrorMessageOutputLengthError] or [shared.MessageAbortedError].
type AssistantMessageErrorUnion interface {
ImplementsAssistantMessageError()
}
@@ -370,6 +369,11 @@ func init() {
Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}),
DiscriminatorValue: "MessageOutputLengthError",
},
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(shared.MessageAbortedError{}),
+ DiscriminatorValue: "MessageAbortedError",
+ },
)
}
@@ -418,114 +422,34 @@ const (
AssistantMessageErrorNameProviderAuthError AssistantMessageErrorName = "ProviderAuthError"
AssistantMessageErrorNameUnknownError AssistantMessageErrorName = "UnknownError"
AssistantMessageErrorNameMessageOutputLengthError AssistantMessageErrorName = "MessageOutputLengthError"
+ AssistantMessageErrorNameMessageAbortedError AssistantMessageErrorName = "MessageAbortedError"
)
func (r AssistantMessageErrorName) IsKnown() bool {
switch r {
- case AssistantMessageErrorNameProviderAuthError, AssistantMessageErrorNameUnknownError, AssistantMessageErrorNameMessageOutputLengthError:
- return true
- }
- return false
-}
-
-type AssistantMessagePart struct {
- Type AssistantMessagePartType `json:"type,required"`
- ID string `json:"id"`
- // This field can have the runtime type of [ToolPartState].
- State interface{} `json:"state"`
- Text string `json:"text"`
- Tool string `json:"tool"`
- JSON assistantMessagePartJSON `json:"-"`
- union AssistantMessagePartUnion
-}
-
-// assistantMessagePartJSON contains the JSON metadata for the struct
-// [AssistantMessagePart]
-type assistantMessagePartJSON struct {
- Type apijson.Field
- ID apijson.Field
- State apijson.Field
- Text apijson.Field
- Tool apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r assistantMessagePartJSON) RawJSON() string {
- return r.raw
-}
-
-func (r *AssistantMessagePart) UnmarshalJSON(data []byte) (err error) {
- *r = AssistantMessagePart{}
- err = apijson.UnmarshalRoot(data, &r.union)
- if err != nil {
- return err
- }
- return apijson.Port(r.union, &r)
-}
-
-// AsUnion returns a [AssistantMessagePartUnion] interface which you can cast to
-// the specific types for more type safety.
-//
-// Possible runtime types of the union are [TextPart], [ToolPart], [StepStartPart].
-func (r AssistantMessagePart) AsUnion() AssistantMessagePartUnion {
- return r.union
-}
-
-// Union satisfied by [TextPart], [ToolPart] or [StepStartPart].
-type AssistantMessagePartUnion interface {
- implementsAssistantMessagePart()
-}
-
-func init() {
- apijson.RegisterUnion(
- reflect.TypeOf((*AssistantMessagePartUnion)(nil)).Elem(),
- "type",
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(TextPart{}),
- DiscriminatorValue: "text",
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolPart{}),
- DiscriminatorValue: "tool",
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(StepStartPart{}),
- DiscriminatorValue: "step-start",
- },
- )
-}
-
-type AssistantMessagePartType string
-
-const (
- AssistantMessagePartTypeText AssistantMessagePartType = "text"
- AssistantMessagePartTypeTool AssistantMessagePartType = "tool"
- AssistantMessagePartTypeStepStart AssistantMessagePartType = "step-start"
-)
-
-func (r AssistantMessagePartType) IsKnown() bool {
- switch r {
- case AssistantMessagePartTypeText, AssistantMessagePartTypeTool, AssistantMessagePartTypeStepStart:
+ case AssistantMessageErrorNameProviderAuthError, AssistantMessageErrorNameUnknownError, AssistantMessageErrorNameMessageOutputLengthError, AssistantMessageErrorNameMessageAbortedError:
return true
}
return false
}
type FilePart struct {
- Mime string `json:"mime,required"`
- Type FilePartType `json:"type,required"`
- URL string `json:"url,required"`
- Filename string `json:"filename"`
- JSON filePartJSON `json:"-"`
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ Mime string `json:"mime,required"`
+ SessionID string `json:"sessionID,required"`
+ Type FilePartType `json:"type,required"`
+ URL string `json:"url,required"`
+ Filename string `json:"filename"`
+ JSON filePartJSON `json:"-"`
}
// filePartJSON contains the JSON metadata for the struct [FilePart]
type filePartJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
Mime apijson.Field
+ SessionID apijson.Field
Type apijson.Field
URL apijson.Field
Filename apijson.Field
@@ -541,7 +465,7 @@ func (r filePartJSON) RawJSON() string {
return r.raw
}
-func (r FilePart) implementsUserMessagePart() {}
+func (r FilePart) implementsPart() {}
type FilePartType string
@@ -558,26 +482,26 @@ func (r FilePartType) IsKnown() bool {
}
type FilePartParam struct {
- Mime param.Field[string] `json:"mime,required"`
- Type param.Field[FilePartType] `json:"type,required"`
- URL param.Field[string] `json:"url,required"`
- Filename param.Field[string] `json:"filename"`
+ 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"`
}
func (r FilePartParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r FilePartParam) implementsUserMessagePartUnionParam() {}
+func (r FilePartParam) implementsSessionChatParamsPartUnion() {}
type Message struct {
- ID string `json:"id,required"`
- // This field can have the runtime type of [[]UserMessagePart],
- // [[]AssistantMessagePart].
- Parts interface{} `json:"parts,required"`
+ ID string `json:"id,required"`
Role MessageRole `json:"role,required"`
SessionID string `json:"sessionID,required"`
- // This field can have the runtime type of [MessageUserMessageTime],
+ // This field can have the runtime type of [UserMessageTime],
// [AssistantMessageTime].
Time interface{} `json:"time,required"`
Cost float64 `json:"cost"`
@@ -599,7 +523,6 @@ type Message struct {
// messageJSON contains the JSON metadata for the struct [Message]
type messageJSON struct {
ID apijson.Field
- Parts apijson.Field
Role apijson.Field
SessionID apijson.Field
Time apijson.Field
@@ -631,13 +554,12 @@ func (r *Message) UnmarshalJSON(data []byte) (err error) {
// AsUnion returns a [MessageUnion] interface which you can cast to the specific
// types for more type safety.
//
-// Possible runtime types of the union are [MessageUserMessage],
-// [AssistantMessage].
+// Possible runtime types of the union are [UserMessage], [AssistantMessage].
func (r Message) AsUnion() MessageUnion {
return r.union
}
-// Union satisfied by [MessageUserMessage] or [AssistantMessage].
+// Union satisfied by [UserMessage] or [AssistantMessage].
type MessageUnion interface {
implementsMessage()
}
@@ -648,7 +570,7 @@ func init() {
"role",
apijson.UnionVariant{
TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(MessageUserMessage{}),
+ Type: reflect.TypeOf(UserMessage{}),
DiscriminatorValue: "user",
},
apijson.UnionVariant{
@@ -659,72 +581,6 @@ func init() {
)
}
-type MessageUserMessage struct {
- ID string `json:"id,required"`
- Parts []UserMessagePart `json:"parts,required"`
- Role MessageUserMessageRole `json:"role,required"`
- SessionID string `json:"sessionID,required"`
- Time MessageUserMessageTime `json:"time,required"`
- JSON messageUserMessageJSON `json:"-"`
-}
-
-// messageUserMessageJSON contains the JSON metadata for the struct
-// [MessageUserMessage]
-type messageUserMessageJSON struct {
- ID apijson.Field
- Parts apijson.Field
- Role apijson.Field
- SessionID apijson.Field
- Time apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *MessageUserMessage) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r messageUserMessageJSON) RawJSON() string {
- return r.raw
-}
-
-func (r MessageUserMessage) implementsMessage() {}
-
-type MessageUserMessageRole string
-
-const (
- MessageUserMessageRoleUser MessageUserMessageRole = "user"
-)
-
-func (r MessageUserMessageRole) IsKnown() bool {
- switch r {
- case MessageUserMessageRoleUser:
- return true
- }
- return false
-}
-
-type MessageUserMessageTime struct {
- Created float64 `json:"created,required"`
- JSON messageUserMessageTimeJSON `json:"-"`
-}
-
-// messageUserMessageTimeJSON contains the JSON metadata for the struct
-// [MessageUserMessageTime]
-type messageUserMessageTimeJSON struct {
- Created apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *MessageUserMessageTime) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r messageUserMessageTimeJSON) RawJSON() string {
- return r.raw
-}
-
type MessageRole string
const (
@@ -740,6 +596,174 @@ func (r MessageRole) IsKnown() bool {
return false
}
+type Part struct {
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Type PartType `json:"type,required"`
+ CallID string `json:"callID"`
+ 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"`
+ Text string `json:"text"`
+ // This field can have the runtime type of [TextPartTime].
+ Time interface{} `json:"time"`
+ // This field can have the runtime type of [StepFinishPartTokens].
+ Tokens interface{} `json:"tokens"`
+ Tool string `json:"tool"`
+ URL string `json:"url"`
+ JSON partJSON `json:"-"`
+ union PartUnion
+}
+
+// partJSON contains the JSON metadata for the struct [Part]
+type partJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
+ Type apijson.Field
+ CallID apijson.Field
+ Cost apijson.Field
+ Filename apijson.Field
+ Mime apijson.Field
+ Snapshot apijson.Field
+ State apijson.Field
+ Synthetic apijson.Field
+ Text apijson.Field
+ Time apijson.Field
+ Tokens apijson.Field
+ Tool apijson.Field
+ URL apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r partJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r *Part) UnmarshalJSON(data []byte) (err error) {
+ *r = Part{}
+ err = apijson.UnmarshalRoot(data, &r.union)
+ if err != nil {
+ return err
+ }
+ return apijson.Port(r.union, &r)
+}
+
+// AsUnion returns a [PartUnion] interface which you can cast to the specific types
+// for more type safety.
+//
+// Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
+// [StepStartPart], [StepFinishPart], [PartObject].
+func (r Part) AsUnion() PartUnion {
+ return r.union
+}
+
+// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
+// [StepFinishPart] or [PartObject].
+type PartUnion interface {
+ implementsPart()
+}
+
+func init() {
+ apijson.RegisterUnion(
+ reflect.TypeOf((*PartUnion)(nil)).Elem(),
+ "",
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(TextPart{}),
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(FilePart{}),
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolPart{}),
+ },
+ apijson.UnionVariant{
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(StepStartPart{}),
+ },
+ apijson.UnionVariant{
+ 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 (
+ PartTypeText PartType = "text"
+ PartTypeFile PartType = "file"
+ 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, PartTypeSnapshot:
+ return true
+ }
+ return false
+}
+
type Session struct {
ID string `json:"id,required"`
Time SessionTime `json:"time,required"`
@@ -838,13 +862,115 @@ func (r sessionShareJSON) RawJSON() string {
return r.raw
}
+type StepFinishPart struct {
+ ID string `json:"id,required"`
+ Cost float64 `json:"cost,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Tokens StepFinishPartTokens `json:"tokens,required"`
+ Type StepFinishPartType `json:"type,required"`
+ JSON stepFinishPartJSON `json:"-"`
+}
+
+// stepFinishPartJSON contains the JSON metadata for the struct [StepFinishPart]
+type stepFinishPartJSON struct {
+ ID apijson.Field
+ Cost apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
+ Tokens apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *StepFinishPart) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r stepFinishPartJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r StepFinishPart) implementsPart() {}
+
+type StepFinishPartTokens struct {
+ Cache StepFinishPartTokensCache `json:"cache,required"`
+ Input float64 `json:"input,required"`
+ Output float64 `json:"output,required"`
+ Reasoning float64 `json:"reasoning,required"`
+ JSON stepFinishPartTokensJSON `json:"-"`
+}
+
+// stepFinishPartTokensJSON contains the JSON metadata for the struct
+// [StepFinishPartTokens]
+type stepFinishPartTokensJSON struct {
+ Cache apijson.Field
+ Input apijson.Field
+ Output apijson.Field
+ Reasoning apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *StepFinishPartTokens) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r stepFinishPartTokensJSON) RawJSON() string {
+ return r.raw
+}
+
+type StepFinishPartTokensCache struct {
+ Read float64 `json:"read,required"`
+ Write float64 `json:"write,required"`
+ JSON stepFinishPartTokensCacheJSON `json:"-"`
+}
+
+// stepFinishPartTokensCacheJSON contains the JSON metadata for the struct
+// [StepFinishPartTokensCache]
+type stepFinishPartTokensCacheJSON struct {
+ Read apijson.Field
+ Write apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *StepFinishPartTokensCache) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r stepFinishPartTokensCacheJSON) RawJSON() string {
+ return r.raw
+}
+
+type StepFinishPartType string
+
+const (
+ StepFinishPartTypeStepFinish StepFinishPartType = "step-finish"
+)
+
+func (r StepFinishPartType) IsKnown() bool {
+ switch r {
+ case StepFinishPartTypeStepFinish:
+ return true
+ }
+ return false
+}
+
type StepStartPart struct {
- Type StepStartPartType `json:"type,required"`
- JSON stepStartPartJSON `json:"-"`
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Type StepStartPartType `json:"type,required"`
+ JSON stepStartPartJSON `json:"-"`
}
// stepStartPartJSON contains the JSON metadata for the struct [StepStartPart]
type stepStartPartJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
Type apijson.Field
raw string
ExtraFields map[string]apijson.Field
@@ -858,7 +984,7 @@ func (r stepStartPartJSON) RawJSON() string {
return r.raw
}
-func (r StepStartPart) implementsAssistantMessagePart() {}
+func (r StepStartPart) implementsPart() {}
type StepStartPartType string
@@ -875,15 +1001,25 @@ func (r StepStartPartType) IsKnown() bool {
}
type TextPart struct {
- Text string `json:"text,required"`
- Type TextPartType `json:"type,required"`
- JSON textPartJSON `json:"-"`
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Text string `json:"text,required"`
+ Type TextPartType `json:"type,required"`
+ Synthetic bool `json:"synthetic"`
+ Time TextPartTime `json:"time"`
+ JSON textPartJSON `json:"-"`
}
// textPartJSON contains the JSON metadata for the struct [TextPart]
type textPartJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
Text apijson.Field
Type apijson.Field
+ Synthetic apijson.Field
+ Time apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -896,9 +1032,7 @@ func (r textPartJSON) RawJSON() string {
return r.raw
}
-func (r TextPart) implementsAssistantMessagePart() {}
-
-func (r TextPart) implementsUserMessagePart() {}
+func (r TextPart) implementsPart() {}
type TextPartType string
@@ -914,28 +1048,70 @@ func (r TextPartType) IsKnown() bool {
return false
}
+type TextPartTime struct {
+ Start float64 `json:"start,required"`
+ End float64 `json:"end"`
+ JSON textPartTimeJSON `json:"-"`
+}
+
+// textPartTimeJSON contains the JSON metadata for the struct [TextPartTime]
+type textPartTimeJSON struct {
+ Start apijson.Field
+ End apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *TextPartTime) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r textPartTimeJSON) RawJSON() string {
+ return r.raw
+}
+
type TextPartParam struct {
- Text param.Field[string] `json:"text,required"`
- Type param.Field[TextPartType] `json:"type,required"`
+ 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"`
}
func (r TextPartParam) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
-func (r TextPartParam) implementsUserMessagePartUnionParam() {}
+func (r TextPartParam) implementsSessionChatParamsPartUnion() {}
+
+type TextPartTimeParam struct {
+ Start param.Field[float64] `json:"start,required"`
+ End param.Field[float64] `json:"end"`
+}
+
+func (r TextPartTimeParam) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
type ToolPart struct {
- ID string `json:"id,required"`
- State ToolPartState `json:"state,required"`
- Tool string `json:"tool,required"`
- Type ToolPartType `json:"type,required"`
- JSON toolPartJSON `json:"-"`
+ ID string `json:"id,required"`
+ CallID string `json:"callID,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ State ToolPartState `json:"state,required"`
+ Tool string `json:"tool,required"`
+ Type ToolPartType `json:"type,required"`
+ JSON toolPartJSON `json:"-"`
}
// toolPartJSON contains the JSON metadata for the struct [ToolPart]
type toolPartJSON struct {
ID apijson.Field
+ CallID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
State apijson.Field
Tool apijson.Field
Type apijson.Field
@@ -951,12 +1127,12 @@ func (r toolPartJSON) RawJSON() string {
return r.raw
}
-func (r ToolPart) implementsAssistantMessagePart() {}
+func (r ToolPart) implementsPart() {}
type ToolPartState struct {
Status ToolPartStateStatus `json:"status,required"`
Error string `json:"error"`
- // This field can have the runtime type of [interface{}].
+ // This field can have the runtime type of [interface{}], [map[string]interface{}].
Input interface{} `json:"input"`
// This field can have the runtime type of [map[string]interface{}].
Metadata interface{} `json:"metadata"`
@@ -1069,24 +1245,24 @@ func (r ToolPartType) IsKnown() bool {
}
type ToolStateCompleted struct {
+ Input map[string]interface{} `json:"input,required"`
Metadata map[string]interface{} `json:"metadata,required"`
Output string `json:"output,required"`
Status ToolStateCompletedStatus `json:"status,required"`
Time ToolStateCompletedTime `json:"time,required"`
Title string `json:"title,required"`
- Input interface{} `json:"input"`
JSON toolStateCompletedJSON `json:"-"`
}
// toolStateCompletedJSON contains the JSON metadata for the struct
// [ToolStateCompleted]
type toolStateCompletedJSON struct {
+ Input apijson.Field
Metadata apijson.Field
Output apijson.Field
Status apijson.Field
Time apijson.Field
Title apijson.Field
- Input apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -1139,19 +1315,19 @@ func (r toolStateCompletedTimeJSON) RawJSON() string {
}
type ToolStateError struct {
- Error string `json:"error,required"`
- Status ToolStateErrorStatus `json:"status,required"`
- Time ToolStateErrorTime `json:"time,required"`
- Input interface{} `json:"input"`
- JSON toolStateErrorJSON `json:"-"`
+ Error string `json:"error,required"`
+ Input map[string]interface{} `json:"input,required"`
+ Status ToolStateErrorStatus `json:"status,required"`
+ Time ToolStateErrorTime `json:"time,required"`
+ JSON toolStateErrorJSON `json:"-"`
}
// toolStateErrorJSON contains the JSON metadata for the struct [ToolStateError]
type toolStateErrorJSON struct {
Error apijson.Field
+ Input apijson.Field
Status apijson.Field
Time apijson.Field
- Input apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
@@ -1306,115 +1482,144 @@ func (r toolStateRunningTimeJSON) RawJSON() string {
return r.raw
}
-type UserMessagePart struct {
- Type UserMessagePartType `json:"type,required"`
- Filename string `json:"filename"`
- Mime string `json:"mime"`
- Text string `json:"text"`
- URL string `json:"url"`
- JSON userMessagePartJSON `json:"-"`
- union UserMessagePartUnion
+type UserMessage struct {
+ ID string `json:"id,required"`
+ Role UserMessageRole `json:"role,required"`
+ SessionID string `json:"sessionID,required"`
+ Time UserMessageTime `json:"time,required"`
+ JSON userMessageJSON `json:"-"`
}
-// userMessagePartJSON contains the JSON metadata for the struct [UserMessagePart]
-type userMessagePartJSON struct {
- Type apijson.Field
- Filename apijson.Field
- Mime apijson.Field
- Text apijson.Field
- URL apijson.Field
+// userMessageJSON contains the JSON metadata for the struct [UserMessage]
+type userMessageJSON struct {
+ ID apijson.Field
+ Role apijson.Field
+ SessionID apijson.Field
+ Time apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
-func (r userMessagePartJSON) RawJSON() string {
+func (r *UserMessage) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r userMessageJSON) RawJSON() string {
return r.raw
}
-func (r *UserMessagePart) UnmarshalJSON(data []byte) (err error) {
- *r = UserMessagePart{}
- err = apijson.UnmarshalRoot(data, &r.union)
- if err != nil {
- return err
- }
- return apijson.Port(r.union, &r)
-}
+func (r UserMessage) implementsMessage() {}
-// AsUnion returns a [UserMessagePartUnion] interface which you can cast to the
-// specific types for more type safety.
-//
-// Possible runtime types of the union are [TextPart], [FilePart].
-func (r UserMessagePart) AsUnion() UserMessagePartUnion {
- return r.union
-}
-
-// Union satisfied by [TextPart] or [FilePart].
-type UserMessagePartUnion interface {
- implementsUserMessagePart()
-}
-
-func init() {
- apijson.RegisterUnion(
- reflect.TypeOf((*UserMessagePartUnion)(nil)).Elem(),
- "type",
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(TextPart{}),
- DiscriminatorValue: "text",
- },
- apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(FilePart{}),
- DiscriminatorValue: "file",
- },
- )
-}
-
-type UserMessagePartType string
+type UserMessageRole string
const (
- UserMessagePartTypeText UserMessagePartType = "text"
- UserMessagePartTypeFile UserMessagePartType = "file"
+ UserMessageRoleUser UserMessageRole = "user"
)
-func (r UserMessagePartType) IsKnown() bool {
+func (r UserMessageRole) IsKnown() bool {
switch r {
- case UserMessagePartTypeText, UserMessagePartTypeFile:
+ case UserMessageRoleUser:
return true
}
return false
}
-type UserMessagePartParam struct {
- Type param.Field[UserMessagePartType] `json:"type,required"`
- Filename param.Field[string] `json:"filename"`
- Mime param.Field[string] `json:"mime"`
- Text param.Field[string] `json:"text"`
- URL param.Field[string] `json:"url"`
+type UserMessageTime struct {
+ Created float64 `json:"created,required"`
+ JSON userMessageTimeJSON `json:"-"`
}
-func (r UserMessagePartParam) MarshalJSON() (data []byte, err error) {
- return apijson.MarshalRoot(r)
+// userMessageTimeJSON contains the JSON metadata for the struct [UserMessageTime]
+type userMessageTimeJSON struct {
+ Created apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
}
-func (r UserMessagePartParam) implementsUserMessagePartUnionParam() {}
+func (r *UserMessageTime) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
-// Satisfied by [TextPartParam], [FilePartParam], [UserMessagePartParam].
-type UserMessagePartUnionParam interface {
- implementsUserMessagePartUnionParam()
+func (r userMessageTimeJSON) RawJSON() string {
+ return r.raw
+}
+
+type SessionMessagesResponse struct {
+ Info Message `json:"info,required"`
+ Parts []Part `json:"parts,required"`
+ JSON sessionMessagesResponseJSON `json:"-"`
+}
+
+// sessionMessagesResponseJSON contains the JSON metadata for the struct
+// [SessionMessagesResponse]
+type sessionMessagesResponseJSON struct {
+ Info apijson.Field
+ Parts apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SessionMessagesResponse) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r sessionMessagesResponseJSON) RawJSON() string {
+ return r.raw
}
type SessionChatParams struct {
- ModelID param.Field[string] `json:"modelID,required"`
- Parts param.Field[[]UserMessagePartUnionParam] `json:"parts,required"`
- ProviderID param.Field[string] `json:"providerID,required"`
+ 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"`
}
func (r SessionChatParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
+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"`
+ Filename param.Field[string] `json:"filename"`
+ Mime param.Field[string] `json:"mime"`
+ Synthetic param.Field[bool] `json:"synthetic"`
+ Text param.Field[string] `json:"text"`
+ Time param.Field[interface{}] `json:"time"`
+ URL param.Field[string] `json:"url"`
+}
+
+func (r SessionChatParamsPart) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+func (r SessionChatParamsPart) implementsSessionChatParamsPartUnion() {}
+
+// Satisfied by [FilePartParam], [TextPartParam], [SessionChatParamsPart].
+type SessionChatParamsPartUnion interface {
+ implementsSessionChatParamsPartUnion()
+}
+
+type SessionChatParamsPartsType string
+
+const (
+ SessionChatParamsPartsTypeFile SessionChatParamsPartsType = "file"
+ SessionChatParamsPartsTypeText SessionChatParamsPartsType = "text"
+)
+
+func (r SessionChatParamsPartsType) IsKnown() bool {
+ switch r {
+ case SessionChatParamsPartsTypeFile, SessionChatParamsPartsTypeText:
+ return true
+ }
+ return false
+}
+
type SessionInitParams struct {
+ MessageID param.Field[string] `json:"messageID,required"`
ModelID param.Field[string] `json:"modelID,required"`
ProviderID param.Field[string] `json:"providerID,required"`
}
diff --git a/session_test.go b/session_test.go
index 15137e6..c74a4a3 100644
--- a/session_test.go
+++ b/session_test.go
@@ -117,10 +117,17 @@ func TestSessionChat(t *testing.T) {
context.TODO(),
"id",
opencode.SessionChatParams{
- ModelID: opencode.F("modelID"),
- Parts: opencode.F([]opencode.UserMessagePartUnionParam{opencode.TextPartParam{
- Text: opencode.F("text"),
- Type: opencode.F(opencode.TextPartTypeText),
+ MessageID: opencode.F("messageID"),
+ Mode: opencode.F("mode"),
+ ModelID: opencode.F("modelID"),
+ Parts: opencode.F([]opencode.SessionChatParamsPartUnion{opencode.FilePartParam{
+ ID: opencode.F("id"),
+ MessageID: opencode.F("messageID"),
+ Mime: opencode.F("mime"),
+ SessionID: opencode.F("sessionID"),
+ Type: opencode.F(opencode.FilePartTypeFile),
+ URL: opencode.F("url"),
+ Filename: opencode.F("filename"),
}}),
ProviderID: opencode.F("providerID"),
},
@@ -150,6 +157,7 @@ func TestSessionInit(t *testing.T) {
context.TODO(),
"id",
opencode.SessionInitParams{
+ MessageID: opencode.F("messageID"),
ModelID: opencode.F("modelID"),
ProviderID: opencode.F("providerID"),
},
diff --git a/shared/shared.go b/shared/shared.go
index 1ab53b6..58baf3d 100644
--- a/shared/shared.go
+++ b/shared/shared.go
@@ -6,6 +6,47 @@ import (
"github.com/sst/opencode-sdk-go/internal/apijson"
)
+type MessageAbortedError struct {
+ Data interface{} `json:"data,required"`
+ Name MessageAbortedErrorName `json:"name,required"`
+ JSON messageAbortedErrorJSON `json:"-"`
+}
+
+// messageAbortedErrorJSON contains the JSON metadata for the struct
+// [MessageAbortedError]
+type messageAbortedErrorJSON struct {
+ Data apijson.Field
+ Name apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *MessageAbortedError) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r messageAbortedErrorJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r MessageAbortedError) ImplementsEventListResponseEventSessionErrorPropertiesError() {}
+
+func (r MessageAbortedError) ImplementsAssistantMessageError() {}
+
+type MessageAbortedErrorName string
+
+const (
+ MessageAbortedErrorNameMessageAbortedError MessageAbortedErrorName = "MessageAbortedError"
+)
+
+func (r MessageAbortedErrorName) IsKnown() bool {
+ switch r {
+ case MessageAbortedErrorNameMessageAbortedError:
+ return true
+ }
+ return false
+}
+
type ProviderAuthError struct {
Data ProviderAuthErrorData `json:"data,required"`
Name ProviderAuthErrorName `json:"name,required"`