Skip to content

Commit 4e0ed1c

Browse files
feat(api): manual updates
1 parent c10dbab commit 4e0ed1c

22 files changed

Lines changed: 3613 additions & 764 deletions

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 11
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/droidrun%2Fdroidrun-cloud-c2003f937f2d33680b6815e4330d17a11e8ce766c2b9c0f2071b4e34ed6c78fc.yml
3-
openapi_spec_hash: 7801da9a4589d1fd4811f9d86b3e39c2
4-
config_hash: b31c431785f82620b575ae9eca23ffea
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/droidrun%2Fdroidrun-cloud-4f4b587e30045f155d30d02200881dbb7c17d5fc5c9b3b7627b817c12c451f63.yml
3+
openapi_spec_hash: bab2879c01d364918e0a136dd286def8
4+
config_hash: 21ecaf3401577ecdb4496cff7e07cb43

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ import DroidrunCloud from 'droidrun-cloud';
2727

2828
const client = new DroidrunCloud();
2929

30-
const response = await client.tasks.run({ task: 'x' });
31-
32-
console.log(response.id);
30+
const response = await client.tasks.run({ body: {} });
3331
```
3432

3533
### Request & Response types
@@ -42,8 +40,8 @@ import DroidrunCloud from 'droidrun-cloud';
4240

4341
const client = new DroidrunCloud();
4442

45-
const params: DroidrunCloud.TaskRunParams = { task: 'x' };
46-
const response: DroidrunCloud.TaskRunResponse = await client.tasks.run(params);
43+
const params: DroidrunCloud.TaskRunParams = { body: {} };
44+
const response: unknown = await client.tasks.run(params);
4745
```
4846

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

5755
<!-- prettier-ignore -->
5856
```ts
59-
const response = await client.tasks.run({ task: 'x' }).catch(async (err) => {
57+
const response = await client.tasks.run({ body: {} }).catch(async (err) => {
6058
if (err instanceof DroidrunCloud.APIError) {
6159
console.log(err.status); // 400
6260
console.log(err.name); // BadRequestError
@@ -93,11 +91,12 @@ You can use the `maxRetries` option to configure or disable this:
9391
// Configure the default for all requests:
9492
const client = new DroidrunCloud({
9593
apiKey: 'My API Key',
94+
bearer: 'My Bearer',
9695
maxRetries: 0, // default is 2
9796
});
9897

9998
// Or, configure per-request:
100-
await client.tasks.run({ task: 'x' }, {
99+
await client.tasks.run({ body: {} }, {
101100
maxRetries: 5,
102101
});
103102
```
@@ -111,11 +110,12 @@ Requests time out after 1 minute by default. You can configure this with a `time
111110
// Configure the default for all requests:
112111
const client = new DroidrunCloud({
113112
apiKey: 'My API Key',
113+
bearer: 'My Bearer',
114114
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
115115
});
116116

117117
// Override per-request:
118-
await client.tasks.run({ task: 'x' }, {
118+
await client.tasks.run({ body: {} }, {
119119
timeout: 5 * 1000,
120120
});
121121
```
@@ -138,13 +138,13 @@ Unlike `.asResponse()` this method consumes the body, returning once it is parse
138138
```ts
139139
const client = new DroidrunCloud();
140140

141-
const response = await client.tasks.run({ task: 'x' }).asResponse();
141+
const response = await client.tasks.run({ body: {} }).asResponse();
142142
console.log(response.headers.get('X-My-Header'));
143143
console.log(response.statusText); // access the underlying Response object
144144

145-
const { data: response, response: raw } = await client.tasks.run({ task: 'x' }).withResponse();
145+
const { data: response, response: raw } = await client.tasks.run({ body: {} }).withResponse();
146146
console.log(raw.headers.get('X-My-Header'));
147-
console.log(response.id);
147+
console.log(response);
148148
```
149149

150150
### Logging

api.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,34 @@
22

33
Types:
44

5-
- <code><a href="./src/resources/tasks/tasks.ts">LlmModel</a></code>
6-
- <code><a href="./src/resources/tasks/tasks.ts">Task</a></code>
7-
- <code><a href="./src/resources/tasks/tasks.ts">TaskCreate</a></code>
8-
- <code><a href="./src/resources/tasks/tasks.ts">TaskStatus</a></code>
95
- <code><a href="./src/resources/tasks/tasks.ts">TaskRetrieveResponse</a></code>
106
- <code><a href="./src/resources/tasks/tasks.ts">TaskListResponse</a></code>
7+
- <code><a href="./src/resources/tasks/tasks.ts">TaskGetGifResponse</a></code>
118
- <code><a href="./src/resources/tasks/tasks.ts">TaskGetStatusResponse</a></code>
129
- <code><a href="./src/resources/tasks/tasks.ts">TaskGetTrajectoryResponse</a></code>
1310
- <code><a href="./src/resources/tasks/tasks.ts">TaskRunResponse</a></code>
1411
- <code><a href="./src/resources/tasks/tasks.ts">TaskStopResponse</a></code>
1512

1613
Methods:
1714

18-
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks/tasks.ts">retrieve</a>(taskID) -> TaskRetrieveResponse</code>
19-
- <code title="get /tasks/">client.tasks.<a href="./src/resources/tasks/tasks.ts">list</a>({ ...params }) -> TaskListResponse</code>
15+
- <code title="get /tasks/{task_id}">client.tasks.<a href="./src/resources/tasks/tasks.ts">retrieve</a>(taskID) -> unknown</code>
16+
- <code title="get /tasks/">client.tasks.<a href="./src/resources/tasks/tasks.ts">list</a>({ ...params }) -> unknown</code>
2017
- <code title="get /tasks/{task_id}/attach">client.tasks.<a href="./src/resources/tasks/tasks.ts">attach</a>(taskID) -> void</code>
21-
- <code title="get /tasks/{task_id}/gif">client.tasks.<a href="./src/resources/tasks/tasks.ts">getGif</a>(taskID) -> MediaResponse</code>
22-
- <code title="get /tasks/{task_id}/status">client.tasks.<a href="./src/resources/tasks/tasks.ts">getStatus</a>(taskID) -> TaskGetStatusResponse</code>
23-
- <code title="get /tasks/{task_id}/trajectory">client.tasks.<a href="./src/resources/tasks/tasks.ts">getTrajectory</a>(taskID) -> TaskGetTrajectoryResponse</code>
24-
- <code title="post /tasks/">client.tasks.<a href="./src/resources/tasks/tasks.ts">run</a>({ ...params }) -> TaskRunResponse</code>
18+
- <code title="get /tasks/{task_id}/gif">client.tasks.<a href="./src/resources/tasks/tasks.ts">getGif</a>(taskID) -> unknown</code>
19+
- <code title="get /tasks/{task_id}/status">client.tasks.<a href="./src/resources/tasks/tasks.ts">getStatus</a>(taskID) -> unknown</code>
20+
- <code title="get /tasks/{task_id}/trajectory">client.tasks.<a href="./src/resources/tasks/tasks.ts">getTrajectory</a>(taskID) -> unknown</code>
21+
- <code title="post /tasks/">client.tasks.<a href="./src/resources/tasks/tasks.ts">run</a>({ ...params }) -> unknown</code>
2522
- <code title="post /tasks/stream">client.tasks.<a href="./src/resources/tasks/tasks.ts">runStreamed</a>({ ...params }) -> void</code>
26-
- <code title="post /tasks/{task_id}/cancel">client.tasks.<a href="./src/resources/tasks/tasks.ts">stop</a>(taskID) -> TaskStopResponse</code>
23+
- <code title="post /tasks/{task_id}/cancel">client.tasks.<a href="./src/resources/tasks/tasks.ts">stop</a>(taskID) -> unknown</code>
2724

2825
## Screenshots
2926

3027
Types:
3128

32-
- <code><a href="./src/resources/tasks/screenshots.ts">MediaResponse</a></code>
29+
- <code><a href="./src/resources/tasks/screenshots.ts">ScreenshotRetrieveResponse</a></code>
3330
- <code><a href="./src/resources/tasks/screenshots.ts">ScreenshotListResponse</a></code>
3431

3532
Methods:
3633

37-
- <code title="get /tasks/{task_id}/screenshots/{index}">client.tasks.screenshots.<a href="./src/resources/tasks/screenshots.ts">retrieve</a>(index, { ...params }) -> MediaResponse</code>
38-
- <code title="get /tasks/{task_id}/screenshots">client.tasks.screenshots.<a href="./src/resources/tasks/screenshots.ts">list</a>(taskID) -> ScreenshotListResponse</code>
34+
- <code title="get /tasks/{task_id}/screenshots/{index}">client.tasks.screenshots.<a href="./src/resources/tasks/screenshots.ts">retrieve</a>(index, { ...params }) -> unknown</code>
35+
- <code title="get /tasks/{task_id}/screenshots">client.tasks.screenshots.<a href="./src/resources/tasks/screenshots.ts">list</a>(taskID) -> unknown</code>

src/client.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import type { APIResponseProps } from './internal/parse';
1111
import { getPlatformHeaders } from './internal/detect-platform';
1212
import * as Shims from './internal/shims';
1313
import * as Opts from './internal/request-options';
14+
import * as qs from './internal/qs';
1415
import { VERSION } from './version';
1516
import * as Errors from './core/error';
1617
import * as Uploads from './core/uploads';
1718
import * as API from './resources/index';
1819
import { APIPromise } from './core/api-promise';
1920
import {
20-
LlmModel,
21-
Task,
22-
TaskCreate,
21+
TaskGetGifResponse,
2322
TaskGetStatusResponse,
2423
TaskGetTrajectoryResponse,
2524
TaskListParams,
@@ -28,7 +27,6 @@ import {
2827
TaskRunParams,
2928
TaskRunResponse,
3029
TaskRunStreamedParams,
31-
TaskStatus,
3230
TaskStopResponse,
3331
Tasks,
3432
} from './resources/tasks/tasks';
@@ -51,6 +49,11 @@ export interface ClientOptions {
5149
*/
5250
apiKey?: string | undefined;
5351

52+
/**
53+
* Defaults to process.env['DROIDRUN_CLOUD_BEARER_TOKEN'].
54+
*/
55+
bearer?: string | undefined;
56+
5457
/**
5558
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
5659
*
@@ -125,6 +128,7 @@ export interface ClientOptions {
125128
*/
126129
export class DroidrunCloud {
127130
apiKey: string;
131+
bearer: string;
128132

129133
baseURL: string;
130134
maxRetries: number;
@@ -142,6 +146,7 @@ export class DroidrunCloud {
142146
* API Client for interfacing with the Droidrun Cloud API.
143147
*
144148
* @param {string | undefined} [opts.apiKey=process.env['DROIDRUN_CLOUD_API_KEY'] ?? undefined]
149+
* @param {string | undefined} [opts.bearer=process.env['DROIDRUN_CLOUD_BEARER_TOKEN'] ?? undefined]
145150
* @param {string} [opts.baseURL=process.env['DROIDRUN_CLOUD_BASE_URL'] ?? https://api.droidrun.ai/v1] - Override the default base URL for the API.
146151
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
147152
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
@@ -153,16 +158,23 @@ export class DroidrunCloud {
153158
constructor({
154159
baseURL = readEnv('DROIDRUN_CLOUD_BASE_URL'),
155160
apiKey = readEnv('DROIDRUN_CLOUD_API_KEY'),
161+
bearer = readEnv('DROIDRUN_CLOUD_BEARER_TOKEN'),
156162
...opts
157163
}: ClientOptions = {}) {
158164
if (apiKey === undefined) {
159165
throw new Errors.DroidrunCloudError(
160166
"The DROIDRUN_CLOUD_API_KEY environment variable is missing or empty; either provide it, or instantiate the DroidrunCloud client with an apiKey option, like new DroidrunCloud({ apiKey: 'My API Key' }).",
161167
);
162168
}
169+
if (bearer === undefined) {
170+
throw new Errors.DroidrunCloudError(
171+
"The DROIDRUN_CLOUD_BEARER_TOKEN environment variable is missing or empty; either provide it, or instantiate the DroidrunCloud client with an bearer option, like new DroidrunCloud({ bearer: 'My Bearer' }).",
172+
);
173+
}
163174

164175
const options: ClientOptions = {
165176
apiKey,
177+
bearer,
166178
...opts,
167179
baseURL: baseURL || `https://api.droidrun.ai/v1`,
168180
};
@@ -185,6 +197,7 @@ export class DroidrunCloud {
185197
this._options = options;
186198

187199
this.apiKey = apiKey;
200+
this.bearer = bearer;
188201
}
189202

190203
/**
@@ -201,6 +214,7 @@ export class DroidrunCloud {
201214
fetch: this.fetch,
202215
fetchOptions: this.fetchOptions,
203216
apiKey: this.apiKey,
217+
bearer: this.bearer,
204218
...options,
205219
});
206220
return client;
@@ -221,24 +235,8 @@ export class DroidrunCloud {
221235
return;
222236
}
223237

224-
/**
225-
* Basic re-implementation of `qs.stringify` for primitive types.
226-
*/
227238
protected stringifyQuery(query: Record<string, unknown>): string {
228-
return Object.entries(query)
229-
.filter(([_, value]) => typeof value !== 'undefined')
230-
.map(([key, value]) => {
231-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
232-
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
233-
}
234-
if (value === null) {
235-
return `${encodeURIComponent(key)}=`;
236-
}
237-
throw new Errors.DroidrunCloudError(
238-
`Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
239-
);
240-
})
241-
.join('&');
239+
return qs.stringify(query, { arrayFormat: 'comma' });
242240
}
243241

244242
private getUserAgent(): string {
@@ -734,12 +732,9 @@ export declare namespace DroidrunCloud {
734732

735733
export {
736734
Tasks as Tasks,
737-
type LlmModel as LlmModel,
738-
type Task as Task,
739-
type TaskCreate as TaskCreate,
740-
type TaskStatus as TaskStatus,
741735
type TaskRetrieveResponse as TaskRetrieveResponse,
742736
type TaskListResponse as TaskListResponse,
737+
type TaskGetGifResponse as TaskGetGifResponse,
743738
type TaskGetStatusResponse as TaskGetStatusResponse,
744739
type TaskGetTrajectoryResponse as TaskGetTrajectoryResponse,
745740
type TaskRunResponse as TaskRunResponse,

src/internal/qs/LICENSE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2014, Nathan LaFreniere and other [contributors](https://github.com/puruvj/neoqs/graphs/contributors) All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8+
9+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10+
11+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
12+
13+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/internal/qs/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# qs
2+
3+
This is a vendored version of [neoqs](https://github.com/PuruVJ/neoqs) which is a TypeScript rewrite of [qs](https://github.com/ljharb/qs), a query string library.

src/internal/qs/formats.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Format } from './types';
2+
3+
export const default_format: Format = 'RFC3986';
4+
export const default_formatter = (v: PropertyKey) => String(v);
5+
export const formatters: Record<Format, (str: PropertyKey) => string> = {
6+
RFC1738: (v: PropertyKey) => String(v).replace(/%20/g, '+'),
7+
RFC3986: default_formatter,
8+
};
9+
export const RFC1738 = 'RFC1738';
10+
export const RFC3986 = 'RFC3986';

src/internal/qs/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { default_format, formatters, RFC1738, RFC3986 } from './formats';
2+
3+
const formats = {
4+
formatters,
5+
RFC1738,
6+
RFC3986,
7+
default: default_format,
8+
};
9+
10+
export { stringify } from './stringify';
11+
export { formats };
12+
13+
export type { DefaultDecoder, DefaultEncoder, Format, ParseOptions, StringifyOptions } from './types';

0 commit comments

Comments
 (0)