@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.
Files changed (277) hide show
  1. package/README.md +28 -29
  2. package/dist/bctrl.d.ts +22 -36
  3. package/dist/bctrl.js +40 -75
  4. package/dist/errors.d.ts +49 -43
  5. package/dist/errors.js +83 -120
  6. package/dist/files.d.ts +31 -0
  7. package/dist/files.js +97 -0
  8. package/dist/http.d.ts +18 -0
  9. package/dist/http.js +135 -0
  10. package/dist/index.d.ts +9 -12
  11. package/dist/index.js +7 -23
  12. package/dist/invocations.d.ts +86 -0
  13. package/dist/invocations.js +159 -0
  14. package/dist/pagination.d.ts +2 -0
  15. package/dist/pagination.js +13 -0
  16. package/dist/runs.d.ts +40 -0
  17. package/dist/runs.js +105 -0
  18. package/dist/runtimes.d.ts +69 -0
  19. package/dist/runtimes.js +202 -0
  20. package/dist/spaces.d.ts +40 -0
  21. package/dist/spaces.js +96 -0
  22. package/dist/types.d.ts +413 -0
  23. package/dist/types.js +1 -0
  24. package/dist/utils.d.ts +4 -0
  25. package/dist/utils.js +27 -0
  26. package/dist/version.js +2 -2
  27. package/package.json +4 -21
  28. package/dist/agents/browser-use/index.d.ts +0 -1
  29. package/dist/agents/browser-use/index.js +0 -9
  30. package/dist/agents/browser-use/namespace.d.ts +0 -39
  31. package/dist/agents/browser-use/namespace.js +0 -93
  32. package/dist/agents/index.d.ts +0 -2
  33. package/dist/agents/index.js +0 -17
  34. package/dist/agents/stagehand/core.d.ts +0 -93
  35. package/dist/agents/stagehand/core.js +0 -144
  36. package/dist/agents/stagehand/index.d.ts +0 -3
  37. package/dist/agents/stagehand/index.js +0 -24
  38. package/dist/agents/stagehand/namespace.d.ts +0 -51
  39. package/dist/agents/stagehand/namespace.js +0 -65
  40. package/dist/ai-credentials/client.d.ts +0 -12
  41. package/dist/ai-credentials/client.js +0 -70
  42. package/dist/ai-credentials/index.d.ts +0 -1
  43. package/dist/ai-credentials/index.js +0 -1
  44. package/dist/base/event-binding.d.ts +0 -7
  45. package/dist/base/event-binding.js +0 -23
  46. package/dist/base/types.d.ts +0 -109
  47. package/dist/base/types.js +0 -4
  48. package/dist/browser-extensions/client.d.ts +0 -15
  49. package/dist/browser-extensions/client.js +0 -72
  50. package/dist/browser-extensions/index.d.ts +0 -2
  51. package/dist/browser-extensions/index.js +0 -1
  52. package/dist/browser-profiles/client.d.ts +0 -11
  53. package/dist/browser-profiles/client.js +0 -63
  54. package/dist/browser-profiles/index.d.ts +0 -1
  55. package/dist/browser-profiles/index.js +0 -1
  56. package/dist/captcha/index.d.ts +0 -1
  57. package/dist/captcha/index.js +0 -1
  58. package/dist/captcha/namespace.d.ts +0 -34
  59. package/dist/captcha/namespace.js +0 -41
  60. package/dist/client/index.d.ts +0 -1
  61. package/dist/client/index.js +0 -1
  62. package/dist/client/rpc.d.ts +0 -83
  63. package/dist/client/rpc.js +0 -354
  64. package/dist/config.d.ts +0 -5
  65. package/dist/config.js +0 -28
  66. package/dist/constants/browser.d.ts +0 -2
  67. package/dist/constants/browser.js +0 -1
  68. package/dist/contracts/agent-tools.d.ts +0 -45
  69. package/dist/contracts/agent-tools.js +0 -31
  70. package/dist/contracts/automation.d.ts +0 -265
  71. package/dist/contracts/automation.js +0 -109
  72. package/dist/contracts/browser-management.d.ts +0 -179
  73. package/dist/contracts/browser-management.js +0 -95
  74. package/dist/contracts/browser-use.d.ts +0 -136
  75. package/dist/contracts/browser-use.js +0 -93
  76. package/dist/contracts/captcha.d.ts +0 -114
  77. package/dist/contracts/captcha.js +0 -40
  78. package/dist/contracts/desktop.d.ts +0 -223
  79. package/dist/contracts/desktop.js +0 -121
  80. package/dist/contracts/drivers/playwright.d.ts +0 -2008
  81. package/dist/contracts/drivers/playwright.js +0 -2033
  82. package/dist/contracts/drivers/puppeteer.d.ts +0 -1221
  83. package/dist/contracts/drivers/puppeteer.js +0 -941
  84. package/dist/contracts/drivers/selenium.d.ts +0 -156
  85. package/dist/contracts/drivers/selenium.js +0 -61
  86. package/dist/contracts/drivers/stagehand.d.ts +0 -155
  87. package/dist/contracts/drivers/stagehand.js +0 -7
  88. package/dist/contracts/extensions.d.ts +0 -13
  89. package/dist/contracts/extensions.js +0 -9
  90. package/dist/contracts/index.d.ts +0 -13
  91. package/dist/contracts/index.js +0 -13
  92. package/dist/contracts/public-api.d.ts +0 -360
  93. package/dist/contracts/public-api.js +0 -17
  94. package/dist/contracts/runtime.d.ts +0 -81
  95. package/dist/contracts/runtime.js +0 -16
  96. package/dist/contracts/stagehand.d.ts +0 -253
  97. package/dist/contracts/stagehand.js +0 -145
  98. package/dist/contracts/storage.d.ts +0 -51
  99. package/dist/contracts/storage.js +0 -56
  100. package/dist/contracts/vault.d.ts +0 -119
  101. package/dist/contracts/vault.js +0 -112
  102. package/dist/contracts/version.d.ts +0 -3
  103. package/dist/contracts/version.js +0 -16
  104. package/dist/desktop.d.ts +0 -2
  105. package/dist/desktop.js +0 -3
  106. package/dist/drivers/desktop/index.d.ts +0 -65
  107. package/dist/drivers/desktop/index.js +0 -68
  108. package/dist/drivers/desktop/session.d.ts +0 -313
  109. package/dist/drivers/desktop/session.js +0 -432
  110. package/dist/drivers/playwright/event-emitter.d.ts +0 -160
  111. package/dist/drivers/playwright/event-emitter.js +0 -297
  112. package/dist/drivers/playwright/generated/api-request-context.d.ts +0 -137
  113. package/dist/drivers/playwright/generated/api-request-context.js +0 -154
  114. package/dist/drivers/playwright/generated/api-response.d.ts +0 -119
  115. package/dist/drivers/playwright/generated/api-response.js +0 -123
  116. package/dist/drivers/playwright/generated/browser-context.d.ts +0 -284
  117. package/dist/drivers/playwright/generated/browser-context.js +0 -458
  118. package/dist/drivers/playwright/generated/browser.d.ts +0 -120
  119. package/dist/drivers/playwright/generated/browser.js +0 -151
  120. package/dist/drivers/playwright/generated/clock.d.ts +0 -80
  121. package/dist/drivers/playwright/generated/clock.js +0 -94
  122. package/dist/drivers/playwright/generated/console-message.d.ts +0 -94
  123. package/dist/drivers/playwright/generated/console-message.js +0 -89
  124. package/dist/drivers/playwright/generated/coverage.d.ts +0 -57
  125. package/dist/drivers/playwright/generated/coverage.js +0 -66
  126. package/dist/drivers/playwright/generated/dialog.d.ts +0 -79
  127. package/dist/drivers/playwright/generated/dialog.js +0 -80
  128. package/dist/drivers/playwright/generated/element-handle.d.ts +0 -399
  129. package/dist/drivers/playwright/generated/element-handle.js +0 -501
  130. package/dist/drivers/playwright/generated/frame-locator.d.ts +0 -34
  131. package/dist/drivers/playwright/generated/frame-locator.js +0 -63
  132. package/dist/drivers/playwright/generated/frame.d.ts +0 -557
  133. package/dist/drivers/playwright/generated/frame.js +0 -634
  134. package/dist/drivers/playwright/generated/js-handle.d.ts +0 -72
  135. package/dist/drivers/playwright/generated/js-handle.js +0 -92
  136. package/dist/drivers/playwright/generated/keyboard.d.ts +0 -103
  137. package/dist/drivers/playwright/generated/keyboard.js +0 -113
  138. package/dist/drivers/playwright/generated/locator.d.ts +0 -795
  139. package/dist/drivers/playwright/generated/locator.js +0 -974
  140. package/dist/drivers/playwright/generated/mouse.d.ts +0 -97
  141. package/dist/drivers/playwright/generated/mouse.js +0 -109
  142. package/dist/drivers/playwright/generated/page.d.ts +0 -762
  143. package/dist/drivers/playwright/generated/page.js +0 -988
  144. package/dist/drivers/playwright/generated/touchscreen.d.ts +0 -34
  145. package/dist/drivers/playwright/generated/touchscreen.js +0 -37
  146. package/dist/drivers/playwright/generated/tracing.d.ts +0 -78
  147. package/dist/drivers/playwright/generated/tracing.js +0 -80
  148. package/dist/drivers/playwright/generated/worker.d.ts +0 -53
  149. package/dist/drivers/playwright/generated/worker.js +0 -59
  150. package/dist/drivers/playwright/index.d.ts +0 -19
  151. package/dist/drivers/playwright/index.js +0 -20
  152. package/dist/drivers/playwright/remote-base.d.ts +0 -62
  153. package/dist/drivers/playwright/remote-base.js +0 -86
  154. package/dist/drivers/playwright/types.d.ts +0 -148
  155. package/dist/drivers/playwright/types.js +0 -8
  156. package/dist/drivers/puppeteer/errors.d.ts +0 -50
  157. package/dist/drivers/puppeteer/errors.js +0 -71
  158. package/dist/drivers/puppeteer/event-emitter.d.ts +0 -145
  159. package/dist/drivers/puppeteer/event-emitter.js +0 -259
  160. package/dist/drivers/puppeteer/generated/accessibility.d.ts +0 -77
  161. package/dist/drivers/puppeteer/generated/accessibility.js +0 -74
  162. package/dist/drivers/puppeteer/generated/browser-context.d.ts +0 -116
  163. package/dist/drivers/puppeteer/generated/browser-context.js +0 -168
  164. package/dist/drivers/puppeteer/generated/browser.d.ts +0 -169
  165. package/dist/drivers/puppeteer/generated/browser.js +0 -246
  166. package/dist/drivers/puppeteer/generated/console-message.d.ts +0 -54
  167. package/dist/drivers/puppeteer/generated/console-message.js +0 -69
  168. package/dist/drivers/puppeteer/generated/coverage.d.ts +0 -49
  169. package/dist/drivers/puppeteer/generated/coverage.js +0 -57
  170. package/dist/drivers/puppeteer/generated/dialog.d.ts +0 -46
  171. package/dist/drivers/puppeteer/generated/dialog.js +0 -60
  172. package/dist/drivers/puppeteer/generated/element-handle.d.ts +0 -261
  173. package/dist/drivers/puppeteer/generated/element-handle.js +0 -341
  174. package/dist/drivers/puppeteer/generated/file-chooser.d.ts +0 -34
  175. package/dist/drivers/puppeteer/generated/file-chooser.js +0 -43
  176. package/dist/drivers/puppeteer/generated/frame.d.ts +0 -221
  177. package/dist/drivers/puppeteer/generated/frame.js +0 -302
  178. package/dist/drivers/puppeteer/generated/http-request.d.ts +0 -195
  179. package/dist/drivers/puppeteer/generated/http-request.js +0 -243
  180. package/dist/drivers/puppeteer/generated/http-response.d.ts +0 -142
  181. package/dist/drivers/puppeteer/generated/http-response.js +0 -169
  182. package/dist/drivers/puppeteer/generated/js-handle.d.ts +0 -104
  183. package/dist/drivers/puppeteer/generated/js-handle.js +0 -125
  184. package/dist/drivers/puppeteer/generated/keyboard.d.ts +0 -79
  185. package/dist/drivers/puppeteer/generated/keyboard.js +0 -89
  186. package/dist/drivers/puppeteer/generated/locator.d.ts +0 -141
  187. package/dist/drivers/puppeteer/generated/locator.js +0 -164
  188. package/dist/drivers/puppeteer/generated/mouse.d.ts +0 -74
  189. package/dist/drivers/puppeteer/generated/mouse.js +0 -94
  190. package/dist/drivers/puppeteer/generated/page.d.ts +0 -604
  191. package/dist/drivers/puppeteer/generated/page.js +0 -776
  192. package/dist/drivers/puppeteer/generated/target.d.ts +0 -105
  193. package/dist/drivers/puppeteer/generated/target.js +0 -123
  194. package/dist/drivers/puppeteer/generated/touchscreen.d.ts +0 -87
  195. package/dist/drivers/puppeteer/generated/touchscreen.js +0 -103
  196. package/dist/drivers/puppeteer/generated/tracing.d.ts +0 -38
  197. package/dist/drivers/puppeteer/generated/tracing.js +0 -43
  198. package/dist/drivers/puppeteer/generated/web-worker.d.ts +0 -63
  199. package/dist/drivers/puppeteer/generated/web-worker.js +0 -73
  200. package/dist/drivers/puppeteer/index.d.ts +0 -21
  201. package/dist/drivers/puppeteer/index.js +0 -23
  202. package/dist/drivers/puppeteer/remote-base.d.ts +0 -57
  203. package/dist/drivers/puppeteer/remote-base.js +0 -79
  204. package/dist/drivers/puppeteer/types.d.ts +0 -178
  205. package/dist/drivers/puppeteer/types.js +0 -8
  206. package/dist/drivers/selenium/driver.d.ts +0 -28
  207. package/dist/drivers/selenium/driver.js +0 -169
  208. package/dist/drivers/selenium/element.d.ts +0 -34
  209. package/dist/drivers/selenium/element.js +0 -73
  210. package/dist/drivers/selenium/index.d.ts +0 -3
  211. package/dist/drivers/selenium/index.js +0 -5
  212. package/dist/drivers/selenium/types.d.ts +0 -2
  213. package/dist/drivers/selenium/types.js +0 -12
  214. package/dist/drivers/stagehand/generated/context.d.ts +0 -127
  215. package/dist/drivers/stagehand/generated/context.js +0 -153
  216. package/dist/drivers/stagehand/generated/locator.d.ts +0 -324
  217. package/dist/drivers/stagehand/generated/locator.js +0 -368
  218. package/dist/drivers/stagehand/generated/page.d.ts +0 -377
  219. package/dist/drivers/stagehand/generated/page.js +0 -439
  220. package/dist/drivers/stagehand/generated/response.d.ts +0 -197
  221. package/dist/drivers/stagehand/generated/response.js +0 -232
  222. package/dist/drivers/stagehand/index.d.ts +0 -5
  223. package/dist/drivers/stagehand/index.js +0 -8
  224. package/dist/drivers/stagehand/types.d.ts +0 -1
  225. package/dist/drivers/stagehand/types.js +0 -7
  226. package/dist/extensions/client.d.ts +0 -47
  227. package/dist/extensions/client.js +0 -154
  228. package/dist/extensions/index.d.ts +0 -1
  229. package/dist/extensions/index.js +0 -1
  230. package/dist/internal/dev-client.d.ts +0 -5
  231. package/dist/internal/dev-client.js +0 -9
  232. package/dist/internal/rpc-targets.d.ts +0 -17
  233. package/dist/internal/rpc-targets.js +0 -58
  234. package/dist/internal/serialization.d.ts +0 -32
  235. package/dist/internal/serialization.js +0 -42
  236. package/dist/internal/transport.d.ts +0 -24
  237. package/dist/internal/transport.js +0 -29
  238. package/dist/playwright.d.ts +0 -1
  239. package/dist/playwright.js +0 -2
  240. package/dist/puppeteer.d.ts +0 -1
  241. package/dist/puppeteer.js +0 -2
  242. package/dist/selenium.d.ts +0 -1
  243. package/dist/selenium.js +0 -2
  244. package/dist/stagehand.d.ts +0 -1
  245. package/dist/stagehand.js +0 -2
  246. package/dist/storage/client.d.ts +0 -151
  247. package/dist/storage/client.js +0 -329
  248. package/dist/storage/index.d.ts +0 -2
  249. package/dist/storage/index.js +0 -4
  250. package/dist/telemetry.d.ts +0 -18
  251. package/dist/telemetry.js +0 -93
  252. package/dist/updates/client.d.ts +0 -8
  253. package/dist/updates/client.js +0 -128
  254. package/dist/updates/index.d.ts +0 -1
  255. package/dist/updates/index.js +0 -1
  256. package/dist/utils/http.d.ts +0 -39
  257. package/dist/utils/http.js +0 -88
  258. package/dist/utils/index.d.ts +0 -4
  259. package/dist/utils/index.js +0 -4
  260. package/dist/utils/logger.d.ts +0 -27
  261. package/dist/utils/logger.js +0 -74
  262. package/dist/utils/schema.d.ts +0 -17
  263. package/dist/utils/schema.js +0 -31
  264. package/dist/utils/url.d.ts +0 -5
  265. package/dist/utils/url.js +0 -7
  266. package/dist/vault/client.d.ts +0 -43
  267. package/dist/vault/client.js +0 -123
  268. package/dist/vault/index.d.ts +0 -1
  269. package/dist/vault/index.js +0 -1
  270. package/dist/workspaces/browser-runtime.d.ts +0 -251
  271. package/dist/workspaces/browser-runtime.js +0 -1025
  272. package/dist/workspaces/client.d.ts +0 -48
  273. package/dist/workspaces/client.js +0 -222
  274. package/dist/workspaces/index.d.ts +0 -2
  275. package/dist/workspaces/index.js +0 -2
  276. package/dist/workspaces/runtime-event-pump.d.ts +0 -65
  277. 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
+ }
@@ -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
+ }
@@ -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
+ }