@bctrl/sdk 1.0.1 → 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 +28 -29
- package/dist/bctrl.d.ts +22 -36
- package/dist/bctrl.js +40 -75
- package/dist/errors.d.ts +49 -43
- package/dist/errors.js +83 -120
- package/dist/files.d.ts +31 -0
- package/dist/files.js +97 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.js +135 -0
- package/dist/index.d.ts +9 -12
- package/dist/index.js +7 -23
- package/dist/invocations.d.ts +86 -0
- package/dist/invocations.js +159 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +13 -0
- package/dist/runs.d.ts +40 -0
- package/dist/runs.js +105 -0
- package/dist/runtimes.d.ts +69 -0
- package/dist/runtimes.js +202 -0
- package/dist/spaces.d.ts +40 -0
- package/dist/spaces.js +96 -0
- package/dist/types.d.ts +413 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +27 -0
- package/dist/version.js +2 -2
- package/package.json +4 -21
- package/dist/agents/browser-use/index.d.ts +0 -1
- package/dist/agents/browser-use/index.js +0 -9
- package/dist/agents/browser-use/namespace.d.ts +0 -39
- package/dist/agents/browser-use/namespace.js +0 -93
- package/dist/agents/index.d.ts +0 -2
- package/dist/agents/index.js +0 -17
- package/dist/agents/stagehand/core.d.ts +0 -93
- package/dist/agents/stagehand/core.js +0 -144
- package/dist/agents/stagehand/index.d.ts +0 -3
- package/dist/agents/stagehand/index.js +0 -24
- package/dist/agents/stagehand/namespace.d.ts +0 -51
- package/dist/agents/stagehand/namespace.js +0 -65
- package/dist/ai-credentials/client.d.ts +0 -12
- package/dist/ai-credentials/client.js +0 -70
- package/dist/ai-credentials/index.d.ts +0 -1
- package/dist/ai-credentials/index.js +0 -1
- package/dist/base/event-binding.d.ts +0 -7
- package/dist/base/event-binding.js +0 -23
- package/dist/base/types.d.ts +0 -109
- package/dist/base/types.js +0 -4
- package/dist/browser-extensions/client.d.ts +0 -15
- package/dist/browser-extensions/client.js +0 -72
- package/dist/browser-extensions/index.d.ts +0 -2
- package/dist/browser-extensions/index.js +0 -1
- package/dist/browser-profiles/client.d.ts +0 -11
- package/dist/browser-profiles/client.js +0 -63
- package/dist/browser-profiles/index.d.ts +0 -1
- package/dist/browser-profiles/index.js +0 -1
- package/dist/captcha/index.d.ts +0 -1
- package/dist/captcha/index.js +0 -1
- package/dist/captcha/namespace.d.ts +0 -34
- package/dist/captcha/namespace.js +0 -41
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +0 -1
- package/dist/client/rpc.d.ts +0 -83
- package/dist/client/rpc.js +0 -354
- package/dist/config.d.ts +0 -5
- package/dist/config.js +0 -28
- package/dist/constants/browser.d.ts +0 -2
- package/dist/constants/browser.js +0 -1
- package/dist/contracts/agent-tools.d.ts +0 -45
- package/dist/contracts/agent-tools.js +0 -31
- package/dist/contracts/automation.d.ts +0 -265
- package/dist/contracts/automation.js +0 -109
- package/dist/contracts/browser-management.d.ts +0 -179
- package/dist/contracts/browser-management.js +0 -95
- package/dist/contracts/browser-use.d.ts +0 -136
- package/dist/contracts/browser-use.js +0 -93
- package/dist/contracts/captcha.d.ts +0 -114
- package/dist/contracts/captcha.js +0 -40
- package/dist/contracts/desktop.d.ts +0 -223
- package/dist/contracts/desktop.js +0 -121
- package/dist/contracts/drivers/playwright.d.ts +0 -2008
- package/dist/contracts/drivers/playwright.js +0 -2033
- package/dist/contracts/drivers/puppeteer.d.ts +0 -1221
- package/dist/contracts/drivers/puppeteer.js +0 -941
- package/dist/contracts/drivers/selenium.d.ts +0 -156
- package/dist/contracts/drivers/selenium.js +0 -61
- package/dist/contracts/drivers/stagehand.d.ts +0 -155
- package/dist/contracts/drivers/stagehand.js +0 -7
- package/dist/contracts/extensions.d.ts +0 -13
- package/dist/contracts/extensions.js +0 -9
- package/dist/contracts/index.d.ts +0 -13
- package/dist/contracts/index.js +0 -13
- package/dist/contracts/public-api.d.ts +0 -360
- package/dist/contracts/public-api.js +0 -17
- package/dist/contracts/runtime.d.ts +0 -81
- package/dist/contracts/runtime.js +0 -16
- package/dist/contracts/stagehand.d.ts +0 -253
- package/dist/contracts/stagehand.js +0 -145
- package/dist/contracts/storage.d.ts +0 -51
- package/dist/contracts/storage.js +0 -56
- package/dist/contracts/vault.d.ts +0 -119
- package/dist/contracts/vault.js +0 -112
- package/dist/contracts/version.d.ts +0 -3
- package/dist/contracts/version.js +0 -16
- package/dist/desktop.d.ts +0 -2
- package/dist/desktop.js +0 -3
- package/dist/drivers/desktop/index.d.ts +0 -65
- package/dist/drivers/desktop/index.js +0 -68
- package/dist/drivers/desktop/session.d.ts +0 -313
- package/dist/drivers/desktop/session.js +0 -432
- package/dist/drivers/playwright/event-emitter.d.ts +0 -160
- package/dist/drivers/playwright/event-emitter.js +0 -297
- package/dist/drivers/playwright/generated/api-request-context.d.ts +0 -137
- package/dist/drivers/playwright/generated/api-request-context.js +0 -154
- package/dist/drivers/playwright/generated/api-response.d.ts +0 -119
- package/dist/drivers/playwright/generated/api-response.js +0 -123
- package/dist/drivers/playwright/generated/browser-context.d.ts +0 -284
- package/dist/drivers/playwright/generated/browser-context.js +0 -458
- package/dist/drivers/playwright/generated/browser.d.ts +0 -120
- package/dist/drivers/playwright/generated/browser.js +0 -151
- package/dist/drivers/playwright/generated/clock.d.ts +0 -80
- package/dist/drivers/playwright/generated/clock.js +0 -94
- package/dist/drivers/playwright/generated/console-message.d.ts +0 -94
- package/dist/drivers/playwright/generated/console-message.js +0 -89
- package/dist/drivers/playwright/generated/coverage.d.ts +0 -57
- package/dist/drivers/playwright/generated/coverage.js +0 -66
- package/dist/drivers/playwright/generated/dialog.d.ts +0 -79
- package/dist/drivers/playwright/generated/dialog.js +0 -80
- package/dist/drivers/playwright/generated/element-handle.d.ts +0 -399
- package/dist/drivers/playwright/generated/element-handle.js +0 -501
- package/dist/drivers/playwright/generated/frame-locator.d.ts +0 -34
- package/dist/drivers/playwright/generated/frame-locator.js +0 -63
- package/dist/drivers/playwright/generated/frame.d.ts +0 -557
- package/dist/drivers/playwright/generated/frame.js +0 -634
- package/dist/drivers/playwright/generated/js-handle.d.ts +0 -72
- package/dist/drivers/playwright/generated/js-handle.js +0 -92
- package/dist/drivers/playwright/generated/keyboard.d.ts +0 -103
- package/dist/drivers/playwright/generated/keyboard.js +0 -113
- package/dist/drivers/playwright/generated/locator.d.ts +0 -795
- package/dist/drivers/playwright/generated/locator.js +0 -974
- package/dist/drivers/playwright/generated/mouse.d.ts +0 -97
- package/dist/drivers/playwright/generated/mouse.js +0 -109
- package/dist/drivers/playwright/generated/page.d.ts +0 -762
- package/dist/drivers/playwright/generated/page.js +0 -988
- package/dist/drivers/playwright/generated/touchscreen.d.ts +0 -34
- package/dist/drivers/playwright/generated/touchscreen.js +0 -37
- package/dist/drivers/playwright/generated/tracing.d.ts +0 -78
- package/dist/drivers/playwright/generated/tracing.js +0 -80
- package/dist/drivers/playwright/generated/worker.d.ts +0 -53
- package/dist/drivers/playwright/generated/worker.js +0 -59
- package/dist/drivers/playwright/index.d.ts +0 -19
- package/dist/drivers/playwright/index.js +0 -20
- package/dist/drivers/playwright/remote-base.d.ts +0 -62
- package/dist/drivers/playwright/remote-base.js +0 -86
- package/dist/drivers/playwright/types.d.ts +0 -148
- package/dist/drivers/playwright/types.js +0 -8
- package/dist/drivers/puppeteer/errors.d.ts +0 -50
- package/dist/drivers/puppeteer/errors.js +0 -71
- package/dist/drivers/puppeteer/event-emitter.d.ts +0 -145
- package/dist/drivers/puppeteer/event-emitter.js +0 -259
- package/dist/drivers/puppeteer/generated/accessibility.d.ts +0 -77
- package/dist/drivers/puppeteer/generated/accessibility.js +0 -74
- package/dist/drivers/puppeteer/generated/browser-context.d.ts +0 -116
- package/dist/drivers/puppeteer/generated/browser-context.js +0 -168
- package/dist/drivers/puppeteer/generated/browser.d.ts +0 -169
- package/dist/drivers/puppeteer/generated/browser.js +0 -246
- package/dist/drivers/puppeteer/generated/console-message.d.ts +0 -54
- package/dist/drivers/puppeteer/generated/console-message.js +0 -69
- package/dist/drivers/puppeteer/generated/coverage.d.ts +0 -49
- package/dist/drivers/puppeteer/generated/coverage.js +0 -57
- package/dist/drivers/puppeteer/generated/dialog.d.ts +0 -46
- package/dist/drivers/puppeteer/generated/dialog.js +0 -60
- package/dist/drivers/puppeteer/generated/element-handle.d.ts +0 -261
- package/dist/drivers/puppeteer/generated/element-handle.js +0 -341
- package/dist/drivers/puppeteer/generated/file-chooser.d.ts +0 -34
- package/dist/drivers/puppeteer/generated/file-chooser.js +0 -43
- package/dist/drivers/puppeteer/generated/frame.d.ts +0 -221
- package/dist/drivers/puppeteer/generated/frame.js +0 -302
- package/dist/drivers/puppeteer/generated/http-request.d.ts +0 -195
- package/dist/drivers/puppeteer/generated/http-request.js +0 -243
- package/dist/drivers/puppeteer/generated/http-response.d.ts +0 -142
- package/dist/drivers/puppeteer/generated/http-response.js +0 -169
- package/dist/drivers/puppeteer/generated/js-handle.d.ts +0 -104
- package/dist/drivers/puppeteer/generated/js-handle.js +0 -125
- package/dist/drivers/puppeteer/generated/keyboard.d.ts +0 -79
- package/dist/drivers/puppeteer/generated/keyboard.js +0 -89
- package/dist/drivers/puppeteer/generated/locator.d.ts +0 -141
- package/dist/drivers/puppeteer/generated/locator.js +0 -164
- package/dist/drivers/puppeteer/generated/mouse.d.ts +0 -74
- package/dist/drivers/puppeteer/generated/mouse.js +0 -94
- package/dist/drivers/puppeteer/generated/page.d.ts +0 -604
- package/dist/drivers/puppeteer/generated/page.js +0 -776
- package/dist/drivers/puppeteer/generated/target.d.ts +0 -105
- package/dist/drivers/puppeteer/generated/target.js +0 -123
- package/dist/drivers/puppeteer/generated/touchscreen.d.ts +0 -87
- package/dist/drivers/puppeteer/generated/touchscreen.js +0 -103
- package/dist/drivers/puppeteer/generated/tracing.d.ts +0 -38
- package/dist/drivers/puppeteer/generated/tracing.js +0 -43
- package/dist/drivers/puppeteer/generated/web-worker.d.ts +0 -63
- package/dist/drivers/puppeteer/generated/web-worker.js +0 -73
- package/dist/drivers/puppeteer/index.d.ts +0 -21
- package/dist/drivers/puppeteer/index.js +0 -23
- package/dist/drivers/puppeteer/remote-base.d.ts +0 -57
- package/dist/drivers/puppeteer/remote-base.js +0 -79
- package/dist/drivers/puppeteer/types.d.ts +0 -178
- package/dist/drivers/puppeteer/types.js +0 -8
- package/dist/drivers/selenium/driver.d.ts +0 -28
- package/dist/drivers/selenium/driver.js +0 -169
- package/dist/drivers/selenium/element.d.ts +0 -34
- package/dist/drivers/selenium/element.js +0 -73
- package/dist/drivers/selenium/index.d.ts +0 -3
- package/dist/drivers/selenium/index.js +0 -5
- package/dist/drivers/selenium/types.d.ts +0 -2
- package/dist/drivers/selenium/types.js +0 -12
- package/dist/drivers/stagehand/generated/context.d.ts +0 -127
- package/dist/drivers/stagehand/generated/context.js +0 -153
- package/dist/drivers/stagehand/generated/locator.d.ts +0 -324
- package/dist/drivers/stagehand/generated/locator.js +0 -368
- package/dist/drivers/stagehand/generated/page.d.ts +0 -377
- package/dist/drivers/stagehand/generated/page.js +0 -439
- package/dist/drivers/stagehand/generated/response.d.ts +0 -197
- package/dist/drivers/stagehand/generated/response.js +0 -232
- package/dist/drivers/stagehand/index.d.ts +0 -5
- package/dist/drivers/stagehand/index.js +0 -8
- package/dist/drivers/stagehand/types.d.ts +0 -1
- package/dist/drivers/stagehand/types.js +0 -7
- package/dist/extensions/client.d.ts +0 -47
- package/dist/extensions/client.js +0 -154
- package/dist/extensions/index.d.ts +0 -1
- package/dist/extensions/index.js +0 -1
- package/dist/internal/dev-client.d.ts +0 -5
- package/dist/internal/dev-client.js +0 -9
- package/dist/internal/rpc-targets.d.ts +0 -17
- package/dist/internal/rpc-targets.js +0 -58
- package/dist/internal/serialization.d.ts +0 -32
- package/dist/internal/serialization.js +0 -42
- package/dist/internal/transport.d.ts +0 -24
- package/dist/internal/transport.js +0 -29
- package/dist/playwright.d.ts +0 -1
- package/dist/playwright.js +0 -2
- package/dist/puppeteer.d.ts +0 -1
- package/dist/puppeteer.js +0 -2
- package/dist/selenium.d.ts +0 -1
- package/dist/selenium.js +0 -2
- package/dist/stagehand.d.ts +0 -1
- package/dist/stagehand.js +0 -2
- package/dist/storage/client.d.ts +0 -151
- package/dist/storage/client.js +0 -329
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -4
- package/dist/telemetry.d.ts +0 -18
- package/dist/telemetry.js +0 -93
- package/dist/updates/client.d.ts +0 -8
- package/dist/updates/client.js +0 -128
- package/dist/updates/index.d.ts +0 -1
- package/dist/updates/index.js +0 -1
- package/dist/utils/http.d.ts +0 -39
- package/dist/utils/http.js +0 -88
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -4
- package/dist/utils/logger.d.ts +0 -27
- package/dist/utils/logger.js +0 -74
- package/dist/utils/schema.d.ts +0 -17
- package/dist/utils/schema.js +0 -31
- package/dist/utils/url.d.ts +0 -5
- package/dist/utils/url.js +0 -7
- package/dist/vault/client.d.ts +0 -43
- package/dist/vault/client.js +0 -123
- package/dist/vault/index.d.ts +0 -1
- package/dist/vault/index.js +0 -1
- package/dist/workspaces/browser-runtime.d.ts +0 -251
- package/dist/workspaces/browser-runtime.js +0 -1025
- package/dist/workspaces/client.d.ts +0 -48
- package/dist/workspaces/client.js +0 -222
- package/dist/workspaces/index.d.ts +0 -2
- package/dist/workspaces/index.js +0 -2
- package/dist/workspaces/runtime-event-pump.d.ts +0 -65
- package/dist/workspaces/runtime-event-pump.js +0 -716
package/dist/runs.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { iterateV1Pages } from './pagination.js';
|
|
2
|
+
import { V1RunFilesClient } from './files.js';
|
|
3
|
+
export class V1RunEventsClient {
|
|
4
|
+
http;
|
|
5
|
+
runId;
|
|
6
|
+
constructor(http, runId) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
this.runId = runId;
|
|
9
|
+
}
|
|
10
|
+
list(query = {}) {
|
|
11
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events`, { query });
|
|
12
|
+
}
|
|
13
|
+
iter(query = {}) {
|
|
14
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
15
|
+
}
|
|
16
|
+
wait(request) {
|
|
17
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events/wait`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: request ?? {},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
streamUrl(query = {}) {
|
|
23
|
+
const url = new URL(`${this.http.baseUrl}/runs/${encodeURIComponent(this.runId)}/events/stream`);
|
|
24
|
+
for (const [key, value] of Object.entries(query)) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
for (const item of value)
|
|
29
|
+
url.searchParams.append(key, item);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
url.searchParams.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return url.toString();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class V1RunCommandsClient {
|
|
39
|
+
http;
|
|
40
|
+
runId;
|
|
41
|
+
constructor(http, runId) {
|
|
42
|
+
this.http = http;
|
|
43
|
+
this.runId = runId;
|
|
44
|
+
}
|
|
45
|
+
list(query = {}) {
|
|
46
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/commands`, { query });
|
|
47
|
+
}
|
|
48
|
+
iter(query = {}) {
|
|
49
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class V1RunResource {
|
|
53
|
+
http;
|
|
54
|
+
data;
|
|
55
|
+
events;
|
|
56
|
+
commands;
|
|
57
|
+
files;
|
|
58
|
+
constructor(http, data) {
|
|
59
|
+
this.http = http;
|
|
60
|
+
this.data = data;
|
|
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
|
+
}
|
|
65
|
+
get id() {
|
|
66
|
+
return this.data.id;
|
|
67
|
+
}
|
|
68
|
+
refresh() {
|
|
69
|
+
return new V1RunsClient(this.http).get(this.id);
|
|
70
|
+
}
|
|
71
|
+
live(request) {
|
|
72
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/live`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body: request ?? {},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
recording(request) {
|
|
78
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/recording`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: request ?? {},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
usage() {
|
|
84
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/usage`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export class V1RunsClient {
|
|
88
|
+
http;
|
|
89
|
+
constructor(http) {
|
|
90
|
+
this.http = http;
|
|
91
|
+
}
|
|
92
|
+
list(query = {}) {
|
|
93
|
+
return this.http.request('/runs', { query });
|
|
94
|
+
}
|
|
95
|
+
iter(query = {}) {
|
|
96
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
97
|
+
}
|
|
98
|
+
async get(id) {
|
|
99
|
+
const run = await this.http.request(`/runs/${encodeURIComponent(id)}`);
|
|
100
|
+
return new V1RunResource(this.http, run);
|
|
101
|
+
}
|
|
102
|
+
usage(id) {
|
|
103
|
+
return this.http.request(`/runs/${encodeURIComponent(id)}/usage`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
private readonly http;
|
|
7
|
+
private readonly runtimeId;
|
|
8
|
+
readonly data: V1RuntimeConnectionCreateResponse;
|
|
9
|
+
constructor(http: V1HttpClient, runtimeId: string, data: V1RuntimeConnectionCreateResponse);
|
|
10
|
+
get id(): string;
|
|
11
|
+
get endpoint(): V1RuntimeConnectionCreateResponse['endpoint'];
|
|
12
|
+
get wsUrl(): string | undefined;
|
|
13
|
+
close(): Promise<V1RuntimeConnection>;
|
|
14
|
+
}
|
|
15
|
+
export declare class V1RuntimeConnectionsClient {
|
|
16
|
+
private readonly http;
|
|
17
|
+
private readonly runtimeId;
|
|
18
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
19
|
+
create(request?: V1RuntimeConnectionCreateOptions): Promise<V1RuntimeConnectionResource>;
|
|
20
|
+
delete(connectionId: string): Promise<V1RuntimeConnection>;
|
|
21
|
+
}
|
|
22
|
+
export declare class V1RuntimeRunsClient {
|
|
23
|
+
private readonly http;
|
|
24
|
+
private readonly runtimeId;
|
|
25
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
26
|
+
list(query?: V1RuntimeRunListQuery): Promise<V1ListEnvelope<V1RunSummary>>;
|
|
27
|
+
iter(query?: V1RuntimeRunListQuery): AsyncGenerator<V1RunSummary, void, undefined>;
|
|
28
|
+
}
|
|
29
|
+
export declare class V1RuntimeFilesClient {
|
|
30
|
+
private readonly http;
|
|
31
|
+
private readonly runtimeId;
|
|
32
|
+
constructor(http: V1HttpClient, runtimeId: string);
|
|
33
|
+
upload(request: V1RuntimeFileUploadRequest): Promise<V1RuntimeFileUploadResponse>;
|
|
34
|
+
stage(request: V1RuntimeFileStageRequest): Promise<V1RuntimeStagedFile>;
|
|
35
|
+
collect(request: V1RuntimeFileCollectRequest): Promise<V1File>;
|
|
36
|
+
}
|
|
37
|
+
export declare class V1RuntimeResource {
|
|
38
|
+
private readonly 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);
|
|
45
|
+
get id(): string;
|
|
46
|
+
get activeRunId(): string | null;
|
|
47
|
+
refresh(): Promise<V1RuntimeResource>;
|
|
48
|
+
connect(request?: V1RuntimeConnectionCreateOptions): Promise<V1RuntimeConnectionResource>;
|
|
49
|
+
start(): Promise<{
|
|
50
|
+
runtime: V1RuntimeResource;
|
|
51
|
+
run: V1RunResource;
|
|
52
|
+
}>;
|
|
53
|
+
stop(): Promise<V1Runtime>;
|
|
54
|
+
run(): Promise<V1RunResource>;
|
|
55
|
+
}
|
|
56
|
+
export declare class V1RuntimesClient {
|
|
57
|
+
private readonly http;
|
|
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>;
|
|
65
|
+
start(id: string): Promise<{
|
|
66
|
+
runtime: V1RuntimeResource;
|
|
67
|
+
run: V1RunResource;
|
|
68
|
+
}>;
|
|
69
|
+
}
|
package/dist/runtimes.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { BctrlValidationError } from './errors.js';
|
|
2
|
+
import { V1RuntimeInvocationsClient } from './invocations.js';
|
|
3
|
+
import { iterateV1Pages } from './pagination.js';
|
|
4
|
+
import { V1RunResource } from './runs.js';
|
|
5
|
+
export class V1RuntimeConnectionResource {
|
|
6
|
+
http;
|
|
7
|
+
runtimeId;
|
|
8
|
+
data;
|
|
9
|
+
constructor(http, runtimeId, data) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
this.runtimeId = runtimeId;
|
|
12
|
+
this.data = data;
|
|
13
|
+
}
|
|
14
|
+
get id() {
|
|
15
|
+
return this.data.id;
|
|
16
|
+
}
|
|
17
|
+
get endpoint() {
|
|
18
|
+
return this.data.endpoint;
|
|
19
|
+
}
|
|
20
|
+
get wsUrl() {
|
|
21
|
+
return this.data.endpoint.type === 'websocket' ? this.data.endpoint.url : undefined;
|
|
22
|
+
}
|
|
23
|
+
close() {
|
|
24
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(this.id)}`, { method: 'DELETE' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class V1RuntimeConnectionsClient {
|
|
28
|
+
http;
|
|
29
|
+
runtimeId;
|
|
30
|
+
constructor(http, runtimeId) {
|
|
31
|
+
this.http = http;
|
|
32
|
+
this.runtimeId = runtimeId;
|
|
33
|
+
}
|
|
34
|
+
async create(request = {}) {
|
|
35
|
+
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
body: {
|
|
38
|
+
protocol: request.protocol ?? 'cdp',
|
|
39
|
+
...request,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return new V1RuntimeConnectionResource(this.http, this.runtimeId, response);
|
|
43
|
+
}
|
|
44
|
+
delete(connectionId) {
|
|
45
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(connectionId)}`, { method: 'DELETE' });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export class V1RuntimeRunsClient {
|
|
49
|
+
http;
|
|
50
|
+
runtimeId;
|
|
51
|
+
constructor(http, runtimeId) {
|
|
52
|
+
this.http = http;
|
|
53
|
+
this.runtimeId = runtimeId;
|
|
54
|
+
}
|
|
55
|
+
list(query = {}) {
|
|
56
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/runs`, { query });
|
|
57
|
+
}
|
|
58
|
+
iter(query = {}) {
|
|
59
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export class V1RuntimeFilesClient {
|
|
63
|
+
http;
|
|
64
|
+
runtimeId;
|
|
65
|
+
constructor(http, runtimeId) {
|
|
66
|
+
this.http = http;
|
|
67
|
+
this.runtimeId = runtimeId;
|
|
68
|
+
}
|
|
69
|
+
async upload(request) {
|
|
70
|
+
const form = new FormData();
|
|
71
|
+
if (request.name) {
|
|
72
|
+
form.set('file', request.file, request.name);
|
|
73
|
+
form.set('name', request.name);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
form.set('file', request.file);
|
|
77
|
+
}
|
|
78
|
+
if (request.storagePath)
|
|
79
|
+
form.set('storagePath', request.storagePath);
|
|
80
|
+
if (request.metadata)
|
|
81
|
+
form.set('metadata', JSON.stringify(request.metadata));
|
|
82
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/upload`, {
|
|
83
|
+
method: 'POST',
|
|
84
|
+
body: form,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
stage(request) {
|
|
88
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/stage`, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
body: request,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
collect(request) {
|
|
94
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/collect`, {
|
|
95
|
+
method: 'POST',
|
|
96
|
+
body: request,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export class V1RuntimeResource {
|
|
101
|
+
http;
|
|
102
|
+
data;
|
|
103
|
+
connections;
|
|
104
|
+
files;
|
|
105
|
+
runs;
|
|
106
|
+
invocations;
|
|
107
|
+
constructor(http, data) {
|
|
108
|
+
this.http = http;
|
|
109
|
+
this.data = data;
|
|
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);
|
|
114
|
+
}
|
|
115
|
+
get id() {
|
|
116
|
+
return this.data.id;
|
|
117
|
+
}
|
|
118
|
+
get activeRunId() {
|
|
119
|
+
return this.data.activeRunId;
|
|
120
|
+
}
|
|
121
|
+
refresh() {
|
|
122
|
+
return new V1RuntimesClient(this.http).get(this.id);
|
|
123
|
+
}
|
|
124
|
+
async connect(request) {
|
|
125
|
+
return this.connections.create(request);
|
|
126
|
+
}
|
|
127
|
+
async start() {
|
|
128
|
+
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.id)}/start`, { method: 'POST' });
|
|
129
|
+
return {
|
|
130
|
+
runtime: new V1RuntimeResource(this.http, response.runtime),
|
|
131
|
+
run: new V1RunResource(this.http, response.run),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
stop() {
|
|
135
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.id)}/stop`, {
|
|
136
|
+
method: 'POST',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async run() {
|
|
140
|
+
const runtime = await this.refresh();
|
|
141
|
+
if (!runtime.activeRunId) {
|
|
142
|
+
throw new BctrlValidationError('Runtime does not have an active run yet', 'runtime.no_active_run', {
|
|
143
|
+
runtimeId: this.id,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const run = await this.http.request(`/runs/${encodeURIComponent(runtime.activeRunId)}`);
|
|
147
|
+
return new V1RunResource(this.http, run);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function validateRuntimeCreateRequest(request) {
|
|
151
|
+
const profileBacked = request.config?.browser?.profile === true;
|
|
152
|
+
if (!profileBacked)
|
|
153
|
+
return;
|
|
154
|
+
if (!request.name?.trim()) {
|
|
155
|
+
throw new BctrlValidationError('name is required when config.browser.profile is true', 'runtime.profile_name_required');
|
|
156
|
+
}
|
|
157
|
+
const unsupported = ['stealth', 'proxy', 'fingerprint', 'extensions'].filter((key) => request.config?.[key] !== undefined);
|
|
158
|
+
if (unsupported.length > 0) {
|
|
159
|
+
throw new BctrlValidationError('Only config.browser.profile and config.lifecycle are supported for profile-backed browser runtimes', 'runtime.profile_config_unsupported', { unsupported });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
export class V1RuntimesClient {
|
|
163
|
+
http;
|
|
164
|
+
constructor(http) {
|
|
165
|
+
this.http = http;
|
|
166
|
+
}
|
|
167
|
+
list(query = {}) {
|
|
168
|
+
return this.http.request('/runtimes', { query });
|
|
169
|
+
}
|
|
170
|
+
iter(query = {}) {
|
|
171
|
+
return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
|
|
172
|
+
}
|
|
173
|
+
async create(request) {
|
|
174
|
+
validateRuntimeCreateRequest(request);
|
|
175
|
+
const runtime = await this.http.request('/runtimes', {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
body: request,
|
|
178
|
+
});
|
|
179
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
180
|
+
}
|
|
181
|
+
async createInSpace(spaceId, request) {
|
|
182
|
+
validateRuntimeCreateRequest(request);
|
|
183
|
+
const runtime = await this.http.request('/runtimes', {
|
|
184
|
+
method: 'POST',
|
|
185
|
+
body: { ...request, spaceId },
|
|
186
|
+
});
|
|
187
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
188
|
+
}
|
|
189
|
+
async get(id) {
|
|
190
|
+
const runtime = await this.http.request(`/runtimes/${encodeURIComponent(id)}`);
|
|
191
|
+
return new V1RuntimeResource(this.http, runtime);
|
|
192
|
+
}
|
|
193
|
+
stop(id) {
|
|
194
|
+
return this.http.request(`/runtimes/${encodeURIComponent(id)}/stop`, {
|
|
195
|
+
method: 'POST',
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
async start(id) {
|
|
199
|
+
const runtime = await this.get(id);
|
|
200
|
+
return runtime.start();
|
|
201
|
+
}
|
|
202
|
+
}
|
package/dist/spaces.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
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 {
|
|
5
|
+
private readonly http;
|
|
6
|
+
private readonly spaceId;
|
|
7
|
+
constructor(http: V1HttpClient, spaceId: string);
|
|
8
|
+
get(): Promise<V1SpaceEnvironment>;
|
|
9
|
+
update(request: V1SpaceEnvironmentUpdateRequest): Promise<V1SpaceEnvironment>;
|
|
10
|
+
}
|
|
11
|
+
export declare class V1SpaceRuntimesClient {
|
|
12
|
+
private readonly http;
|
|
13
|
+
private readonly spaceId;
|
|
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
|
+
}
|
|
22
|
+
export declare class V1SpaceResource {
|
|
23
|
+
private readonly http;
|
|
24
|
+
readonly data: V1Space;
|
|
25
|
+
readonly environment: V1SpaceEnvironmentClient;
|
|
26
|
+
readonly runtimes: V1SpaceRuntimesClient;
|
|
27
|
+
constructor(http: V1HttpClient, data: V1Space);
|
|
28
|
+
get id(): string;
|
|
29
|
+
refresh(): Promise<V1SpaceResource>;
|
|
30
|
+
update(request: V1SpaceUpdateRequest): Promise<V1SpaceResource>;
|
|
31
|
+
}
|
|
32
|
+
export declare class V1SpacesClient {
|
|
33
|
+
private readonly http;
|
|
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>;
|
|
40
|
+
}
|
package/dist/spaces.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { iterateV1Pages } from './pagination.js';
|
|
2
|
+
import { V1RuntimesClient } from './runtimes.js';
|
|
3
|
+
export class V1SpaceEnvironmentClient {
|
|
4
|
+
http;
|
|
5
|
+
spaceId;
|
|
6
|
+
constructor(http, spaceId) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
this.spaceId = spaceId;
|
|
9
|
+
}
|
|
10
|
+
get() {
|
|
11
|
+
return this.http.request(`/spaces/${encodeURIComponent(this.spaceId)}/environment`);
|
|
12
|
+
}
|
|
13
|
+
update(request) {
|
|
14
|
+
return this.http.request(`/spaces/${encodeURIComponent(this.spaceId)}/environment`, {
|
|
15
|
+
method: 'PATCH',
|
|
16
|
+
body: request,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class V1SpaceRuntimesClient {
|
|
21
|
+
http;
|
|
22
|
+
spaceId;
|
|
23
|
+
constructor(http, spaceId) {
|
|
24
|
+
this.http = http;
|
|
25
|
+
this.spaceId = spaceId;
|
|
26
|
+
}
|
|
27
|
+
list(query = {}) {
|
|
28
|
+
return new V1RuntimesClient(this.http).list({ ...query, spaceId: this.spaceId });
|
|
29
|
+
}
|
|
30
|
+
iter(query = {}) {
|
|
31
|
+
return new V1RuntimesClient(this.http).iter({ ...query, spaceId: this.spaceId });
|
|
32
|
+
}
|
|
33
|
+
async create(request) {
|
|
34
|
+
return new V1RuntimesClient(this.http).createInSpace(this.spaceId, request);
|
|
35
|
+
}
|
|
36
|
+
async get(runtimeId) {
|
|
37
|
+
return new V1RuntimesClient(this.http).get(runtimeId);
|
|
38
|
+
}
|
|
39
|
+
stop(runtimeId) {
|
|
40
|
+
return new V1RuntimesClient(this.http).stop(runtimeId);
|
|
41
|
+
}
|
|
42
|
+
start(runtimeId) {
|
|
43
|
+
return new V1RuntimesClient(this.http).start(runtimeId);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export class V1SpaceResource {
|
|
47
|
+
http;
|
|
48
|
+
data;
|
|
49
|
+
environment;
|
|
50
|
+
runtimes;
|
|
51
|
+
constructor(http, data) {
|
|
52
|
+
this.http = http;
|
|
53
|
+
this.data = data;
|
|
54
|
+
this.environment = new V1SpaceEnvironmentClient(http, data.id);
|
|
55
|
+
this.runtimes = new V1SpaceRuntimesClient(http, data.id);
|
|
56
|
+
}
|
|
57
|
+
get id() {
|
|
58
|
+
return this.data.id;
|
|
59
|
+
}
|
|
60
|
+
refresh() {
|
|
61
|
+
return new V1SpacesClient(this.http).get(this.id);
|
|
62
|
+
}
|
|
63
|
+
async update(request) {
|
|
64
|
+
return new V1SpacesClient(this.http).update(this.id, request);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class V1SpacesClient {
|
|
68
|
+
http;
|
|
69
|
+
constructor(http) {
|
|
70
|
+
this.http = http;
|
|
71
|
+
}
|
|
72
|
+
async list() {
|
|
73
|
+
return this.http.request('/spaces');
|
|
74
|
+
}
|
|
75
|
+
iter() {
|
|
76
|
+
return iterateV1Pages({}, () => this.list());
|
|
77
|
+
}
|
|
78
|
+
async create(request) {
|
|
79
|
+
const space = await this.http.request('/spaces', {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
body: request,
|
|
82
|
+
});
|
|
83
|
+
return new V1SpaceResource(this.http, space);
|
|
84
|
+
}
|
|
85
|
+
async get(id) {
|
|
86
|
+
const space = await this.http.request(`/spaces/${encodeURIComponent(id)}`);
|
|
87
|
+
return new V1SpaceResource(this.http, space);
|
|
88
|
+
}
|
|
89
|
+
async update(id, request) {
|
|
90
|
+
const space = await this.http.request(`/spaces/${encodeURIComponent(id)}`, {
|
|
91
|
+
method: 'PATCH',
|
|
92
|
+
body: request,
|
|
93
|
+
});
|
|
94
|
+
return new V1SpaceResource(this.http, space);
|
|
95
|
+
}
|
|
96
|
+
}
|