@bctrl/sdk 1.0.4 → 1.0.5

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 (57) hide show
  1. package/README.md +0 -1
  2. package/dist/account.d.ts +43 -0
  3. package/dist/account.js +100 -0
  4. package/dist/accountTypes.d.ts +126 -0
  5. package/dist/accountTypes.js +1 -0
  6. package/dist/aiProviderTypes.d.ts +58 -0
  7. package/dist/aiProviderTypes.js +1 -0
  8. package/dist/aiProviders.d.ts +13 -0
  9. package/dist/aiProviders.js +36 -0
  10. package/dist/bctrl.d.ts +35 -3
  11. package/dist/bctrl.js +74 -6
  12. package/dist/browserExtensionTypes.d.ts +45 -0
  13. package/dist/browserExtensionTypes.js +1 -0
  14. package/dist/browserExtensions.d.ts +14 -0
  15. package/dist/browserExtensions.js +53 -0
  16. package/dist/files.d.ts +6 -24
  17. package/dist/files.js +9 -56
  18. package/dist/help.d.ts +7 -0
  19. package/dist/help.js +9 -0
  20. package/dist/http.d.ts +12 -1
  21. package/dist/http.js +73 -10
  22. package/dist/index.d.ts +17 -6
  23. package/dist/index.js +15 -5
  24. package/dist/invocations.d.ts +85 -47
  25. package/dist/invocations.js +144 -102
  26. package/dist/node.d.ts +12 -0
  27. package/dist/node.js +11 -0
  28. package/dist/proxies.d.ts +21 -0
  29. package/dist/proxies.js +55 -0
  30. package/dist/proxyTypes.d.ts +114 -0
  31. package/dist/proxyTypes.js +1 -0
  32. package/dist/runs.d.ts +35 -31
  33. package/dist/runs.js +95 -38
  34. package/dist/runtimes.d.ts +26 -42
  35. package/dist/runtimes.js +64 -65
  36. package/dist/schemas.d.ts +7 -0
  37. package/dist/schemas.js +36 -0
  38. package/dist/spaces.d.ts +20 -32
  39. package/dist/spaces.js +48 -36
  40. package/dist/toolCallTypes.d.ts +41 -0
  41. package/dist/toolCallTypes.js +1 -0
  42. package/dist/toolCalls.d.ts +9 -0
  43. package/dist/toolCalls.js +16 -0
  44. package/dist/tools.d.ts +23 -0
  45. package/dist/tools.js +49 -0
  46. package/dist/toolsetTypes.d.ts +32 -0
  47. package/dist/toolsetTypes.js +1 -0
  48. package/dist/toolsets.d.ts +12 -0
  49. package/dist/toolsets.js +31 -0
  50. package/dist/types.d.ts +499 -155
  51. package/dist/utils.d.ts +2 -1
  52. package/dist/utils.js +28 -3
  53. package/dist/vault.d.ts +14 -0
  54. package/dist/vault.js +37 -0
  55. package/dist/vaultTypes.d.ts +73 -0
  56. package/dist/vaultTypes.js +1 -0
  57. package/package.json +21 -12
package/dist/runs.js CHANGED
@@ -1,6 +1,6 @@
1
+ import { v1IdempotencyHeaders } from './http.js';
1
2
  import { iterateV1Pages } from './pagination.js';
2
- import { V1RunFilesClient } from './files.js';
3
- export class V1RunEventsClient {
3
+ class V1RunEventsClient {
4
4
  http;
5
5
  runId;
6
6
  constructor(http, runId) {
@@ -13,12 +13,6 @@ export class V1RunEventsClient {
13
13
  iter(query = {}) {
14
14
  return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
15
15
  }
16
- wait(request) {
17
- return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events/wait`, {
18
- method: 'POST',
19
- body: request ?? {},
20
- });
21
- }
22
16
  streamUrl(query = {}) {
23
17
  const url = new URL(`${this.http.baseUrl}/runs/${encodeURIComponent(this.runId)}/events/stream`);
24
18
  for (const [key, value] of Object.entries(query)) {
@@ -35,7 +29,7 @@ export class V1RunEventsClient {
35
29
  return url.toString();
36
30
  }
37
31
  }
38
- export class V1RunCommandsClient {
32
+ class V1RunActivityClient {
39
33
  http;
40
34
  runId;
41
35
  constructor(http, runId) {
@@ -43,63 +37,126 @@ export class V1RunCommandsClient {
43
37
  this.runId = runId;
44
38
  }
45
39
  list(query = {}) {
46
- return this.http.request(`/runs/${encodeURIComponent(this.runId)}/commands`, { query });
40
+ return this.http.request(`/runs/${encodeURIComponent(this.runId)}/activity`, { query });
47
41
  }
48
42
  iter(query = {}) {
49
43
  return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
50
44
  }
45
+ streamUrl(query = {}) {
46
+ const url = new URL(`${this.http.baseUrl}/runs/${encodeURIComponent(this.runId)}/activity/stream`);
47
+ for (const [key, value] of Object.entries(query)) {
48
+ if (value === undefined)
49
+ continue;
50
+ if (Array.isArray(value)) {
51
+ for (const item of value)
52
+ url.searchParams.append(key, String(item));
53
+ }
54
+ else {
55
+ url.searchParams.set(key, String(value));
56
+ }
57
+ }
58
+ return url.toString();
59
+ }
51
60
  }
52
- export class V1RunResource {
61
+ export class V1RunsClient {
53
62
  http;
54
- data;
55
63
  events;
56
- commands;
64
+ activity;
57
65
  files;
58
- constructor(http, data) {
66
+ invocations;
67
+ constructor(http) {
59
68
  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);
69
+ this.events = new V1RunEventsNamespaceClient(http);
70
+ this.activity = new V1RunActivityNamespaceClient(http);
71
+ this.files = new V1RunFilesNamespaceClient(http);
72
+ this.invocations = new V1RunInvocationsNamespaceClient(http);
73
+ }
74
+ list(query = {}) {
75
+ return this.http.request('/runs', { query });
76
+ }
77
+ iter(query = {}) {
78
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
64
79
  }
65
- get id() {
66
- return this.data.id;
80
+ get(id) {
81
+ return this.http.request(`/runs/${encodeURIComponent(id)}`);
67
82
  }
68
- refresh() {
69
- return new V1RunsClient(this.http).get(this.id);
83
+ usage(id) {
84
+ return this.http.request(`/runs/${encodeURIComponent(id)}/usage`);
70
85
  }
71
- live(request) {
72
- return this.http.request(`/runs/${encodeURIComponent(this.id)}/live`, {
86
+ live(id, request) {
87
+ return this.http.request(`/runs/${encodeURIComponent(id)}/live`, {
73
88
  method: 'POST',
74
89
  body: request ?? {},
75
90
  });
76
91
  }
77
- recording(request) {
78
- return this.http.request(`/runs/${encodeURIComponent(this.id)}/recording`, {
92
+ recording(id, request) {
93
+ return this.http.request(`/runs/${encodeURIComponent(id)}/recording`, {
79
94
  method: 'POST',
80
95
  body: request ?? {},
81
96
  });
82
97
  }
83
- usage() {
84
- return this.http.request(`/runs/${encodeURIComponent(this.id)}/usage`);
98
+ }
99
+ export class V1RunEventsNamespaceClient {
100
+ http;
101
+ constructor(http) {
102
+ this.http = http;
103
+ }
104
+ list(runId, query = {}) {
105
+ return new V1RunEventsClient(this.http, runId).list(query);
106
+ }
107
+ iter(runId, query = {}) {
108
+ return new V1RunEventsClient(this.http, runId).iter(query);
109
+ }
110
+ streamUrl(runId, query = {}) {
111
+ return new V1RunEventsClient(this.http, runId).streamUrl(query);
85
112
  }
86
113
  }
87
- export class V1RunsClient {
114
+ export class V1RunActivityNamespaceClient {
88
115
  http;
89
116
  constructor(http) {
90
117
  this.http = http;
91
118
  }
92
- list(query = {}) {
93
- return this.http.request('/runs', { query });
119
+ list(runId, query = {}) {
120
+ return new V1RunActivityClient(this.http, runId).list(query);
94
121
  }
95
- iter(query = {}) {
96
- return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
122
+ iter(runId, query = {}) {
123
+ return new V1RunActivityClient(this.http, runId).iter(query);
97
124
  }
98
- async get(id) {
99
- const run = await this.http.request(`/runs/${encodeURIComponent(id)}`);
100
- return new V1RunResource(this.http, run);
125
+ streamUrl(runId, query = {}) {
126
+ return new V1RunActivityClient(this.http, runId).streamUrl(query);
101
127
  }
102
- usage(id) {
103
- return this.http.request(`/runs/${encodeURIComponent(id)}/usage`);
128
+ }
129
+ export class V1RunFilesNamespaceClient {
130
+ http;
131
+ constructor(http) {
132
+ this.http = http;
133
+ }
134
+ list(runId, query = {}) {
135
+ return this.http.request(`/runs/${encodeURIComponent(runId)}/files`, { query });
136
+ }
137
+ iter(runId, query = {}) {
138
+ return iterateV1Pages(query, (pageQuery) => this.list(runId, pageQuery));
139
+ }
140
+ export(runId, request = {}, options) {
141
+ return this.http.request(`/runs/${encodeURIComponent(runId)}/files/export`, {
142
+ method: 'POST',
143
+ body: request,
144
+ headers: v1IdempotencyHeaders(options),
145
+ });
146
+ }
147
+ }
148
+ export class V1RunInvocationsNamespaceClient {
149
+ http;
150
+ constructor(http) {
151
+ this.http = http;
152
+ }
153
+ list(runId, query = {}) {
154
+ return this.http.request(`/runs/${encodeURIComponent(runId)}/invocations`, { query });
155
+ }
156
+ iter(runId, query = {}) {
157
+ return iterateV1Pages(query, (pageQuery) => this.list(runId, pageQuery));
158
+ }
159
+ get(runId, invocationId) {
160
+ return this.http.request(`/runs/${encodeURIComponent(runId)}/invocations/${encodeURIComponent(invocationId)}`);
104
161
  }
105
162
  }
@@ -1,49 +1,33 @@
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, V1RuntimeCreateRequest, V1RuntimeFileCollectRequest, V1RuntimeFileStageRequest, V1RuntimeFileUploadRequest, V1RuntimeFileUploadResponse, V1RuntimeStagedFile, V1RuntimeListQuery, V1RuntimeRunListQuery, V1RuntimeStartBrowser, V1RuntimeStartRuntime, V1RunSummary, V1SpaceRuntimeCreateRequest } from './types.js';
5
- export type V1RuntimeStartResult = {
6
- runtime: V1RuntimeResource;
7
- run: V1RunResource;
8
- browser: V1RuntimeStartBrowser;
9
- };
10
- export declare class V1RuntimeRunsClient {
11
- private readonly http;
12
- private readonly runtimeId;
13
- constructor(http: V1HttpClient, runtimeId: string);
14
- list(query?: V1RuntimeRunListQuery): Promise<V1ListEnvelope<V1RunSummary>>;
15
- iter(query?: V1RuntimeRunListQuery): AsyncGenerator<V1RunSummary, void, undefined>;
16
- }
17
- export declare class V1RuntimeFilesClient {
1
+ import { type V1HttpClient, type V1IdempotencyOptions } from './http.js';
2
+ import { V1RuntimeInvocationsNamespaceClient } from './invocations.js';
3
+ import type { V1ListEnvelope, V1File, V1Runtime, V1RuntimeCreateRequest, V1RuntimeFileCollectRequest, V1RuntimeFilesListQuery, V1RuntimeFileStageRequest, V1RuntimeFileUploadRequest, V1RuntimeStagedFile, V1RuntimeListQuery, V1RuntimeRunListQuery, V1RuntimeStartResponse, V1RuntimeStopResponse, V1RunSummary, V1SpaceRuntimeCreateRequest } from './types.js';
4
+ export type V1RuntimeStartResult = V1RuntimeStartResponse;
5
+ export declare class V1RuntimesClient {
18
6
  private readonly http;
19
- private readonly runtimeId;
20
- constructor(http: V1HttpClient, runtimeId: string);
21
- upload(request: V1RuntimeFileUploadRequest): Promise<V1RuntimeFileUploadResponse>;
22
- stage(request: V1RuntimeFileStageRequest): Promise<V1RuntimeStagedFile>;
23
- collect(request: V1RuntimeFileCollectRequest): Promise<V1File>;
7
+ readonly files: V1RuntimeFilesNamespaceClient;
8
+ readonly runs: V1RuntimeRunsNamespaceClient;
9
+ readonly invocations: V1RuntimeInvocationsNamespaceClient;
10
+ constructor(http: V1HttpClient);
11
+ list(query?: V1RuntimeListQuery): Promise<V1ListEnvelope<V1Runtime>>;
12
+ iter(query?: V1RuntimeListQuery): AsyncGenerator<V1Runtime, void, undefined>;
13
+ create(request: V1RuntimeCreateRequest): Promise<V1Runtime>;
14
+ createInSpace(spaceId: string, request: V1SpaceRuntimeCreateRequest): Promise<V1Runtime>;
15
+ get(id: string): Promise<V1Runtime>;
16
+ stop(id: string): Promise<V1RuntimeStopResponse>;
17
+ start(id: string, options?: V1IdempotencyOptions): Promise<V1RuntimeStartResult>;
24
18
  }
25
- export declare class V1RuntimeResource {
19
+ export declare class V1RuntimeRunsNamespaceClient {
26
20
  private readonly http;
27
- readonly data: V1Runtime | V1RuntimeStartRuntime;
28
- readonly files: V1RuntimeFilesClient;
29
- readonly runs: V1RuntimeRunsClient;
30
- readonly invocations: V1RuntimeInvocationsClient;
31
- constructor(http: V1HttpClient, data: V1Runtime | V1RuntimeStartRuntime);
32
- get id(): string;
33
- get activeRunId(): string | null;
34
- refresh(): Promise<V1RuntimeResource>;
35
- start(): Promise<V1RuntimeStartResult>;
36
- stop(): Promise<V1Runtime>;
37
- run(): Promise<V1RunResource>;
21
+ constructor(http: V1HttpClient);
22
+ list(runtimeId: string, query?: V1RuntimeRunListQuery): Promise<V1ListEnvelope<V1RunSummary>>;
23
+ iter(runtimeId: string, query?: V1RuntimeRunListQuery): AsyncGenerator<V1RunSummary, void, undefined>;
38
24
  }
39
- export declare class V1RuntimesClient {
25
+ export declare class V1RuntimeFilesNamespaceClient {
40
26
  private readonly http;
41
27
  constructor(http: V1HttpClient);
42
- list(query?: V1RuntimeListQuery): Promise<V1ListEnvelope<V1Runtime>>;
43
- iter(query?: V1RuntimeListQuery): AsyncGenerator<V1Runtime, void, undefined>;
44
- create(request: V1RuntimeCreateRequest): Promise<V1RuntimeResource>;
45
- createInSpace(spaceId: string, request: V1SpaceRuntimeCreateRequest): Promise<V1RuntimeResource>;
46
- get(id: string): Promise<V1RuntimeResource>;
47
- stop(id: string): Promise<V1Runtime>;
48
- start(id: string): Promise<V1RuntimeStartResult>;
28
+ list(runtimeId: string, query?: V1RuntimeFilesListQuery): Promise<V1ListEnvelope<V1File>>;
29
+ iter(runtimeId: string, query?: V1RuntimeFilesListQuery): AsyncGenerator<V1File, void, undefined>;
30
+ upload(runtimeId: string, request: V1RuntimeFileUploadRequest): Promise<V1RuntimeStagedFile>;
31
+ stage(runtimeId: string, request: V1RuntimeFileStageRequest): Promise<V1RuntimeStagedFile>;
32
+ collect(runtimeId: string, request: V1RuntimeFileCollectRequest): Promise<V1File>;
49
33
  }
package/dist/runtimes.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BctrlValidationError } from './errors.js';
2
- import { V1RuntimeInvocationsClient } from './invocations.js';
2
+ import { v1IdempotencyHeaders } from './http.js';
3
+ import { V1RuntimeInvocationsNamespaceClient } from './invocations.js';
3
4
  import { iterateV1Pages } from './pagination.js';
4
- import { V1RunResource } from './runs.js';
5
- export class V1RuntimeRunsClient {
5
+ class V1RuntimeRunsClient {
6
6
  http;
7
7
  runtimeId;
8
8
  constructor(http, runtimeId) {
@@ -16,13 +16,19 @@ export class V1RuntimeRunsClient {
16
16
  return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
17
17
  }
18
18
  }
19
- export class V1RuntimeFilesClient {
19
+ class V1RuntimeFilesClient {
20
20
  http;
21
21
  runtimeId;
22
22
  constructor(http, runtimeId) {
23
23
  this.http = http;
24
24
  this.runtimeId = runtimeId;
25
25
  }
26
+ list(query = {}) {
27
+ return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files`, { query });
28
+ }
29
+ iter(query = {}) {
30
+ return iterateV1Pages(query, (pageQuery) => this.list(pageQuery));
31
+ }
26
32
  async upload(request) {
27
33
  const form = new FormData();
28
34
  if (request.name) {
@@ -32,8 +38,10 @@ export class V1RuntimeFilesClient {
32
38
  else {
33
39
  form.set('file', request.file);
34
40
  }
35
- if (request.storagePath)
36
- form.set('storagePath', request.storagePath);
41
+ if (request.destinationPath)
42
+ form.set('destinationPath', request.destinationPath);
43
+ if (request.runtimePath)
44
+ form.set('runtimePath', request.runtimePath);
37
45
  if (request.metadata)
38
46
  form.set('metadata', JSON.stringify(request.metadata));
39
47
  return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/upload`, {
@@ -54,53 +62,6 @@ export class V1RuntimeFilesClient {
54
62
  });
55
63
  }
56
64
  }
57
- export class V1RuntimeResource {
58
- http;
59
- data;
60
- files;
61
- runs;
62
- invocations;
63
- constructor(http, data) {
64
- this.http = http;
65
- this.data = data;
66
- this.files = new V1RuntimeFilesClient(http, data.id);
67
- this.runs = new V1RuntimeRunsClient(http, data.id);
68
- this.invocations = new V1RuntimeInvocationsClient(http, data.id);
69
- }
70
- get id() {
71
- return this.data.id;
72
- }
73
- get activeRunId() {
74
- return 'activeRunId' in this.data ? this.data.activeRunId : null;
75
- }
76
- refresh() {
77
- return new V1RuntimesClient(this.http).get(this.id);
78
- }
79
- async start() {
80
- const response = await this.http.request(`/runtimes/${encodeURIComponent(this.id)}/start`, { method: 'POST' });
81
- return {
82
- runtime: new V1RuntimeResource(this.http, response.runtime),
83
- run: new V1RunResource(this.http, response.run),
84
- browser: response.browser,
85
- };
86
- }
87
- stop() {
88
- return this.http.request(`/runtimes/${encodeURIComponent(this.id)}/stop`, {
89
- method: 'POST',
90
- });
91
- }
92
- async run() {
93
- const runtime = await this.refresh();
94
- const activeRunId = runtime.activeRunId;
95
- if (!activeRunId) {
96
- throw new BctrlValidationError('Runtime does not have an active run yet', 'runtime.no_active_run', {
97
- runtimeId: this.id,
98
- });
99
- }
100
- const run = await this.http.request(`/runs/${encodeURIComponent(activeRunId)}`);
101
- return new V1RunResource(this.http, run);
102
- }
103
- }
104
65
  function validateRuntimeCreateRequest(request) {
105
66
  const profileBacked = request.config?.profile === true;
106
67
  if (!profileBacked)
@@ -108,15 +69,21 @@ function validateRuntimeCreateRequest(request) {
108
69
  if (!request.name?.trim()) {
109
70
  throw new BctrlValidationError('name is required when config.profile is true', 'runtime.profile_name_required');
110
71
  }
111
- const unsupported = ['stealth', 'proxy', 'fingerprint', 'extensions'].filter((key) => request.config?.[key] !== undefined);
72
+ const unsupported = ['stealth', 'proxy', 'fingerprint', 'extensionIds'].filter((key) => request.config?.[key] !== undefined);
112
73
  if (unsupported.length > 0) {
113
- throw new BctrlValidationError('Only config.profile, config.idleTimeoutMinutes, config.webRtcProxyOnly, and config.forceOpenShadowRoots are supported for profile-backed browser runtimes', 'runtime.profile_config_unsupported', { unsupported });
74
+ throw new BctrlValidationError('Only config.profile, config.idleTimeoutMinutes, config.webRtcProxyOnly, config.forceOpenShadowRoots, and config.networkTraffic are supported for profile-backed browser runtimes', 'runtime.profile_config_unsupported', { unsupported });
114
75
  }
115
76
  }
116
77
  export class V1RuntimesClient {
117
78
  http;
79
+ files;
80
+ runs;
81
+ invocations;
118
82
  constructor(http) {
119
83
  this.http = http;
84
+ this.files = new V1RuntimeFilesNamespaceClient(http);
85
+ this.runs = new V1RuntimeRunsNamespaceClient(http);
86
+ this.invocations = new V1RuntimeInvocationsNamespaceClient(http);
120
87
  }
121
88
  list(query = {}) {
122
89
  return this.http.request('/runtimes', { query });
@@ -126,31 +93,63 @@ export class V1RuntimesClient {
126
93
  }
127
94
  async create(request) {
128
95
  validateRuntimeCreateRequest(request);
129
- const runtime = await this.http.request('/runtimes', {
96
+ return this.http.request('/runtimes', {
130
97
  method: 'POST',
131
98
  body: request,
132
99
  });
133
- return new V1RuntimeResource(this.http, runtime);
134
100
  }
135
101
  async createInSpace(spaceId, request) {
136
102
  validateRuntimeCreateRequest(request);
137
- const runtime = await this.http.request('/runtimes', {
103
+ return this.http.request('/runtimes', {
138
104
  method: 'POST',
139
105
  body: { ...request, spaceId },
140
106
  });
141
- return new V1RuntimeResource(this.http, runtime);
142
107
  }
143
- async get(id) {
144
- const runtime = await this.http.request(`/runtimes/${encodeURIComponent(id)}`);
145
- return new V1RuntimeResource(this.http, runtime);
108
+ get(id) {
109
+ return this.http.request(`/runtimes/${encodeURIComponent(id)}`);
146
110
  }
147
111
  stop(id) {
148
112
  return this.http.request(`/runtimes/${encodeURIComponent(id)}/stop`, {
149
113
  method: 'POST',
150
114
  });
151
115
  }
152
- async start(id) {
153
- const runtime = await this.get(id);
154
- return runtime.start();
116
+ async start(id, options) {
117
+ return this.http.request(`/runtimes/${encodeURIComponent(id)}/start`, {
118
+ method: 'POST',
119
+ headers: v1IdempotencyHeaders(options),
120
+ });
121
+ }
122
+ }
123
+ export class V1RuntimeRunsNamespaceClient {
124
+ http;
125
+ constructor(http) {
126
+ this.http = http;
127
+ }
128
+ list(runtimeId, query = {}) {
129
+ return new V1RuntimeRunsClient(this.http, runtimeId).list(query);
130
+ }
131
+ iter(runtimeId, query = {}) {
132
+ return new V1RuntimeRunsClient(this.http, runtimeId).iter(query);
133
+ }
134
+ }
135
+ export class V1RuntimeFilesNamespaceClient {
136
+ http;
137
+ constructor(http) {
138
+ this.http = http;
139
+ }
140
+ list(runtimeId, query = {}) {
141
+ return new V1RuntimeFilesClient(this.http, runtimeId).list(query);
142
+ }
143
+ iter(runtimeId, query = {}) {
144
+ return new V1RuntimeFilesClient(this.http, runtimeId).iter(query);
145
+ }
146
+ upload(runtimeId, request) {
147
+ return new V1RuntimeFilesClient(this.http, runtimeId).upload(request);
148
+ }
149
+ stage(runtimeId, request) {
150
+ return new V1RuntimeFilesClient(this.http, runtimeId).stage(request);
151
+ }
152
+ collect(runtimeId, request) {
153
+ return new V1RuntimeFilesClient(this.http, runtimeId).collect(request);
155
154
  }
156
155
  }
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ import type { JsonObject } from './types.js';
3
+ export type JsonSchemaObject = JsonObject;
4
+ export type JsonSchemaLike = JsonSchemaObject | {
5
+ toJSONSchema: () => unknown;
6
+ } | z.ZodType;
7
+ export declare function toOutputSchema(schema: JsonSchemaLike, label?: string): JsonSchemaObject;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ export function toOutputSchema(schema, label = 'schema') {
3
+ const value = resolveSchema(schema);
4
+ if (!isJsonObject(value)) {
5
+ throw new TypeError(`${label} must resolve to a JSON Schema object`);
6
+ }
7
+ const { $schema, ...jsonSchema } = value;
8
+ void $schema;
9
+ return jsonSchema;
10
+ }
11
+ function resolveSchema(schema) {
12
+ if (hasToJSONSchema(schema)) {
13
+ return schema.toJSONSchema();
14
+ }
15
+ const zodJsonSchema = tryZodToJsonSchema(schema);
16
+ if (zodJsonSchema !== undefined)
17
+ return zodJsonSchema;
18
+ return schema;
19
+ }
20
+ function hasToJSONSchema(value) {
21
+ return Boolean(value &&
22
+ typeof value === 'object' &&
23
+ 'toJSONSchema' in value &&
24
+ typeof value.toJSONSchema === 'function');
25
+ }
26
+ function tryZodToJsonSchema(value) {
27
+ try {
28
+ return z.toJSONSchema(value);
29
+ }
30
+ catch {
31
+ return undefined;
32
+ }
33
+ }
34
+ function isJsonObject(value) {
35
+ return value !== null && typeof value === 'object' && !Array.isArray(value);
36
+ }
package/dist/spaces.d.ts CHANGED
@@ -1,40 +1,28 @@
1
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 {
2
+ import { V1RuntimesClient } from './runtimes.js';
3
+ import type { V1ListEnvelope, V1Runtime, V1RuntimeListQuery, V1Space, V1SpaceCreateRequest, V1SpaceDeleteResponse, V1SpaceEnvironment, V1SpaceEnvironmentUpdateRequest, V1SpaceListQuery, V1SpaceRuntimeCreateRequest, V1SpaceUpdateRequest } from './types.js';
4
+ export declare class V1SpacesClient {
12
5
  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']>;
6
+ readonly environment: V1SpaceEnvironmentNamespaceClient;
7
+ readonly runtimes: V1SpaceRuntimesNamespaceClient;
8
+ constructor(http: V1HttpClient);
9
+ list(query?: V1SpaceListQuery): Promise<V1ListEnvelope<V1Space>>;
10
+ iter(query?: V1SpaceListQuery): AsyncGenerator<V1Space, void, undefined>;
11
+ create(request: V1SpaceCreateRequest): Promise<V1Space>;
12
+ get(id: string): Promise<V1Space>;
13
+ update(id: string, request: V1SpaceUpdateRequest): Promise<V1Space>;
14
+ delete(id: string): Promise<V1SpaceDeleteResponse>;
21
15
  }
22
- export declare class V1SpaceResource {
16
+ export declare class V1SpaceEnvironmentNamespaceClient {
23
17
  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>;
18
+ constructor(http: V1HttpClient);
19
+ get(spaceId: string): Promise<V1SpaceEnvironment>;
20
+ update(spaceId: string, request: V1SpaceEnvironmentUpdateRequest): Promise<V1SpaceEnvironment>;
31
21
  }
32
- export declare class V1SpacesClient {
22
+ export declare class V1SpaceRuntimesNamespaceClient {
33
23
  private readonly http;
34
24
  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>;
25
+ list(spaceId: string, query?: Omit<V1RuntimeListQuery, 'spaceId'>): ReturnType<V1RuntimesClient['list']>;
26
+ iter(spaceId: string, query?: Omit<V1RuntimeListQuery, 'spaceId'>): ReturnType<V1RuntimesClient['iter']>;
27
+ create(spaceId: string, request: V1SpaceRuntimeCreateRequest): Promise<V1Runtime>;
40
28
  }