mirror of
https://github.com/sst/opencode.git
synced 2025-08-23 06:24:08 +00:00
147 lines
5 KiB
Go
147 lines
5 KiB
Go
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
package opencode
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/sst/opencode-sdk-go/internal/apijson"
|
|
"github.com/sst/opencode-sdk-go/internal/param"
|
|
"github.com/sst/opencode-sdk-go/internal/requestconfig"
|
|
"github.com/sst/opencode-sdk-go/option"
|
|
)
|
|
|
|
// TuiService contains methods and other services that help with interacting with
|
|
// the opencode API.
|
|
//
|
|
// Note, unlike clients, this service does not read variables from the environment
|
|
// automatically. You should not instantiate this service directly, and instead use
|
|
// the [NewTuiService] method instead.
|
|
type TuiService struct {
|
|
Options []option.RequestOption
|
|
}
|
|
|
|
// NewTuiService generates a new service that applies the given options to each
|
|
// request. These options are applied after the parent client's options (if there
|
|
// is one), and before any request-specific options.
|
|
func NewTuiService(opts ...option.RequestOption) (r *TuiService) {
|
|
r = &TuiService{}
|
|
r.Options = opts
|
|
return
|
|
}
|
|
|
|
// Append prompt to the TUI
|
|
func (r *TuiService) AppendPrompt(ctx context.Context, body TuiAppendPromptParams, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/append-prompt"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Clear the prompt
|
|
func (r *TuiService) ClearPrompt(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/clear-prompt"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Execute a TUI command (e.g. agent_cycle)
|
|
func (r *TuiService) ExecuteCommand(ctx context.Context, body TuiExecuteCommandParams, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/execute-command"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Open the help dialog
|
|
func (r *TuiService) OpenHelp(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/open-help"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Open the model dialog
|
|
func (r *TuiService) OpenModels(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/open-models"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Open the session dialog
|
|
func (r *TuiService) OpenSessions(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/open-sessions"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return
|
|
}
|
|
|
|
// Open the theme dialog
|
|
func (r *TuiService) OpenThemes(ctx context.Context, opts ...option.RequestOption) (res *bool, err error) {
|
|
opts = append(r.Options[:], opts...)
|
|
path := "tui/open-themes"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
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...)
|
|
path := "tui/submit-prompt"
|
|
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &res, opts...)
|
|
return
|
|
}
|
|
|
|
type TuiAppendPromptParams struct {
|
|
Text param.Field[string] `json:"text,required"`
|
|
}
|
|
|
|
func (r TuiAppendPromptParams) MarshalJSON() (data []byte, err error) {
|
|
return apijson.MarshalRoot(r)
|
|
}
|
|
|
|
type TuiExecuteCommandParams struct {
|
|
Command param.Field[string] `json:"command,required"`
|
|
}
|
|
|
|
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
|
|
}
|