Skip to content

Commit 2320f32

Browse files
feat(api): update via SDK Studio
1 parent c53ef25 commit 2320f32

21 files changed

Lines changed: 54 additions & 178 deletions

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 17
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-72b567bbc0e7006bc20c12ae64e7cf89232ec5d1c3ef87c3de578e7bdacbb458.yml
33
openapi_spec_hash: 86cd58211d0a31fbb767498c7fab07e6
4-
config_hash: 3bd5036fa5676b4a32198ca725e22a5f
4+
config_hash: f01a819fee7d5be99f224dd62abb8cbd

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ The full API of this library can be found in [api.md](api.md).
2222
```js
2323
import Opencode from '@opencode-ai/sdk';
2424

25-
const client = new Opencode({
26-
apiKey: process.env['OPENCODE_API_KEY'], // This is the default and can be omitted
27-
});
25+
const client = new Opencode();
2826

2927
const events = await client.event.list();
3028
```
@@ -37,9 +35,7 @@ This library includes TypeScript definitions for all request params and response
3735
```ts
3836
import Opencode from '@opencode-ai/sdk';
3937

40-
const client = new Opencode({
41-
apiKey: process.env['OPENCODE_API_KEY'], // This is the default and can be omitted
42-
});
38+
const client = new Opencode();
4339

4440
const events: Opencode.EventListResponse = await client.event.list();
4541
```

src/client.ts

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ import {
6666
import { isEmptyObj } from './internal/utils/values';
6767

6868
export interface ClientOptions {
69-
/**
70-
* Defaults to process.env['OPENCODE_API_KEY'].
71-
*/
72-
apiKey?: string | null | undefined;
73-
7469
/**
7570
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
7671
*
@@ -142,8 +137,6 @@ export interface ClientOptions {
142137
* API Client for interfacing with the Opencode API.
143138
*/
144139
export class Opencode {
145-
apiKey: string | null;
146-
147140
baseURL: string;
148141
maxRetries: number;
149142
timeout: number;
@@ -159,7 +152,6 @@ export class Opencode {
159152
/**
160153
* API Client for interfacing with the Opencode API.
161154
*
162-
* @param {string | null | undefined} [opts.apiKey=process.env['OPENCODE_API_KEY'] ?? null]
163155
* @param {string} [opts.baseURL=process.env['OPENCODE_BASE_URL'] ?? http://localhost:54321] - Override the default base URL for the API.
164156
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
165157
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -168,13 +160,8 @@ export class Opencode {
168160
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
169161
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
170162
*/
171-
constructor({
172-
baseURL = readEnv('OPENCODE_BASE_URL'),
173-
apiKey = readEnv('OPENCODE_API_KEY') ?? null,
174-
...opts
175-
}: ClientOptions = {}) {
163+
constructor({ baseURL = readEnv('OPENCODE_BASE_URL'), ...opts }: ClientOptions = {}) {
176164
const options: ClientOptions = {
177-
apiKey,
178165
...opts,
179166
baseURL: baseURL || `http://localhost:54321`,
180167
};
@@ -195,8 +182,6 @@ export class Opencode {
195182
this.#encoder = Opts.FallbackEncoder;
196183

197184
this._options = options;
198-
199-
this.apiKey = apiKey;
200185
}
201186

202187
/**
@@ -212,7 +197,6 @@ export class Opencode {
212197
logLevel: this.logLevel,
213198
fetch: this.fetch,
214199
fetchOptions: this.fetchOptions,
215-
apiKey: this.apiKey,
216200
...options,
217201
});
218202
}
@@ -229,23 +213,7 @@ export class Opencode {
229213
}
230214

231215
protected validateHeaders({ values, nulls }: NullableHeaders) {
232-
if (this.apiKey && values.get('authorization')) {
233-
return;
234-
}
235-
if (nulls.has('authorization')) {
236-
return;
237-
}
238-
239-
throw new Error(
240-
'Could not resolve authentication method. Expected the apiKey to be set. Or for the "Authorization" headers to be explicitly omitted',
241-
);
242-
}
243-
244-
protected authHeaders(opts: FinalRequestOptions): NullableHeaders | undefined {
245-
if (this.apiKey == null) {
246-
return undefined;
247-
}
248-
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
216+
return;
249217
}
250218

251219
/**
@@ -683,7 +651,6 @@ export class Opencode {
683651
...(options.timeout ? { 'X-Stainless-Timeout': String(Math.trunc(options.timeout / 1000)) } : {}),
684652
...getPlatformHeaders(),
685653
},
686-
this.authHeaders(options),
687654
this._options.defaultHeaders,
688655
bodyHeaders,
689656
options.headers,

tests/api-resources/app-info.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource appInfo', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/app-initialize.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource appInitialize', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/config-get.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource configGet', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/event.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource event', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/file-search.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource fileSearch', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/installation-info.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource installationInfo', () => {
118
// skipped: tests are disabled for the time being

tests/api-resources/path-get.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22

33
import Opencode from '@opencode-ai/sdk';
44

5-
const client = new Opencode({
6-
apiKey: 'My API Key',
7-
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
8-
});
5+
const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010' });
96

107
describe('resource pathGet', () => {
118
// skipped: tests are disabled for the time being

0 commit comments

Comments
 (0)