Skip to content

Commit 8b5d592

Browse files
feat(api): api update
1 parent ebd8986 commit 8b5d592

File tree

2 files changed

+10
-28
lines changed

2 files changed

+10
-28
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 22
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-7270b9e4859010d6680bcc92afcd6f7c679d80a2645f65d7097d19ce2e8cdc5a.yml
33
openapi_spec_hash: 5fcbfaedebfea62c17c74437a9728b04
4-
config_hash: 931828b5dd9393834a3c1703e02e02b0
4+
config_hash: 38a50dff50297c2f735b5e1c83fa0188

README.md

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,9 @@ import Opencode from '@opencode-ai/sdk';
2424

2525
const client = new Opencode();
2626

27-
const events = await client.event.list();
27+
const sessions = await client.session.list();
2828
```
2929

30-
## Streaming responses
31-
32-
We provide support for streaming responses using Server Sent Events (SSE).
33-
34-
```ts
35-
import Opencode from '@opencode-ai/sdk';
36-
37-
const client = new Opencode();
38-
39-
const stream = await client.event.list();
40-
for await (const eventListResponse of stream) {
41-
console.log(eventListResponse);
42-
}
43-
```
44-
45-
If you need to cancel a stream, you can `break` from the loop
46-
or call `stream.controller.abort()`.
47-
4830
### Request & Response types
4931

5032
This library includes TypeScript definitions for all request params and response fields. You may import and use them like so:
@@ -55,7 +37,7 @@ import Opencode from '@opencode-ai/sdk';
5537

5638
const client = new Opencode();
5739

58-
const events: Opencode.EventListResponse = await client.event.list();
40+
const sessions: Opencode.SessionListResponse = await client.session.list();
5941
```
6042

6143
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
@@ -68,7 +50,7 @@ a subclass of `APIError` will be thrown:
6850

6951
<!-- prettier-ignore -->
7052
```ts
71-
const events = await client.event.list().catch(async (err) => {
53+
const sessions = await client.session.list().catch(async (err) => {
7254
if (err instanceof Opencode.APIError) {
7355
console.log(err.status); // 400
7456
console.log(err.name); // BadRequestError
@@ -108,7 +90,7 @@ const client = new Opencode({
10890
});
10991

11092
// Or, configure per-request:
111-
await client.event.list({
93+
await client.session.list({
11294
maxRetries: 5,
11395
});
11496
```
@@ -125,7 +107,7 @@ const client = new Opencode({
125107
});
126108

127109
// Override per-request:
128-
await client.event.list({
110+
await client.session.list({
129111
timeout: 5 * 1000,
130112
});
131113
```
@@ -148,13 +130,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
148130
```ts
149131
const client = new Opencode();
150132

151-
const response = await client.event.list().asResponse();
133+
const response = await client.session.list().asResponse();
152134
console.log(response.headers.get('X-My-Header'));
153135
console.log(response.statusText); // access the underlying Response object
154136

155-
const { data: events, response: raw } = await client.event.list().withResponse();
137+
const { data: sessions, response: raw } = await client.session.list().withResponse();
156138
console.log(raw.headers.get('X-My-Header'));
157-
console.log(events);
139+
console.log(sessions);
158140
```
159141

160142
### Logging
@@ -234,7 +216,7 @@ parameter. This library doesn't validate at runtime that the request matches the
234216
send will be sent as-is.
235217

236218
```ts
237-
client.event.list({
219+
client.session.list({
238220
// ...
239221
// @ts-expect-error baz is not yet public
240222
baz: 'undocumented option',

0 commit comments

Comments
 (0)