@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/dist/invocations.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export class
|
|
1
|
+
export class V1InvocationResource {
|
|
2
2
|
http;
|
|
3
3
|
data;
|
|
4
4
|
constructor(http, data) {
|
|
@@ -27,14 +27,14 @@ export class V2InvocationResource {
|
|
|
27
27
|
.then((response) => response.data);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
export class
|
|
30
|
+
export class V1InvocationsClient {
|
|
31
31
|
http;
|
|
32
32
|
constructor(http) {
|
|
33
33
|
this.http = http;
|
|
34
34
|
}
|
|
35
35
|
async get(id) {
|
|
36
36
|
const response = await this.http.request(`/invocations/${encodeURIComponent(id)}`);
|
|
37
|
-
return new
|
|
37
|
+
return new V1InvocationResource(this.http, response.data);
|
|
38
38
|
}
|
|
39
39
|
wait(id, request) {
|
|
40
40
|
return this.http.request(`/invocations/${encodeURIComponent(id)}/wait`, {
|
|
@@ -46,21 +46,114 @@ export class V2InvocationsClient {
|
|
|
46
46
|
const response = await this.http.request(`/invocations/${encodeURIComponent(id)}/cancel`, {
|
|
47
47
|
method: 'POST',
|
|
48
48
|
});
|
|
49
|
-
return new
|
|
49
|
+
return new V1InvocationResource(this.http, response.data);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
export class
|
|
52
|
+
export class V1RuntimeInvocationsClient {
|
|
53
53
|
http;
|
|
54
54
|
runtimeId;
|
|
55
|
+
stagehand;
|
|
56
|
+
browserUse;
|
|
55
57
|
constructor(http, runtimeId) {
|
|
56
58
|
this.http = http;
|
|
57
59
|
this.runtimeId = runtimeId;
|
|
60
|
+
this.stagehand = new V1RuntimeStagehandInvocationsClient(this);
|
|
61
|
+
this.browserUse = new V1RuntimeBrowserUseInvocationsClient(this);
|
|
58
62
|
}
|
|
59
63
|
async create(request) {
|
|
60
64
|
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/invocations`, {
|
|
61
65
|
method: 'POST',
|
|
62
66
|
body: request,
|
|
63
67
|
});
|
|
64
|
-
return new
|
|
68
|
+
return new V1InvocationResource(this.http, response.data);
|
|
65
69
|
}
|
|
66
70
|
}
|
|
71
|
+
export class V1RuntimeStagehandInvocationsClient {
|
|
72
|
+
invocations;
|
|
73
|
+
constructor(invocations) {
|
|
74
|
+
this.invocations = invocations;
|
|
75
|
+
}
|
|
76
|
+
act(options) {
|
|
77
|
+
const { instruction, timeoutMs, ...common } = options;
|
|
78
|
+
return this.invocations.create({
|
|
79
|
+
provider: 'stagehand',
|
|
80
|
+
method: 'act',
|
|
81
|
+
...common,
|
|
82
|
+
input: {
|
|
83
|
+
instruction,
|
|
84
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
observe(options) {
|
|
89
|
+
const { instruction, selector, timeoutMs, ...common } = options;
|
|
90
|
+
return this.invocations.create({
|
|
91
|
+
provider: 'stagehand',
|
|
92
|
+
method: 'observe',
|
|
93
|
+
...common,
|
|
94
|
+
input: {
|
|
95
|
+
instruction,
|
|
96
|
+
...(selector !== undefined ? { selector } : {}),
|
|
97
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
extract(options) {
|
|
102
|
+
const { instruction, schema, ...common } = options;
|
|
103
|
+
return this.invocations.create({
|
|
104
|
+
provider: 'stagehand',
|
|
105
|
+
method: 'extract',
|
|
106
|
+
...common,
|
|
107
|
+
input: { instruction },
|
|
108
|
+
...(schema !== undefined ? { outputSchema: toJsonSchemaObject(schema) } : {}),
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
agent(options) {
|
|
112
|
+
const { instruction, maxSteps, timeoutMs, variables, config, options: agentOptions, ...common } = options;
|
|
113
|
+
return this.invocations.create({
|
|
114
|
+
provider: 'stagehand',
|
|
115
|
+
method: 'agent',
|
|
116
|
+
...common,
|
|
117
|
+
input: {
|
|
118
|
+
instruction,
|
|
119
|
+
...(maxSteps !== undefined ? { maxSteps } : {}),
|
|
120
|
+
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
121
|
+
...(variables !== undefined ? { variables } : {}),
|
|
122
|
+
},
|
|
123
|
+
...(config !== undefined ? { config } : {}),
|
|
124
|
+
...(agentOptions !== undefined ? { options: agentOptions } : {}),
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export class V1RuntimeBrowserUseInvocationsClient {
|
|
129
|
+
invocations;
|
|
130
|
+
constructor(invocations) {
|
|
131
|
+
this.invocations = invocations;
|
|
132
|
+
}
|
|
133
|
+
agent(options) {
|
|
134
|
+
const { instruction, maxSteps, config, options: agentOptions, ...common } = options;
|
|
135
|
+
return this.invocations.create({
|
|
136
|
+
provider: 'browserUse',
|
|
137
|
+
method: 'agent',
|
|
138
|
+
...common,
|
|
139
|
+
input: {
|
|
140
|
+
instruction,
|
|
141
|
+
...(maxSteps !== undefined ? { maxSteps } : {}),
|
|
142
|
+
},
|
|
143
|
+
...(config !== undefined ? { config } : {}),
|
|
144
|
+
...(agentOptions !== undefined ? { options: agentOptions } : {}),
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function toJsonSchemaObject(schema) {
|
|
149
|
+
const value = typeof schema.toJSONSchema === 'function' ? schema.toJSONSchema() : schema;
|
|
150
|
+
if (!isJsonObject(value)) {
|
|
151
|
+
throw new TypeError('Stagehand extract schema must resolve to a JSON object');
|
|
152
|
+
}
|
|
153
|
+
const { $schema, ...jsonSchema } = value;
|
|
154
|
+
void $schema;
|
|
155
|
+
return jsonSchema;
|
|
156
|
+
}
|
|
157
|
+
function isJsonObject(value) {
|
|
158
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
159
|
+
}
|
package/dist/pagination.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function
|
|
1
|
+
import type { V1ListEnvelope, V1PageQuery } from './types.js';
|
|
2
|
+
export declare function iterateV1Pages<T, Q extends V1PageQuery>(initialQuery: Q, fetchPage: (query: Q) => Promise<V1ListEnvelope<T>>): AsyncGenerator<T, void, undefined>;
|
package/dist/pagination.js
CHANGED
package/dist/runs.d.ts
CHANGED
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import type {
|
|
4
|
-
export declare class
|
|
1
|
+
import type { V1HttpClient } from './http.js';
|
|
2
|
+
import { V1RunFilesClient } from './files.js';
|
|
3
|
+
import type { V1ListEnvelope, V1Run, V1RunCommand, V1RunCommandsListQuery, V1RunEvent, V1RunEventsListQuery, V1RunEventsWaitRequest, V1RunEventsWaitResponse, V1RunListQuery, V1RunLiveRequest, V1RunLiveResponse, V1RunRecordingRequest, V1RunRecordingResponse, V1RunUsage } from './types.js';
|
|
4
|
+
export declare class V1RunEventsClient {
|
|
5
5
|
private readonly http;
|
|
6
6
|
private readonly runId;
|
|
7
|
-
constructor(http:
|
|
8
|
-
list(query?:
|
|
9
|
-
iter(query?:
|
|
10
|
-
wait(request?:
|
|
11
|
-
streamUrl(query?: Pick<
|
|
7
|
+
constructor(http: V1HttpClient, runId: string);
|
|
8
|
+
list(query?: V1RunEventsListQuery): Promise<V1ListEnvelope<V1RunEvent>>;
|
|
9
|
+
iter(query?: V1RunEventsListQuery): AsyncGenerator<V1RunEvent, void, undefined>;
|
|
10
|
+
wait(request?: V1RunEventsWaitRequest): Promise<V1RunEventsWaitResponse>;
|
|
11
|
+
streamUrl(query?: Pick<V1RunEventsListQuery, 'type' | 'category' | 'connectionId'>): string;
|
|
12
12
|
}
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class V1RunCommandsClient {
|
|
14
14
|
private readonly http;
|
|
15
15
|
private readonly runId;
|
|
16
|
-
constructor(http:
|
|
17
|
-
list(query?:
|
|
18
|
-
iter(query?:
|
|
16
|
+
constructor(http: V1HttpClient, runId: string);
|
|
17
|
+
list(query?: V1RunCommandsListQuery): Promise<V1ListEnvelope<V1RunCommand>>;
|
|
18
|
+
iter(query?: V1RunCommandsListQuery): AsyncGenerator<V1RunCommand, void, undefined>;
|
|
19
19
|
}
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class V1RunResource {
|
|
21
21
|
private readonly http;
|
|
22
|
-
readonly data:
|
|
23
|
-
readonly events:
|
|
24
|
-
readonly commands:
|
|
25
|
-
readonly files:
|
|
26
|
-
constructor(http:
|
|
22
|
+
readonly data: V1Run;
|
|
23
|
+
readonly events: V1RunEventsClient;
|
|
24
|
+
readonly commands: V1RunCommandsClient;
|
|
25
|
+
readonly files: V1RunFilesClient;
|
|
26
|
+
constructor(http: V1HttpClient, data: V1Run);
|
|
27
27
|
get id(): string;
|
|
28
|
-
refresh(): Promise<
|
|
29
|
-
live(request?:
|
|
30
|
-
recording(request?:
|
|
28
|
+
refresh(): Promise<V1RunResource>;
|
|
29
|
+
live(request?: V1RunLiveRequest): Promise<V1RunLiveResponse>;
|
|
30
|
+
recording(request?: V1RunRecordingRequest): Promise<V1RunRecordingResponse>;
|
|
31
|
+
usage(): Promise<V1RunUsage>;
|
|
31
32
|
}
|
|
32
|
-
export declare class
|
|
33
|
+
export declare class V1RunsClient {
|
|
33
34
|
private readonly http;
|
|
34
|
-
constructor(http:
|
|
35
|
-
list(query?:
|
|
36
|
-
iter(query?:
|
|
37
|
-
get(id: string): Promise<
|
|
35
|
+
constructor(http: V1HttpClient);
|
|
36
|
+
list(query?: V1RunListQuery): Promise<V1ListEnvelope<V1Run>>;
|
|
37
|
+
iter(query?: V1RunListQuery): AsyncGenerator<V1Run, void, undefined>;
|
|
38
|
+
get(id: string): Promise<V1RunResource>;
|
|
39
|
+
usage(id: string): Promise<V1RunUsage>;
|
|
38
40
|
}
|
package/dist/runs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export class
|
|
1
|
+
import { iterateV1Pages } from './pagination.js';
|
|
2
|
+
import { V1RunFilesClient } from './files.js';
|
|
3
|
+
export class V1RunEventsClient {
|
|
4
4
|
http;
|
|
5
5
|
runId;
|
|
6
6
|
constructor(http, runId) {
|
|
@@ -11,7 +11,7 @@ export class V2RunEventsClient {
|
|
|
11
11
|
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events`, { query });
|
|
12
12
|
}
|
|
13
13
|
iter(query = {}) {
|
|
14
|
-
return
|
|
14
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
15
15
|
}
|
|
16
16
|
wait(request) {
|
|
17
17
|
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events/wait`, {
|
|
@@ -35,7 +35,7 @@ export class V2RunEventsClient {
|
|
|
35
35
|
return url.toString();
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
export class
|
|
38
|
+
export class V1RunCommandsClient {
|
|
39
39
|
http;
|
|
40
40
|
runId;
|
|
41
41
|
constructor(http, runId) {
|
|
@@ -46,10 +46,10 @@ export class V2RunCommandsClient {
|
|
|
46
46
|
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/commands`, { query });
|
|
47
47
|
}
|
|
48
48
|
iter(query = {}) {
|
|
49
|
-
return
|
|
49
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
export class
|
|
52
|
+
export class V1RunResource {
|
|
53
53
|
http;
|
|
54
54
|
data;
|
|
55
55
|
events;
|
|
@@ -58,15 +58,15 @@ export class V2RunResource {
|
|
|
58
58
|
constructor(http, data) {
|
|
59
59
|
this.http = http;
|
|
60
60
|
this.data = data;
|
|
61
|
-
this.events = new
|
|
62
|
-
this.commands = new
|
|
63
|
-
this.files = new
|
|
61
|
+
this.events = new V1RunEventsClient(http, data.id);
|
|
62
|
+
this.commands = new V1RunCommandsClient(http, data.id);
|
|
63
|
+
this.files = new V1RunFilesClient(http, data.id);
|
|
64
64
|
}
|
|
65
65
|
get id() {
|
|
66
66
|
return this.data.id;
|
|
67
67
|
}
|
|
68
68
|
refresh() {
|
|
69
|
-
return new
|
|
69
|
+
return new V1RunsClient(this.http).get(this.id);
|
|
70
70
|
}
|
|
71
71
|
live(request) {
|
|
72
72
|
return this.http.request(`/runs/${encodeURIComponent(this.id)}/live`, {
|
|
@@ -80,8 +80,11 @@ export class V2RunResource {
|
|
|
80
80
|
body: request ?? {},
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
+
usage() {
|
|
84
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/usage`);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
|
-
export class
|
|
87
|
+
export class V1RunsClient {
|
|
85
88
|
http;
|
|
86
89
|
constructor(http) {
|
|
87
90
|
this.http = http;
|
|
@@ -90,10 +93,13 @@ export class V2RunsClient {
|
|
|
90
93
|
return this.http.request('/runs', { query });
|
|
91
94
|
}
|
|
92
95
|
iter(query = {}) {
|
|
93
|
-
return
|
|
96
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
94
97
|
}
|
|
95
98
|
async get(id) {
|
|
96
99
|
const run = await this.http.request(`/runs/${encodeURIComponent(id)}`);
|
|
97
|
-
return new
|
|
100
|
+
return new V1RunResource(this.http, run);
|
|
101
|
+
}
|
|
102
|
+
usage(id) {
|
|
103
|
+
return this.http.request(`/runs/${encodeURIComponent(id)}/usage`);
|
|
98
104
|
}
|
|
99
105
|
}
|
package/dist/runtimes.d.ts
CHANGED
|
@@ -1,73 +1,69 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
export declare class
|
|
1
|
+
import type { V1HttpClient } from './http.js';
|
|
2
|
+
import { V1RuntimeInvocationsClient } from './invocations.js';
|
|
3
|
+
import { V1RunResource } from './runs.js';
|
|
4
|
+
import type { V1ListEnvelope, V1File, V1Runtime, V1RuntimeConnection, V1RuntimeConnectionCreateOptions, V1RuntimeConnectionCreateResponse, V1RuntimeCreateRequest, V1RuntimeFileCollectRequest, V1RuntimeFileStageRequest, V1RuntimeFileUploadRequest, V1RuntimeFileUploadResponse, V1RuntimeStagedFile, V1RuntimeListQuery, V1RuntimeRunListQuery, V1RunSummary, V1SpaceRuntimeCreateRequest } from './types.js';
|
|
5
|
+
export declare class V1RuntimeConnectionResource {
|
|
6
6
|
private readonly http;
|
|
7
7
|
private readonly runtimeId;
|
|
8
|
-
readonly data:
|
|
9
|
-
constructor(http:
|
|
8
|
+
readonly data: V1RuntimeConnectionCreateResponse;
|
|
9
|
+
constructor(http: V1HttpClient, runtimeId: string, data: V1RuntimeConnectionCreateResponse);
|
|
10
10
|
get id(): string;
|
|
11
|
-
get endpoint():
|
|
11
|
+
get endpoint(): V1RuntimeConnectionCreateResponse['endpoint'];
|
|
12
12
|
get wsUrl(): string | undefined;
|
|
13
|
-
close(): Promise<
|
|
13
|
+
close(): Promise<V1RuntimeConnection>;
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class V1RuntimeConnectionsClient {
|
|
16
16
|
private readonly http;
|
|
17
17
|
private readonly runtimeId;
|
|
18
|
-
constructor(http:
|
|
19
|
-
create(request?:
|
|
20
|
-
|
|
21
|
-
status?: string | string[];
|
|
22
|
-
limit?: number;
|
|
23
|
-
}): Promise<V2ListEnvelope<V2RuntimeConnection>>;
|
|
24
|
-
delete(connectionId: string): Promise<V2RuntimeConnection>;
|
|
18
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
19
|
+
create(request?: V1RuntimeConnectionCreateOptions): Promise<V1RuntimeConnectionResource>;
|
|
20
|
+
delete(connectionId: string): Promise<V1RuntimeConnection>;
|
|
25
21
|
}
|
|
26
|
-
export declare class
|
|
22
|
+
export declare class V1RuntimeRunsClient {
|
|
27
23
|
private readonly http;
|
|
28
24
|
private readonly runtimeId;
|
|
29
|
-
constructor(http:
|
|
30
|
-
list(query?:
|
|
31
|
-
iter(query?:
|
|
25
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
26
|
+
list(query?: V1RuntimeRunListQuery): Promise<V1ListEnvelope<V1RunSummary>>;
|
|
27
|
+
iter(query?: V1RuntimeRunListQuery): AsyncGenerator<V1RunSummary, void, undefined>;
|
|
32
28
|
}
|
|
33
|
-
export declare class
|
|
29
|
+
export declare class V1RuntimeFilesClient {
|
|
34
30
|
private readonly http;
|
|
35
31
|
private readonly runtimeId;
|
|
36
|
-
constructor(http:
|
|
37
|
-
upload(request:
|
|
38
|
-
stage(request:
|
|
39
|
-
collect(request:
|
|
32
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
33
|
+
upload(request: V1RuntimeFileUploadRequest): Promise<V1RuntimeFileUploadResponse>;
|
|
34
|
+
stage(request: V1RuntimeFileStageRequest): Promise<V1RuntimeStagedFile>;
|
|
35
|
+
collect(request: V1RuntimeFileCollectRequest): Promise<V1File>;
|
|
40
36
|
}
|
|
41
|
-
export declare class
|
|
37
|
+
export declare class V1RuntimeResource {
|
|
42
38
|
private readonly http;
|
|
43
|
-
readonly data:
|
|
44
|
-
readonly connections:
|
|
45
|
-
readonly files:
|
|
46
|
-
readonly runs:
|
|
47
|
-
readonly invocations:
|
|
48
|
-
constructor(http:
|
|
39
|
+
readonly data: V1Runtime;
|
|
40
|
+
readonly connections: V1RuntimeConnectionsClient;
|
|
41
|
+
readonly files: V1RuntimeFilesClient;
|
|
42
|
+
readonly runs: V1RuntimeRunsClient;
|
|
43
|
+
readonly invocations: V1RuntimeInvocationsClient;
|
|
44
|
+
constructor(http: V1HttpClient, data: V1Runtime);
|
|
49
45
|
get id(): string;
|
|
50
46
|
get activeRunId(): string | null;
|
|
51
|
-
refresh(): Promise<
|
|
52
|
-
connect(request?:
|
|
47
|
+
refresh(): Promise<V1RuntimeResource>;
|
|
48
|
+
connect(request?: V1RuntimeConnectionCreateOptions): Promise<V1RuntimeConnectionResource>;
|
|
53
49
|
start(): Promise<{
|
|
54
|
-
runtime:
|
|
55
|
-
run:
|
|
50
|
+
runtime: V1RuntimeResource;
|
|
51
|
+
run: V1RunResource;
|
|
56
52
|
}>;
|
|
57
|
-
stop(): Promise<
|
|
58
|
-
run(): Promise<
|
|
53
|
+
stop(): Promise<V1Runtime>;
|
|
54
|
+
run(): Promise<V1RunResource>;
|
|
59
55
|
}
|
|
60
|
-
export declare class
|
|
56
|
+
export declare class V1RuntimesClient {
|
|
61
57
|
private readonly http;
|
|
62
|
-
constructor(http:
|
|
63
|
-
list(query?:
|
|
64
|
-
iter(query?:
|
|
65
|
-
create(request:
|
|
66
|
-
createInSpace(spaceId: string, request:
|
|
67
|
-
get(id: string): Promise<
|
|
68
|
-
stop(id: string): Promise<
|
|
58
|
+
constructor(http: V1HttpClient);
|
|
59
|
+
list(query?: V1RuntimeListQuery): Promise<V1ListEnvelope<V1Runtime>>;
|
|
60
|
+
iter(query?: V1RuntimeListQuery): AsyncGenerator<V1Runtime, void, undefined>;
|
|
61
|
+
create(request: V1RuntimeCreateRequest): Promise<V1RuntimeResource>;
|
|
62
|
+
createInSpace(spaceId: string, request: V1SpaceRuntimeCreateRequest): Promise<V1RuntimeResource>;
|
|
63
|
+
get(id: string): Promise<V1RuntimeResource>;
|
|
64
|
+
stop(id: string): Promise<V1Runtime>;
|
|
69
65
|
start(id: string): Promise<{
|
|
70
|
-
runtime:
|
|
71
|
-
run:
|
|
66
|
+
runtime: V1RuntimeResource;
|
|
67
|
+
run: V1RunResource;
|
|
72
68
|
}>;
|
|
73
69
|
}
|
package/dist/runtimes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BctrlValidationError } from './errors.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
export class
|
|
2
|
+
import { V1RuntimeInvocationsClient } from './invocations.js';
|
|
3
|
+
import { iterateV1Pages } from './pagination.js';
|
|
4
|
+
import { V1RunResource } from './runs.js';
|
|
5
|
+
export class V1RuntimeConnectionResource {
|
|
6
6
|
http;
|
|
7
7
|
runtimeId;
|
|
8
8
|
data;
|
|
@@ -24,7 +24,7 @@ export class V2RuntimeConnectionResource {
|
|
|
24
24
|
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(this.id)}`, { method: 'DELETE' });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
export class
|
|
27
|
+
export class V1RuntimeConnectionsClient {
|
|
28
28
|
http;
|
|
29
29
|
runtimeId;
|
|
30
30
|
constructor(http, runtimeId) {
|
|
@@ -39,16 +39,13 @@ export class V2RuntimeConnectionsClient {
|
|
|
39
39
|
...request,
|
|
40
40
|
},
|
|
41
41
|
});
|
|
42
|
-
return new
|
|
43
|
-
}
|
|
44
|
-
list(query = {}) {
|
|
45
|
-
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections`, { query });
|
|
42
|
+
return new V1RuntimeConnectionResource(this.http, this.runtimeId, response);
|
|
46
43
|
}
|
|
47
44
|
delete(connectionId) {
|
|
48
45
|
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(connectionId)}`, { method: 'DELETE' });
|
|
49
46
|
}
|
|
50
47
|
}
|
|
51
|
-
export class
|
|
48
|
+
export class V1RuntimeRunsClient {
|
|
52
49
|
http;
|
|
53
50
|
runtimeId;
|
|
54
51
|
constructor(http, runtimeId) {
|
|
@@ -59,10 +56,10 @@ export class V2RuntimeRunsClient {
|
|
|
59
56
|
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/runs`, { query });
|
|
60
57
|
}
|
|
61
58
|
iter(query = {}) {
|
|
62
|
-
return
|
|
59
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
63
60
|
}
|
|
64
61
|
}
|
|
65
|
-
export class
|
|
62
|
+
export class V1RuntimeFilesClient {
|
|
66
63
|
http;
|
|
67
64
|
runtimeId;
|
|
68
65
|
constructor(http, runtimeId) {
|
|
@@ -100,7 +97,7 @@ export class V2RuntimeFilesClient {
|
|
|
100
97
|
});
|
|
101
98
|
}
|
|
102
99
|
}
|
|
103
|
-
export class
|
|
100
|
+
export class V1RuntimeResource {
|
|
104
101
|
http;
|
|
105
102
|
data;
|
|
106
103
|
connections;
|
|
@@ -110,10 +107,10 @@ export class V2RuntimeResource {
|
|
|
110
107
|
constructor(http, data) {
|
|
111
108
|
this.http = http;
|
|
112
109
|
this.data = data;
|
|
113
|
-
this.connections = new
|
|
114
|
-
this.files = new
|
|
115
|
-
this.runs = new
|
|
116
|
-
this.invocations = new
|
|
110
|
+
this.connections = new V1RuntimeConnectionsClient(http, data.id);
|
|
111
|
+
this.files = new V1RuntimeFilesClient(http, data.id);
|
|
112
|
+
this.runs = new V1RuntimeRunsClient(http, data.id);
|
|
113
|
+
this.invocations = new V1RuntimeInvocationsClient(http, data.id);
|
|
117
114
|
}
|
|
118
115
|
get id() {
|
|
119
116
|
return this.data.id;
|
|
@@ -122,7 +119,7 @@ export class V2RuntimeResource {
|
|
|
122
119
|
return this.data.activeRunId;
|
|
123
120
|
}
|
|
124
121
|
refresh() {
|
|
125
|
-
return new
|
|
122
|
+
return new V1RuntimesClient(this.http).get(this.id);
|
|
126
123
|
}
|
|
127
124
|
async connect(request) {
|
|
128
125
|
return this.connections.create(request);
|
|
@@ -130,8 +127,8 @@ export class V2RuntimeResource {
|
|
|
130
127
|
async start() {
|
|
131
128
|
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.id)}/start`, { method: 'POST' });
|
|
132
129
|
return {
|
|
133
|
-
runtime: new
|
|
134
|
-
run: new
|
|
130
|
+
runtime: new V1RuntimeResource(this.http, response.runtime),
|
|
131
|
+
run: new V1RunResource(this.http, response.run),
|
|
135
132
|
};
|
|
136
133
|
}
|
|
137
134
|
stop() {
|
|
@@ -147,7 +144,7 @@ export class V2RuntimeResource {
|
|
|
147
144
|
});
|
|
148
145
|
}
|
|
149
146
|
const run = await this.http.request(`/runs/${encodeURIComponent(runtime.activeRunId)}`);
|
|
150
|
-
return new
|
|
147
|
+
return new V1RunResource(this.http, run);
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
150
|
function validateRuntimeCreateRequest(request) {
|
|
@@ -162,7 +159,7 @@ function validateRuntimeCreateRequest(request) {
|
|
|
162
159
|
throw new BctrlValidationError('Only config.browser.profile and config.lifecycle are supported for profile-backed browser runtimes', 'runtime.profile_config_unsupported', { unsupported });
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
|
-
export class
|
|
162
|
+
export class V1RuntimesClient {
|
|
166
163
|
http;
|
|
167
164
|
constructor(http) {
|
|
168
165
|
this.http = http;
|
|
@@ -171,7 +168,7 @@ export class V2RuntimesClient {
|
|
|
171
168
|
return this.http.request('/runtimes', { query });
|
|
172
169
|
}
|
|
173
170
|
iter(query = {}) {
|
|
174
|
-
return
|
|
171
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
175
172
|
}
|
|
176
173
|
async create(request) {
|
|
177
174
|
validateRuntimeCreateRequest(request);
|
|
@@ -179,7 +176,7 @@ export class V2RuntimesClient {
|
|
|
179
176
|
method: 'POST',
|
|
180
177
|
body: request,
|
|
181
178
|
});
|
|
182
|
-
return new
|
|
179
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
183
180
|
}
|
|
184
181
|
async createInSpace(spaceId, request) {
|
|
185
182
|
validateRuntimeCreateRequest(request);
|
|
@@ -187,11 +184,11 @@ export class V2RuntimesClient {
|
|
|
187
184
|
method: 'POST',
|
|
188
185
|
body: { ...request, spaceId },
|
|
189
186
|
});
|
|
190
|
-
return new
|
|
187
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
191
188
|
}
|
|
192
189
|
async get(id) {
|
|
193
190
|
const runtime = await this.http.request(`/runtimes/${encodeURIComponent(id)}`);
|
|
194
|
-
return new
|
|
191
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
195
192
|
}
|
|
196
193
|
stop(id) {
|
|
197
194
|
return this.http.request(`/runtimes/${encodeURIComponent(id)}/stop`, {
|
package/dist/spaces.d.ts
CHANGED
|
@@ -1,41 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare class V2SpaceEnvironmentClient {
|
|
1
|
+
import type { V1HttpClient } from './http.js';
|
|
2
|
+
import { V1RuntimeResource, V1RuntimesClient } from './runtimes.js';
|
|
3
|
+
import type { V1ListEnvelope, V1RuntimeListQuery, V1Space, V1SpaceCreateRequest, V1SpaceEnvironment, V1SpaceEnvironmentUpdateRequest, V1SpaceRuntimeCreateRequest, V1SpaceUpdateRequest } from './types.js';
|
|
4
|
+
export declare class V1SpaceEnvironmentClient {
|
|
6
5
|
private readonly http;
|
|
7
6
|
private readonly spaceId;
|
|
8
|
-
constructor(http:
|
|
9
|
-
get(): Promise<
|
|
10
|
-
update(request:
|
|
7
|
+
constructor(http: V1HttpClient, spaceId: string);
|
|
8
|
+
get(): Promise<V1SpaceEnvironment>;
|
|
9
|
+
update(request: V1SpaceEnvironmentUpdateRequest): Promise<V1SpaceEnvironment>;
|
|
11
10
|
}
|
|
12
|
-
export declare class
|
|
11
|
+
export declare class V1SpaceRuntimesClient {
|
|
13
12
|
private readonly http;
|
|
14
13
|
private readonly spaceId;
|
|
15
|
-
constructor(http:
|
|
16
|
-
list(query?: Omit<
|
|
17
|
-
iter(query?: Omit<
|
|
18
|
-
create(request:
|
|
19
|
-
get(runtimeId: string): Promise<
|
|
20
|
-
stop(runtimeId: string): ReturnType<
|
|
14
|
+
constructor(http: V1HttpClient, spaceId: string);
|
|
15
|
+
list(query?: Omit<V1RuntimeListQuery, 'spaceId'>): ReturnType<V1RuntimesClient['list']>;
|
|
16
|
+
iter(query?: Omit<V1RuntimeListQuery, 'spaceId'>): ReturnType<V1RuntimesClient['iter']>;
|
|
17
|
+
create(request: V1SpaceRuntimeCreateRequest): Promise<V1RuntimeResource>;
|
|
18
|
+
get(runtimeId: string): Promise<V1RuntimeResource>;
|
|
19
|
+
stop(runtimeId: string): ReturnType<V1RuntimesClient['stop']>;
|
|
20
|
+
start(runtimeId: string): ReturnType<V1RuntimesClient['start']>;
|
|
21
21
|
}
|
|
22
|
-
export declare class
|
|
22
|
+
export declare class V1SpaceResource {
|
|
23
23
|
private readonly http;
|
|
24
|
-
readonly data:
|
|
25
|
-
readonly environment:
|
|
26
|
-
readonly runtimes:
|
|
27
|
-
|
|
28
|
-
constructor(http: V2HttpClient, data: V2Space);
|
|
24
|
+
readonly data: V1Space;
|
|
25
|
+
readonly environment: V1SpaceEnvironmentClient;
|
|
26
|
+
readonly runtimes: V1SpaceRuntimesClient;
|
|
27
|
+
constructor(http: V1HttpClient, data: V1Space);
|
|
29
28
|
get id(): string;
|
|
30
|
-
refresh(): Promise<
|
|
31
|
-
update(request:
|
|
29
|
+
refresh(): Promise<V1SpaceResource>;
|
|
30
|
+
update(request: V1SpaceUpdateRequest): Promise<V1SpaceResource>;
|
|
32
31
|
}
|
|
33
|
-
export declare class
|
|
32
|
+
export declare class V1SpacesClient {
|
|
34
33
|
private readonly http;
|
|
35
|
-
constructor(http:
|
|
36
|
-
list(): Promise<
|
|
37
|
-
iter(): AsyncGenerator<
|
|
38
|
-
create(request:
|
|
39
|
-
get(id: string): Promise<
|
|
40
|
-
update(id: string, request:
|
|
34
|
+
constructor(http: V1HttpClient);
|
|
35
|
+
list(): Promise<V1ListEnvelope<V1Space>>;
|
|
36
|
+
iter(): AsyncGenerator<V1Space, void, undefined>;
|
|
37
|
+
create(request: V1SpaceCreateRequest): Promise<V1SpaceResource>;
|
|
38
|
+
get(id: string): Promise<V1SpaceResource>;
|
|
39
|
+
update(id: string, request: V1SpaceUpdateRequest): Promise<V1SpaceResource>;
|
|
41
40
|
}
|