@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.
@@ -1,4 +1,4 @@
1
- export class V2InvocationResource {
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 V2InvocationsClient {
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 V2InvocationResource(this.http, response.data);
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 V2InvocationResource(this.http, response.data);
49
+ return new V1InvocationResource(this.http, response.data);
50
50
  }
51
51
  }
52
- export class V2RuntimeInvocationsClient {
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 V2InvocationResource(this.http, response.data);
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
+ }
@@ -1,2 +1,2 @@
1
- import type { V2ListEnvelope, V2PageQuery } from './types.js';
2
- export declare function iterateV2Pages<T, Q extends V2PageQuery>(initialQuery: Q, fetchPage: (query: Q) => Promise<V2ListEnvelope<T>>): AsyncGenerator<T, void, undefined>;
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>;
@@ -1,4 +1,4 @@
1
- export async function* iterateV2Pages(initialQuery, fetchPage) {
1
+ export async function* iterateV1Pages(initialQuery, fetchPage) {
2
2
  let cursor = initialQuery.cursor;
3
3
  for (;;) {
4
4
  const page = await fetchPage({ ...initialQuery, cursor });
package/dist/runs.d.ts CHANGED
@@ -1,38 +1,40 @@
1
- import type { V2HttpClient } from './http.js';
2
- import { V2RunFilesClient } from './files.js';
3
- import type { V2ListEnvelope, V2Run, V2RunCommand, V2RunCommandsListQuery, V2RunEvent, V2RunEventsListQuery, V2RunEventsWaitRequest, V2RunEventsWaitResponse, V2RunListQuery, V2RunLiveRequest, V2RunLiveResponse, V2RunRecordingRequest, V2RunRecordingResponse } from './types.js';
4
- export declare class V2RunEventsClient {
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: V2HttpClient, runId: string);
8
- list(query?: V2RunEventsListQuery): Promise<V2ListEnvelope<V2RunEvent>>;
9
- iter(query?: V2RunEventsListQuery): AsyncGenerator<V2RunEvent, void, undefined>;
10
- wait(request?: V2RunEventsWaitRequest): Promise<V2RunEventsWaitResponse>;
11
- streamUrl(query?: Pick<V2RunEventsListQuery, 'type' | 'category' | 'connectionId'>): string;
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 V2RunCommandsClient {
13
+ export declare class V1RunCommandsClient {
14
14
  private readonly http;
15
15
  private readonly runId;
16
- constructor(http: V2HttpClient, runId: string);
17
- list(query?: V2RunCommandsListQuery): Promise<V2ListEnvelope<V2RunCommand>>;
18
- iter(query?: V2RunCommandsListQuery): AsyncGenerator<V2RunCommand, void, undefined>;
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 V2RunResource {
20
+ export declare class V1RunResource {
21
21
  private readonly http;
22
- readonly data: V2Run;
23
- readonly events: V2RunEventsClient;
24
- readonly commands: V2RunCommandsClient;
25
- readonly files: V2RunFilesClient;
26
- constructor(http: V2HttpClient, data: V2Run);
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<V2RunResource>;
29
- live(request?: V2RunLiveRequest): Promise<V2RunLiveResponse>;
30
- recording(request?: V2RunRecordingRequest): Promise<V2RunRecordingResponse>;
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 V2RunsClient {
33
+ export declare class V1RunsClient {
33
34
  private readonly http;
34
- constructor(http: V2HttpClient);
35
- list(query?: V2RunListQuery): Promise<V2ListEnvelope<V2Run>>;
36
- iter(query?: V2RunListQuery): AsyncGenerator<V2Run, void, undefined>;
37
- get(id: string): Promise<V2RunResource>;
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 { iterateV2Pages } from './pagination.js';
2
- import { V2RunFilesClient } from './files.js';
3
- export class V2RunEventsClient {
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 iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
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 V2RunCommandsClient {
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 iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
49
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
50
50
  }
51
51
  }
52
- export class V2RunResource {
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 V2RunEventsClient(http, data.id);
62
- this.commands = new V2RunCommandsClient(http, data.id);
63
- this.files = new V2RunFilesClient(http, data.id);
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 V2RunsClient(this.http).get(this.id);
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 V2RunsClient {
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 iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
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 V2RunResource(this.http, run);
100
+ return new V1RunResource(this.http, run);
101
+ }
102
+ usage(id) {
103
+ return this.http.request(`/runs/${encodeURIComponent(id)}/usage`);
98
104
  }
99
105
  }
@@ -1,73 +1,69 @@
1
- import type { V2HttpClient } from './http.js';
2
- import { V2RuntimeInvocationsClient } from './invocations.js';
3
- import { V2RunResource } from './runs.js';
4
- import type { V2ListEnvelope, V2File, V2Runtime, V2RuntimeConnection, V2RuntimeConnectionCreateOptions, V2RuntimeConnectionCreateResponse, V2RuntimeCreateRequest, V2RuntimeFileCollectRequest, V2RuntimeFileStageRequest, V2RuntimeFileUploadRequest, V2RuntimeFileUploadResponse, V2RuntimeStagedFile, V2RuntimeListQuery, V2RuntimeRunListQuery, V2RunSummary, V2SpaceRuntimeCreateRequest } from './types.js';
5
- export declare class V2RuntimeConnectionResource {
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: V2RuntimeConnectionCreateResponse;
9
- constructor(http: V2HttpClient, runtimeId: string, data: V2RuntimeConnectionCreateResponse);
8
+ readonly data: V1RuntimeConnectionCreateResponse;
9
+ constructor(http: V1HttpClient, runtimeId: string, data: V1RuntimeConnectionCreateResponse);
10
10
  get id(): string;
11
- get endpoint(): V2RuntimeConnectionCreateResponse['endpoint'];
11
+ get endpoint(): V1RuntimeConnectionCreateResponse['endpoint'];
12
12
  get wsUrl(): string | undefined;
13
- close(): Promise<V2RuntimeConnection>;
13
+ close(): Promise<V1RuntimeConnection>;
14
14
  }
15
- export declare class V2RuntimeConnectionsClient {
15
+ export declare class V1RuntimeConnectionsClient {
16
16
  private readonly http;
17
17
  private readonly runtimeId;
18
- constructor(http: V2HttpClient, runtimeId: string);
19
- create(request?: V2RuntimeConnectionCreateOptions): Promise<V2RuntimeConnectionResource>;
20
- list(query?: {
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 V2RuntimeRunsClient {
22
+ export declare class V1RuntimeRunsClient {
27
23
  private readonly http;
28
24
  private readonly runtimeId;
29
- constructor(http: V2HttpClient, runtimeId: string);
30
- list(query?: V2RuntimeRunListQuery): Promise<V2ListEnvelope<V2RunSummary>>;
31
- iter(query?: V2RuntimeRunListQuery): AsyncGenerator<V2RunSummary, void, undefined>;
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 V2RuntimeFilesClient {
29
+ export declare class V1RuntimeFilesClient {
34
30
  private readonly http;
35
31
  private readonly runtimeId;
36
- constructor(http: V2HttpClient, runtimeId: string);
37
- upload(request: V2RuntimeFileUploadRequest): Promise<V2RuntimeFileUploadResponse>;
38
- stage(request: V2RuntimeFileStageRequest): Promise<V2RuntimeStagedFile>;
39
- collect(request: V2RuntimeFileCollectRequest): Promise<V2File>;
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 V2RuntimeResource {
37
+ export declare class V1RuntimeResource {
42
38
  private readonly http;
43
- readonly data: V2Runtime;
44
- readonly connections: V2RuntimeConnectionsClient;
45
- readonly files: V2RuntimeFilesClient;
46
- readonly runs: V2RuntimeRunsClient;
47
- readonly invocations: V2RuntimeInvocationsClient;
48
- constructor(http: V2HttpClient, data: V2Runtime);
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<V2RuntimeResource>;
52
- connect(request?: V2RuntimeConnectionCreateOptions): Promise<V2RuntimeConnectionResource>;
47
+ refresh(): Promise<V1RuntimeResource>;
48
+ connect(request?: V1RuntimeConnectionCreateOptions): Promise<V1RuntimeConnectionResource>;
53
49
  start(): Promise<{
54
- runtime: V2RuntimeResource;
55
- run: V2RunResource;
50
+ runtime: V1RuntimeResource;
51
+ run: V1RunResource;
56
52
  }>;
57
- stop(): Promise<V2Runtime>;
58
- run(): Promise<V2RunResource>;
53
+ stop(): Promise<V1Runtime>;
54
+ run(): Promise<V1RunResource>;
59
55
  }
60
- export declare class V2RuntimesClient {
56
+ export declare class V1RuntimesClient {
61
57
  private readonly http;
62
- constructor(http: V2HttpClient);
63
- list(query?: V2RuntimeListQuery): Promise<V2ListEnvelope<V2Runtime>>;
64
- iter(query?: V2RuntimeListQuery): AsyncGenerator<V2Runtime, void, undefined>;
65
- create(request: V2RuntimeCreateRequest): Promise<V2RuntimeResource>;
66
- createInSpace(spaceId: string, request: V2SpaceRuntimeCreateRequest): Promise<V2RuntimeResource>;
67
- get(id: string): Promise<V2RuntimeResource>;
68
- stop(id: string): Promise<V2Runtime>;
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: V2RuntimeResource;
71
- run: V2RunResource;
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 { V2RuntimeInvocationsClient } from './invocations.js';
3
- import { iterateV2Pages } from './pagination.js';
4
- import { V2RunResource } from './runs.js';
5
- export class V2RuntimeConnectionResource {
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 V2RuntimeConnectionsClient {
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 V2RuntimeConnectionResource(this.http, this.runtimeId, response);
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 V2RuntimeRunsClient {
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 iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
59
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
63
60
  }
64
61
  }
65
- export class V2RuntimeFilesClient {
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 V2RuntimeResource {
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 V2RuntimeConnectionsClient(http, data.id);
114
- this.files = new V2RuntimeFilesClient(http, data.id);
115
- this.runs = new V2RuntimeRunsClient(http, data.id);
116
- this.invocations = new V2RuntimeInvocationsClient(http, data.id);
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 V2RuntimesClient(this.http).get(this.id);
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 V2RuntimeResource(this.http, response.runtime),
134
- run: new V2RunResource(this.http, response.run),
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 V2RunResource(this.http, run);
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 V2RuntimesClient {
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 iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
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 V2RuntimeResource(this.http, runtime);
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 V2RuntimeResource(this.http, runtime);
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 V2RuntimeResource(this.http, runtime);
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 { V2SpaceBrowsersClient } from './browsers.js';
2
- import type { V2HttpClient } from './http.js';
3
- import { V2RuntimeResource, V2RuntimesClient } from './runtimes.js';
4
- import type { V2ListEnvelope, V2RuntimeListQuery, V2Space, V2SpaceCreateRequest, V2SpaceEnvironment, V2SpaceEnvironmentUpdateRequest, V2SpaceRuntimeCreateRequest, V2SpaceUpdateRequest } from './types.js';
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: V2HttpClient, spaceId: string);
9
- get(): Promise<V2SpaceEnvironment>;
10
- update(request: V2SpaceEnvironmentUpdateRequest): Promise<V2SpaceEnvironment>;
7
+ constructor(http: V1HttpClient, spaceId: string);
8
+ get(): Promise<V1SpaceEnvironment>;
9
+ update(request: V1SpaceEnvironmentUpdateRequest): Promise<V1SpaceEnvironment>;
11
10
  }
12
- export declare class V2SpaceRuntimesClient {
11
+ export declare class V1SpaceRuntimesClient {
13
12
  private readonly http;
14
13
  private readonly spaceId;
15
- constructor(http: V2HttpClient, spaceId: string);
16
- list(query?: Omit<V2RuntimeListQuery, 'spaceId'>): ReturnType<V2RuntimesClient['list']>;
17
- iter(query?: Omit<V2RuntimeListQuery, 'spaceId'>): ReturnType<V2RuntimesClient['iter']>;
18
- create(request: V2SpaceRuntimeCreateRequest): Promise<V2RuntimeResource>;
19
- get(runtimeId: string): Promise<V2RuntimeResource>;
20
- stop(runtimeId: string): ReturnType<V2RuntimesClient['stop']>;
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 V2SpaceResource {
22
+ export declare class V1SpaceResource {
23
23
  private readonly http;
24
- readonly data: V2Space;
25
- readonly environment: V2SpaceEnvironmentClient;
26
- readonly runtimes: V2SpaceRuntimesClient;
27
- readonly browsers: V2SpaceBrowsersClient;
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<V2SpaceResource>;
31
- update(request: V2SpaceUpdateRequest): Promise<V2SpaceResource>;
29
+ refresh(): Promise<V1SpaceResource>;
30
+ update(request: V1SpaceUpdateRequest): Promise<V1SpaceResource>;
32
31
  }
33
- export declare class V2SpacesClient {
32
+ export declare class V1SpacesClient {
34
33
  private readonly http;
35
- constructor(http: V2HttpClient);
36
- list(): Promise<V2ListEnvelope<V2Space>>;
37
- iter(): AsyncGenerator<V2Space, void, undefined>;
38
- create(request: V2SpaceCreateRequest): Promise<V2SpaceResource>;
39
- get(id: string): Promise<V2SpaceResource>;
40
- update(id: string, request: V2SpaceUpdateRequest): Promise<V2SpaceResource>;
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
  }