chore: rework openapi spec and use stainless sdk

This commit is contained in:
adamdottv
2025-06-27 07:46:42 -05:00
committed by Jay V
parent 0676bcd4fd
commit be0811ecc3
28 changed files with 658 additions and 6634 deletions

View File

@@ -1,4 +0,0 @@
package client
//go:generate bun run ../../../opencode/src/index.ts generate
//go:generate go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --package=client --generate=types,client,models -o generated-client.go ./gen/openapi.json

View File

@@ -6,11 +6,13 @@ import (
"encoding/json"
"net/http"
"strings"
"github.com/sst/opencode-sdk-go"
)
func (c *Client) Event(ctx context.Context) (<-chan any, error) {
func Event(c *opencode.Client, url string, ctx context.Context) (<-chan any, error) {
events := make(chan any)
req, err := http.NewRequestWithContext(ctx, "GET", c.Server+"event", nil)
req, err := http.NewRequestWithContext(ctx, "GET", url+"event", nil)
if err != nil {
return nil, err
}
@@ -31,15 +33,12 @@ func (c *Client) Event(ctx context.Context) (<-chan any, error) {
if strings.HasPrefix(line, "data: ") {
data := strings.TrimPrefix(line, "data: ")
var event Event
var event opencode.EventListResponse
if err := json.Unmarshal([]byte(data), &event); err != nil {
continue
}
val, err := event.ValueByDiscriminator()
if err != nil {
continue
}
val := event.AsUnion()
select {
case events <- val:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff