summaryrefslogtreecommitdiffhomepage
path: root/packages
diff options
context:
space:
mode:
authoradamdotdevin <[email protected]>2025-07-15 10:03:11 -0500
committeradamdotdevin <[email protected]>2025-07-15 10:03:11 -0500
commit6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75 (patch)
tree9f9fa881050f60df1eb5f1e2cb9821e226b6e248 /packages
parent2487b18f62d53b739dd09b797c2a57319224284d (diff)
downloadopencode-6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75.tar.gz
opencode-6b98acb7be04ed04a56ea69b4cdbdcc5b4788a75.zip
chore: update stainless defs
Diffstat (limited to 'packages')
-rw-r--r--packages/opencode/src/session/message-v2.ts3
-rw-r--r--packages/tui/sdk/.stats.yml6
-rw-r--r--packages/tui/sdk/README.md27
-rw-r--r--packages/tui/sdk/api.md1
-rw-r--r--packages/tui/sdk/client_test.go44
-rw-r--r--packages/tui/sdk/session.go124
-rw-r--r--packages/tui/sdk/usage_test.go7
7 files changed, 94 insertions, 118 deletions
diff --git a/packages/opencode/src/session/message-v2.ts b/packages/opencode/src/session/message-v2.ts
index 744eaadc9..c74a39a7a 100644
--- a/packages/opencode/src/session/message-v2.ts
+++ b/packages/opencode/src/session/message-v2.ts
@@ -88,7 +88,10 @@ export namespace MessageV2 {
export const SnapshotPart = PartBase.extend({
type: z.literal("snapshot"),
snapshot: z.string(),
+ }).openapi({
+ ref: "SnapshotPart",
})
+ export type SnapshotPart = z.infer<typeof SnapshotPart>
export const TextPart = PartBase.extend({
type: z.literal("text"),
diff --git a/packages/tui/sdk/.stats.yml b/packages/tui/sdk/.stats.yml
index 5aeba9efe..805d02803 100644
--- a/packages/tui/sdk/.stats.yml
+++ b/packages/tui/sdk/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 22
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-05150c78e0e6e97b0ce97ed685ebcf1cb01dc839beccb99e9d3ead5b783cfd47.yml
-openapi_spec_hash: 833a5b6d53d98dc2beac2c4c394b20d5
-config_hash: 3695cfc829cfaae14490850b4a1ed282
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-7270b9e4859010d6680bcc92afcd6f7c679d80a2645f65d7097d19ce2e8cdc5a.yml
+openapi_spec_hash: 5fcbfaedebfea62c17c74437a9728b04
+config_hash: 38041c37df28a1c4383718e6d148dd0a
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)
diff --git a/packages/tui/sdk/api.md b/packages/tui/sdk/api.md
index a48e6d7f1..9d41e7522 100644
--- a/packages/tui/sdk/api.md
+++ b/packages/tui/sdk/api.md
@@ -85,6 +85,7 @@ Response Types:
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Message">Message</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Part">Part</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#Session">Session</a>
+- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#SnapshotPart">SnapshotPart</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#StepFinishPart">StepFinishPart</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#StepStartPart">StepStartPart</a>
- <a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go">opencode</a>.<a href="https://pkg.go.dev/github.com/sst/opencode-sdk-go#TextPart">TextPart</a>
diff --git a/packages/tui/sdk/client_test.go b/packages/tui/sdk/client_test.go
index 62222a465..0f5b8205d 100644
--- a/packages/tui/sdk/client_test.go
+++ b/packages/tui/sdk/client_test.go
@@ -38,7 +38,7 @@ func TestUserAgentHeader(t *testing.T) {
},
}),
)
- client.Event.ListStreaming(context.Background())
+ client.Session.List(context.Background())
if userAgent != fmt.Sprintf("Opencode/Go %s", internal.PackageVersion) {
t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent)
}
@@ -61,11 +61,7 @@ func TestRetryAfter(t *testing.T) {
},
}),
)
- stream := client.Event.ListStreaming(context.Background())
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(context.Background())
if err == nil {
t.Error("Expected there to be a cancel error")
}
@@ -99,11 +95,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
}),
option.WithHeaderDel("X-Stainless-Retry-Count"),
)
- stream := client.Event.ListStreaming(context.Background())
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(context.Background())
if err == nil {
t.Error("Expected there to be a cancel error")
}
@@ -132,11 +124,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
}),
option.WithHeader("X-Stainless-Retry-Count", "42"),
)
- stream := client.Event.ListStreaming(context.Background())
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(context.Background())
if err == nil {
t.Error("Expected there to be a cancel error")
}
@@ -164,11 +152,7 @@ func TestRetryAfterMs(t *testing.T) {
},
}),
)
- stream := client.Event.ListStreaming(context.Background())
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(context.Background())
if err == nil {
t.Error("Expected there to be a cancel error")
}
@@ -190,11 +174,7 @@ func TestContextCancel(t *testing.T) {
)
cancelCtx, cancel := context.WithCancel(context.Background())
cancel()
- stream := client.Event.ListStreaming(cancelCtx)
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(cancelCtx)
if err == nil {
t.Error("Expected there to be a cancel error")
}
@@ -213,11 +193,7 @@ func TestContextCancelDelay(t *testing.T) {
)
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
defer cancel()
- stream := client.Event.ListStreaming(cancelCtx)
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(cancelCtx)
if err == nil {
t.Error("expected there to be a cancel error")
}
@@ -242,11 +218,7 @@ func TestContextDeadline(t *testing.T) {
},
}),
)
- stream := client.Event.ListStreaming(deadlineCtx)
- for stream.Next() {
- // ...
- }
- err := stream.Err()
+ _, err := client.Session.List(deadlineCtx)
if err == nil {
t.Error("expected there to be a deadline error")
}
diff --git a/packages/tui/sdk/session.go b/packages/tui/sdk/session.go
index c91de85bd..b62ade1f0 100644
--- a/packages/tui/sdk/session.go
+++ b/packages/tui/sdk/session.go
@@ -659,13 +659,13 @@ func (r *Part) UnmarshalJSON(data []byte) (err error) {
// for more type safety.
//
// Possible runtime types of the union are [TextPart], [FilePart], [ToolPart],
-// [StepStartPart], [StepFinishPart], [PartObject].
+// [StepStartPart], [StepFinishPart], [SnapshotPart].
func (r Part) AsUnion() PartUnion {
return r.union
}
// Union satisfied by [TextPart], [FilePart], [ToolPart], [StepStartPart],
-// [StepFinishPart] or [PartObject].
+// [StepFinishPart] or [SnapshotPart].
type PartUnion interface {
implementsPart()
}
@@ -673,78 +673,40 @@ type PartUnion interface {
func init() {
apijson.RegisterUnion(
reflect.TypeOf((*PartUnion)(nil)).Elem(),
- "",
+ "type",
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(TextPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(TextPart{}),
+ DiscriminatorValue: "text",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(FilePart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(FilePart{}),
+ DiscriminatorValue: "file",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(ToolPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(ToolPart{}),
+ DiscriminatorValue: "tool",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(StepStartPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(StepStartPart{}),
+ DiscriminatorValue: "step-start",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(StepFinishPart{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(StepFinishPart{}),
+ DiscriminatorValue: "step-finish",
},
apijson.UnionVariant{
- TypeFilter: gjson.JSON,
- Type: reflect.TypeOf(PartObject{}),
+ TypeFilter: gjson.JSON,
+ Type: reflect.TypeOf(SnapshotPart{}),
+ DiscriminatorValue: "snapshot",
},
)
}
-type PartObject struct {
- ID string `json:"id,required"`
- MessageID string `json:"messageID,required"`
- SessionID string `json:"sessionID,required"`
- Snapshot string `json:"snapshot,required"`
- Type PartObjectType `json:"type,required"`
- JSON partObjectJSON `json:"-"`
-}
-
-// partObjectJSON contains the JSON metadata for the struct [PartObject]
-type partObjectJSON struct {
- ID apijson.Field
- MessageID apijson.Field
- SessionID apijson.Field
- Snapshot apijson.Field
- Type apijson.Field
- raw string
- ExtraFields map[string]apijson.Field
-}
-
-func (r *PartObject) UnmarshalJSON(data []byte) (err error) {
- return apijson.UnmarshalRoot(data, r)
-}
-
-func (r partObjectJSON) RawJSON() string {
- return r.raw
-}
-
-func (r PartObject) implementsPart() {}
-
-type PartObjectType string
-
-const (
- PartObjectTypeSnapshot PartObjectType = "snapshot"
-)
-
-func (r PartObjectType) IsKnown() bool {
- switch r {
- case PartObjectTypeSnapshot:
- return true
- }
- return false
-}
-
type PartType string
const (
@@ -862,6 +824,50 @@ func (r sessionShareJSON) RawJSON() string {
return r.raw
}
+type SnapshotPart struct {
+ ID string `json:"id,required"`
+ MessageID string `json:"messageID,required"`
+ SessionID string `json:"sessionID,required"`
+ Snapshot string `json:"snapshot,required"`
+ Type SnapshotPartType `json:"type,required"`
+ JSON snapshotPartJSON `json:"-"`
+}
+
+// snapshotPartJSON contains the JSON metadata for the struct [SnapshotPart]
+type snapshotPartJSON struct {
+ ID apijson.Field
+ MessageID apijson.Field
+ SessionID apijson.Field
+ Snapshot apijson.Field
+ Type apijson.Field
+ raw string
+ ExtraFields map[string]apijson.Field
+}
+
+func (r *SnapshotPart) UnmarshalJSON(data []byte) (err error) {
+ return apijson.UnmarshalRoot(data, r)
+}
+
+func (r snapshotPartJSON) RawJSON() string {
+ return r.raw
+}
+
+func (r SnapshotPart) implementsPart() {}
+
+type SnapshotPartType string
+
+const (
+ SnapshotPartTypeSnapshot SnapshotPartType = "snapshot"
+)
+
+func (r SnapshotPartType) IsKnown() bool {
+ switch r {
+ case SnapshotPartTypeSnapshot:
+ return true
+ }
+ return false
+}
+
type StepFinishPart struct {
ID string `json:"id,required"`
Cost float64 `json:"cost,required"`
diff --git a/packages/tui/sdk/usage_test.go b/packages/tui/sdk/usage_test.go
index 5e8f44c7c..ef7ce8bde 100644
--- a/packages/tui/sdk/usage_test.go
+++ b/packages/tui/sdk/usage_test.go
@@ -23,13 +23,10 @@ func TestUsage(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
- stream := client.Event.ListStreaming(context.TODO())
- for stream.Next() {
- t.Logf("%+v\n", stream.Current())
- }
- err := stream.Err()
+ sessions, err := client.Session.List(context.TODO())
if err != nil {
t.Error(err)
return
}
+ t.Logf("%+v\n", sessions)
}