From 93b71477e6656005353ce8c71224a99170f4ae2f Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Wed, 13 Aug 2025 15:25:51 -0400 Subject: support !shell commands --- packages/sdk/go/.stats.yml | 6 ++--- packages/sdk/go/api.md | 2 +- packages/sdk/go/session.go | 42 ++++++++++++++--------------- packages/sdk/go/session_test.go | 58 ++++++++++++++++++++--------------------- 4 files changed, 54 insertions(+), 54 deletions(-) (limited to 'packages/sdk/go') diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml index d9ba9daf4..9f1e13803 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-9031231386199b2baadcaaed5b8df17899f8bc82efef4a74d7a0646fc035268a.yml -openapi_spec_hash: 8ef902a2a7039a4a6fde44ee7c26c87d -config_hash: 2b388a88fa9da825b43cbc25c2b349b5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-a881262c7de4ab59bdfbfc6e30a23c47dee465d7270ffb867b760b0103aff8ed.yml +openapi_spec_hash: 7dbb6f96f5c26a25c849e50298f58586 +config_hash: 8d85a768523cff92b85ef06c443d49fa diff --git a/packages/sdk/go/api.md b/packages/sdk/go/api.md index 5f2bc310d..79a67e42d 100644 --- a/packages/sdk/go/api.md +++ b/packages/sdk/go/api.md @@ -115,13 +115,13 @@ Methods: - client.Session.List(ctx context.Context) ([]opencode.Session, error) - client.Session.Delete(ctx context.Context, id string) (bool, error) - client.Session.Abort(ctx context.Context, id string) (bool, error) -- client.Session.Bash(ctx context.Context, id string, body opencode.SessionBashParams) (opencode.AssistantMessage, error) - client.Session.Chat(ctx context.Context, id string, body opencode.SessionChatParams) (opencode.AssistantMessage, error) - client.Session.Init(ctx context.Context, id string, body opencode.SessionInitParams) (bool, error) - client.Session.Message(ctx context.Context, id string, messageID string) (opencode.SessionMessageResponse, error) - client.Session.Messages(ctx context.Context, id string) ([]opencode.SessionMessagesResponse, error) - client.Session.Revert(ctx context.Context, id string, body opencode.SessionRevertParams) (opencode.Session, error) - client.Session.Share(ctx context.Context, id string) (opencode.Session, error) +- client.Session.Shell(ctx context.Context, id string, body opencode.SessionShellParams) (opencode.AssistantMessage, error) - client.Session.Summarize(ctx context.Context, id string, body opencode.SessionSummarizeParams) (bool, error) - client.Session.Unrevert(ctx context.Context, id string) (opencode.Session, error) - client.Session.Unshare(ctx context.Context, id string) (opencode.Session, error) diff --git a/packages/sdk/go/session.go b/packages/sdk/go/session.go index b8c156b6b..76a9d46fb 100644 --- a/packages/sdk/go/session.go +++ b/packages/sdk/go/session.go @@ -90,18 +90,6 @@ func (r *SessionService) Abort(ctx context.Context, id string, opts ...option.Re return } -// Run a bash command -func (r *SessionService) Bash(ctx context.Context, id string, body SessionBashParams, opts ...option.RequestOption) (res *AssistantMessage, err error) { - opts = append(r.Options[:], opts...) - if id == "" { - err = errors.New("missing required id parameter") - return - } - path := fmt.Sprintf("session/%s/bash", id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - // 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) { opts = append(r.Options[:], opts...) @@ -178,6 +166,18 @@ func (r *SessionService) Share(ctx context.Context, id string, opts ...option.Re return } +// Run a shell command +func (r *SessionService) Shell(ctx context.Context, id string, body SessionShellParams, opts ...option.RequestOption) (res *AssistantMessage, err error) { + opts = append(r.Options[:], opts...) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("session/%s/shell", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + // Summarize the session func (r *SessionService) Summarize(ctx context.Context, id string, body SessionSummarizeParams, opts ...option.RequestOption) (res *bool, err error) { opts = append(r.Options[:], opts...) @@ -2306,15 +2306,6 @@ func (r SessionUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type SessionBashParams struct { - Agent param.Field[string] `json:"agent,required"` - Command param.Field[string] `json:"command,required"` -} - -func (r SessionBashParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type SessionChatParams struct { ModelID param.Field[string] `json:"modelID,required"` Parts param.Field[[]SessionChatParamsPartUnion] `json:"parts,required"` @@ -2389,6 +2380,15 @@ func (r SessionRevertParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type SessionShellParams struct { + Agent param.Field[string] `json:"agent,required"` + Command param.Field[string] `json:"command,required"` +} + +func (r SessionShellParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type SessionSummarizeParams struct { ModelID param.Field[string] `json:"modelID,required"` ProviderID param.Field[string] `json:"providerID,required"` diff --git a/packages/sdk/go/session_test.go b/packages/sdk/go/session_test.go index 61a340e12..cf4a851c3 100644 --- a/packages/sdk/go/session_test.go +++ b/packages/sdk/go/session_test.go @@ -129,35 +129,6 @@ func TestSessionAbort(t *testing.T) { } } -func TestSessionBash(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.Session.Bash( - context.TODO(), - "id", - opencode.SessionBashParams{ - Agent: opencode.F("agent"), - Command: opencode.F("command"), - }, - ) - 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 TestSessionChatWithOptionalParams(t *testing.T) { t.Skip("skipped: tests are disabled for the time being") baseURL := "http://localhost:4010" @@ -332,6 +303,35 @@ func TestSessionShare(t *testing.T) { } } +func TestSessionShell(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.Session.Shell( + context.TODO(), + "id", + opencode.SessionShellParams{ + Agent: opencode.F("agent"), + Command: opencode.F("command"), + }, + ) + 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 TestSessionSummarize(t *testing.T) { t.Skip("skipped: tests are disabled for the time being") baseURL := "http://localhost:4010" -- cgit v1.2.3