@miosa/sdk 1.2.4 → 1.2.6

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 (100) hide show
  1. package/README.md +75 -3
  2. package/dist/index.d.ts +323 -175
  3. package/dist/index.js +441 -386
  4. package/dist/index.js.map +1 -1
  5. package/package.json +1 -2
  6. package/src/client.ts +0 -293
  7. package/src/errors.ts +0 -136
  8. package/src/http.test.ts +0 -374
  9. package/src/http.ts +0 -390
  10. package/src/index.ts +0 -564
  11. package/src/resources/admin.ts +0 -359
  12. package/src/resources/analytics.ts +0 -60
  13. package/src/resources/api-keys.ts +0 -135
  14. package/src/resources/audit-log.ts +0 -64
  15. package/src/resources/benchmarks.ts +0 -104
  16. package/src/resources/builder-sessions.ts +0 -75
  17. package/src/resources/channels.ts +0 -143
  18. package/src/resources/checkpoints.ts +0 -225
  19. package/src/resources/command-center.ts +0 -73
  20. package/src/resources/community.ts +0 -103
  21. package/src/resources/completions.ts +0 -104
  22. package/src/resources/computer-auto-stop.ts +0 -43
  23. package/src/resources/computer-env.ts +0 -76
  24. package/src/resources/computer-logs.ts +0 -50
  25. package/src/resources/computer-osa.ts +0 -76
  26. package/src/resources/computer-ports.ts +0 -91
  27. package/src/resources/computer-terminal.ts +0 -61
  28. package/src/resources/computer-volumes.ts +0 -64
  29. package/src/resources/computer.ts +0 -551
  30. package/src/resources/computers.ts +0 -75
  31. package/src/resources/credits.ts +0 -43
  32. package/src/resources/cron-jobs.ts +0 -191
  33. package/src/resources/custom_domains.ts +0 -123
  34. package/src/resources/dashboard.ts +0 -49
  35. package/src/resources/databases.ts +0 -218
  36. package/src/resources/deployments.test.ts +0 -194
  37. package/src/resources/deployments.ts +0 -1060
  38. package/src/resources/desktop.ts +0 -134
  39. package/src/resources/docker-deploy.test.ts +0 -102
  40. package/src/resources/docker-deploy.ts +0 -183
  41. package/src/resources/egress.test.ts +0 -318
  42. package/src/resources/egressAudit.ts +0 -245
  43. package/src/resources/egressNetwork.ts +0 -450
  44. package/src/resources/egressSecrets.ts +0 -577
  45. package/src/resources/email.ts +0 -212
  46. package/src/resources/embeddings.ts +0 -36
  47. package/src/resources/events.ts +0 -296
  48. package/src/resources/exec.ts +0 -319
  49. package/src/resources/external-keys.ts +0 -79
  50. package/src/resources/files.test.ts +0 -339
  51. package/src/resources/files.ts +0 -220
  52. package/src/resources/flat-custom-domains.ts +0 -127
  53. package/src/resources/functions.ts +0 -178
  54. package/src/resources/governance.test.ts +0 -355
  55. package/src/resources/governance.ts +0 -528
  56. package/src/resources/health-checks.ts +0 -165
  57. package/src/resources/integrations.ts +0 -183
  58. package/src/resources/mcp.ts +0 -70
  59. package/src/resources/models.ts +0 -45
  60. package/src/resources/network_policy.ts +0 -73
  61. package/src/resources/open-computers/agents.ts +0 -91
  62. package/src/resources/open-computers/apps.ts +0 -102
  63. package/src/resources/open-computers/clusters.ts +0 -88
  64. package/src/resources/open-computers/desktop.ts +0 -34
  65. package/src/resources/open-computers/files.ts +0 -97
  66. package/src/resources/open-computers/hosts.ts +0 -85
  67. package/src/resources/open-computers/index.ts +0 -98
  68. package/src/resources/open-computers/jobs.ts +0 -75
  69. package/src/resources/open-computers/open_computers.test.ts +0 -288
  70. package/src/resources/open-computers/secrets.ts +0 -115
  71. package/src/resources/open-computers/terminal.ts +0 -33
  72. package/src/resources/open-computers/tunnels.ts +0 -87
  73. package/src/resources/open-computers/types.ts +0 -343
  74. package/src/resources/open-computers/workspaces.ts +0 -135
  75. package/src/resources/org-invites.ts +0 -189
  76. package/src/resources/phase1.test.ts +0 -187
  77. package/src/resources/project-auth.ts +0 -142
  78. package/src/resources/project-integrations.ts +0 -133
  79. package/src/resources/provider-defaults.ts +0 -89
  80. package/src/resources/quotas.ts +0 -77
  81. package/src/resources/regions.ts +0 -94
  82. package/src/resources/sandbox-processes.ts +0 -112
  83. package/src/resources/sandbox-shares.ts +0 -83
  84. package/src/resources/sandbox-templates.ts +0 -195
  85. package/src/resources/sandboxes.live.test.ts +0 -92
  86. package/src/resources/sandboxes.test.ts +0 -653
  87. package/src/resources/sandboxes.ts +0 -1433
  88. package/src/resources/settings.ts +0 -143
  89. package/src/resources/snapshots-standalone.ts +0 -51
  90. package/src/resources/storage.ts +0 -221
  91. package/src/resources/tenant-events.ts +0 -32
  92. package/src/resources/tenant.ts +0 -148
  93. package/src/resources/usage.ts +0 -85
  94. package/src/resources/volumes.ts +0 -117
  95. package/src/resources/webhooks.ts +0 -224
  96. package/src/resources/workspace-invites.ts +0 -188
  97. package/src/resources/workspace-members.test.ts +0 -121
  98. package/src/resources/workspace-members.ts +0 -143
  99. package/src/resources/workspaces.ts +0 -285
  100. package/src/types.ts +0 -463
@@ -1,115 +0,0 @@
1
- import { HttpClient } from "../../http.js";
2
- import type {
3
- HostId,
4
- SecretCreateParams,
5
- SecretData,
6
- SecretId,
7
- SecretUpdateParams,
8
- } from "./types.js";
9
-
10
- /**
11
- * Secrets resource — manage encrypted per-host (and per-tenant) env vars.
12
- *
13
- * Secrets are injected into exec sessions and PTY sessions on the host.
14
- * The value is encrypted at rest; `reveal()` decrypts it for one-time display.
15
- *
16
- * ```ts
17
- * // Tenant-wide secret (shared across all hosts)
18
- * await client.openComputers.secrets.createForTenant({ name: "OPENAI_KEY", value: "sk-..." });
19
- *
20
- * // Host-specific secret
21
- * const secret = await client.openComputers.secrets.createForHost(hostId, {
22
- * name: "DB_PASSWORD", value: "hunter2",
23
- * });
24
- * ```
25
- */
26
- export class Secrets {
27
- private readonly http: HttpClient;
28
-
29
- constructor(http: HttpClient) {
30
- this.http = http;
31
- }
32
-
33
- // ── Tenant-scoped secrets ────────────────────────────────────────────────────
34
-
35
- /**
36
- * List all tenant-scoped secrets.
37
- */
38
- async listForTenant(): Promise<SecretData[]> {
39
- const result = await this.http.get<{ data: SecretData[] }>(
40
- "/opencomputers/secrets",
41
- );
42
- return result.data;
43
- }
44
-
45
- /**
46
- * Create a tenant-scoped secret (available to all hosts).
47
- */
48
- async createForTenant(params: SecretCreateParams): Promise<SecretData> {
49
- return this.http.post<SecretData>("/opencomputers/secrets", params);
50
- }
51
-
52
- // ── Host-scoped secrets ──────────────────────────────────────────────────────
53
-
54
- /**
55
- * List secrets scoped to a specific host.
56
- */
57
- async listForHost(hostId: HostId | string): Promise<SecretData[]> {
58
- const result = await this.http.get<{ data: SecretData[] }>(
59
- `/opencomputers/hosts/${hostId}/secrets`,
60
- );
61
- return result.data;
62
- }
63
-
64
- /**
65
- * Create a secret scoped to a specific host.
66
- */
67
- async createForHost(
68
- hostId: HostId | string,
69
- params: SecretCreateParams,
70
- ): Promise<SecretData> {
71
- return this.http.post<SecretData>(
72
- `/opencomputers/hosts/${hostId}/secrets`,
73
- params,
74
- );
75
- }
76
-
77
- /**
78
- * Update a host-scoped secret (rotate value or update description).
79
- */
80
- async updateForHost(
81
- hostId: HostId | string,
82
- secretId: SecretId | string,
83
- params: SecretUpdateParams,
84
- ): Promise<SecretData> {
85
- return this.http.patch<SecretData>(
86
- `/opencomputers/hosts/${hostId}/secrets/${secretId}`,
87
- params,
88
- );
89
- }
90
-
91
- /**
92
- * Delete a host-scoped secret.
93
- */
94
- async deleteForHost(
95
- hostId: HostId | string,
96
- secretId: SecretId | string,
97
- ): Promise<void> {
98
- return this.http.delete<void>(
99
- `/opencomputers/hosts/${hostId}/secrets/${secretId}`,
100
- );
101
- }
102
-
103
- /**
104
- * Reveal (decrypt and return) the plaintext value of a secret.
105
- * Use sparingly — each call is audit-logged.
106
- */
107
- async reveal(
108
- hostId: HostId | string,
109
- secretId: SecretId | string,
110
- ): Promise<{ value: string }> {
111
- return this.http.post<{ value: string }>(
112
- `/opencomputers/hosts/${hostId}/secrets/${secretId}/reveal`,
113
- );
114
- }
115
- }
@@ -1,33 +0,0 @@
1
- import { HttpClient } from "../../http.js";
2
- import type { HostId, WsTicket } from "./types.js";
3
-
4
- /**
5
- * Terminal resource — issue WebSocket tickets for interactive PTY sessions on
6
- * a remote OpenComputers host.
7
- *
8
- * The ticket is consumed by a WebSocket upgrade at the URL in `ws_url`. Use
9
- * xterm.js or any raw WebSocket client to drive the terminal.
10
- *
11
- * ```ts
12
- * const { ws_url } = await client.openComputers.terminal.ticket(hostId);
13
- * const ws = new WebSocket(ws_url);
14
- * ```
15
- */
16
- export class Terminal {
17
- private readonly http: HttpClient;
18
-
19
- constructor(http: HttpClient) {
20
- this.http = http;
21
- }
22
-
23
- /**
24
- * Issue a short-lived WebSocket ticket for a terminal session.
25
- *
26
- * The ticket expires quickly — open the WebSocket immediately after receiving it.
27
- */
28
- async ticket(hostId: HostId | string): Promise<WsTicket> {
29
- return this.http.post<WsTicket>(
30
- `/opencomputers/hosts/${hostId}/terminal/ticket`,
31
- );
32
- }
33
- }
@@ -1,87 +0,0 @@
1
- import { HttpClient } from "../../http.js";
2
- import type {
3
- HostId,
4
- TunnelCreateParams,
5
- TunnelData,
6
- TunnelId,
7
- TunnelListResponse,
8
- TunnelUpdateParams,
9
- } from "./types.js";
10
-
11
- /**
12
- * Tunnels resource — expose ports on a remote host as publicly reachable URLs.
13
- *
14
- * The public proxy is served at `/t/:slug/*path`. The `auth_mode` field on each
15
- * tunnel controls whether the URL is open to the internet or requires
16
- * tenant credentials / a password.
17
- *
18
- * ```ts
19
- * const tunnel = await client.openComputers.tunnels.create(hostId, {
20
- * target_port: 8080,
21
- * auth_mode: "public",
22
- * });
23
- * console.log(tunnel.public_url); // https://api.miosa.ai/t/<slug>
24
- * ```
25
- */
26
- export class Tunnels {
27
- private readonly http: HttpClient;
28
-
29
- constructor(http: HttpClient) {
30
- this.http = http;
31
- }
32
-
33
- private base(hostId: string): string {
34
- return `/opencomputers/hosts/${hostId}/tunnels`;
35
- }
36
-
37
- /**
38
- * List all tunnels for a host.
39
- */
40
- async list(hostId: HostId | string): Promise<TunnelListResponse> {
41
- return this.http.get<TunnelListResponse>(this.base(hostId));
42
- }
43
-
44
- /**
45
- * Create a new tunnel that forwards traffic to `target_port` on the host.
46
- */
47
- async create(
48
- hostId: HostId | string,
49
- params: TunnelCreateParams,
50
- ): Promise<TunnelData> {
51
- return this.http.post<TunnelData>(this.base(hostId), params);
52
- }
53
-
54
- /**
55
- * Fetch a single tunnel.
56
- */
57
- async get(
58
- hostId: HostId | string,
59
- tunnelId: TunnelId | string,
60
- ): Promise<TunnelData> {
61
- return this.http.get<TunnelData>(`${this.base(hostId)}/${tunnelId}`);
62
- }
63
-
64
- /**
65
- * Update a tunnel (target port, auth mode, or enabled state).
66
- */
67
- async update(
68
- hostId: HostId | string,
69
- tunnelId: TunnelId | string,
70
- params: TunnelUpdateParams,
71
- ): Promise<TunnelData> {
72
- return this.http.patch<TunnelData>(
73
- `${this.base(hostId)}/${tunnelId}`,
74
- params,
75
- );
76
- }
77
-
78
- /**
79
- * Delete a tunnel. The public URL immediately becomes unreachable.
80
- */
81
- async delete(
82
- hostId: HostId | string,
83
- tunnelId: TunnelId | string,
84
- ): Promise<void> {
85
- return this.http.delete<void>(`${this.base(hostId)}/${tunnelId}`);
86
- }
87
- }
@@ -1,343 +0,0 @@
1
- // ─── OpenComputers shared types ──────────────────────────────────────────────
2
-
3
- export type HostId = string & { readonly __brand: "HostId" };
4
- export type JobId = string & { readonly __brand: "JobId" };
5
- export type TunnelId = string & { readonly __brand: "TunnelId" };
6
- export type ClusterId = string & { readonly __brand: "ClusterId" };
7
- export type WorkspaceId = string & { readonly __brand: "WorkspaceId" };
8
- export type SecretId = string & { readonly __brand: "SecretId" };
9
-
10
- // ─── Hosts ───────────────────────────────────────────────────────────────────
11
-
12
- export type HostStatus = "pending" | "online" | "offline" | "error" | "revoked";
13
-
14
- export interface HostData {
15
- id: HostId;
16
- name: string;
17
- region: string | null;
18
- status: HostStatus;
19
- tenant_id: string;
20
- labels: Record<string, string>;
21
- /** Present only on create response — treat as write-once. */
22
- host_key?: string;
23
- created_at: string;
24
- updated_at: string;
25
- }
26
-
27
- export interface HostCreateParams {
28
- name: string;
29
- region?: string;
30
- labels?: Record<string, string>;
31
- }
32
-
33
- export interface HostUpdateParams {
34
- name?: string;
35
- labels?: Record<string, string>;
36
- }
37
-
38
- export interface HostListResponse {
39
- data: HostData[];
40
- meta: { total: number; page: number; per_page: number };
41
- }
42
-
43
- export interface HostEvent {
44
- type: "host_connected" | "host_disconnected" | "host_error" | string;
45
- host_id: HostId;
46
- data: unknown;
47
- timestamp: string;
48
- }
49
-
50
- // ─── Jobs (exec on host) ─────────────────────────────────────────────────────
51
-
52
- export type JobStatus =
53
- | "queued"
54
- | "running"
55
- | "completed"
56
- | "failed"
57
- | "cancelled";
58
-
59
- export interface JobData {
60
- id: JobId;
61
- host_id: HostId;
62
- status: JobStatus;
63
- command: string;
64
- args: string[];
65
- env: string[];
66
- cwd: string | null;
67
- exit_code: number | null;
68
- stdout: string | null;
69
- stderr: string | null;
70
- created_at: string;
71
- updated_at: string;
72
- completed_at: string | null;
73
- }
74
-
75
- export interface JobRunParams {
76
- command: string;
77
- args?: string[];
78
- env?: string[];
79
- cwd?: string;
80
- timeout?: number;
81
- }
82
-
83
- export interface JobListResponse {
84
- data: JobData[];
85
- meta: { total: number; page: number; per_page: number };
86
- }
87
-
88
- export type JobEventType =
89
- | "stdout"
90
- | "stderr"
91
- | "exit"
92
- | "error"
93
- | "started"
94
- | "done";
95
-
96
- export interface JobEvent {
97
- type: JobEventType;
98
- job_id: JobId;
99
- data: string | number | null;
100
- timestamp: string;
101
- }
102
-
103
- // ─── File system ─────────────────────────────────────────────────────────────
104
-
105
- export interface FsEntry {
106
- name: string;
107
- path: string;
108
- size: number;
109
- is_dir: boolean;
110
- modified_at: string;
111
- }
112
-
113
- export interface FsStat {
114
- path: string;
115
- size: number;
116
- mode: number;
117
- is_dir: boolean;
118
- is_symlink: boolean;
119
- symlink_target?: string;
120
- modified_at: string;
121
- }
122
-
123
- export interface FsListResponse {
124
- entries: FsEntry[];
125
- path: string;
126
- }
127
-
128
- // ─── Terminal / Desktop tickets ───────────────────────────────────────────────
129
-
130
- export interface WsTicket {
131
- /** Short-lived JWT for WS authentication. */
132
- ticket: string;
133
- /** Fully-qualified WS URL to connect to. */
134
- ws_url: string;
135
- expires_at: string;
136
- }
137
-
138
- // ─── Tunnels ─────────────────────────────────────────────────────────────────
139
-
140
- export type TunnelAuthMode = "public" | "tenant_only" | "password";
141
-
142
- export interface TunnelData {
143
- id: TunnelId;
144
- host_id: HostId;
145
- slug: string;
146
- target_port: number;
147
- auth_mode: TunnelAuthMode;
148
- public_url: string;
149
- enabled: boolean;
150
- created_at: string;
151
- updated_at: string;
152
- }
153
-
154
- export interface TunnelCreateParams {
155
- target_port: number;
156
- auth_mode?: TunnelAuthMode;
157
- slug?: string;
158
- }
159
-
160
- export interface TunnelUpdateParams {
161
- target_port?: number;
162
- auth_mode?: TunnelAuthMode;
163
- enabled?: boolean;
164
- }
165
-
166
- export interface TunnelListResponse {
167
- data: TunnelData[];
168
- }
169
-
170
- // ─── Agents ──────────────────────────────────────────────────────────────────
171
-
172
- export type AgentSessionStatus =
173
- | "pending"
174
- | "running"
175
- | "completed"
176
- | "failed"
177
- | "cancelled";
178
-
179
- export interface OcAgentSessionData {
180
- id: string;
181
- host_id: HostId;
182
- task: string;
183
- model_id: string | null;
184
- status: AgentSessionStatus;
185
- max_turns: number;
186
- turns_used: number;
187
- created_at: string;
188
- updated_at: string;
189
- completed_at: string | null;
190
- error: string | null;
191
- }
192
-
193
- export interface AgentDispatchParams {
194
- task: string;
195
- model_id?: string;
196
- max_turns?: number;
197
- context?: Record<string, unknown>;
198
- }
199
-
200
- export interface AgentSessionListResponse {
201
- data: OcAgentSessionData[];
202
- }
203
-
204
- export interface AgentEvent {
205
- type: string;
206
- session_id: string;
207
- data: unknown;
208
- timestamp: string;
209
- }
210
-
211
- // ─── Inference Clusters ───────────────────────────────────────────────────────
212
-
213
- export type ClusterStatus =
214
- | "provisioning"
215
- | "active"
216
- | "stopped"
217
- | "error"
218
- | "destroyed";
219
-
220
- export interface ClusterData {
221
- id: ClusterId;
222
- name: string;
223
- model: string;
224
- slug: string;
225
- status: ClusterStatus;
226
- host_ids: HostId[];
227
- /** OpenAI-compatible endpoint: POST /inference/{slug}/v1/chat/completions */
228
- inference_url: string;
229
- created_at: string;
230
- updated_at: string;
231
- }
232
-
233
- export interface ClusterCreateParams {
234
- name: string;
235
- model: string;
236
- host_ids: string[];
237
- }
238
-
239
- export interface ClusterListResponse {
240
- data: ClusterData[];
241
- }
242
-
243
- export interface ClusterEvent {
244
- type: string;
245
- cluster_id: ClusterId;
246
- data: unknown;
247
- timestamp: string;
248
- }
249
-
250
- // ─── Apps ────────────────────────────────────────────────────────────────────
251
-
252
- export interface AppCatalogEntry {
253
- id: string;
254
- name: string;
255
- description: string;
256
- category: string;
257
- version: string;
258
- icon_url: string | null;
259
- }
260
-
261
- export interface AppInstallData {
262
- id: string;
263
- host_id: HostId;
264
- app_id: string;
265
- status: "pending" | "installing" | "installed" | "failed" | "uninstalled";
266
- error: string | null;
267
- created_at: string;
268
- updated_at: string;
269
- }
270
-
271
- export interface AppInstallEvent {
272
- type: string;
273
- install_id: string;
274
- data: unknown;
275
- timestamp: string;
276
- }
277
-
278
- // ─── Workspaces ───────────────────────────────────────────────────────────────
279
-
280
- export type OcWorkspaceStatus =
281
- | "creating"
282
- | "ready"
283
- | "running"
284
- | "stopped"
285
- | "error";
286
-
287
- export interface OcWorkspaceData {
288
- id: WorkspaceId;
289
- host_id: HostId;
290
- name: string;
291
- repo_url: string | null;
292
- branch: string | null;
293
- status: OcWorkspaceStatus;
294
- directory: string;
295
- created_at: string;
296
- updated_at: string;
297
- }
298
-
299
- export interface OcWorkspaceCreateParams {
300
- name: string;
301
- repo_url?: string;
302
- branch?: string;
303
- directory?: string;
304
- }
305
-
306
- export interface OcWorkspaceUpdateParams {
307
- name?: string;
308
- branch?: string;
309
- }
310
-
311
- export interface OcWorkspaceListResponse {
312
- data: OcWorkspaceData[];
313
- }
314
-
315
- export interface OcWorkspaceEvent {
316
- type: string;
317
- workspace_id: WorkspaceId;
318
- data: unknown;
319
- timestamp: string;
320
- }
321
-
322
- // ─── Secrets ─────────────────────────────────────────────────────────────────
323
-
324
- export interface SecretData {
325
- id: SecretId;
326
- name: string;
327
- description: string | null;
328
- host_id: HostId | null;
329
- tenant_id: string;
330
- created_at: string;
331
- updated_at: string;
332
- }
333
-
334
- export interface SecretCreateParams {
335
- name: string;
336
- value: string;
337
- description?: string;
338
- }
339
-
340
- export interface SecretUpdateParams {
341
- value?: string;
342
- description?: string;
343
- }
@@ -1,135 +0,0 @@
1
- import { HttpClient } from "../../http.js";
2
- import type {
3
- HostId,
4
- OcWorkspaceCreateParams,
5
- OcWorkspaceData,
6
- OcWorkspaceEvent,
7
- OcWorkspaceListResponse,
8
- OcWorkspaceUpdateParams,
9
- WorkspaceId,
10
- WsTicket,
11
- } from "./types.js";
12
-
13
- /**
14
- * Workspaces resource — git-backed development environments on a remote host.
15
- *
16
- * A workspace clones a repository, installs dependencies, and gives you a
17
- * ready-to-use terminal scoped to the project root.
18
- *
19
- * ```ts
20
- * const ws = await client.openComputers.workspaces.create(hostId, {
21
- * name: "my-project",
22
- * repo_url: "https://github.com/acme/backend",
23
- * branch: "main",
24
- * });
25
- * const { ws_url } = await client.openComputers.workspaces.openTerminal(hostId, ws.id);
26
- * ```
27
- */
28
- export class OcWorkspaces {
29
- private readonly http: HttpClient;
30
-
31
- constructor(http: HttpClient) {
32
- this.http = http;
33
- }
34
-
35
- private base(hostId: string): string {
36
- return `/opencomputers/hosts/${hostId}/workspaces`;
37
- }
38
-
39
- /**
40
- * List all workspaces across all hosts for the tenant.
41
- */
42
- async listAll(): Promise<OcWorkspaceListResponse> {
43
- return this.http.get<OcWorkspaceListResponse>("/opencomputers/workspaces");
44
- }
45
-
46
- /**
47
- * List workspaces on a specific host.
48
- */
49
- async list(hostId: HostId | string): Promise<OcWorkspaceListResponse> {
50
- return this.http.get<OcWorkspaceListResponse>(this.base(hostId));
51
- }
52
-
53
- /**
54
- * Create a new workspace on a host.
55
- */
56
- async create(
57
- hostId: HostId | string,
58
- params: OcWorkspaceCreateParams,
59
- ): Promise<OcWorkspaceData> {
60
- return this.http.post<OcWorkspaceData>(this.base(hostId), params);
61
- }
62
-
63
- /**
64
- * Fetch a single workspace.
65
- */
66
- async get(
67
- hostId: HostId | string,
68
- workspaceId: WorkspaceId | string,
69
- ): Promise<OcWorkspaceData> {
70
- return this.http.get<OcWorkspaceData>(
71
- `${this.base(hostId)}/${workspaceId}`,
72
- );
73
- }
74
-
75
- /**
76
- * Update workspace metadata (name, branch).
77
- */
78
- async update(
79
- hostId: HostId | string,
80
- workspaceId: WorkspaceId | string,
81
- params: OcWorkspaceUpdateParams,
82
- ): Promise<OcWorkspaceData> {
83
- return this.http.patch<OcWorkspaceData>(
84
- `${this.base(hostId)}/${workspaceId}`,
85
- params,
86
- );
87
- }
88
-
89
- /**
90
- * Delete a workspace.
91
- */
92
- async delete(
93
- hostId: HostId | string,
94
- workspaceId: WorkspaceId | string,
95
- ): Promise<void> {
96
- return this.http.delete<void>(`${this.base(hostId)}/${workspaceId}`);
97
- }
98
-
99
- /**
100
- * Pull the latest changes from the remote repository.
101
- */
102
- async pull(
103
- hostId: HostId | string,
104
- workspaceId: WorkspaceId | string,
105
- ): Promise<OcWorkspaceData> {
106
- return this.http.post<OcWorkspaceData>(
107
- `${this.base(hostId)}/${workspaceId}/pull`,
108
- );
109
- }
110
-
111
- /**
112
- * Open a terminal session scoped to the workspace root directory.
113
- * Returns a short-lived WebSocket ticket.
114
- */
115
- async openTerminal(
116
- hostId: HostId | string,
117
- workspaceId: WorkspaceId | string,
118
- ): Promise<WsTicket> {
119
- return this.http.post<WsTicket>(
120
- `${this.base(hostId)}/${workspaceId}/open-terminal`,
121
- );
122
- }
123
-
124
- /**
125
- * Stream workspace setup / clone / install events.
126
- */
127
- events(
128
- hostId: HostId | string,
129
- workspaceId: WorkspaceId | string,
130
- ): AsyncIterableIterator<OcWorkspaceEvent> {
131
- return this.http.stream<OcWorkspaceEvent>(
132
- `${this.base(hostId)}/${workspaceId}/events`,
133
- );
134
- }
135
- }