@@ -24,27 +24,9 @@ import Opencode from '@opencode-ai/sdk';
24
24
25
25
const client = new Opencode ();
26
26
27
- const events = await client .event .list ();
27
+ const sessions = await client .session .list ();
28
28
```
29
29
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
-
48
30
### Request & Response types
49
31
50
32
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';
55
37
56
38
const client = new Opencode ();
57
39
58
- const events : Opencode .EventListResponse = await client .event .list ();
40
+ const sessions : Opencode .SessionListResponse = await client .session .list ();
59
41
```
60
42
61
43
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:
68
50
69
51
<!-- prettier-ignore -->
70
52
``` ts
71
- const events = await client .event .list ().catch (async (err ) => {
53
+ const sessions = await client .session .list ().catch (async (err ) => {
72
54
if (err instanceof Opencode .APIError ) {
73
55
console .log (err .status ); // 400
74
56
console .log (err .name ); // BadRequestError
@@ -108,7 +90,7 @@ const client = new Opencode({
108
90
});
109
91
110
92
// Or, configure per-request:
111
- await client .event .list ({
93
+ await client .session .list ({
112
94
maxRetries: 5 ,
113
95
});
114
96
```
@@ -125,7 +107,7 @@ const client = new Opencode({
125
107
});
126
108
127
109
// Override per-request:
128
- await client .event .list ({
110
+ await client .session .list ({
129
111
timeout: 5 * 1000 ,
130
112
});
131
113
```
@@ -148,13 +130,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
148
130
``` ts
149
131
const client = new Opencode ();
150
132
151
- const response = await client .event .list ().asResponse ();
133
+ const response = await client .session .list ().asResponse ();
152
134
console .log (response .headers .get (' X-My-Header' ));
153
135
console .log (response .statusText ); // access the underlying Response object
154
136
155
- const { data : events , response : raw } = await client .event .list ().withResponse ();
137
+ const { data : sessions , response : raw } = await client .session .list ().withResponse ();
156
138
console .log (raw .headers .get (' X-My-Header' ));
157
- console .log (events );
139
+ console .log (sessions );
158
140
```
159
141
160
142
### Logging
@@ -234,7 +216,7 @@ parameter. This library doesn't validate at runtime that the request matches the
234
216
send will be sent as-is.
235
217
236
218
``` ts
237
- client .event .list ({
219
+ client .session .list ({
238
220
// ...
239
221
// @ts-expect-error baz is not yet public
240
222
baz: ' undocumented option' ,
0 commit comments