Skip to content

Commit f8ad145

Browse files
chore(internal): version bump
1 parent c62aca7 commit f8ad145

File tree

4 files changed

+10
-79
lines changed

4 files changed

+10
-79
lines changed

src/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ export interface ClientOptions {
8989
*
9090
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
9191
* much longer than this timeout before the promise succeeds or fails.
92-
*
93-
* @unit milliseconds
9492
*/
9593
timeout?: number | undefined;
9694
/**

src/core/streaming.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { findDoubleNewlineIndex, LineDecoder } from '../internal/decoders/line';
55
import { ReadableStreamToAsyncIterable } from '../internal/shims';
66
import { isAbortError } from '../internal/errors';
77
import { encodeUTF8 } from '../internal/utils/bytes';
8-
import { loggerFor } from '../internal/utils/log';
9-
import type { Opencode } from '../client';
108

119
type Bytes = string | ArrayBuffer | Uint8Array | null | undefined;
1210

@@ -18,24 +16,16 @@ export type ServerSentEvent = {
1816

1917
export class Stream<Item> implements AsyncIterable<Item> {
2018
controller: AbortController;
21-
#client: Opencode | undefined;
2219

2320
constructor(
2421
private iterator: () => AsyncIterator<Item>,
2522
controller: AbortController,
26-
client?: Opencode,
2723
) {
2824
this.controller = controller;
29-
this.#client = client;
3025
}
3126

32-
static fromSSEResponse<Item>(
33-
response: Response,
34-
controller: AbortController,
35-
client?: Opencode,
36-
): Stream<Item> {
27+
static fromSSEResponse<Item>(response: Response, controller: AbortController): Stream<Item> {
3728
let consumed = false;
38-
const logger = client ? loggerFor(client) : console;
3929

4030
async function* iterator(): AsyncIterator<Item, any, undefined> {
4131
if (consumed) {
@@ -48,8 +38,8 @@ export class Stream<Item> implements AsyncIterable<Item> {
4838
try {
4939
yield JSON.parse(sse.data);
5040
} catch (e) {
51-
logger.error(`Could not parse message into JSON:`, sse.data);
52-
logger.error(`From chunk:`, sse.raw);
41+
console.error(`Could not parse message into JSON:`, sse.data);
42+
console.error(`From chunk:`, sse.raw);
5343
throw e;
5444
}
5545
}
@@ -64,18 +54,14 @@ export class Stream<Item> implements AsyncIterable<Item> {
6454
}
6555
}
6656

67-
return new Stream(iterator, controller, client);
57+
return new Stream(iterator, controller);
6858
}
6959

7060
/**
7161
* Generates a Stream from a newline-separated ReadableStream
7262
* where each item is a JSON value.
7363
*/
74-
static fromReadableStream<Item>(
75-
readableStream: ReadableStream,
76-
controller: AbortController,
77-
client?: Opencode,
78-
): Stream<Item> {
64+
static fromReadableStream<Item>(readableStream: ReadableStream, controller: AbortController): Stream<Item> {
7965
let consumed = false;
8066

8167
async function* iterLines(): AsyncGenerator<string, void, unknown> {
@@ -115,7 +101,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
115101
}
116102
}
117103

118-
return new Stream(iterator, controller, client);
104+
return new Stream(iterator, controller);
119105
}
120106

121107
[Symbol.asyncIterator](): AsyncIterator<Item> {
@@ -145,8 +131,8 @@ export class Stream<Item> implements AsyncIterable<Item> {
145131
};
146132

147133
return [
148-
new Stream(() => teeIterator(left), this.controller, this.#client),
149-
new Stream(() => teeIterator(right), this.controller, this.#client),
134+
new Stream(() => teeIterator(left), this.controller),
135+
new Stream(() => teeIterator(right), this.controller),
150136
];
151137
}
152138

src/internal/parse.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export async function defaultParseResponse<T>(client: Opencode, props: APIRespon
2424
// that if you set `stream: true` the response type must also be `Stream<T>`
2525

2626
if (props.options.__streamClass) {
27-
return props.options.__streamClass.fromSSEResponse(response, props.controller, client) as any;
27+
return props.options.__streamClass.fromSSEResponse(response, props.controller) as any;
2828
}
2929

30-
return Stream.fromSSEResponse(response, props.controller, client) as any;
30+
return Stream.fromSSEResponse(response, props.controller) as any;
3131
}
3232

3333
// fetch refuses to read the body when the status code is 204.

src/internal/request-options.ts

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -10,70 +10,17 @@ import { type HeadersLike } from './headers';
1010
export type FinalRequestOptions = RequestOptions & { method: HTTPMethod; path: string };
1111

1212
export type RequestOptions = {
13-
/**
14-
* The HTTP method for the request (e.g., 'get', 'post', 'put', 'delete').
15-
*/
1613
method?: HTTPMethod;
17-
18-
/**
19-
* The URL path for the request.
20-
*
21-
* @example "/v1/foo"
22-
*/
2314
path?: string;
24-
25-
/**
26-
* Query parameters to include in the request URL.
27-
*/
2815
query?: object | undefined | null;
29-
30-
/**
31-
* The request body. Can be a string, JSON object, FormData, or other supported types.
32-
*/
3316
body?: unknown;
34-
35-
/**
36-
* HTTP headers to include with the request. Can be a Headers object, plain object, or array of tuples.
37-
*/
3817
headers?: HeadersLike;
39-
40-
/**
41-
* The maximum number of times that the client will retry a request in case of a
42-
* temporary failure, like a network error or a 5XX error from the server.
43-
*
44-
* @default 2
45-
*/
4618
maxRetries?: number;
47-
4819
stream?: boolean | undefined;
49-
50-
/**
51-
* The maximum amount of time (in milliseconds) that the client should wait for a response
52-
* from the server before timing out a single request.
53-
*
54-
* @unit milliseconds
55-
*/
5620
timeout?: number;
57-
58-
/**
59-
* Additional `RequestInit` options to be passed to the underlying `fetch` call.
60-
* These options will be merged with the client's default fetch options.
61-
*/
6221
fetchOptions?: MergedRequestInit;
63-
64-
/**
65-
* An AbortSignal that can be used to cancel the request.
66-
*/
6722
signal?: AbortSignal | undefined | null;
68-
69-
/**
70-
* A unique key for this request to enable idempotency.
71-
*/
7223
idempotencyKey?: string;
73-
74-
/**
75-
* Override the default base URL for this specific request.
76-
*/
7724
defaultBaseURL?: string | undefined;
7825

7926
__binaryResponse?: boolean | undefined;

0 commit comments

Comments
 (0)