diff options
| author | Dax <[email protected]> | 2025-09-15 03:12:07 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-15 03:12:07 -0400 |
| commit | c1b4e1f19dd45eeea791354cb041c520f55e1cdb (patch) | |
| tree | cc238910a99092592bc4baf926d5c5509128f29f /packages/sdk/go | |
| parent | 89d820b1c44028e673f2b4317a2104abb2be2e67 (diff) | |
| download | opencode-c1b4e1f19dd45eeea791354cb041c520f55e1cdb.tar.gz opencode-c1b4e1f19dd45eeea791354cb041c520f55e1cdb.zip | |
Upgrade to Zod v4 (#2605)
Co-authored-by: GitHub Action <[email protected]>
Diffstat (limited to 'packages/sdk/go')
| -rw-r--r-- | packages/sdk/go/.release-please-manifest.json | 2 | ||||
| -rw-r--r-- | packages/sdk/go/.stats.yml | 4 | ||||
| -rw-r--r-- | packages/sdk/go/CHANGELOG.md | 32 | ||||
| -rw-r--r-- | packages/sdk/go/README.md | 2 | ||||
| -rw-r--r-- | packages/sdk/go/aliases.go | 3 | ||||
| -rw-r--r-- | packages/sdk/go/command.go | 2 | ||||
| -rw-r--r-- | packages/sdk/go/config.go | 133 | ||||
| -rw-r--r-- | packages/sdk/go/event.go | 367 | ||||
| -rw-r--r-- | packages/sdk/go/internal/version.go | 2 | ||||
| -rw-r--r-- | packages/sdk/go/session.go | 129 | ||||
| -rw-r--r-- | packages/sdk/go/session_test.go | 8 | ||||
| -rw-r--r-- | packages/sdk/go/shared/shared.go | 23 |
12 files changed, 364 insertions, 343 deletions
diff --git a/packages/sdk/go/.release-please-manifest.json b/packages/sdk/go/.release-please-manifest.json index 76d5538a4..ed21d28cb 100644 --- a/packages/sdk/go/.release-please-manifest.json +++ b/packages/sdk/go/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.9.0" + ".": "0.13.0" } diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml index db9407052..7f4a9c119 100644 --- a/packages/sdk/go/.stats.yml +++ b/packages/sdk/go/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 43 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-46826ba8640557721614b0c9a3f1860681d825ca8d8b12869652fa25aacb0b4c.yml -openapi_spec_hash: 33b8db6fde3021579b21325ce910197d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-2e754dafcad0636137256cef499b2bcd72cf17de08f44ec03c3589b2a05341a2.yml +openapi_spec_hash: 2d3cf84d3033068ce6c07386411527ef config_hash: 026ef000d34bf2f930e7b41e77d2d3ff diff --git a/packages/sdk/go/CHANGELOG.md b/packages/sdk/go/CHANGELOG.md index fad7e6837..018017066 100644 --- a/packages/sdk/go/CHANGELOG.md +++ b/packages/sdk/go/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## 0.13.0 (2025-09-14) + +Full Changelog: [v0.12.0...v0.13.0](https://github.com/sst/opencode-sdk-go/compare/v0.12.0...v0.13.0) + +### Features + +- **api:** api update ([80da4fb](https://github.com/sst/opencode-sdk-go/commit/80da4fb4ea9c6afb51a7e7135d9f5560ce6f2a6c)) + +## 0.12.0 (2025-09-14) + +Full Changelog: [v0.11.0...v0.12.0](https://github.com/sst/opencode-sdk-go/compare/v0.11.0...v0.12.0) + +### Features + +- **api:** api update ([7e3808b](https://github.com/sst/opencode-sdk-go/commit/7e3808ba349dc653174b32b48a1120c18d2975c2)) + +## 0.11.0 (2025-09-14) + +Full Changelog: [v0.10.0...v0.11.0](https://github.com/sst/opencode-sdk-go/compare/v0.10.0...v0.11.0) + +### Features + +- **api:** api update ([a3d37f5](https://github.com/sst/opencode-sdk-go/commit/a3d37f5671545866547d351fc21b49809cc8b3c2)) + +## 0.10.0 (2025-09-11) + +Full Changelog: [v0.9.0...v0.10.0](https://github.com/sst/opencode-sdk-go/compare/v0.9.0...v0.10.0) + +### Features + +- **api:** api update ([0dc01f6](https://github.com/sst/opencode-sdk-go/commit/0dc01f6695c9b8400a4dc92166c5002bb120cf50)) + ## 0.9.0 (2025-09-10) Full Changelog: [v0.8.0...v0.9.0](https://github.com/sst/opencode-sdk-go/compare/v0.8.0...v0.9.0) diff --git a/packages/sdk/go/README.md b/packages/sdk/go/README.md index 0fe3d32bf..2c48f53ce 100644 --- a/packages/sdk/go/README.md +++ b/packages/sdk/go/README.md @@ -24,7 +24,7 @@ Or to pin the version: <!-- x-release-please-start-version --> ```sh -go get -u 'github.com/sst/[email protected]' +go get -u 'github.com/sst/[email protected]' ``` <!-- x-release-please-end --> diff --git a/packages/sdk/go/aliases.go b/packages/sdk/go/aliases.go index 6ab36d04c..50beeae91 100644 --- a/packages/sdk/go/aliases.go +++ b/packages/sdk/go/aliases.go @@ -13,6 +13,9 @@ type Error = apierror.Error type MessageAbortedError = shared.MessageAbortedError // This is an alias to an internal type. +type MessageAbortedErrorData = shared.MessageAbortedErrorData + +// This is an alias to an internal type. type MessageAbortedErrorName = shared.MessageAbortedErrorName // This is an alias to an internal value. diff --git a/packages/sdk/go/command.go b/packages/sdk/go/command.go index 2638fc607..44e3beb1c 100644 --- a/packages/sdk/go/command.go +++ b/packages/sdk/go/command.go @@ -47,6 +47,7 @@ type Command struct { Agent string `json:"agent"` Description string `json:"description"` Model string `json:"model"` + Subtask bool `json:"subtask"` JSON commandJSON `json:"-"` } @@ -57,6 +58,7 @@ type commandJSON struct { Agent apijson.Field Description apijson.Field Model apijson.Field + Subtask apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/packages/sdk/go/config.go b/packages/sdk/go/config.go index b79bcb2ef..d469bdff1 100644 --- a/packages/sdk/go/config.go +++ b/packages/sdk/go/config.go @@ -676,6 +676,7 @@ type ConfigCommand struct { Agent string `json:"agent"` Description string `json:"description"` Model string `json:"model"` + Subtask bool `json:"subtask"` JSON configCommandJSON `json:"-"` } @@ -685,6 +686,7 @@ type configCommandJSON struct { Agent apijson.Field Description apijson.Field Model apijson.Field + Subtask apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -698,18 +700,18 @@ func (r configCommandJSON) RawJSON() string { } type ConfigExperimental struct { - Hook ConfigExperimentalHook `json:"hook"` DisablePasteSummary bool `json:"disable_paste_summary"` + Hook ConfigExperimentalHook `json:"hook"` JSON configExperimentalJSON `json:"-"` } // configExperimentalJSON contains the JSON metadata for the struct // [ConfigExperimental] type configExperimentalJSON struct { - Hook apijson.Field - SummarizePaste apijson.Field - raw string - ExtraFields map[string]apijson.Field + DisablePasteSummary apijson.Field + Hook apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *ConfigExperimental) UnmarshalJSON(data []byte) (err error) { @@ -1022,16 +1024,14 @@ type ConfigMcpUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*ConfigMcpUnion)(nil)).Elem(), - "type", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(McpLocalConfig{}), - DiscriminatorValue: "local", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(McpLocalConfig{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(McpRemoteConfig{}), - DiscriminatorValue: "remote", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(McpRemoteConfig{}), }, ) } @@ -1753,15 +1753,15 @@ func (r ConfigShare) IsKnown() bool { // TUI specific settings type ConfigTui struct { // TUI scroll speed - ScrollSpeed float64 `json:"scroll_speed,required"` - JSON configTuiJSON `json:"-"` + ScrollSpeed float64 `json:"scroll_speed"` + JSON configTuiJSON `json:"-"` } // configTuiJSON contains the JSON metadata for the struct [ConfigTui] type configTuiJSON struct { - ScrollSpeed apijson.Field - raw string - ExtraFields map[string]apijson.Field + ScrollSpeed apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *ConfigTui) UnmarshalJSON(data []byte) (err error) { @@ -1772,105 +1772,106 @@ func (r configTuiJSON) RawJSON() string { return r.raw } +// Custom keybind configurations type KeybindsConfig struct { // Next agent - AgentCycle string `json:"agent_cycle,required"` + AgentCycle string `json:"agent_cycle"` // Previous agent - AgentCycleReverse string `json:"agent_cycle_reverse,required"` + AgentCycleReverse string `json:"agent_cycle_reverse"` // List agents - AgentList string `json:"agent_list,required"` + AgentList string `json:"agent_list"` // Exit the application - AppExit string `json:"app_exit,required"` + AppExit string `json:"app_exit"` // Show help dialog - AppHelp string `json:"app_help,required"` + AppHelp string `json:"app_help"` // Open external editor - EditorOpen string `json:"editor_open,required"` + EditorOpen string `json:"editor_open"` // @deprecated Close file - FileClose string `json:"file_close,required"` + FileClose string `json:"file_close"` // @deprecated Split/unified diff - FileDiffToggle string `json:"file_diff_toggle,required"` + FileDiffToggle string `json:"file_diff_toggle"` // @deprecated Currently not available. List files - FileList string `json:"file_list,required"` + FileList string `json:"file_list"` // @deprecated Search file - FileSearch string `json:"file_search,required"` + FileSearch string `json:"file_search"` // Clear input field - InputClear string `json:"input_clear,required"` + InputClear string `json:"input_clear"` // Insert newline in input - InputNewline string `json:"input_newline,required"` + InputNewline string `json:"input_newline"` // Paste from clipboard - InputPaste string `json:"input_paste,required"` + InputPaste string `json:"input_paste"` // Submit input - InputSubmit string `json:"input_submit,required"` + InputSubmit string `json:"input_submit"` // Leader key for keybind combinations - Leader string `json:"leader,required"` + Leader string `json:"leader"` // Copy message - MessagesCopy string `json:"messages_copy,required"` + MessagesCopy string `json:"messages_copy"` // Navigate to first message - MessagesFirst string `json:"messages_first,required"` + MessagesFirst string `json:"messages_first"` // Scroll messages down by half page - MessagesHalfPageDown string `json:"messages_half_page_down,required"` + MessagesHalfPageDown string `json:"messages_half_page_down"` // Scroll messages up by half page - MessagesHalfPageUp string `json:"messages_half_page_up,required"` + MessagesHalfPageUp string `json:"messages_half_page_up"` // Navigate to last message - MessagesLast string `json:"messages_last,required"` + MessagesLast string `json:"messages_last"` // @deprecated Toggle layout - MessagesLayoutToggle string `json:"messages_layout_toggle,required"` + MessagesLayoutToggle string `json:"messages_layout_toggle"` // @deprecated Navigate to next message - MessagesNext string `json:"messages_next,required"` + MessagesNext string `json:"messages_next"` // Scroll messages down by one page - MessagesPageDown string `json:"messages_page_down,required"` + MessagesPageDown string `json:"messages_page_down"` // Scroll messages up by one page - MessagesPageUp string `json:"messages_page_up,required"` + MessagesPageUp string `json:"messages_page_up"` // @deprecated Navigate to previous message - MessagesPrevious string `json:"messages_previous,required"` + MessagesPrevious string `json:"messages_previous"` // Redo message - MessagesRedo string `json:"messages_redo,required"` + MessagesRedo string `json:"messages_redo"` // @deprecated use messages_undo. Revert message - MessagesRevert string `json:"messages_revert,required"` + MessagesRevert string `json:"messages_revert"` // Undo message - MessagesUndo string `json:"messages_undo,required"` + MessagesUndo string `json:"messages_undo"` // Next recent model - ModelCycleRecent string `json:"model_cycle_recent,required"` + ModelCycleRecent string `json:"model_cycle_recent"` // Previous recent model - ModelCycleRecentReverse string `json:"model_cycle_recent_reverse,required"` + ModelCycleRecentReverse string `json:"model_cycle_recent_reverse"` // List available models - ModelList string `json:"model_list,required"` + ModelList string `json:"model_list"` // Create/update AGENTS.md - ProjectInit string `json:"project_init,required"` + ProjectInit string `json:"project_init"` // Cycle to next child session - SessionChildCycle string `json:"session_child_cycle,required"` + SessionChildCycle string `json:"session_child_cycle"` // Cycle to previous child session - SessionChildCycleReverse string `json:"session_child_cycle_reverse,required"` + SessionChildCycleReverse string `json:"session_child_cycle_reverse"` // Compact the session - SessionCompact string `json:"session_compact,required"` + SessionCompact string `json:"session_compact"` // Export session to editor - SessionExport string `json:"session_export,required"` + SessionExport string `json:"session_export"` // Interrupt current session - SessionInterrupt string `json:"session_interrupt,required"` + SessionInterrupt string `json:"session_interrupt"` // List all sessions - SessionList string `json:"session_list,required"` + SessionList string `json:"session_list"` // Create a new session - SessionNew string `json:"session_new,required"` + SessionNew string `json:"session_new"` // Share current session - SessionShare string `json:"session_share,required"` + SessionShare string `json:"session_share"` // Show session timeline - SessionTimeline string `json:"session_timeline,required"` + SessionTimeline string `json:"session_timeline"` // Unshare current session - SessionUnshare string `json:"session_unshare,required"` + SessionUnshare string `json:"session_unshare"` // @deprecated use agent_cycle. Next agent - SwitchAgent string `json:"switch_agent,required"` + SwitchAgent string `json:"switch_agent"` // @deprecated use agent_cycle_reverse. Previous agent - SwitchAgentReverse string `json:"switch_agent_reverse,required"` + SwitchAgentReverse string `json:"switch_agent_reverse"` // @deprecated use agent_cycle. Next mode - SwitchMode string `json:"switch_mode,required"` + SwitchMode string `json:"switch_mode"` // @deprecated use agent_cycle_reverse. Previous mode - SwitchModeReverse string `json:"switch_mode_reverse,required"` + SwitchModeReverse string `json:"switch_mode_reverse"` // List available themes - ThemeList string `json:"theme_list,required"` + ThemeList string `json:"theme_list"` // Toggle thinking blocks - ThinkingBlocks string `json:"thinking_blocks,required"` + ThinkingBlocks string `json:"thinking_blocks"` // Toggle tool details - ToolDetails string `json:"tool_details,required"` + ToolDetails string `json:"tool_details"` JSON keybindsConfigJSON `json:"-"` } diff --git a/packages/sdk/go/event.go b/packages/sdk/go/event.go index 00ba202cc..5d3bffcc2 100644 --- a/packages/sdk/go/event.go +++ b/packages/sdk/go/event.go @@ -57,14 +57,14 @@ type EventListResponse struct { // [EventListResponseEventMessageUpdatedProperties], // [EventListResponseEventMessageRemovedProperties], // [EventListResponseEventMessagePartUpdatedProperties], - // [EventListResponseEventMessagePartRemovedProperties], [Permission], + // [EventListResponseEventMessagePartRemovedProperties], + // [EventListResponseEventSessionCompactedProperties], [Permission], // [EventListResponseEventPermissionRepliedProperties], // [EventListResponseEventFileEditedProperties], + // [EventListResponseEventSessionIdleProperties], // [EventListResponseEventSessionUpdatedProperties], // [EventListResponseEventSessionDeletedProperties], - // [EventListResponseEventSessionIdleProperties], - // [EventListResponseEventSessionErrorProperties], - // [EventListResponseEventSessionCompactedProperties], [interface{}]. + // [EventListResponseEventSessionErrorProperties], [interface{}]. Properties interface{} `json:"properties,required"` Type EventListResponseType `json:"type,required"` JSON eventListResponseJSON `json:"-"` @@ -102,11 +102,11 @@ func (r *EventListResponse) UnmarshalJSON(data []byte) (err error) { // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartRemoved], +// [EventListResponseEventSessionCompacted], // [EventListResponseEventPermissionUpdated], // [EventListResponseEventPermissionReplied], [EventListResponseEventFileEdited], -// [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted], -// [EventListResponseEventSessionIdle], [EventListResponseEventSessionError], -// [EventListResponseEventSessionCompacted], +// [EventListResponseEventSessionIdle], [EventListResponseEventSessionUpdated], +// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionError], // [EventListResponseEventServerConnected]. func (r EventListResponse) AsUnion() EventListResponseUnion { return r.union @@ -117,11 +117,11 @@ func (r EventListResponse) AsUnion() EventListResponseUnion { // [EventListResponseEventMessageUpdated], [EventListResponseEventMessageRemoved], // [EventListResponseEventMessagePartUpdated], // [EventListResponseEventMessagePartRemoved], +// [EventListResponseEventSessionCompacted], // [EventListResponseEventPermissionUpdated], // [EventListResponseEventPermissionReplied], [EventListResponseEventFileEdited], -// [EventListResponseEventSessionUpdated], [EventListResponseEventSessionDeleted], -// [EventListResponseEventSessionIdle], [EventListResponseEventSessionError], -// [EventListResponseEventSessionCompacted] or +// [EventListResponseEventSessionIdle], [EventListResponseEventSessionUpdated], +// [EventListResponseEventSessionDeleted], [EventListResponseEventSessionError] or // [EventListResponseEventServerConnected]. type EventListResponseUnion interface { implementsEventListResponse() @@ -130,81 +130,66 @@ type EventListResponseUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*EventListResponseUnion)(nil)).Elem(), - "type", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventInstallationUpdated{}), - DiscriminatorValue: "installation.updated", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventInstallationUpdated{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventLspClientDiagnostics{}), - DiscriminatorValue: "lsp.client.diagnostics", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventLspClientDiagnostics{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventMessageUpdated{}), - DiscriminatorValue: "message.updated", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventMessageUpdated{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventMessageRemoved{}), - DiscriminatorValue: "message.removed", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventMessageRemoved{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventMessagePartUpdated{}), - DiscriminatorValue: "message.part.updated", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventMessagePartUpdated{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventMessagePartRemoved{}), - DiscriminatorValue: "message.part.removed", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventMessagePartRemoved{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventPermissionUpdated{}), - DiscriminatorValue: "permission.updated", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionCompacted{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventPermissionReplied{}), - DiscriminatorValue: "permission.replied", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventPermissionUpdated{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventFileEdited{}), - DiscriminatorValue: "file.edited", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventPermissionReplied{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}), - DiscriminatorValue: "session.updated", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventFileEdited{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionDeleted{}), - DiscriminatorValue: "session.deleted", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionIdle{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionIdle{}), - DiscriminatorValue: "session.idle", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionUpdated{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionError{}), - DiscriminatorValue: "session.error", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionDeleted{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionCompacted{}), - DiscriminatorValue: "session.compacted", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventServerConnected{}), - DiscriminatorValue: "server.connected", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventServerConnected{}), }, ) } @@ -577,6 +562,66 @@ func (r EventListResponseEventMessagePartRemovedType) IsKnown() bool { return false } +type EventListResponseEventSessionCompacted struct { + Properties EventListResponseEventSessionCompactedProperties `json:"properties,required"` + Type EventListResponseEventSessionCompactedType `json:"type,required"` + JSON eventListResponseEventSessionCompactedJSON `json:"-"` +} + +// eventListResponseEventSessionCompactedJSON contains the JSON metadata for the +// struct [EventListResponseEventSessionCompacted] +type eventListResponseEventSessionCompactedJSON struct { + Properties apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEventSessionCompacted) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEventSessionCompactedJSON) RawJSON() string { + return r.raw +} + +func (r EventListResponseEventSessionCompacted) implementsEventListResponse() {} + +type EventListResponseEventSessionCompactedProperties struct { + SessionID string `json:"sessionID,required"` + JSON eventListResponseEventSessionCompactedPropertiesJSON `json:"-"` +} + +// eventListResponseEventSessionCompactedPropertiesJSON contains the JSON metadata +// for the struct [EventListResponseEventSessionCompactedProperties] +type eventListResponseEventSessionCompactedPropertiesJSON struct { + SessionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEventSessionCompactedProperties) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEventSessionCompactedPropertiesJSON) RawJSON() string { + return r.raw +} + +type EventListResponseEventSessionCompactedType string + +const ( + EventListResponseEventSessionCompactedTypeSessionCompacted EventListResponseEventSessionCompactedType = "session.compacted" +) + +func (r EventListResponseEventSessionCompactedType) IsKnown() bool { + switch r { + case EventListResponseEventSessionCompactedTypeSessionCompacted: + return true + } + return false +} + type EventListResponseEventPermissionUpdated struct { Properties Permission `json:"properties,required"` Type EventListResponseEventPermissionUpdatedType `json:"type,required"` @@ -740,6 +785,66 @@ func (r EventListResponseEventFileEditedType) IsKnown() bool { return false } +type EventListResponseEventSessionIdle struct { + Properties EventListResponseEventSessionIdleProperties `json:"properties,required"` + Type EventListResponseEventSessionIdleType `json:"type,required"` + JSON eventListResponseEventSessionIdleJSON `json:"-"` +} + +// eventListResponseEventSessionIdleJSON contains the JSON metadata for the struct +// [EventListResponseEventSessionIdle] +type eventListResponseEventSessionIdleJSON struct { + Properties apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEventSessionIdle) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEventSessionIdleJSON) RawJSON() string { + return r.raw +} + +func (r EventListResponseEventSessionIdle) implementsEventListResponse() {} + +type EventListResponseEventSessionIdleProperties struct { + SessionID string `json:"sessionID,required"` + JSON eventListResponseEventSessionIdlePropertiesJSON `json:"-"` +} + +// eventListResponseEventSessionIdlePropertiesJSON contains the JSON metadata for +// the struct [EventListResponseEventSessionIdleProperties] +type eventListResponseEventSessionIdlePropertiesJSON struct { + SessionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEventSessionIdleProperties) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEventSessionIdlePropertiesJSON) RawJSON() string { + return r.raw +} + +type EventListResponseEventSessionIdleType string + +const ( + EventListResponseEventSessionIdleTypeSessionIdle EventListResponseEventSessionIdleType = "session.idle" +) + +func (r EventListResponseEventSessionIdleType) IsKnown() bool { + switch r { + case EventListResponseEventSessionIdleTypeSessionIdle: + return true + } + return false +} + type EventListResponseEventSessionUpdated struct { Properties EventListResponseEventSessionUpdatedProperties `json:"properties,required"` Type EventListResponseEventSessionUpdatedType `json:"type,required"` @@ -860,66 +965,6 @@ func (r EventListResponseEventSessionDeletedType) IsKnown() bool { return false } -type EventListResponseEventSessionIdle struct { - Properties EventListResponseEventSessionIdleProperties `json:"properties,required"` - Type EventListResponseEventSessionIdleType `json:"type,required"` - JSON eventListResponseEventSessionIdleJSON `json:"-"` -} - -// eventListResponseEventSessionIdleJSON contains the JSON metadata for the struct -// [EventListResponseEventSessionIdle] -type eventListResponseEventSessionIdleJSON struct { - Properties apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionIdle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionIdleJSON) RawJSON() string { - return r.raw -} - -func (r EventListResponseEventSessionIdle) implementsEventListResponse() {} - -type EventListResponseEventSessionIdleProperties struct { - SessionID string `json:"sessionID,required"` - JSON eventListResponseEventSessionIdlePropertiesJSON `json:"-"` -} - -// eventListResponseEventSessionIdlePropertiesJSON contains the JSON metadata for -// the struct [EventListResponseEventSessionIdleProperties] -type eventListResponseEventSessionIdlePropertiesJSON struct { - SessionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionIdleProperties) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionIdlePropertiesJSON) RawJSON() string { - return r.raw -} - -type EventListResponseEventSessionIdleType string - -const ( - EventListResponseEventSessionIdleTypeSessionIdle EventListResponseEventSessionIdleType = "session.idle" -) - -func (r EventListResponseEventSessionIdleType) IsKnown() bool { - switch r { - case EventListResponseEventSessionIdleTypeSessionIdle: - return true - } - return false -} - type EventListResponseEventSessionError struct { Properties EventListResponseEventSessionErrorProperties `json:"properties,required"` Type EventListResponseEventSessionErrorType `json:"type,required"` @@ -970,7 +1015,7 @@ func (r eventListResponseEventSessionErrorPropertiesJSON) RawJSON() string { type EventListResponseEventSessionErrorPropertiesError struct { // This field can have the runtime type of [shared.ProviderAuthErrorData], - // [shared.UnknownErrorData], [interface{}]. + // [shared.UnknownErrorData], [interface{}], [shared.MessageAbortedErrorData]. Data interface{} `json:"data,required"` Name EventListResponseEventSessionErrorPropertiesErrorName `json:"name,required"` JSON eventListResponseEventSessionErrorPropertiesErrorJSON `json:"-"` @@ -1020,26 +1065,22 @@ type EventListResponseEventSessionErrorPropertiesErrorUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*EventListResponseEventSessionErrorPropertiesErrorUnion)(nil)).Elem(), - "name", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.ProviderAuthError{}), - DiscriminatorValue: "ProviderAuthError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.ProviderAuthError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.UnknownError{}), - DiscriminatorValue: "UnknownError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.UnknownError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError{}), - DiscriminatorValue: "MessageOutputLengthError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(EventListResponseEventSessionErrorPropertiesErrorMessageOutputLengthError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.MessageAbortedError{}), - DiscriminatorValue: "MessageAbortedError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.MessageAbortedError{}), }, ) } @@ -1116,66 +1157,6 @@ func (r EventListResponseEventSessionErrorType) IsKnown() bool { return false } -type EventListResponseEventSessionCompacted struct { - Properties EventListResponseEventSessionCompactedProperties `json:"properties,required"` - Type EventListResponseEventSessionCompactedType `json:"type,required"` - JSON eventListResponseEventSessionCompactedJSON `json:"-"` -} - -// eventListResponseEventSessionCompactedJSON contains the JSON metadata for the -// struct [EventListResponseEventSessionCompacted] -type eventListResponseEventSessionCompactedJSON struct { - Properties apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionCompacted) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionCompactedJSON) RawJSON() string { - return r.raw -} - -func (r EventListResponseEventSessionCompacted) implementsEventListResponse() {} - -type EventListResponseEventSessionCompactedProperties struct { - SessionID string `json:"sessionID,required"` - JSON eventListResponseEventSessionCompactedPropertiesJSON `json:"-"` -} - -// eventListResponseEventSessionCompactedPropertiesJSON contains the JSON metadata -// for the struct [EventListResponseEventSessionCompactedProperties] -type eventListResponseEventSessionCompactedPropertiesJSON struct { - SessionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EventListResponseEventSessionCompactedProperties) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r eventListResponseEventSessionCompactedPropertiesJSON) RawJSON() string { - return r.raw -} - -type EventListResponseEventSessionCompactedType string - -const ( - EventListResponseEventSessionCompactedTypeSessionCompacted EventListResponseEventSessionCompactedType = "session.compacted" -) - -func (r EventListResponseEventSessionCompactedType) IsKnown() bool { - switch r { - case EventListResponseEventSessionCompactedTypeSessionCompacted: - return true - } - return false -} - type EventListResponseEventServerConnected struct { Properties interface{} `json:"properties,required"` Type EventListResponseEventServerConnectedType `json:"type,required"` @@ -1224,20 +1205,20 @@ const ( EventListResponseTypeMessageRemoved EventListResponseType = "message.removed" EventListResponseTypeMessagePartUpdated EventListResponseType = "message.part.updated" EventListResponseTypeMessagePartRemoved EventListResponseType = "message.part.removed" + EventListResponseTypeSessionCompacted EventListResponseType = "session.compacted" EventListResponseTypePermissionUpdated EventListResponseType = "permission.updated" EventListResponseTypePermissionReplied EventListResponseType = "permission.replied" EventListResponseTypeFileEdited EventListResponseType = "file.edited" + EventListResponseTypeSessionIdle EventListResponseType = "session.idle" EventListResponseTypeSessionUpdated EventListResponseType = "session.updated" EventListResponseTypeSessionDeleted EventListResponseType = "session.deleted" - EventListResponseTypeSessionIdle EventListResponseType = "session.idle" EventListResponseTypeSessionError EventListResponseType = "session.error" - EventListResponseTypeSessionCompacted EventListResponseType = "session.compacted" EventListResponseTypeServerConnected EventListResponseType = "server.connected" ) func (r EventListResponseType) IsKnown() bool { switch r { - case EventListResponseTypeInstallationUpdated, EventListResponseTypeLspClientDiagnostics, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypePermissionUpdated, EventListResponseTypePermissionReplied, EventListResponseTypeFileEdited, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionIdle, EventListResponseTypeSessionError, EventListResponseTypeSessionCompacted, EventListResponseTypeServerConnected: + case EventListResponseTypeInstallationUpdated, EventListResponseTypeLspClientDiagnostics, EventListResponseTypeMessageUpdated, EventListResponseTypeMessageRemoved, EventListResponseTypeMessagePartUpdated, EventListResponseTypeMessagePartRemoved, EventListResponseTypeSessionCompacted, EventListResponseTypePermissionUpdated, EventListResponseTypePermissionReplied, EventListResponseTypeFileEdited, EventListResponseTypeSessionIdle, EventListResponseTypeSessionUpdated, EventListResponseTypeSessionDeleted, EventListResponseTypeSessionError, EventListResponseTypeServerConnected: return true } return false diff --git a/packages/sdk/go/internal/version.go b/packages/sdk/go/internal/version.go index 0e818c5b2..871f0965d 100644 --- a/packages/sdk/go/internal/version.go +++ b/packages/sdk/go/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.9.0" // x-release-please-version +const PackageVersion = "0.13.0" // x-release-please-version diff --git a/packages/sdk/go/session.go b/packages/sdk/go/session.go index 6696e0faf..260724e9a 100644 --- a/packages/sdk/go/session.go +++ b/packages/sdk/go/session.go @@ -518,7 +518,7 @@ func (r assistantMessageTokensCacheJSON) RawJSON() string { type AssistantMessageError struct { // This field can have the runtime type of [shared.ProviderAuthErrorData], - // [shared.UnknownErrorData], [interface{}]. + // [shared.UnknownErrorData], [interface{}], [shared.MessageAbortedErrorData]. Data interface{} `json:"data,required"` Name AssistantMessageErrorName `json:"name,required"` JSON assistantMessageErrorJSON `json:"-"` @@ -566,26 +566,22 @@ type AssistantMessageErrorUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*AssistantMessageErrorUnion)(nil)).Elem(), - "name", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.ProviderAuthError{}), - DiscriminatorValue: "ProviderAuthError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.ProviderAuthError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.UnknownError{}), - DiscriminatorValue: "UnknownError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.UnknownError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}), - DiscriminatorValue: "MessageOutputLengthError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AssistantMessageErrorMessageOutputLengthError{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(shared.MessageAbortedError{}), - DiscriminatorValue: "MessageAbortedError", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(shared.MessageAbortedError{}), }, ) } @@ -778,16 +774,14 @@ type FilePartSourceUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*FilePartSourceUnion)(nil)).Elem(), - "type", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FileSource{}), - DiscriminatorValue: "file", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(FileSource{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SymbolSource{}), - DiscriminatorValue: "symbol", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SymbolSource{}), }, ) } @@ -986,16 +980,14 @@ type MessageUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*MessageUnion)(nil)).Elem(), - "role", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserMessage{}), - DiscriminatorValue: "user", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(UserMessage{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AssistantMessage{}), - DiscriminatorValue: "assistant", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AssistantMessage{}), }, ) } @@ -1107,51 +1099,42 @@ type PartUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*PartUnion)(nil)).Elem(), - "type", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(TextPart{}), - DiscriminatorValue: "text", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TextPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ReasoningPart{}), - DiscriminatorValue: "reasoning", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ReasoningPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FilePart{}), - DiscriminatorValue: "file", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(FilePart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolPart{}), - DiscriminatorValue: "tool", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(StepStartPart{}), - DiscriminatorValue: "step-start", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(StepStartPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(StepFinishPart{}), - DiscriminatorValue: "step-finish", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(StepFinishPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SnapshotPart{}), - DiscriminatorValue: "snapshot", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SnapshotPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PartPatchPart{}), - DiscriminatorValue: "patch", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PartPatchPart{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AgentPart{}), - DiscriminatorValue: "agent", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AgentPart{}), }, ) } @@ -1941,26 +1924,22 @@ type ToolPartStateUnion interface { func init() { apijson.RegisterUnion( reflect.TypeOf((*ToolPartStateUnion)(nil)).Elem(), - "status", + "", apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolStatePending{}), - DiscriminatorValue: "pending", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolStatePending{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolStateRunning{}), - DiscriminatorValue: "running", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolStateRunning{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolStateCompleted{}), - DiscriminatorValue: "completed", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolStateCompleted{}), }, apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ToolStateError{}), - DiscriminatorValue: "error", + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ToolStateError{}), }, ) } @@ -2044,9 +2023,10 @@ func (r ToolStateCompletedStatus) IsKnown() bool { } type ToolStateCompletedTime struct { - End float64 `json:"end,required"` - Start float64 `json:"start,required"` - JSON toolStateCompletedTimeJSON `json:"-"` + End float64 `json:"end,required"` + Start float64 `json:"start,required"` + Compacted float64 `json:"compacted"` + JSON toolStateCompletedTimeJSON `json:"-"` } // toolStateCompletedTimeJSON contains the JSON metadata for the struct @@ -2054,6 +2034,7 @@ type ToolStateCompletedTime struct { type toolStateCompletedTimeJSON struct { End apijson.Field Start apijson.Field + Compacted apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -2171,9 +2152,9 @@ func (r ToolStatePendingStatus) IsKnown() bool { } type ToolStateRunning struct { + Input interface{} `json:"input,required"` Status ToolStateRunningStatus `json:"status,required"` Time ToolStateRunningTime `json:"time,required"` - Input interface{} `json:"input"` Metadata map[string]interface{} `json:"metadata"` Title string `json:"title"` JSON toolStateRunningJSON `json:"-"` @@ -2182,9 +2163,9 @@ type ToolStateRunning struct { // toolStateRunningJSON contains the JSON metadata for the struct // [ToolStateRunning] type toolStateRunningJSON struct { + Input apijson.Field Status apijson.Field Time apijson.Field - Input apijson.Field Metadata apijson.Field Title apijson.Field raw string diff --git a/packages/sdk/go/session_test.go b/packages/sdk/go/session_test.go index f4cbc04b1..61404d8b5 100644 --- a/packages/sdk/go/session_test.go +++ b/packages/sdk/go/session_test.go @@ -196,7 +196,7 @@ func TestSessionCommandWithOptionalParams(t *testing.T) { Command: opencode.F("command"), Directory: opencode.F("directory"), Agent: opencode.F("agent"), - MessageID: opencode.F("msg"), + MessageID: opencode.F("msgJ!"), Model: opencode.F("model"), }, ) @@ -353,7 +353,7 @@ func TestSessionPromptWithOptionalParams(t *testing.T) { }}), Directory: opencode.F("directory"), Agent: opencode.F("agent"), - MessageID: opencode.F("msg"), + MessageID: opencode.F("msgJ!"), Model: opencode.F(opencode.SessionPromptParamsModel{ ModelID: opencode.F("modelID"), ProviderID: opencode.F("providerID"), @@ -389,9 +389,9 @@ func TestSessionRevertWithOptionalParams(t *testing.T) { context.TODO(), "id", opencode.SessionRevertParams{ - MessageID: opencode.F("msg"), + MessageID: opencode.F("msgJ!"), Directory: opencode.F("directory"), - PartID: opencode.F("prt"), + PartID: opencode.F("prtJ!"), }, ) if err != nil { diff --git a/packages/sdk/go/shared/shared.go b/packages/sdk/go/shared/shared.go index 58baf3d9c..f2c6db0d1 100644 --- a/packages/sdk/go/shared/shared.go +++ b/packages/sdk/go/shared/shared.go @@ -7,7 +7,7 @@ import ( ) type MessageAbortedError struct { - Data interface{} `json:"data,required"` + Data MessageAbortedErrorData `json:"data,required"` Name MessageAbortedErrorName `json:"name,required"` JSON messageAbortedErrorJSON `json:"-"` } @@ -33,6 +33,27 @@ func (r MessageAbortedError) ImplementsEventListResponseEventSessionErrorPropert func (r MessageAbortedError) ImplementsAssistantMessageError() {} +type MessageAbortedErrorData struct { + Message string `json:"message,required"` + JSON messageAbortedErrorDataJSON `json:"-"` +} + +// messageAbortedErrorDataJSON contains the JSON metadata for the struct +// [MessageAbortedErrorData] +type messageAbortedErrorDataJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MessageAbortedErrorData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r messageAbortedErrorDataJSON) RawJSON() string { + return r.raw +} + type MessageAbortedErrorName string const ( |
