mirror of
https://github.com/anomalyco/opencode-sdk-go.git
synced 2026-04-28 04:29:49 +00:00
fix: use slices.Concat instead of sometimes modifying r.Options
This commit is contained in:
parent
355379d50e
commit
e5e2ea9897
13 changed files with 57 additions and 44 deletions
3
agent.go
3
agent.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewAgentService(opts ...option.RequestOption) (r *AgentService) {
|
|||
|
||||
// List all agents
|
||||
func (r *AgentService) List(ctx context.Context, query AgentListParams, opts ...option.RequestOption) (res *[]Agent, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "agent"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
5
app.go
5
app.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewAppService(opts ...option.RequestOption) (r *AppService) {
|
|||
|
||||
// Write a log entry to the server logs
|
||||
func (r *AppService) Log(ctx context.Context, params AppLogParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "log"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
|
||||
return
|
||||
|
|
@ -43,7 +44,7 @@ func (r *AppService) Log(ctx context.Context, params AppLogParams, opts ...optio
|
|||
|
||||
// List all providers
|
||||
func (r *AppService) Providers(ctx context.Context, query AppProvidersParams, opts ...option.RequestOption) (res *AppProvidersResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "config/providers"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/requestconfig"
|
||||
"github.com/sst/opencode-sdk-go/option"
|
||||
|
|
@ -95,7 +96,7 @@ func NewClient(opts ...option.RequestOption) (r *Client) {
|
|||
// For even greater flexibility, see [option.WithResponseInto] and
|
||||
// [option.WithResponseBodyInto].
|
||||
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error {
|
||||
opts = append(r.Options, opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
return requestconfig.ExecuteNewRequest(ctx, method, path, params, res, opts...)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewCommandService(opts ...option.RequestOption) (r *CommandService) {
|
|||
|
||||
// List all commands
|
||||
func (r *CommandService) List(ctx context.Context, query CommandListParams, opts ...option.RequestOption) (res *[]Command, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "command"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -38,7 +39,7 @@ func NewConfigService(opts ...option.RequestOption) (r *ConfigService) {
|
|||
|
||||
// Get config info
|
||||
func (r *ConfigService) Get(ctx context.Context, query ConfigGetParams, opts ...option.RequestOption) (res *Config, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "config"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
3
event.go
3
event.go
|
|
@ -7,6 +7,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -43,7 +44,7 @@ func (r *EventService) ListStreaming(ctx context.Context, query EventListParams,
|
|||
raw *http.Response
|
||||
err error
|
||||
)
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
opts = append([]option.RequestOption{option.WithHeader("Accept", "text/event-stream")}, opts...)
|
||||
path := "event"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &raw, opts...)
|
||||
|
|
|
|||
7
file.go
7
file.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewFileService(opts ...option.RequestOption) (r *FileService) {
|
|||
|
||||
// List files and directories
|
||||
func (r *FileService) List(ctx context.Context, query FileListParams, opts ...option.RequestOption) (res *[]FileNode, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "file"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -43,7 +44,7 @@ func (r *FileService) List(ctx context.Context, query FileListParams, opts ...op
|
|||
|
||||
// Read a file
|
||||
func (r *FileService) Read(ctx context.Context, query FileReadParams, opts ...option.RequestOption) (res *FileReadResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "file/content"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -51,7 +52,7 @@ func (r *FileService) Read(ctx context.Context, query FileReadParams, opts ...op
|
|||
|
||||
// Get file status
|
||||
func (r *FileService) Status(ctx context.Context, query FileStatusParams, opts ...option.RequestOption) (res *[]File, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "file/status"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
7
find.go
7
find.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewFindService(opts ...option.RequestOption) (r *FindService) {
|
|||
|
||||
// Find files
|
||||
func (r *FindService) Files(ctx context.Context, query FindFilesParams, opts ...option.RequestOption) (res *[]string, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "find/file"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -43,7 +44,7 @@ func (r *FindService) Files(ctx context.Context, query FindFilesParams, opts ...
|
|||
|
||||
// Find workspace symbols
|
||||
func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts ...option.RequestOption) (res *[]Symbol, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "find/symbol"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -51,7 +52,7 @@ func (r *FindService) Symbols(ctx context.Context, query FindSymbolsParams, opts
|
|||
|
||||
// Find text in files
|
||||
func (r *FindService) Text(ctx context.Context, query FindTextParams, opts ...option.RequestOption) (res *[]FindTextResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "find"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
3
path.go
3
path.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewPathService(opts ...option.RequestOption) (r *PathService) {
|
|||
|
||||
// Get the current path
|
||||
func (r *PathService) Get(ctx context.Context, query PathGetParams, opts ...option.RequestOption) (res *Path, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "path"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewProjectService(opts ...option.RequestOption) (r *ProjectService) {
|
|||
|
||||
// List all projects
|
||||
func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *[]Project, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "project"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -43,7 +44,7 @@ func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts
|
|||
|
||||
// Get the current project
|
||||
func (r *ProjectService) Current(ctx context.Context, query ProjectCurrentParams, opts ...option.RequestOption) (res *Project, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "project/current"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
37
session.go
37
session.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -42,7 +43,7 @@ func NewSessionService(opts ...option.RequestOption) (r *SessionService) {
|
|||
|
||||
// Create a new session
|
||||
func (r *SessionService) New(ctx context.Context, params SessionNewParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "session"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
|
||||
return
|
||||
|
|
@ -50,7 +51,7 @@ func (r *SessionService) New(ctx context.Context, params SessionNewParams, opts
|
|||
|
||||
// Update session properties
|
||||
func (r *SessionService) Update(ctx context.Context, id string, params SessionUpdateParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -62,7 +63,7 @@ func (r *SessionService) Update(ctx context.Context, id string, params SessionUp
|
|||
|
||||
// List all sessions
|
||||
func (r *SessionService) List(ctx context.Context, query SessionListParams, opts ...option.RequestOption) (res *[]Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "session"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...)
|
||||
return
|
||||
|
|
@ -70,7 +71,7 @@ func (r *SessionService) List(ctx context.Context, query SessionListParams, opts
|
|||
|
||||
// Delete a session and all its data
|
||||
func (r *SessionService) Delete(ctx context.Context, id string, body SessionDeleteParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -82,7 +83,7 @@ func (r *SessionService) Delete(ctx context.Context, id string, body SessionDele
|
|||
|
||||
// Abort a session
|
||||
func (r *SessionService) Abort(ctx context.Context, id string, body SessionAbortParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -94,7 +95,7 @@ func (r *SessionService) Abort(ctx context.Context, id string, body SessionAbort
|
|||
|
||||
// Get a session's children
|
||||
func (r *SessionService) Children(ctx context.Context, id string, query SessionChildrenParams, opts ...option.RequestOption) (res *[]Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -106,7 +107,7 @@ func (r *SessionService) Children(ctx context.Context, id string, query SessionC
|
|||
|
||||
// Send a new command to a session
|
||||
func (r *SessionService) Command(ctx context.Context, id string, params SessionCommandParams, opts ...option.RequestOption) (res *SessionCommandResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -118,7 +119,7 @@ func (r *SessionService) Command(ctx context.Context, id string, params SessionC
|
|||
|
||||
// Get session
|
||||
func (r *SessionService) Get(ctx context.Context, id string, query SessionGetParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -130,7 +131,7 @@ func (r *SessionService) Get(ctx context.Context, id string, query SessionGetPar
|
|||
|
||||
// Analyze the app and create an AGENTS.md file
|
||||
func (r *SessionService) Init(ctx context.Context, id string, params SessionInitParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -142,7 +143,7 @@ func (r *SessionService) Init(ctx context.Context, id string, params SessionInit
|
|||
|
||||
// Get a message from a session
|
||||
func (r *SessionService) Message(ctx context.Context, id string, messageID string, query SessionMessageParams, opts ...option.RequestOption) (res *SessionMessageResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -158,7 +159,7 @@ func (r *SessionService) Message(ctx context.Context, id string, messageID strin
|
|||
|
||||
// List messages for a session
|
||||
func (r *SessionService) Messages(ctx context.Context, id string, query SessionMessagesParams, opts ...option.RequestOption) (res *[]SessionMessagesResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -170,7 +171,7 @@ func (r *SessionService) Messages(ctx context.Context, id string, query SessionM
|
|||
|
||||
// Create and send a new message to a session
|
||||
func (r *SessionService) Prompt(ctx context.Context, id string, params SessionPromptParams, opts ...option.RequestOption) (res *SessionPromptResponse, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -182,7 +183,7 @@ func (r *SessionService) Prompt(ctx context.Context, id string, params SessionPr
|
|||
|
||||
// Revert a message
|
||||
func (r *SessionService) Revert(ctx context.Context, id string, params SessionRevertParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -194,7 +195,7 @@ func (r *SessionService) Revert(ctx context.Context, id string, params SessionRe
|
|||
|
||||
// Share a session
|
||||
func (r *SessionService) Share(ctx context.Context, id string, body SessionShareParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -206,7 +207,7 @@ func (r *SessionService) Share(ctx context.Context, id string, body SessionShare
|
|||
|
||||
// Run a shell command
|
||||
func (r *SessionService) Shell(ctx context.Context, id string, params SessionShellParams, opts ...option.RequestOption) (res *AssistantMessage, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -218,7 +219,7 @@ func (r *SessionService) Shell(ctx context.Context, id string, params SessionShe
|
|||
|
||||
// Summarize the session
|
||||
func (r *SessionService) Summarize(ctx context.Context, id string, params SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -230,7 +231,7 @@ func (r *SessionService) Summarize(ctx context.Context, id string, params Sessio
|
|||
|
||||
// Restore all reverted messages
|
||||
func (r *SessionService) Unrevert(ctx context.Context, id string, body SessionUnrevertParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
@ -242,7 +243,7 @@ func (r *SessionService) Unrevert(ctx context.Context, id string, body SessionUn
|
|||
|
||||
// Unshare the session
|
||||
func (r *SessionService) Unshare(ctx context.Context, id string, body SessionUnshareParams, opts ...option.RequestOption) (res *Session, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import (
|
|||
"net/http"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -40,7 +41,7 @@ func NewSessionPermissionService(opts ...option.RequestOption) (r *SessionPermis
|
|||
|
||||
// Respond to a permission request
|
||||
func (r *SessionPermissionService) Respond(ctx context.Context, id string, permissionID string, params SessionPermissionRespondParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
if id == "" {
|
||||
err = errors.New("missing required id parameter")
|
||||
return
|
||||
|
|
|
|||
19
tui.go
19
tui.go
|
|
@ -6,6 +6,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"slices"
|
||||
|
||||
"github.com/sst/opencode-sdk-go/internal/apijson"
|
||||
"github.com/sst/opencode-sdk-go/internal/apiquery"
|
||||
|
|
@ -35,7 +36,7 @@ func NewTuiService(opts ...option.RequestOption) (r *TuiService) {
|
|||
|
||||
// Append prompt to the TUI
|
||||
func (r *TuiService) AppendPrompt(ctx context.Context, params TuiAppendPromptParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/append-prompt"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
|
||||
return
|
||||
|
|
@ -43,7 +44,7 @@ func (r *TuiService) AppendPrompt(ctx context.Context, params TuiAppendPromptPar
|
|||
|
||||
// Clear the prompt
|
||||
func (r *TuiService) ClearPrompt(ctx context.Context, body TuiClearPromptParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/clear-prompt"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
@ -51,7 +52,7 @@ func (r *TuiService) ClearPrompt(ctx context.Context, body TuiClearPromptParams,
|
|||
|
||||
// Execute a TUI command (e.g. agent_cycle)
|
||||
func (r *TuiService) ExecuteCommand(ctx context.Context, params TuiExecuteCommandParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/execute-command"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
|
||||
return
|
||||
|
|
@ -59,7 +60,7 @@ func (r *TuiService) ExecuteCommand(ctx context.Context, params TuiExecuteComman
|
|||
|
||||
// Open the help dialog
|
||||
func (r *TuiService) OpenHelp(ctx context.Context, body TuiOpenHelpParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/open-help"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
@ -67,7 +68,7 @@ func (r *TuiService) OpenHelp(ctx context.Context, body TuiOpenHelpParams, opts
|
|||
|
||||
// Open the model dialog
|
||||
func (r *TuiService) OpenModels(ctx context.Context, body TuiOpenModelsParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/open-models"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
@ -75,7 +76,7 @@ func (r *TuiService) OpenModels(ctx context.Context, body TuiOpenModelsParams, o
|
|||
|
||||
// Open the session dialog
|
||||
func (r *TuiService) OpenSessions(ctx context.Context, body TuiOpenSessionsParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/open-sessions"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
@ -83,7 +84,7 @@ func (r *TuiService) OpenSessions(ctx context.Context, body TuiOpenSessionsParam
|
|||
|
||||
// Open the theme dialog
|
||||
func (r *TuiService) OpenThemes(ctx context.Context, body TuiOpenThemesParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/open-themes"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
@ -91,7 +92,7 @@ func (r *TuiService) OpenThemes(ctx context.Context, body TuiOpenThemesParams, o
|
|||
|
||||
// Show a toast notification in the TUI
|
||||
func (r *TuiService) ShowToast(ctx context.Context, params TuiShowToastParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/show-toast"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...)
|
||||
return
|
||||
|
|
@ -99,7 +100,7 @@ func (r *TuiService) ShowToast(ctx context.Context, params TuiShowToastParams, o
|
|||
|
||||
// Submit the prompt
|
||||
func (r *TuiService) SubmitPrompt(ctx context.Context, body TuiSubmitPromptParams, opts ...option.RequestOption) (res *bool, err error) {
|
||||
opts = append(r.Options[:], opts...)
|
||||
opts = slices.Concat(r.Options, opts)
|
||||
path := "tui/submit-prompt"
|
||||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue