diff options
| author | adamdotdevin <[email protected]> | 2025-07-15 10:03:11 -0500 |
|---|---|---|
| committer | adamdotdevin <[email protected]> | 2025-07-15 10:03:11 -0500 |
| commit | 6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75 (patch) | |
| tree | 9f9fa881050f60df1eb5f1e2cb9821e226b6e248 /packages/tui/sdk/README.md | |
| parent | 2487b18f62d53b739dd09b797c2a57319224284d (diff) | |
| download | opencode-6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75.tar.gz opencode-6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75.zip | |
chore: update stainless defs
Diffstat (limited to 'packages/tui/sdk/README.md')
| -rw-r--r-- | packages/tui/sdk/README.md | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/packages/tui/sdk/README.md b/packages/tui/sdk/README.md index 38840b28a..2588b6147 100644 --- a/packages/tui/sdk/README.md +++ b/packages/tui/sdk/README.md @@ -49,14 +49,11 @@ import ( func main() { client := opencode.NewClient() - stream := client.Event.ListStreaming(context.TODO()) - for stream.Next() { - fmt.Printf("%+v\n", stream.Current()) - } - err := stream.Err() + sessions, err := client.Session.List(context.TODO()) if err != nil { panic(err.Error()) } + fmt.Printf("%+v\n", sessions) } ``` @@ -145,7 +142,7 @@ client := opencode.NewClient( option.WithHeader("X-Some-Header", "custom_header_info"), ) -client.Event.List(context.TODO(), ..., +client.Session.List(context.TODO(), ..., // Override the header option.WithHeader("X-Some-Header", "some_other_custom_header_info"), // Add an undocumented field to the request body, using sjson syntax @@ -174,14 +171,14 @@ When the API returns a non-success status code, we return an error with type To handle errors, we recommend that you use the `errors.As` pattern: ```go -stream := client.Event.ListStreaming(context.TODO()) -if stream.Err() != nil { +_, err := client.Session.List(context.TODO()) +if err != nil { var apierr *opencode.Error - if errors.As(stream.Err(), &apierr) { + if errors.As(err, &apierr) { println(string(apierr.DumpRequest(true))) // Prints the serialized HTTP request println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response } - panic(stream.Err().Error()) // GET "/event": 400 Bad Request { ... } + panic(err.Error()) // GET "/session": 400 Bad Request { ... } } ``` @@ -199,7 +196,7 @@ To set a per-retry timeout, use `option.WithRequestTimeout()`. // This sets the timeout for the request, including all the retries. ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() -client.Event.ListStreaming( +client.Session.List( ctx, // This sets the per-retry timeout option.WithRequestTimeout(20*time.Second), @@ -234,7 +231,7 @@ client := opencode.NewClient( ) // Override per-request: -client.Event.ListStreaming(context.TODO(), option.WithMaxRetries(5)) +client.Session.List(context.TODO(), option.WithMaxRetries(5)) ``` ### Accessing raw response data (e.g. response headers) @@ -245,11 +242,11 @@ you need to examine response headers, status codes, or other details. ```go // Create a variable to store the HTTP response var response *http.Response -stream := client.Event.ListStreaming(context.TODO(), option.WithResponseInto(&response)) -if stream.Err() != nil { +sessions, err := client.Session.List(context.TODO(), option.WithResponseInto(&response)) +if err != nil { // handle error } -fmt.Printf("%+v\n", events) +fmt.Printf("%+v\n", sessions) fmt.Printf("Status Code: %d\n", response.StatusCode) fmt.Printf("Headers: %+#v\n", response.Header) |
