summaryrefslogtreecommitdiffhomepage
path: root/packages/sdk/go
diff options
context:
space:
mode:
authoradamdotdevin <[email protected]>2025-08-15 08:39:58 -0500
committeradamdotdevin <[email protected]>2025-08-15 08:39:58 -0500
commit9609c1803e68ecd753572972cb2cd531b48f1438 (patch)
tree89de4df40402bf1021b47fc52b6a4b00d6315c1b /packages/sdk/go
parent6e0e87fb2ad5cc440cc5455c4e43cafc9d07aff0 (diff)
downloadopencode-9609c1803e68ecd753572972cb2cd531b48f1438.tar.gz
opencode-9609c1803e68ecd753572972cb2cd531b48f1438.zip
feat: /tui/show-toast api
Diffstat (limited to 'packages/sdk/go')
-rw-r--r--packages/sdk/go/.stats.yml8
-rw-r--r--packages/sdk/go/api.md1
-rw-r--r--packages/sdk/go/tui.go35
-rw-r--r--packages/sdk/go/tui_test.go26
4 files changed, 66 insertions, 4 deletions
diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml
index e3713a1ca..6a6c7c1fe 100644
--- a/packages/sdk/go/.stats.yml
+++ b/packages/sdk/go/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 36
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-d0eaf92deaa53a25bbbc3181540ad73ed5a4aec6381ac08d8122e24318e5e455.yml
-openapi_spec_hash: 22196d859c0711e564b9538d988abda6
-config_hash: 8d85a768523cff92b85ef06c443d49fa
+configured_endpoints: 37
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-e438f89b86b573c957866c9b057efacc912e3946be03390e4027e8dfab5b83ba.yml
+openapi_spec_hash: 4e9d257b86172e266dc9d72fb04548bc
+config_hash: a78225c7474eb9ab8745e72a0cfe6f96
diff --git a/packages/sdk/go/api.md b/packages/sdk/go/api.md
index 79a67e42d..f48d06870 100644
--- a/packages/sdk/go/api.md
+++ b/packages/sdk/go/api.md
@@ -147,4 +147,5 @@ Methods:
- <code title="post /tui/open-models">client.Tui.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TuiService.OpenModels">OpenModels</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/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /tui/open-sessions">client.Tui.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TuiService.OpenSessions">OpenSessions</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/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /tui/open-themes">client.Tui.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TuiService.OpenThemes">OpenThemes</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/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
+- <code title="post /tui/show-toast">client.Tui.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TuiService.ShowToast">ShowToast</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</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#TuiShowToastParams">TuiShowToastParams</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 /tui/submit-prompt">client.Tui.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TuiService.SubmitPrompt">SubmitPrompt</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/builtin#bool">bool</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
diff --git a/packages/sdk/go/tui.go b/packages/sdk/go/tui.go
index 6f36ce543..ab5ed6403 100644
--- a/packages/sdk/go/tui.go
+++ b/packages/sdk/go/tui.go
@@ -87,6 +87,14 @@ func (r *TuiService) OpenThemes(ctx context.Context, opts ...option.RequestOptio
return
}
+// Show a toast notification in the TUI
+func (r *TuiService) ShowToast(ctx context.Context, body TuiShowToastParams, opts ...option.RequestOption) (res *bool, err error) {
+ opts = append(r.Options[:], opts...)
+ path := "tui/show-toast"
+ err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
+ return
+}
+
// Submit the prompt
func (r *TuiService) SubmitPrompt(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
opts = append(r.Options[:], opts...)
@@ -110,3 +118,30 @@ type TuiExecuteCommandParams struct {
func (r TuiExecuteCommandParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
+
+type TuiShowToastParams struct {
+ Message param.Field[string] `json:"message,required"`
+ Variant param.Field[TuiShowToastParamsVariant] `json:"variant,required"`
+ Title param.Field[string] `json:"title"`
+}
+
+func (r TuiShowToastParams) MarshalJSON() (data []byte, err error) {
+ return apijson.MarshalRoot(r)
+}
+
+type TuiShowToastParamsVariant string
+
+const (
+ TuiShowToastParamsVariantInfo TuiShowToastParamsVariant = "info"
+ TuiShowToastParamsVariantSuccess TuiShowToastParamsVariant = "success"
+ TuiShowToastParamsVariantWarning TuiShowToastParamsVariant = "warning"
+ TuiShowToastParamsVariantError TuiShowToastParamsVariant = "error"
+)
+
+func (r TuiShowToastParamsVariant) IsKnown() bool {
+ switch r {
+ case TuiShowToastParamsVariantInfo, TuiShowToastParamsVariantSuccess, TuiShowToastParamsVariantWarning, TuiShowToastParamsVariantError:
+ return true
+ }
+ return false
+}
diff --git a/packages/sdk/go/tui_test.go b/packages/sdk/go/tui_test.go
index f3260aafd..cb482226c 100644
--- a/packages/sdk/go/tui_test.go
+++ b/packages/sdk/go/tui_test.go
@@ -171,6 +171,32 @@ func TestTuiOpenThemes(t *testing.T) {
}
}
+func TestTuiShowToastWithOptionalParams(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.Tui.ShowToast(context.TODO(), opencode.TuiShowToastParams{
+ Message: opencode.F("message"),
+ Variant: opencode.F(opencode.TuiShowToastParamsVariantInfo),
+ Title: opencode.F("title"),
+ })
+ 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 TestTuiSubmitPrompt(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"