@bctrl/sdk 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/dist/bctrl.d.ts +15 -15
- package/dist/bctrl.js +14 -14
- package/dist/errors.d.ts +14 -14
- package/dist/errors.js +1 -1
- package/dist/files.d.ts +21 -21
- package/dist/files.js +14 -14
- package/dist/http.d.ts +6 -6
- package/dist/http.js +17 -17
- package/dist/index.d.ts +7 -7
- package/dist/index.js +6 -7
- package/dist/invocations.d.ts +78 -16
- package/dist/invocations.js +99 -6
- package/dist/pagination.d.ts +2 -2
- package/dist/pagination.js +1 -1
- package/dist/runs.d.ts +29 -27
- package/dist/runs.js +20 -14
- package/dist/runtimes.d.ts +45 -49
- package/dist/runtimes.js +23 -26
- package/dist/spaces.d.ts +29 -30
- package/dist/spaces.js +22 -22
- package/dist/types.d.ts +116 -89
- package/package.json +14 -12
- package/dist/browsers.d.ts +0 -24
- package/dist/browsers.js +0 -82
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bctrl/sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for BCTRL
|
|
3
|
+
TypeScript SDK for BCTRL v1 spaces, browser runtimes, invocations, runs, and files.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -24,10 +24,14 @@ const space = await bctrl.spaces.create({
|
|
|
24
24
|
region: 'us-east-1',
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
-
const
|
|
27
|
+
const runtime = await space.runtimes.create({
|
|
28
|
+
type: 'browser',
|
|
28
29
|
name: 'browser-task',
|
|
29
|
-
|
|
30
|
+
config: {
|
|
31
|
+
browser: { profile: false },
|
|
32
|
+
},
|
|
30
33
|
});
|
|
34
|
+
const { runtime: browser } = await runtime.start();
|
|
31
35
|
|
|
32
36
|
const connection = await browser.connect();
|
|
33
37
|
console.log(connection.wsUrl);
|
|
@@ -42,8 +46,8 @@ const result = await invocation.wait({ timeoutMs: 60_000 });
|
|
|
42
46
|
console.log(result.data.status);
|
|
43
47
|
```
|
|
44
48
|
|
|
45
|
-
The public SDK targets `https://api.bctrl.ai/
|
|
46
|
-
local origin or
|
|
49
|
+
The public SDK targets `https://api.bctrl.ai/v1`. For local development, pass a
|
|
50
|
+
local origin or v1 base URL:
|
|
47
51
|
|
|
48
52
|
```ts
|
|
49
53
|
const bctrl = new Bctrl({
|
|
@@ -52,11 +56,11 @@ const bctrl = new Bctrl({
|
|
|
52
56
|
});
|
|
53
57
|
```
|
|
54
58
|
|
|
55
|
-
`baseUrl` may include or omit `/
|
|
59
|
+
`baseUrl` may include or omit `/v1`; the client normalizes either form.
|
|
56
60
|
|
|
57
61
|
## Entry points
|
|
58
62
|
|
|
59
|
-
- `@bctrl/sdk`:
|
|
63
|
+
- `@bctrl/sdk`: v1 client, resources, errors, and public types
|
|
60
64
|
|
|
61
65
|
## Documentation
|
|
62
66
|
|
package/dist/bctrl.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
export type
|
|
8
|
-
export declare class
|
|
1
|
+
import { V1FilesClient } from './files.js';
|
|
2
|
+
import { type V1ClientOptions } from './http.js';
|
|
3
|
+
import { V1InvocationsClient } from './invocations.js';
|
|
4
|
+
import { V1RunsClient } from './runs.js';
|
|
5
|
+
import { V1RuntimesClient } from './runtimes.js';
|
|
6
|
+
import { V1SpacesClient } from './spaces.js';
|
|
7
|
+
export type BctrlV1Options = V1ClientOptions;
|
|
8
|
+
export declare class BctrlV1 {
|
|
9
9
|
private readonly http;
|
|
10
10
|
private _spaces;
|
|
11
11
|
private _runtimes;
|
|
@@ -13,11 +13,11 @@ export declare class BctrlV2 {
|
|
|
13
13
|
private _invocations;
|
|
14
14
|
private _files;
|
|
15
15
|
static isControllerBusy(error: unknown): boolean;
|
|
16
|
-
constructor(options?:
|
|
17
|
-
get spaces():
|
|
18
|
-
get runtimes():
|
|
19
|
-
get runs():
|
|
20
|
-
get invocations():
|
|
21
|
-
get files():
|
|
16
|
+
constructor(options?: BctrlV1Options);
|
|
17
|
+
get spaces(): V1SpacesClient;
|
|
18
|
+
get runtimes(): V1RuntimesClient;
|
|
19
|
+
get runs(): V1RunsClient;
|
|
20
|
+
get invocations(): V1InvocationsClient;
|
|
21
|
+
get files(): V1FilesClient;
|
|
22
22
|
}
|
|
23
|
-
export {
|
|
23
|
+
export { BctrlV1 as Bctrl };
|
package/dist/bctrl.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { isControllerBusy } from './errors.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
export class
|
|
2
|
+
import { V1FilesClient } from './files.js';
|
|
3
|
+
import { V1HttpClient } from './http.js';
|
|
4
|
+
import { V1InvocationsClient } from './invocations.js';
|
|
5
|
+
import { V1RunsClient } from './runs.js';
|
|
6
|
+
import { V1RuntimesClient } from './runtimes.js';
|
|
7
|
+
import { V1SpacesClient } from './spaces.js';
|
|
8
|
+
export class BctrlV1 {
|
|
9
9
|
http;
|
|
10
10
|
_spaces = null;
|
|
11
11
|
_runtimes = null;
|
|
@@ -16,27 +16,27 @@ export class BctrlV2 {
|
|
|
16
16
|
return isControllerBusy(error);
|
|
17
17
|
}
|
|
18
18
|
constructor(options = {}) {
|
|
19
|
-
this.http = new
|
|
19
|
+
this.http = new V1HttpClient(options);
|
|
20
20
|
}
|
|
21
21
|
get spaces() {
|
|
22
|
-
this._spaces ??= new
|
|
22
|
+
this._spaces ??= new V1SpacesClient(this.http);
|
|
23
23
|
return this._spaces;
|
|
24
24
|
}
|
|
25
25
|
get runtimes() {
|
|
26
|
-
this._runtimes ??= new
|
|
26
|
+
this._runtimes ??= new V1RuntimesClient(this.http);
|
|
27
27
|
return this._runtimes;
|
|
28
28
|
}
|
|
29
29
|
get runs() {
|
|
30
|
-
this._runs ??= new
|
|
30
|
+
this._runs ??= new V1RunsClient(this.http);
|
|
31
31
|
return this._runs;
|
|
32
32
|
}
|
|
33
33
|
get invocations() {
|
|
34
|
-
this._invocations ??= new
|
|
34
|
+
this._invocations ??= new V1InvocationsClient(this.http);
|
|
35
35
|
return this._invocations;
|
|
36
36
|
}
|
|
37
37
|
get files() {
|
|
38
|
-
this._files ??= new
|
|
38
|
+
this._files ??= new V1FilesClient(this.http);
|
|
39
39
|
return this._files;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
export {
|
|
42
|
+
export { BctrlV1 as Bctrl };
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface V1ErrorContext {
|
|
2
2
|
status?: number;
|
|
3
3
|
code?: string;
|
|
4
4
|
requestId?: string;
|
|
@@ -7,43 +7,43 @@ export interface V2ErrorContext {
|
|
|
7
7
|
}
|
|
8
8
|
export declare class BctrlError extends Error {
|
|
9
9
|
readonly code: string;
|
|
10
|
-
readonly context?:
|
|
11
|
-
constructor(message: string, code: string, context?:
|
|
10
|
+
readonly context?: V1ErrorContext;
|
|
11
|
+
constructor(message: string, code: string, context?: V1ErrorContext);
|
|
12
12
|
toJSON(): Record<string, unknown>;
|
|
13
13
|
}
|
|
14
14
|
export declare class BctrlApiError extends BctrlError {
|
|
15
|
-
constructor(message: string, code?: string, context?:
|
|
15
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
16
16
|
get status(): number | undefined;
|
|
17
17
|
get requestId(): string | undefined;
|
|
18
18
|
}
|
|
19
19
|
export declare class BctrlAuthenticationError extends BctrlApiError {
|
|
20
|
-
constructor(message: string, code?: string, context?:
|
|
20
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
21
21
|
}
|
|
22
22
|
export declare class BctrlPermissionError extends BctrlApiError {
|
|
23
|
-
constructor(message: string, code?: string, context?:
|
|
23
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
24
24
|
}
|
|
25
25
|
export declare class BctrlNotFoundError extends BctrlApiError {
|
|
26
|
-
constructor(message: string, code?: string, context?:
|
|
26
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
27
27
|
}
|
|
28
28
|
export declare class BctrlConflictError extends BctrlApiError {
|
|
29
|
-
constructor(message: string, code?: string, context?:
|
|
29
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
30
30
|
}
|
|
31
31
|
export declare class BctrlRateLimitError extends BctrlApiError {
|
|
32
|
-
constructor(message: string, code?: string, context?:
|
|
32
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
33
33
|
}
|
|
34
34
|
export declare class BctrlValidationError extends BctrlApiError {
|
|
35
|
-
constructor(message: string, code?: string, context?:
|
|
35
|
+
constructor(message: string, code?: string, context?: V1ErrorContext);
|
|
36
36
|
}
|
|
37
37
|
export declare class BctrlNetworkError extends BctrlError {
|
|
38
|
-
constructor(message: string, context?:
|
|
38
|
+
constructor(message: string, context?: V1ErrorContext);
|
|
39
39
|
}
|
|
40
40
|
export declare class BctrlNotReadyError extends BctrlError {
|
|
41
|
-
constructor(message: string, context?:
|
|
41
|
+
constructor(message: string, context?: V1ErrorContext);
|
|
42
42
|
}
|
|
43
43
|
export declare class BctrlUnsupportedError extends BctrlError {
|
|
44
|
-
constructor(message: string, context?:
|
|
44
|
+
constructor(message: string, context?: V1ErrorContext);
|
|
45
45
|
}
|
|
46
|
-
export declare function
|
|
46
|
+
export declare function createV1HttpError(input: {
|
|
47
47
|
status: number;
|
|
48
48
|
message: string;
|
|
49
49
|
code?: string;
|
package/dist/errors.js
CHANGED
|
@@ -82,7 +82,7 @@ export class BctrlUnsupportedError extends BctrlError {
|
|
|
82
82
|
this.name = 'BctrlUnsupportedError';
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
export function
|
|
85
|
+
export function createV1HttpError(input) {
|
|
86
86
|
const context = {
|
|
87
87
|
status: input.status,
|
|
88
88
|
requestId: input.requestId,
|
package/dist/files.d.ts
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export declare class
|
|
1
|
+
import type { V1HttpClient } from './http.js';
|
|
2
|
+
import type { V1File, V1FileDeleteResponse, V1FilesListQuery, V1FileUpdateRequest, V1FileUploadRequest, V1ListEnvelope, V1RunFilesExportRequest, V1RunFilesListQuery } from './types.js';
|
|
3
|
+
export declare class V1FileResource {
|
|
4
4
|
private readonly http;
|
|
5
|
-
readonly data:
|
|
6
|
-
constructor(http:
|
|
5
|
+
readonly data: V1File;
|
|
6
|
+
constructor(http: V1HttpClient, data: V1File);
|
|
7
7
|
get id(): string;
|
|
8
|
-
refresh(): Promise<
|
|
8
|
+
refresh(): Promise<V1FileResource>;
|
|
9
9
|
content(): Promise<Response>;
|
|
10
|
-
update(request:
|
|
11
|
-
delete(): Promise<
|
|
10
|
+
update(request: V1FileUpdateRequest): Promise<V1FileResource>;
|
|
11
|
+
delete(): Promise<V1FileDeleteResponse>;
|
|
12
12
|
}
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class V1FilesClient {
|
|
14
14
|
private readonly http;
|
|
15
|
-
constructor(http:
|
|
16
|
-
list(query:
|
|
17
|
-
iter(query:
|
|
18
|
-
get(id: string): Promise<
|
|
19
|
-
update(id: string, request:
|
|
15
|
+
constructor(http: V1HttpClient);
|
|
16
|
+
list(query: V1FilesListQuery): Promise<V1ListEnvelope<V1File>>;
|
|
17
|
+
iter(query: V1FilesListQuery): AsyncGenerator<V1File, void, undefined>;
|
|
18
|
+
get(id: string): Promise<V1FileResource>;
|
|
19
|
+
update(id: string, request: V1FileUpdateRequest): Promise<V1FileResource>;
|
|
20
20
|
content(id: string): Promise<Response>;
|
|
21
|
-
delete(id: string): Promise<
|
|
22
|
-
upload(request:
|
|
21
|
+
delete(id: string): Promise<V1FileDeleteResponse>;
|
|
22
|
+
upload(request: V1FileUploadRequest): Promise<V1FileResource>;
|
|
23
23
|
}
|
|
24
|
-
export declare class
|
|
24
|
+
export declare class V1RunFilesClient {
|
|
25
25
|
private readonly http;
|
|
26
26
|
private readonly runId;
|
|
27
|
-
constructor(http:
|
|
28
|
-
list(query?:
|
|
29
|
-
iter(query?:
|
|
30
|
-
export(request:
|
|
27
|
+
constructor(http: V1HttpClient, runId: string);
|
|
28
|
+
list(query?: V1RunFilesListQuery): Promise<V1ListEnvelope<V1File>>;
|
|
29
|
+
iter(query?: V1RunFilesListQuery): AsyncGenerator<V1File, void, undefined>;
|
|
30
|
+
export(request: V1RunFilesExportRequest): Promise<V1FileResource>;
|
|
31
31
|
}
|
package/dist/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export class
|
|
1
|
+
import { iterateV1Pages } from './pagination.js';
|
|
2
|
+
export class V1FileResource {
|
|
3
3
|
http;
|
|
4
4
|
data;
|
|
5
5
|
constructor(http, data) {
|
|
@@ -10,19 +10,19 @@ export class V2FileResource {
|
|
|
10
10
|
return this.data.id;
|
|
11
11
|
}
|
|
12
12
|
refresh() {
|
|
13
|
-
return new
|
|
13
|
+
return new V1FilesClient(this.http).get(this.id);
|
|
14
14
|
}
|
|
15
15
|
async content() {
|
|
16
|
-
return new
|
|
16
|
+
return new V1FilesClient(this.http).content(this.id);
|
|
17
17
|
}
|
|
18
18
|
async update(request) {
|
|
19
|
-
return new
|
|
19
|
+
return new V1FilesClient(this.http).update(this.id, request);
|
|
20
20
|
}
|
|
21
21
|
delete() {
|
|
22
|
-
return new
|
|
22
|
+
return new V1FilesClient(this.http).delete(this.id);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export class
|
|
25
|
+
export class V1FilesClient {
|
|
26
26
|
http;
|
|
27
27
|
constructor(http) {
|
|
28
28
|
this.http = http;
|
|
@@ -31,18 +31,18 @@ export class V2FilesClient {
|
|
|
31
31
|
return this.http.request('/files', { query });
|
|
32
32
|
}
|
|
33
33
|
iter(query) {
|
|
34
|
-
return
|
|
34
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
35
35
|
}
|
|
36
36
|
async get(id) {
|
|
37
37
|
const file = await this.http.request(`/files/${encodeURIComponent(id)}`);
|
|
38
|
-
return new
|
|
38
|
+
return new V1FileResource(this.http, file);
|
|
39
39
|
}
|
|
40
40
|
async update(id, request) {
|
|
41
41
|
const file = await this.http.request(`/files/${encodeURIComponent(id)}`, {
|
|
42
42
|
method: 'PATCH',
|
|
43
43
|
body: request,
|
|
44
44
|
});
|
|
45
|
-
return new
|
|
45
|
+
return new V1FileResource(this.http, file);
|
|
46
46
|
}
|
|
47
47
|
content(id) {
|
|
48
48
|
return this.http.raw(`/files/${encodeURIComponent(id)}/content`);
|
|
@@ -71,10 +71,10 @@ export class V2FilesClient {
|
|
|
71
71
|
query: { spaceId: request.spaceId },
|
|
72
72
|
body: form,
|
|
73
73
|
});
|
|
74
|
-
return new
|
|
74
|
+
return new V1FileResource(this.http, file);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
export class
|
|
77
|
+
export class V1RunFilesClient {
|
|
78
78
|
http;
|
|
79
79
|
runId;
|
|
80
80
|
constructor(http, runId) {
|
|
@@ -85,13 +85,13 @@ export class V2RunFilesClient {
|
|
|
85
85
|
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/files`, { query });
|
|
86
86
|
}
|
|
87
87
|
iter(query = {}) {
|
|
88
|
-
return
|
|
88
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
89
89
|
}
|
|
90
90
|
async export(request) {
|
|
91
91
|
const file = await this.http.request(`/runs/${encodeURIComponent(this.runId)}/files/export`, {
|
|
92
92
|
method: 'POST',
|
|
93
93
|
body: request,
|
|
94
94
|
});
|
|
95
|
-
return new
|
|
95
|
+
return new V1FileResource(this.http, file);
|
|
96
96
|
}
|
|
97
97
|
}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface V1ClientOptions {
|
|
2
2
|
apiKey?: string;
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
}
|
|
5
|
-
export interface
|
|
5
|
+
export interface V1RequestOptions {
|
|
6
6
|
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
7
7
|
query?: object;
|
|
8
8
|
body?: unknown;
|
|
9
9
|
headers?: Record<string, string>;
|
|
10
10
|
timeoutMs?: number;
|
|
11
11
|
}
|
|
12
|
-
export declare class
|
|
12
|
+
export declare class V1HttpClient {
|
|
13
13
|
readonly baseUrl: string;
|
|
14
14
|
readonly apiKey: string;
|
|
15
|
-
constructor(options:
|
|
16
|
-
request<T>(path: string, options?:
|
|
17
|
-
raw(path: string, options?:
|
|
15
|
+
constructor(options: V1ClientOptions);
|
|
16
|
+
request<T>(path: string, options?: V1RequestOptions): Promise<T>;
|
|
17
|
+
raw(path: string, options?: V1RequestOptions): Promise<Response>;
|
|
18
18
|
}
|
package/dist/http.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { BctrlNetworkError,
|
|
1
|
+
import { BctrlNetworkError, createV1HttpError } from './errors.js';
|
|
2
2
|
import { BCTRL_PRODUCTION_ORIGIN, fetchWithTimeout, resolveApiKey, stripTrailingSlash, } from './utils.js';
|
|
3
3
|
import { SDK_VERSION } from './version.js';
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const raw = stripTrailingSlash(baseUrl?.trim() ||
|
|
7
|
-
|
|
4
|
+
const API_PREFIX = '/v1';
|
|
5
|
+
function resolveV1ApiBaseUrl(baseUrl) {
|
|
6
|
+
const raw = stripTrailingSlash(baseUrl?.trim() ||
|
|
7
|
+
process.env.BCTRL_BASE_URL?.trim() ||
|
|
8
|
+
process.env.BCTRL_API_BASE_URL?.trim() ||
|
|
9
|
+
BCTRL_PRODUCTION_ORIGIN);
|
|
10
|
+
if (raw.endsWith(API_PREFIX)) {
|
|
8
11
|
return raw;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
return `${raw.slice(0, -3)}${V2_PREFIX}`;
|
|
12
|
-
}
|
|
13
|
-
return `${raw}${V2_PREFIX}`;
|
|
13
|
+
return `${raw}${API_PREFIX}`;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function resolveV1ApiKey(apiKey) {
|
|
16
16
|
return resolveApiKey(apiKey ?? process.env.BCTRL_API_KEY ?? '');
|
|
17
17
|
}
|
|
18
18
|
function appendQuery(params, key, value) {
|
|
@@ -50,7 +50,7 @@ function responseRequestId(response) {
|
|
|
50
50
|
function isRecord(value) {
|
|
51
51
|
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function parseV1ErrorBody(parsed, fallbackText) {
|
|
54
54
|
if (isRecord(parsed) && typeof parsed.error === 'string') {
|
|
55
55
|
return {
|
|
56
56
|
error: parsed.error,
|
|
@@ -70,12 +70,12 @@ function isBodyInit(value) {
|
|
|
70
70
|
value instanceof URLSearchParams ||
|
|
71
71
|
value instanceof ArrayBuffer);
|
|
72
72
|
}
|
|
73
|
-
export class
|
|
73
|
+
export class V1HttpClient {
|
|
74
74
|
baseUrl;
|
|
75
75
|
apiKey;
|
|
76
76
|
constructor(options) {
|
|
77
|
-
this.baseUrl =
|
|
78
|
-
this.apiKey =
|
|
77
|
+
this.baseUrl = resolveV1ApiBaseUrl(options.baseUrl);
|
|
78
|
+
this.apiKey = resolveV1ApiKey(options.apiKey);
|
|
79
79
|
}
|
|
80
80
|
async request(path, options = {}) {
|
|
81
81
|
const response = await this.raw(path, options);
|
|
@@ -92,7 +92,7 @@ export class V2HttpClient {
|
|
|
92
92
|
Accept: 'application/json',
|
|
93
93
|
Authorization: `Bearer ${this.apiKey}`,
|
|
94
94
|
'x-sdk-version': SDK_VERSION,
|
|
95
|
-
'User-Agent': `@bctrl/sdk/${SDK_VERSION}
|
|
95
|
+
'User-Agent': `@bctrl/sdk/${SDK_VERSION} v1`,
|
|
96
96
|
...options.headers,
|
|
97
97
|
};
|
|
98
98
|
const init = {
|
|
@@ -121,8 +121,8 @@ export class V2HttpClient {
|
|
|
121
121
|
if (!response.ok) {
|
|
122
122
|
const text = await response.text();
|
|
123
123
|
const parsed = parseResponseBody(text);
|
|
124
|
-
const errorBody =
|
|
125
|
-
throw
|
|
124
|
+
const errorBody = parseV1ErrorBody(parsed, text);
|
|
125
|
+
throw createV1HttpError({
|
|
126
126
|
status: response.status,
|
|
127
127
|
message: errorBody.error,
|
|
128
128
|
code: errorBody.code,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { Bctrl,
|
|
1
|
+
export { Bctrl, BctrlV1, type BctrlV1Options } from './bctrl.js';
|
|
2
2
|
export { BctrlError, BctrlApiError, BctrlAuthenticationError, BctrlConflictError, BctrlNetworkError, BctrlNotFoundError, BctrlNotReadyError, BctrlPermissionError, BctrlRateLimitError, BctrlUnsupportedError, BctrlValidationError, isControllerBusy, } from './errors.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
3
|
+
export { V1FileResource, V1FilesClient, V1RunFilesClient } from './files.js';
|
|
4
|
+
export { V1InvocationsClient, V1InvocationResource, V1RuntimeBrowserUseInvocationsClient, V1RuntimeInvocationsClient, V1RuntimeStagehandInvocationsClient, } from './invocations.js';
|
|
5
|
+
export type { BrowserUseAgentOptions, StagehandActOptions, StagehandAgentOptions, StagehandExtractOptions, StagehandObserveOptions, StagehandVariablePrimitive, StagehandVariableValue, StagehandVariables, } from './invocations.js';
|
|
6
|
+
export { V1RuntimeConnectionResource, V1RuntimeConnectionsClient, V1RuntimeFilesClient, V1RuntimeResource, V1RuntimeRunsClient, V1RuntimesClient, } from './runtimes.js';
|
|
7
|
+
export { V1RunCommandsClient, V1RunEventsClient, V1RunResource, V1RunsClient, } from './runs.js';
|
|
8
|
+
export { V1SpaceEnvironmentClient, V1SpaceResource, V1SpaceRuntimesClient, V1SpacesClient, } from './spaces.js';
|
|
9
9
|
export type * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export { Bctrl,
|
|
1
|
+
export { Bctrl, BctrlV1 } from './bctrl.js';
|
|
2
2
|
export { BctrlError, BctrlApiError, BctrlAuthenticationError, BctrlConflictError, BctrlNetworkError, BctrlNotFoundError, BctrlNotReadyError, BctrlPermissionError, BctrlRateLimitError, BctrlUnsupportedError, BctrlValidationError, isControllerBusy, } from './errors.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export { V2SpaceEnvironmentClient, V2SpaceResource, V2SpaceRuntimesClient, V2SpacesClient, } from './spaces.js';
|
|
3
|
+
export { V1FileResource, V1FilesClient, V1RunFilesClient } from './files.js';
|
|
4
|
+
export { V1InvocationsClient, V1InvocationResource, V1RuntimeBrowserUseInvocationsClient, V1RuntimeInvocationsClient, V1RuntimeStagehandInvocationsClient, } from './invocations.js';
|
|
5
|
+
export { V1RuntimeConnectionResource, V1RuntimeConnectionsClient, V1RuntimeFilesClient, V1RuntimeResource, V1RuntimeRunsClient, V1RuntimesClient, } from './runtimes.js';
|
|
6
|
+
export { V1RunCommandsClient, V1RunEventsClient, V1RunResource, V1RunsClient, } from './runs.js';
|
|
7
|
+
export { V1SpaceEnvironmentClient, V1SpaceResource, V1SpaceRuntimesClient, V1SpacesClient, } from './spaces.js';
|
package/dist/invocations.d.ts
CHANGED
|
@@ -1,24 +1,86 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
1
|
+
import type { V1HttpClient } from './http.js';
|
|
2
|
+
import type { JsonObject, V1Invocation, V1RuntimeInvocationCreateRequest, V1RuntimeInvocationFileInput, V1InvocationWaitRequest, V1InvocationWaitResponse } from './types.js';
|
|
3
|
+
type JsonSchemaLike = JsonObject | {
|
|
4
|
+
toJSONSchema: () => unknown;
|
|
5
|
+
};
|
|
6
|
+
export type StagehandVariablePrimitive = string | number | boolean;
|
|
7
|
+
export type StagehandVariableValue = StagehandVariablePrimitive | {
|
|
8
|
+
value: StagehandVariablePrimitive;
|
|
9
|
+
description?: string;
|
|
10
|
+
};
|
|
11
|
+
export type StagehandVariables = Record<string, StagehandVariableValue>;
|
|
12
|
+
interface RuntimeInvocationCommonOptions {
|
|
13
|
+
target?: JsonObject;
|
|
14
|
+
idempotencyKey?: string;
|
|
15
|
+
metadata?: JsonObject;
|
|
16
|
+
}
|
|
17
|
+
interface RuntimeAgentCommonOptions extends RuntimeInvocationCommonOptions {
|
|
18
|
+
toolsetId?: string;
|
|
19
|
+
files?: V1RuntimeInvocationFileInput[];
|
|
20
|
+
outputSchema?: JsonObject;
|
|
21
|
+
}
|
|
22
|
+
export interface StagehandActOptions extends RuntimeInvocationCommonOptions {
|
|
23
|
+
instruction: string;
|
|
24
|
+
timeoutMs?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface StagehandObserveOptions extends RuntimeInvocationCommonOptions {
|
|
27
|
+
instruction: string;
|
|
28
|
+
selector?: string;
|
|
29
|
+
timeoutMs?: number;
|
|
30
|
+
}
|
|
31
|
+
export type StagehandExtractOptions<TSchema extends JsonSchemaLike | undefined = undefined> = RuntimeInvocationCommonOptions & {
|
|
32
|
+
instruction: string;
|
|
33
|
+
schema?: TSchema;
|
|
34
|
+
};
|
|
35
|
+
export interface StagehandAgentOptions extends RuntimeAgentCommonOptions {
|
|
36
|
+
instruction: string;
|
|
37
|
+
maxSteps?: number;
|
|
38
|
+
timeoutMs?: number;
|
|
39
|
+
variables?: StagehandVariables;
|
|
40
|
+
config?: JsonObject;
|
|
41
|
+
options?: JsonObject;
|
|
42
|
+
}
|
|
43
|
+
export interface BrowserUseAgentOptions extends RuntimeAgentCommonOptions {
|
|
44
|
+
instruction: string;
|
|
45
|
+
maxSteps?: number;
|
|
46
|
+
config?: JsonObject;
|
|
47
|
+
options?: JsonObject;
|
|
48
|
+
}
|
|
49
|
+
export declare class V1InvocationResource {
|
|
4
50
|
private readonly http;
|
|
5
|
-
readonly data:
|
|
6
|
-
constructor(http:
|
|
51
|
+
readonly data: V1Invocation;
|
|
52
|
+
constructor(http: V1HttpClient, data: V1Invocation);
|
|
7
53
|
get id(): string;
|
|
8
|
-
refresh(): Promise<
|
|
9
|
-
wait(request?:
|
|
10
|
-
cancel(): Promise<
|
|
54
|
+
refresh(): Promise<V1Invocation>;
|
|
55
|
+
wait(request?: V1InvocationWaitRequest): Promise<V1InvocationWaitResponse>;
|
|
56
|
+
cancel(): Promise<V1Invocation>;
|
|
11
57
|
}
|
|
12
|
-
export declare class
|
|
58
|
+
export declare class V1InvocationsClient {
|
|
13
59
|
private readonly http;
|
|
14
|
-
constructor(http:
|
|
15
|
-
get(id: string): Promise<
|
|
16
|
-
wait(id: string, request?:
|
|
17
|
-
cancel(id: string): Promise<
|
|
60
|
+
constructor(http: V1HttpClient);
|
|
61
|
+
get(id: string): Promise<V1InvocationResource>;
|
|
62
|
+
wait(id: string, request?: V1InvocationWaitRequest): Promise<V1InvocationWaitResponse>;
|
|
63
|
+
cancel(id: string): Promise<V1InvocationResource>;
|
|
18
64
|
}
|
|
19
|
-
export declare class
|
|
65
|
+
export declare class V1RuntimeInvocationsClient {
|
|
20
66
|
private readonly http;
|
|
21
67
|
private readonly runtimeId;
|
|
22
|
-
|
|
23
|
-
|
|
68
|
+
readonly stagehand: V1RuntimeStagehandInvocationsClient;
|
|
69
|
+
readonly browserUse: V1RuntimeBrowserUseInvocationsClient;
|
|
70
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
71
|
+
create(request: V1RuntimeInvocationCreateRequest): Promise<V1InvocationResource>;
|
|
72
|
+
}
|
|
73
|
+
export declare class V1RuntimeStagehandInvocationsClient {
|
|
74
|
+
private readonly invocations;
|
|
75
|
+
constructor(invocations: V1RuntimeInvocationsClient);
|
|
76
|
+
act(options: StagehandActOptions): Promise<V1InvocationResource>;
|
|
77
|
+
observe(options: StagehandObserveOptions): Promise<V1InvocationResource>;
|
|
78
|
+
extract<TSchema extends JsonSchemaLike | undefined = undefined>(options: StagehandExtractOptions<TSchema>): Promise<V1InvocationResource>;
|
|
79
|
+
agent(options: StagehandAgentOptions): Promise<V1InvocationResource>;
|
|
80
|
+
}
|
|
81
|
+
export declare class V1RuntimeBrowserUseInvocationsClient {
|
|
82
|
+
private readonly invocations;
|
|
83
|
+
constructor(invocations: V1RuntimeInvocationsClient);
|
|
84
|
+
agent(options: BrowserUseAgentOptions): Promise<V1InvocationResource>;
|
|
24
85
|
}
|
|
86
|
+
export {};
|