tui.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
  2. package opencode
  3. import (
  4. "context"
  5. "net/http"
  6. "github.com/sst/opencode-sdk-go/internal/apijson"
  7. "github.com/sst/opencode-sdk-go/internal/param"
  8. "github.com/sst/opencode-sdk-go/internal/requestconfig"
  9. "github.com/sst/opencode-sdk-go/option"
  10. )
  11. // TuiService contains methods and other services that help with interacting with
  12. // the opencode API.
  13. //
  14. // Note, unlike clients, this service does not read variables from the environment
  15. // automatically. You should not instantiate this service directly, and instead use
  16. // the [NewTuiService] method instead.
  17. type TuiService struct {
  18. Options []option.RequestOption
  19. }
  20. // NewTuiService generates a new service that applies the given options to each
  21. // request. These options are applied after the parent client's options (if there
  22. // is one), and before any request-specific options.
  23. func NewTuiService(opts ...option.RequestOption) (r *TuiService) {
  24. r = &TuiService{}
  25. r.Options = opts
  26. return
  27. }
  28. // Append prompt to the TUI
  29. func (r *TuiService) AppendPrompt(ctx context.Context, body TuiAppendPromptParams, opts ...option.RequestOption) (res *bool, err error) {
  30. opts = append(r.Options[:], opts...)
  31. path := "tui/append-prompt"
  32. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
  33. return
  34. }
  35. // Open the help dialog
  36. func (r *TuiService) OpenHelp(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
  37. opts = append(r.Options[:], opts...)
  38. path := "tui/open-help"
  39. err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
  40. return
  41. }
  42. type TuiAppendPromptParams struct {
  43. Text param.Field[string] `json:"text,required"`
  44. }
  45. func (r TuiAppendPromptParams) MarshalJSON() (data []byte, err error) {
  46. return apijson.MarshalRoot(r)
  47. }