diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index 1a3d42b5..0b1f9167 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -248,6 +248,34 @@ export namespace Server { return c.json(session) }, ) + .get( + "/session/:id/children", + describeRoute({ + description: "Get a session's children", + operationId: "session.children", + responses: { + 200: { + description: "List of children", + content: { + "application/json": { + schema: resolver(Session.Info.array()), + }, + }, + }, + }, + }), + zValidator( + "param", + z.object({ + id: z.string(), + }), + ), + async (c) => { + const sessionID = c.req.valid("param").id + const session = await Session.children(sessionID) + return c.json(session) + }, + ) .post( "/session", describeRoute({ diff --git a/packages/sdk/go/.stats.yml b/packages/sdk/go/.stats.yml index 6a6c7c1f..156ca97e 100644 --- a/packages/sdk/go/.stats.yml +++ b/packages/sdk/go/.stats.yml @@ -1,4 +1,4 @@ -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 +configured_endpoints: 39 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-b751e5c3cd3ab7fc61b18fbbfd6092b7264ea2ee305858aa538b884e7c492090.yml +openapi_spec_hash: a61f8b1d9b834cf321f0cb7805cc8522 +config_hash: eab3723c4c2232a6ba1821151259d6da diff --git a/packages/sdk/go/api.md b/packages/sdk/go/api.md index f48d0687..7be0d3a4 100644 --- a/packages/sdk/go/api.md +++ b/packages/sdk/go/api.md @@ -116,6 +116,8 @@ Methods: - client.Session.Delete(ctx context.Context, id string) (bool, error) - client.Session.Abort(ctx context.Context, id string) (bool, error) - client.Session.Chat(ctx context.Context, id string, body opencode.SessionChatParams) (opencode.AssistantMessage, error) +- client.Session.Children(ctx context.Context, id string) ([]opencode.Session, error) +- client.Session.Get(ctx context.Context, id string) (opencode.Session, 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) diff --git a/packages/sdk/go/session.go b/packages/sdk/go/session.go index 29cc92a2..0ab9c7d9 100644 --- a/packages/sdk/go/session.go +++ b/packages/sdk/go/session.go @@ -102,6 +102,30 @@ func (r *SessionService) Chat(ctx context.Context, id string, body SessionChatPa return } +// Get a session's children +func (r *SessionService) Children(ctx context.Context, id string, opts ...option.RequestOption) (res *[]Session, err error) { + opts = append(r.Options[:], opts...) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("session/%s/children", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// Get session +func (r *SessionService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *Session, err error) { + opts = append(r.Options[:], opts...) + if id == "" { + err = errors.New("missing required id parameter") + return + } + path := fmt.Sprintf("session/%s", id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + // Analyze the app and create an AGENTS.md file func (r *SessionService) Init(ctx context.Context, id string, body SessionInitParams, opts ...option.RequestOption) (res *bool, err error) { opts = append(r.Options[:], opts...) diff --git a/packages/sdk/go/session_test.go b/packages/sdk/go/session_test.go index cf4a851c..2f5e1110 100644 --- a/packages/sdk/go/session_test.go +++ b/packages/sdk/go/session_test.go @@ -174,6 +174,50 @@ func TestSessionChatWithOptionalParams(t *testing.T) { } } +func TestSessionChildren(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.Children(context.TODO(), "id") + 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 TestSessionGet(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.Get(context.TODO(), "id") + 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 TestSessionInit(t *testing.T) { t.Skip("skipped: tests are disabled for the time being") baseURL := "http://localhost:4010" diff --git a/packages/sdk/js/src/gen/sdk.gen.ts b/packages/sdk/js/src/gen/sdk.gen.ts index 1e0e1ae5..cb17a9b9 100644 --- a/packages/sdk/js/src/gen/sdk.gen.ts +++ b/packages/sdk/js/src/gen/sdk.gen.ts @@ -21,6 +21,8 @@ import type { SessionGetResponses, SessionUpdateData, SessionUpdateResponses, + SessionChildrenData, + SessionChildrenResponses, SessionInitData, SessionInitResponses, SessionAbortData, @@ -247,6 +249,16 @@ class Session extends _HeyApiClient { }) } + /** + * Get a session's children + */ + public children(options: Options) { + return (options.client ?? this._client).get({ + url: "/session/{id}/children", + ...options, + }) + } + /** * Analyze the app and create an AGENTS.md file */ diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 81faf7bf..59679c71 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -1319,6 +1319,24 @@ export type SessionUpdateResponses = { export type SessionUpdateResponse = SessionUpdateResponses[keyof SessionUpdateResponses] +export type SessionChildrenData = { + body?: never + path: { + id: string + } + query?: never + url: "/session/{id}/children" +} + +export type SessionChildrenResponses = { + /** + * List of children + */ + 200: Array +} + +export type SessionChildrenResponse = SessionChildrenResponses[keyof SessionChildrenResponses] + export type SessionInitData = { body?: { messageID: string diff --git a/packages/sdk/stainless/stainless.yml b/packages/sdk/stainless/stainless.yml index 4ce3cd2a..e0c040ec 100644 --- a/packages/sdk/stainless/stainless.yml +++ b/packages/sdk/stainless/stainless.yml @@ -113,7 +113,9 @@ resources: toolStateError: ToolStateError methods: + get: get /session/{id} list: get /session + children: get /session/{id}/children create: post /session delete: delete /session/{id} init: post /session/{id}/init