Refactor to support multiple instances inside single opencode process (#2360)
This release has a bunch of minor breaking changes if you are using opencode plugins or sdk 1. storage events have been removed (we might bring this back but had some issues) 2. concept of `app` is gone - there is a new concept called `project` and endpoints to list projects and get the current project 3. plugin receives `directory` which is cwd and `worktree` which is where the root of the project is if it's a git repo 4. the session.chat function has been renamed to session.prompt in sdk. it no longer requires model to be passed in (model is now an object) 5. every endpoint takes an optional `directory` parameter to operate as though opencode is running in that directory
This commit is contained in:
@@ -38,7 +38,7 @@ func TestUserAgentHeader(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
client.Session.List(context.Background())
|
||||
client.Session.List(context.Background(), opencode.SessionListParams{})
|
||||
if userAgent != fmt.Sprintf("Opencode/Go %s", internal.PackageVersion) {
|
||||
t.Errorf("Expected User-Agent to be correct, but got: %#v", userAgent)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func TestRetryAfter(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
_, err := client.Session.List(context.Background())
|
||||
_, err := client.Session.List(context.Background(), opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("Expected there to be a cancel error")
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
|
||||
}),
|
||||
option.WithHeaderDel("X-Stainless-Retry-Count"),
|
||||
)
|
||||
_, err := client.Session.List(context.Background())
|
||||
_, err := client.Session.List(context.Background(), opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("Expected there to be a cancel error")
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
|
||||
}),
|
||||
option.WithHeader("X-Stainless-Retry-Count", "42"),
|
||||
)
|
||||
_, err := client.Session.List(context.Background())
|
||||
_, err := client.Session.List(context.Background(), opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("Expected there to be a cancel error")
|
||||
}
|
||||
@@ -152,7 +152,7 @@ func TestRetryAfterMs(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
_, err := client.Session.List(context.Background())
|
||||
_, err := client.Session.List(context.Background(), opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("Expected there to be a cancel error")
|
||||
}
|
||||
@@ -174,7 +174,7 @@ func TestContextCancel(t *testing.T) {
|
||||
)
|
||||
cancelCtx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
_, err := client.Session.List(cancelCtx)
|
||||
_, err := client.Session.List(cancelCtx, opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("Expected there to be a cancel error")
|
||||
}
|
||||
@@ -193,7 +193,7 @@ func TestContextCancelDelay(t *testing.T) {
|
||||
)
|
||||
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
|
||||
defer cancel()
|
||||
_, err := client.Session.List(cancelCtx)
|
||||
_, err := client.Session.List(cancelCtx, opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("expected there to be a cancel error")
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func TestContextDeadline(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
_, err := client.Session.List(deadlineCtx)
|
||||
_, err := client.Session.List(deadlineCtx, opencode.SessionListParams{})
|
||||
if err == nil {
|
||||
t.Error("expected there to be a deadline error")
|
||||
}
|
||||
@@ -262,7 +262,7 @@ func TestContextDeadlineStreaming(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
stream := client.Event.ListStreaming(deadlineCtx)
|
||||
stream := client.Event.ListStreaming(deadlineCtx, opencode.EventListParams{})
|
||||
for stream.Next() {
|
||||
_ = stream.Current()
|
||||
}
|
||||
@@ -306,7 +306,11 @@ func TestContextDeadlineStreamingWithRequestTimeout(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
)
|
||||
stream := client.Event.ListStreaming(context.Background(), option.WithRequestTimeout((100 * time.Millisecond)))
|
||||
stream := client.Event.ListStreaming(
|
||||
context.Background(),
|
||||
opencode.EventListParams{},
|
||||
option.WithRequestTimeout((100 * time.Millisecond)),
|
||||
)
|
||||
for stream.Next() {
|
||||
_ = stream.Current()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user