The open source coding agent.
TypeScript
fix(js-sdk): fix types in session.chat (#1925)
zWingbca523eb631e
diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.tsindex e661471ae02..69805fbeea6 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.ymlindex 09dd20f426f..5f222f03fb4 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: c1bbb3ebd807656bd9f31a618077e76bconfig_hash: eab3723c4c2232a6ba1821151259d6dadiff --git a/packages/sdk/go/api.md b/packages/sdk/go/api.mdindex cf548532893..5accfcb5014 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.goindex e83bd57efe4..aae6e5e2b38 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 settingsTui ConfigTui `json:"tui"`// Custom username to display in conversations instead of system username@@ -110,6 +111,7 @@ type configJSON struct {SmallModel apijson.FieldSnapshot apijson.FieldTheme apijson.Field+ Tools apijson.FieldTui apijson.FieldUsername apijson.Fieldraw string@@ -1760,6 +1762,8 @@ type KeybindsConfig struct {SessionNew string `json:"session_new,required"`// Share current sessionSessionShare string `json:"session_share,required"`+ // Show session timeline+ SessionTimeline string `json:"session_timeline,required"`// Unshare current sessionSessionUnshare string `json:"session_unshare,required"`// @deprecated use agent_cycle. Next agent@@ -1821,6 +1825,7 @@ type keybindsConfigJSON struct {SessionList apijson.FieldSessionNew apijson.FieldSessionShare apijson.Field+ SessionTimeline apijson.FieldSessionUnshare apijson.FieldSwitchAgent apijson.FieldSwitchAgentReverse apijson.Fielddiff --git a/packages/sdk/go/session.go b/packages/sdk/go/session.goindex 9cc0492cf76..a4ad09e254a 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.tsindex f7cb3c1a898..9919dc4197c 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]