@miosa/sdk 1.2.5 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -59
- package/dist/index.d.ts +513 -193
- package/dist/index.js +1266 -891
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
- package/src/client.ts +0 -293
- package/src/errors.ts +0 -136
- package/src/http.test.ts +0 -374
- package/src/http.ts +0 -390
- package/src/index.ts +0 -569
- package/src/resources/admin.ts +0 -348
- package/src/resources/analytics.ts +0 -60
- package/src/resources/api-keys.ts +0 -119
- package/src/resources/audit-log.ts +0 -64
- package/src/resources/benchmarks.ts +0 -104
- package/src/resources/builder-sessions.ts +0 -75
- package/src/resources/channels.ts +0 -143
- package/src/resources/checkpoints.ts +0 -225
- package/src/resources/command-center.ts +0 -73
- package/src/resources/community.ts +0 -103
- package/src/resources/completions.ts +0 -104
- package/src/resources/computer-auto-stop.ts +0 -43
- package/src/resources/computer-env.ts +0 -76
- package/src/resources/computer-logs.ts +0 -50
- package/src/resources/computer-osa.ts +0 -76
- package/src/resources/computer-ports.ts +0 -91
- package/src/resources/computer-terminal.ts +0 -61
- package/src/resources/computer-volumes.ts +0 -64
- package/src/resources/computer.ts +0 -551
- package/src/resources/computers.ts +0 -75
- package/src/resources/credits.ts +0 -43
- package/src/resources/cron-jobs.ts +0 -191
- package/src/resources/custom_domains.ts +0 -123
- package/src/resources/dashboard.ts +0 -49
- package/src/resources/databases.ts +0 -218
- package/src/resources/deployments.test.ts +0 -197
- package/src/resources/deployments.ts +0 -1208
- package/src/resources/desktop.ts +0 -134
- package/src/resources/devices.test.ts +0 -92
- package/src/resources/devices.ts +0 -291
- package/src/resources/egress.test.ts +0 -318
- package/src/resources/egressAudit.ts +0 -245
- package/src/resources/egressNetwork.ts +0 -450
- package/src/resources/egressSecrets.ts +0 -577
- package/src/resources/email.ts +0 -212
- package/src/resources/embeddings.ts +0 -36
- package/src/resources/events.ts +0 -296
- package/src/resources/exec.ts +0 -319
- package/src/resources/external-keys.ts +0 -79
- package/src/resources/files.test.ts +0 -339
- package/src/resources/files.ts +0 -220
- package/src/resources/flat-custom-domains.ts +0 -127
- package/src/resources/functions.ts +0 -178
- package/src/resources/health-checks.ts +0 -165
- package/src/resources/integrations.ts +0 -183
- package/src/resources/mcp.ts +0 -70
- package/src/resources/models.ts +0 -45
- package/src/resources/network_policy.ts +0 -73
- package/src/resources/open-computers/agents.ts +0 -91
- package/src/resources/open-computers/apps.ts +0 -102
- package/src/resources/open-computers/clusters.ts +0 -88
- package/src/resources/open-computers/desktop.ts +0 -34
- package/src/resources/open-computers/files.ts +0 -97
- package/src/resources/open-computers/hosts.ts +0 -85
- package/src/resources/open-computers/index.ts +0 -98
- package/src/resources/open-computers/jobs.ts +0 -75
- package/src/resources/open-computers/open_computers.test.ts +0 -288
- package/src/resources/open-computers/secrets.ts +0 -115
- package/src/resources/open-computers/terminal.ts +0 -33
- package/src/resources/open-computers/tunnels.ts +0 -87
- package/src/resources/open-computers/types.ts +0 -343
- package/src/resources/open-computers/workspaces.ts +0 -135
- package/src/resources/org-invites.ts +0 -189
- package/src/resources/project-auth.ts +0 -142
- package/src/resources/project-integrations.ts +0 -133
- package/src/resources/provider-defaults.ts +0 -89
- package/src/resources/regions.ts +0 -94
- package/src/resources/sandbox-templates.ts +0 -195
- package/src/resources/sandboxes.live.test.ts +0 -92
- package/src/resources/sandboxes.test.ts +0 -655
- package/src/resources/sandboxes.ts +0 -1437
- package/src/resources/settings.ts +0 -143
- package/src/resources/snapshots-standalone.ts +0 -51
- package/src/resources/storage.ts +0 -221
- package/src/resources/tenant.ts +0 -66
- package/src/resources/usage.ts +0 -85
- package/src/resources/volumes.ts +0 -117
- package/src/resources/webhooks.ts +0 -239
- package/src/resources/workspace-invites.ts +0 -188
- package/src/resources/workspace-members.test.ts +0 -121
- package/src/resources/workspace-members.ts +0 -143
- package/src/types.ts +0 -463
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../http.js";
|
|
2
|
-
import type { NetworkPolicyData, NetworkPolicySetParams } from "../types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Manage egress network policy for a computer.
|
|
6
|
-
*
|
|
7
|
-
* A policy is a list of rules evaluated top-to-bottom, with a `default_effect`
|
|
8
|
-
* applied when no rule matches.
|
|
9
|
-
*
|
|
10
|
-
* Example — block IMDS and allow everything else:
|
|
11
|
-
* ```ts
|
|
12
|
-
* await computer.networkPolicy.set({
|
|
13
|
-
* default_effect: "allow",
|
|
14
|
-
* rules: [
|
|
15
|
-
* { effect: "deny", destination: "169.254.169.254/32" },
|
|
16
|
-
* { effect: "deny", destination: "metadata.google.internal" },
|
|
17
|
-
* ],
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* Example — allowlist mode (deny all by default, allow only example.com):
|
|
22
|
-
* ```ts
|
|
23
|
-
* await computer.networkPolicy.set({
|
|
24
|
-
* default_effect: "deny",
|
|
25
|
-
* rules: [
|
|
26
|
-
* { effect: "allow", destination: "example.com", ports: "443", protocol: "tcp" },
|
|
27
|
-
* ],
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
export class NetworkPolicy {
|
|
32
|
-
private readonly http: HttpClient;
|
|
33
|
-
private readonly computerId: string;
|
|
34
|
-
|
|
35
|
-
constructor(http: HttpClient, computerId: string) {
|
|
36
|
-
this.http = http;
|
|
37
|
-
this.computerId = computerId;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get the current network policy.
|
|
42
|
-
* Returns an empty allow-all policy if none is set.
|
|
43
|
-
*/
|
|
44
|
-
async get(): Promise<NetworkPolicyData> {
|
|
45
|
-
const response = await this.http.get<{ data: NetworkPolicyData }>(
|
|
46
|
-
`/computers/${this.computerId}/network-policy`,
|
|
47
|
-
);
|
|
48
|
-
return response.data;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Set (create or replace) the network policy.
|
|
53
|
-
* Triggers immediate nftables update on the host — running VMs pick up
|
|
54
|
-
* the new rules without a restart.
|
|
55
|
-
*/
|
|
56
|
-
async set(params: NetworkPolicySetParams): Promise<NetworkPolicyData> {
|
|
57
|
-
const response = await this.http.put<{ data: NetworkPolicyData }>(
|
|
58
|
-
`/computers/${this.computerId}/network-policy`,
|
|
59
|
-
params,
|
|
60
|
-
);
|
|
61
|
-
return response.data;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Reset to the default policy (allow all egress).
|
|
66
|
-
* Idempotent — safe to call even if no policy was set.
|
|
67
|
-
*/
|
|
68
|
-
async reset(): Promise<void> {
|
|
69
|
-
await this.http.delete<unknown>(
|
|
70
|
-
`/computers/${this.computerId}/network-policy`,
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
AgentDispatchParams,
|
|
4
|
-
AgentEvent,
|
|
5
|
-
AgentSessionListResponse,
|
|
6
|
-
HostId,
|
|
7
|
-
OcAgentSessionData,
|
|
8
|
-
} from "./types.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Agents resource — dispatch Optimal AI agent sessions that execute on a
|
|
12
|
-
* remote OpenComputers host via the OSA/WS tunnel.
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* const session = await client.openComputers.agents.dispatch(hostId, {
|
|
16
|
-
* task: "Run the test suite and report failures",
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* for await (const event of client.openComputers.agents.events(hostId, session.id)) {
|
|
20
|
-
* console.log(event.type, event.data);
|
|
21
|
-
* if (event.type === "session_completed" || event.type === "done") break;
|
|
22
|
-
* }
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
export class Agents {
|
|
26
|
-
private readonly http: HttpClient;
|
|
27
|
-
|
|
28
|
-
constructor(http: HttpClient) {
|
|
29
|
-
this.http = http;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private base(hostId: string): string {
|
|
33
|
-
return `/opencomputers/hosts/${hostId}/agent`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Dispatch a new agent session on the host.
|
|
38
|
-
*/
|
|
39
|
-
async dispatch(
|
|
40
|
-
hostId: HostId | string,
|
|
41
|
-
params: AgentDispatchParams,
|
|
42
|
-
): Promise<OcAgentSessionData> {
|
|
43
|
-
return this.http.post<OcAgentSessionData>(
|
|
44
|
-
`${this.base(hostId)}/dispatch`,
|
|
45
|
-
params,
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* List all agent sessions for a host.
|
|
51
|
-
*/
|
|
52
|
-
async list(hostId: HostId | string): Promise<AgentSessionListResponse> {
|
|
53
|
-
return this.http.get<AgentSessionListResponse>(
|
|
54
|
-
`${this.base(hostId)}/sessions`,
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Fetch the current state of a specific agent session.
|
|
60
|
-
*/
|
|
61
|
-
async get(
|
|
62
|
-
hostId: HostId | string,
|
|
63
|
-
sessionId: string,
|
|
64
|
-
): Promise<OcAgentSessionData> {
|
|
65
|
-
return this.http.get<OcAgentSessionData>(
|
|
66
|
-
`${this.base(hostId)}/sessions/${sessionId}`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Stream live events from an agent session.
|
|
72
|
-
*
|
|
73
|
-
* Yields `AgentEvent` objects. Break on `type === "done"` or
|
|
74
|
-
* `type === "session_completed"`.
|
|
75
|
-
*/
|
|
76
|
-
events(
|
|
77
|
-
hostId: HostId | string,
|
|
78
|
-
sessionId: string,
|
|
79
|
-
): AsyncIterableIterator<AgentEvent> {
|
|
80
|
-
return this.http.stream<AgentEvent>(
|
|
81
|
-
`${this.base(hostId)}/sessions/${sessionId}/events`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Cancel a running or pending agent session.
|
|
87
|
-
*/
|
|
88
|
-
async cancel(hostId: HostId | string, sessionId: string): Promise<void> {
|
|
89
|
-
return this.http.delete<void>(`${this.base(hostId)}/sessions/${sessionId}`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
AppCatalogEntry,
|
|
4
|
-
AppInstallData,
|
|
5
|
-
AppInstallEvent,
|
|
6
|
-
HostId,
|
|
7
|
-
} from "./types.js";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Apps resource — one-click install of common dev services on a remote host.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const catalog = await client.openComputers.apps.catalog();
|
|
14
|
-
* const install = await client.openComputers.apps.install(hostId, "postgres");
|
|
15
|
-
*
|
|
16
|
-
* for await (const evt of client.openComputers.apps.installEvents(hostId, install.id)) {
|
|
17
|
-
* console.log(evt.type, evt.data);
|
|
18
|
-
* if (evt.type === "installed" || evt.type === "failed") break;
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export class Apps {
|
|
23
|
-
private readonly http: HttpClient;
|
|
24
|
-
|
|
25
|
-
constructor(http: HttpClient) {
|
|
26
|
-
this.http = http;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* List all available apps in the MIOSA app library.
|
|
31
|
-
*/
|
|
32
|
-
async catalog(): Promise<AppCatalogEntry[]> {
|
|
33
|
-
const result = await this.http.get<{ data: AppCatalogEntry[] }>(
|
|
34
|
-
"/opencomputers/apps",
|
|
35
|
-
);
|
|
36
|
-
return result.data;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* List apps installed on a specific host.
|
|
41
|
-
*/
|
|
42
|
-
async listInstalled(hostId: HostId | string): Promise<AppInstallData[]> {
|
|
43
|
-
const result = await this.http.get<{ data: AppInstallData[] }>(
|
|
44
|
-
`/opencomputers/hosts/${hostId}/apps`,
|
|
45
|
-
);
|
|
46
|
-
return result.data;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Install an app on a host by app catalog ID.
|
|
51
|
-
*/
|
|
52
|
-
async install(
|
|
53
|
-
hostId: HostId | string,
|
|
54
|
-
appId: string,
|
|
55
|
-
): Promise<AppInstallData> {
|
|
56
|
-
return this.http.post<AppInstallData>(
|
|
57
|
-
`/opencomputers/hosts/${hostId}/apps/${appId}/install`,
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get the current state of an install operation.
|
|
63
|
-
*/
|
|
64
|
-
async getInstall(
|
|
65
|
-
hostId: HostId | string,
|
|
66
|
-
installId: string,
|
|
67
|
-
): Promise<AppInstallData> {
|
|
68
|
-
return this.http.get<AppInstallData>(
|
|
69
|
-
`/opencomputers/hosts/${hostId}/apps/installs/${installId}`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Stream install progress events.
|
|
75
|
-
*/
|
|
76
|
-
installEvents(
|
|
77
|
-
hostId: HostId | string,
|
|
78
|
-
installId: string,
|
|
79
|
-
): AsyncIterableIterator<AppInstallEvent> {
|
|
80
|
-
return this.http.stream<AppInstallEvent>(
|
|
81
|
-
`/opencomputers/hosts/${hostId}/apps/installs/${installId}/events`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Uninstall an app from a host.
|
|
87
|
-
*/
|
|
88
|
-
async uninstall(hostId: HostId | string, appId: string): Promise<void> {
|
|
89
|
-
return this.http.delete<void>(
|
|
90
|
-
`/opencomputers/hosts/${hostId}/apps/${appId}`,
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Start a previously installed app (e.g. start the postgres service).
|
|
96
|
-
*/
|
|
97
|
-
async startApp(hostId: HostId | string, appId: string): Promise<void> {
|
|
98
|
-
return this.http.post<void>(
|
|
99
|
-
`/opencomputers/hosts/${hostId}/apps/${appId}/start`,
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
ClusterCreateParams,
|
|
4
|
-
ClusterData,
|
|
5
|
-
ClusterEvent,
|
|
6
|
-
ClusterId,
|
|
7
|
-
ClusterListResponse,
|
|
8
|
-
} from "./types.js";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Clusters resource — manage multi-host LLM inference clusters (exo / MLX
|
|
12
|
-
* Distributed). Hosts must be Apple Silicon.
|
|
13
|
-
*
|
|
14
|
-
* Once a cluster is active it exposes an OpenAI-compatible endpoint at:
|
|
15
|
-
* `POST /inference/{slug}/v1/chat/completions`
|
|
16
|
-
*
|
|
17
|
-
* Point any OpenAI client at `https://api.miosa.ai/inference/{slug}/v1` with
|
|
18
|
-
* your `msk_*` Bearer token.
|
|
19
|
-
*
|
|
20
|
-
* ```ts
|
|
21
|
-
* const cluster = await client.openComputers.clusters.create({
|
|
22
|
-
* name: "llama-cluster",
|
|
23
|
-
* model: "llama3:70b",
|
|
24
|
-
* host_ids: [hostA.id, hostB.id],
|
|
25
|
-
* });
|
|
26
|
-
* console.log(cluster.inference_url); // OpenAI-compatible base URL
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export class Clusters {
|
|
30
|
-
private readonly http: HttpClient;
|
|
31
|
-
|
|
32
|
-
constructor(http: HttpClient) {
|
|
33
|
-
this.http = http;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
private base(): string {
|
|
37
|
-
return "/opencomputers/clusters";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* List all inference clusters for the tenant.
|
|
42
|
-
*/
|
|
43
|
-
async list(): Promise<ClusterListResponse> {
|
|
44
|
-
return this.http.get<ClusterListResponse>(this.base());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Create and provision a new inference cluster.
|
|
49
|
-
*/
|
|
50
|
-
async create(params: ClusterCreateParams): Promise<ClusterData> {
|
|
51
|
-
return this.http.post<ClusterData>(this.base(), params);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Fetch a single cluster.
|
|
56
|
-
*/
|
|
57
|
-
async get(id: ClusterId | string): Promise<ClusterData> {
|
|
58
|
-
return this.http.get<ClusterData>(`${this.base()}/${id}`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Start a stopped cluster.
|
|
63
|
-
*/
|
|
64
|
-
async start(id: ClusterId | string): Promise<ClusterData> {
|
|
65
|
-
return this.http.post<ClusterData>(`${this.base()}/${id}/start`);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Stop a running cluster (preserves configuration).
|
|
70
|
-
*/
|
|
71
|
-
async stop(id: ClusterId | string): Promise<ClusterData> {
|
|
72
|
-
return this.http.post<ClusterData>(`${this.base()}/${id}/stop`);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Permanently delete a cluster.
|
|
77
|
-
*/
|
|
78
|
-
async delete(id: ClusterId | string): Promise<void> {
|
|
79
|
-
return this.http.delete<void>(`${this.base()}/${id}`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Stream cluster provisioning / health events.
|
|
84
|
-
*/
|
|
85
|
-
events(id: ClusterId | string): AsyncIterableIterator<ClusterEvent> {
|
|
86
|
-
return this.http.stream<ClusterEvent>(`${this.base()}/${id}/events`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type { HostId, WsTicket } from "./types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Desktop resource — issue WebSocket tickets for KasmVNC desktop streaming on
|
|
6
|
-
* a remote OpenComputers host.
|
|
7
|
-
*
|
|
8
|
-
* The ticket is consumed by a WebSocket upgrade at the URL in `ws_url`. Connect
|
|
9
|
-
* a KasmVNC-compatible client (or an iframe pointing at the VNC web client) to
|
|
10
|
-
* drive the desktop.
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* const { ws_url } = await client.openComputers.desktop.ticket(hostId);
|
|
14
|
-
* // Open ws_url in an iframe or VNC client
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export class Desktop {
|
|
18
|
-
private readonly http: HttpClient;
|
|
19
|
-
|
|
20
|
-
constructor(http: HttpClient) {
|
|
21
|
-
this.http = http;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Issue a short-lived WebSocket ticket for a desktop streaming session.
|
|
26
|
-
*
|
|
27
|
-
* The ticket expires quickly — open the WebSocket immediately after receiving it.
|
|
28
|
-
*/
|
|
29
|
-
async ticket(hostId: HostId | string): Promise<WsTicket> {
|
|
30
|
-
return this.http.post<WsTicket>(
|
|
31
|
-
`/opencomputers/hosts/${hostId}/desktop/ticket`,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type { FsEntry, FsListResponse, FsStat, HostId } from "./types.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Files resource — direct file-system access on a remote OpenComputers host.
|
|
6
|
-
*
|
|
7
|
-
* Operations are proxied through the OSA daemon running on the host.
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const entries = await client.openComputers.files.list(hostId, "/home/user");
|
|
11
|
-
* const bytes = await client.openComputers.files.download(hostId, "/home/user/report.pdf");
|
|
12
|
-
* await client.openComputers.files.upload(hostId, "/tmp/data.json", new TextEncoder().encode("{}"));
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export class OcFiles {
|
|
16
|
-
private readonly http: HttpClient;
|
|
17
|
-
|
|
18
|
-
constructor(http: HttpClient) {
|
|
19
|
-
this.http = http;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private base(hostId: string): string {
|
|
23
|
-
return `/opencomputers/hosts/${hostId}/fs`;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* List directory entries at `path`.
|
|
28
|
-
*/
|
|
29
|
-
async list(hostId: HostId | string, path: string): Promise<FsListResponse> {
|
|
30
|
-
return this.http.get<FsListResponse>(this.base(hostId), { path });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Stat a path (does not follow symlinks).
|
|
35
|
-
*/
|
|
36
|
-
async stat(hostId: HostId | string, path: string): Promise<FsStat> {
|
|
37
|
-
return this.http.get<FsStat>(`${this.base(hostId)}/stat`, { path });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Download a file from the host. Returns raw bytes.
|
|
42
|
-
*/
|
|
43
|
-
async download(hostId: HostId | string, path: string): Promise<Uint8Array> {
|
|
44
|
-
const url = `${this.base(hostId)}/download?path=${encodeURIComponent(path)}`;
|
|
45
|
-
return this.http.getBinary(url);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Upload content to `remotePath` on the host.
|
|
50
|
-
*
|
|
51
|
-
* @param content - `Blob`, `Uint8Array`, or UTF-8 string.
|
|
52
|
-
* @param remotePath - Absolute destination path on the host.
|
|
53
|
-
* @param filename - Optional filename hint; defaults to `remotePath` basename.
|
|
54
|
-
*/
|
|
55
|
-
async upload(
|
|
56
|
-
hostId: HostId | string,
|
|
57
|
-
remotePath: string,
|
|
58
|
-
content: Blob | Uint8Array | string,
|
|
59
|
-
filename?: string,
|
|
60
|
-
): Promise<FsEntry> {
|
|
61
|
-
const fd = new FormData();
|
|
62
|
-
const name = filename ?? remotePath.split("/").pop() ?? "file";
|
|
63
|
-
|
|
64
|
-
if (typeof content === "string") {
|
|
65
|
-
fd.append("file", new Blob([content]), name);
|
|
66
|
-
} else if (content instanceof Uint8Array) {
|
|
67
|
-
fd.append("file", new Blob([content.buffer as ArrayBuffer]), name);
|
|
68
|
-
} else {
|
|
69
|
-
fd.append("file", content, name);
|
|
70
|
-
}
|
|
71
|
-
fd.append("path", remotePath);
|
|
72
|
-
|
|
73
|
-
return this.http.postFormData<FsEntry>(`${this.base(hostId)}/upload`, fd);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Delete a file or directory.
|
|
78
|
-
*
|
|
79
|
-
* @param recursive - When `true`, delete non-empty directories recursively.
|
|
80
|
-
*/
|
|
81
|
-
async delete(
|
|
82
|
-
hostId: HostId | string,
|
|
83
|
-
path: string,
|
|
84
|
-
recursive = false,
|
|
85
|
-
): Promise<void> {
|
|
86
|
-
return this.http.delete<void>(
|
|
87
|
-
`${this.base(hostId)}?path=${encodeURIComponent(path)}&recursive=${recursive}`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Create a directory (and any missing parents).
|
|
93
|
-
*/
|
|
94
|
-
async mkdir(hostId: HostId | string, path: string): Promise<void> {
|
|
95
|
-
return this.http.post<void>(`${this.base(hostId)}/mkdir`, { path });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import type {
|
|
3
|
-
HostCreateParams,
|
|
4
|
-
HostData,
|
|
5
|
-
HostEvent,
|
|
6
|
-
HostId,
|
|
7
|
-
HostListResponse,
|
|
8
|
-
HostUpdateParams,
|
|
9
|
-
} from "./types.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Hosts resource — manage BYOC (Bring Your Own Computer) hosts registered
|
|
13
|
-
* under your tenant.
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const host = await client.openComputers.hosts.create({ name: "my-mac" });
|
|
17
|
-
* console.log(host.host_key); // store this — shown only once
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export class Hosts {
|
|
21
|
-
private readonly http: HttpClient;
|
|
22
|
-
|
|
23
|
-
constructor(http: HttpClient) {
|
|
24
|
-
this.http = http;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private base(): string {
|
|
28
|
-
return "/opencomputers/hosts";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* List all hosts registered for the tenant.
|
|
33
|
-
*/
|
|
34
|
-
async list(): Promise<HostListResponse> {
|
|
35
|
-
return this.http.get<HostListResponse>(this.base());
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Register a new host. The returned `host_key` is shown **once** — store it
|
|
40
|
-
* immediately and install it on the target machine.
|
|
41
|
-
*/
|
|
42
|
-
async create(params: HostCreateParams): Promise<HostData> {
|
|
43
|
-
return this.http.post<HostData>(this.base(), params);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Fetch a single host by ID.
|
|
48
|
-
*/
|
|
49
|
-
async get(id: HostId | string): Promise<HostData> {
|
|
50
|
-
return this.http.get<HostData>(`${this.base()}/${id}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Update host metadata (name / labels).
|
|
55
|
-
*/
|
|
56
|
-
async update(
|
|
57
|
-
id: HostId | string,
|
|
58
|
-
params: HostUpdateParams,
|
|
59
|
-
): Promise<HostData> {
|
|
60
|
-
return this.http.patch<HostData>(`${this.base()}/${id}`, params);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Revoke a host. Permanently removes the registration; the host key is
|
|
65
|
-
* invalidated and the host will disconnect on next heartbeat.
|
|
66
|
-
*/
|
|
67
|
-
async revoke(id: HostId | string): Promise<void> {
|
|
68
|
-
return this.http.delete<void>(`${this.base()}/${id}`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Stream host state-change events (connect / disconnect / error) as an
|
|
73
|
-
* `AsyncIterable`.
|
|
74
|
-
*
|
|
75
|
-
* ```ts
|
|
76
|
-
* for await (const event of client.openComputers.hosts.events()) {
|
|
77
|
-
* console.log(event.type, event.host_id);
|
|
78
|
-
* if (shouldStop) break;
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
events(): AsyncIterableIterator<HostEvent> {
|
|
83
|
-
return this.http.stream<HostEvent>("/opencomputers/hosts/events");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../../http.js";
|
|
2
|
-
import { Agents } from "./agents.js";
|
|
3
|
-
import { Apps } from "./apps.js";
|
|
4
|
-
import { Clusters } from "./clusters.js";
|
|
5
|
-
import { Desktop } from "./desktop.js";
|
|
6
|
-
import { OcFiles } from "./files.js";
|
|
7
|
-
import { Hosts } from "./hosts.js";
|
|
8
|
-
import { Jobs } from "./jobs.js";
|
|
9
|
-
import { Secrets } from "./secrets.js";
|
|
10
|
-
import { Terminal } from "./terminal.js";
|
|
11
|
-
import { Tunnels } from "./tunnels.js";
|
|
12
|
-
import { OcWorkspaces } from "./workspaces.js";
|
|
13
|
-
|
|
14
|
-
export * from "./types.js";
|
|
15
|
-
export { Agents } from "./agents.js";
|
|
16
|
-
export { Apps } from "./apps.js";
|
|
17
|
-
export { Clusters } from "./clusters.js";
|
|
18
|
-
export { Desktop } from "./desktop.js";
|
|
19
|
-
export { OcFiles } from "./files.js";
|
|
20
|
-
export { Hosts } from "./hosts.js";
|
|
21
|
-
export { Jobs } from "./jobs.js";
|
|
22
|
-
export { Secrets } from "./secrets.js";
|
|
23
|
-
export { Terminal } from "./terminal.js";
|
|
24
|
-
export { Tunnels } from "./tunnels.js";
|
|
25
|
-
export { OcWorkspaces } from "./workspaces.js";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* OpenComputers namespace — BYOC (Bring Your Own Computer) host management.
|
|
29
|
-
*
|
|
30
|
-
* Register your own machines (Mac, Linux, Windows) with MIOSA and use them
|
|
31
|
-
* just like cloud computers: run jobs, manage files, open terminals, expose
|
|
32
|
-
* ports, dispatch AI agents, and run LLM inference clusters.
|
|
33
|
-
*
|
|
34
|
-
* Access via `client.openComputers`:
|
|
35
|
-
*
|
|
36
|
-
* ```ts
|
|
37
|
-
* const miosa = new Miosa({ apiKey: "msk_u_..." });
|
|
38
|
-
*
|
|
39
|
-
* // Register a host — save host_key immediately, shown only once
|
|
40
|
-
* const host = await miosa.openComputers.hosts.create({ name: "my-mac" });
|
|
41
|
-
*
|
|
42
|
-
* // Run a command
|
|
43
|
-
* const job = await miosa.openComputers.jobs.run(host.id, { command: "npm test" });
|
|
44
|
-
*
|
|
45
|
-
* // Stream output
|
|
46
|
-
* for await (const event of miosa.openComputers.jobs.stream(host.id, job.id)) {
|
|
47
|
-
* process.stdout.write(String(event.data ?? ""));
|
|
48
|
-
* if (event.type === "done") break;
|
|
49
|
-
* }
|
|
50
|
-
*
|
|
51
|
-
* // Expose a port
|
|
52
|
-
* const tunnel = await miosa.openComputers.tunnels.create(host.id, { target_port: 3000 });
|
|
53
|
-
* console.log(tunnel.public_url);
|
|
54
|
-
*
|
|
55
|
-
* // Dispatch an AI agent
|
|
56
|
-
* const session = await miosa.openComputers.agents.dispatch(host.id, {
|
|
57
|
-
* task: "Run tests and fix failing ones",
|
|
58
|
-
* });
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export class OpenComputers {
|
|
62
|
-
/** Host registration and lifecycle. */
|
|
63
|
-
readonly hosts: Hosts;
|
|
64
|
-
/** Command execution on remote hosts. */
|
|
65
|
-
readonly jobs: Jobs;
|
|
66
|
-
/** File system access on remote hosts. */
|
|
67
|
-
readonly files: OcFiles;
|
|
68
|
-
/** Interactive terminal session tickets. */
|
|
69
|
-
readonly terminal: Terminal;
|
|
70
|
-
/** Desktop streaming session tickets. */
|
|
71
|
-
readonly desktop: Desktop;
|
|
72
|
-
/** HTTP tunnel management (expose host ports publicly). */
|
|
73
|
-
readonly tunnels: Tunnels;
|
|
74
|
-
/** AI agent dispatch and session management. */
|
|
75
|
-
readonly agents: Agents;
|
|
76
|
-
/** Multi-host LLM inference clusters. */
|
|
77
|
-
readonly clusters: Clusters;
|
|
78
|
-
/** App library — one-click installs on hosts. */
|
|
79
|
-
readonly apps: Apps;
|
|
80
|
-
/** Git-backed workspace environments. */
|
|
81
|
-
readonly workspaces: OcWorkspaces;
|
|
82
|
-
/** Encrypted per-host / per-tenant secrets. */
|
|
83
|
-
readonly secrets: Secrets;
|
|
84
|
-
|
|
85
|
-
constructor(http: HttpClient) {
|
|
86
|
-
this.hosts = new Hosts(http);
|
|
87
|
-
this.jobs = new Jobs(http);
|
|
88
|
-
this.files = new OcFiles(http);
|
|
89
|
-
this.terminal = new Terminal(http);
|
|
90
|
-
this.desktop = new Desktop(http);
|
|
91
|
-
this.tunnels = new Tunnels(http);
|
|
92
|
-
this.agents = new Agents(http);
|
|
93
|
-
this.clusters = new Clusters(http);
|
|
94
|
-
this.apps = new Apps(http);
|
|
95
|
-
this.workspaces = new OcWorkspaces(http);
|
|
96
|
-
this.secrets = new Secrets(http);
|
|
97
|
-
}
|
|
98
|
-
}
|