diff options
| author | zWing <[email protected]> | 2025-08-21 23:44:20 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-21 10:44:20 -0500 |
| commit | bca523eb631e46562f169b5a2db7f29e9f5362a2 (patch) | |
| tree | 349162a783fed1f199bd5668f8b6b2b02f69e57b | |
| parent | 2ff4cd2c2b30f6702548cb66950a643b5a458572 (diff) | |
| download | opencode-bca523eb631e46562f169b5a2db7f29e9f5362a2.tar.gz opencode-bca523eb631e46562f169b5a2db7f29e9f5362a2.zip | |
fix(js-sdk): fix types in session.chat (#1925)
Co-authored-by: zwingzheng <[email protected]>
Co-authored-by: rekram1-node <[email protected]>
| -rw-r--r-- | packages/opencode/src/server/server.ts | 5 | ||||
| -rw-r--r-- | packages/sdk/go/.stats.yml | 4 | ||||
| -rw-r--r-- | packages/sdk/go/api.md | 3 | ||||
| -rw-r--r-- | packages/sdk/go/config.go | 7 | ||||
| -rw-r--r-- | packages/sdk/go/session.go | 25 | ||||
| -rw-r--r-- | packages/sdk/js/src/gen/types.gen.ts | 5 |
6 files changed, 42 insertions, 7 deletions
diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index e661471ae..69805fbee 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -611,7 +611,10 @@ export namespace Server { description: "Created message", content: { "application/json": { - schema: resolver(MessageV2.Assistant), + schema: resolver(z.object({ + info: MessageV2.Assistant, + parts: MessageV2.Part.array(), + })), }, }, }, diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml index 09dd20f42..5f222f03f 100644 --- a/packages/sdk/go/.stats.yml +++ b/packages/sdk/go/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 39 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-e4b6496e5f2c68fa8b3ea1b88e40041eaf5ce2652001344df80bf130675d1766.yml -openapi_spec_hash: df474311dc9e4a89cd483bd8b8d971d8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-be3e40e0bf7dde2bb15ff82d5d104418fb47fe335808a1aa6468b0be2210a88f.yml +openapi_spec_hash: c1bbb3ebd807656bd9f31a618077e76b config_hash: eab3723c4c2232a6ba1821151259d6da diff --git a/packages/sdk/go/api.md b/packages/sdk/go/api.md index cf5485328..5accfcb50 100644 --- a/packages/sdk/go/api.md +++ b/packages/sdk/go/api.md @@ -105,6 +105,7 @@ Response Types: - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#ToolStatePending">ToolStatePending</a> - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#ToolStateRunning">ToolStateRunning</a> - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#UserMessage">UserMessage</a> +- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionChatResponse">SessionChatResponse</a> - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionMessageResponse">SessionMessageResponse</a> - <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionMessagesResponse">SessionMessagesResponse</a> @@ -115,7 +116,7 @@ Methods: - <code title="get /session">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="delete /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="post /session/{id}/abort">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Abort">Abort</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> -- <code title="post /session/{id}/message">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Chat">Chat</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionChatParams">SessionChatParams</a>) (<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#AssistantMessage">AssistantMessage</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> +- <code title="post /session/{id}/message">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Chat">Chat</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionChatParams">SessionChatParams</a>) (<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionChatResponse">SessionChatResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /session/{id}/children">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Children">Children</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) ([]<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="get /session/{id}">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Session">Session</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> - <code title="post /session/{id}/init">client.Session.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionService.Init">Init</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, id <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SessionInitParams">SessionInitParams</a>) (<a href="https://pkg.go.dev/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code> diff --git a/packages/sdk/go/config.go b/packages/sdk/go/config.go index e83bd57ef..aae6e5e2b 100644 --- a/packages/sdk/go/config.go +++ b/packages/sdk/go/config.go @@ -79,7 +79,8 @@ type Config struct { SmallModel string `json:"small_model"` Snapshot bool `json:"snapshot"` // Theme name to use for the interface - Theme string `json:"theme"` + Theme string `json:"theme"` + Tools map[string]bool `json:"tools"` // TUI specific settings Tui ConfigTui `json:"tui"` // Custom username to display in conversations instead of system username @@ -110,6 +111,7 @@ type configJSON struct { SmallModel apijson.Field Snapshot apijson.Field Theme apijson.Field + Tools apijson.Field Tui apijson.Field Username apijson.Field raw string @@ -1760,6 +1762,8 @@ type KeybindsConfig struct { SessionNew string `json:"session_new,required"` // Share current session SessionShare string `json:"session_share,required"` + // Show session timeline + SessionTimeline string `json:"session_timeline,required"` // Unshare current session SessionUnshare string `json:"session_unshare,required"` // @deprecated use agent_cycle. Next agent @@ -1821,6 +1825,7 @@ type keybindsConfigJSON struct { SessionList apijson.Field SessionNew apijson.Field SessionShare apijson.Field + SessionTimeline apijson.Field SessionUnshare apijson.Field SwitchAgent apijson.Field SwitchAgentReverse apijson.Field diff --git a/packages/sdk/go/session.go b/packages/sdk/go/session.go index 9cc0492cf..a4ad09e25 100644 --- a/packages/sdk/go/session.go +++ b/packages/sdk/go/session.go @@ -91,7 +91,7 @@ func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.Re } // Create and send a new message to a session -func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *AssistantMessage, err error) { +func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatParams, opts ...option.RequestOption) (res *SessionChatResponse, err error) { opts = append(r.Options[:], opts...) if id == "" { err = errors.New("missing required id parameter") @@ -2278,6 +2278,29 @@ func (r userMessageTimeJSON) RawJSON() string { return r.raw } +type SessionChatResponse struct { + Info AssistantMessage `json:"info,required"` + Parts []Part `json:"parts,required"` + JSON sessionChatResponseJSON `json:"-"` +} + +// sessionChatResponseJSON contains the JSON metadata for the struct +// [SessionChatResponse] +type sessionChatResponseJSON struct { + Info apijson.Field + Parts apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SessionChatResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sessionChatResponseJSON) RawJSON() string { + return r.raw +} + type SessionMessageResponse struct { Info Message `json:"info,required"` Parts []Part `json:"parts,required"` diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index f7cb3c1a8..9919dc419 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -1527,7 +1527,10 @@ export type SessionChatResponses = { /** * Created message */ - 200: AssistantMessage + 200: { + info: AssistantMessage + parts: Array<Part> + } } export type SessionChatResponse = SessionChatResponses[keyof SessionChatResponses] |
