@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.
- package/README.md +75 -3
- package/dist/index.d.ts +323 -175
- package/dist/index.js +441 -386
- 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 -564
- package/src/resources/admin.ts +0 -359
- package/src/resources/analytics.ts +0 -60
- package/src/resources/api-keys.ts +0 -135
- 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 -194
- package/src/resources/deployments.ts +0 -1060
- package/src/resources/desktop.ts +0 -134
- package/src/resources/docker-deploy.test.ts +0 -102
- package/src/resources/docker-deploy.ts +0 -183
- 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/governance.test.ts +0 -355
- package/src/resources/governance.ts +0 -528
- 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/phase1.test.ts +0 -187
- 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/quotas.ts +0 -77
- package/src/resources/regions.ts +0 -94
- package/src/resources/sandbox-processes.ts +0 -112
- package/src/resources/sandbox-shares.ts +0 -83
- package/src/resources/sandbox-templates.ts +0 -195
- package/src/resources/sandboxes.live.test.ts +0 -92
- package/src/resources/sandboxes.test.ts +0 -653
- package/src/resources/sandboxes.ts +0 -1433
- 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-events.ts +0 -32
- package/src/resources/tenant.ts +0 -148
- package/src/resources/usage.ts +0 -85
- package/src/resources/volumes.ts +0 -117
- package/src/resources/webhooks.ts +0 -224
- 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/resources/workspaces.ts +0 -285
- package/src/types.ts +0 -463
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Integrations — OAuth account-level connections (GitHub, Slack, Linear, Discord).
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { HttpClient } from "../http.js";
|
|
6
|
-
|
|
7
|
-
// ── Resource shapes ──────────────────────────────────────────────────────────
|
|
8
|
-
|
|
9
|
-
export interface IntegrationData {
|
|
10
|
-
id?: string;
|
|
11
|
-
provider?: string;
|
|
12
|
-
status?: string;
|
|
13
|
-
connected_at?: string;
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface IntegrationCatalogEntry {
|
|
18
|
-
provider?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
[key: string]: unknown;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface GithubRepo {
|
|
25
|
-
id?: number;
|
|
26
|
-
name?: string;
|
|
27
|
-
full_name?: string;
|
|
28
|
-
private?: boolean;
|
|
29
|
-
[key: string]: unknown;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface GithubSshKey {
|
|
33
|
-
id?: number;
|
|
34
|
-
title?: string;
|
|
35
|
-
key?: string;
|
|
36
|
-
[key: string]: unknown;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
40
|
-
|
|
41
|
-
export interface SlackSendTestParams {
|
|
42
|
-
message?: string;
|
|
43
|
-
channel?: string;
|
|
44
|
-
[key: string]: unknown;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface DiscordSendTestParams {
|
|
48
|
-
message?: string;
|
|
49
|
-
channel_id?: string;
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export interface LinearCreateIssueParams {
|
|
54
|
-
title?: string;
|
|
55
|
-
description?: string;
|
|
56
|
-
team_id?: string;
|
|
57
|
-
[key: string]: unknown;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
61
|
-
|
|
62
|
-
function unwrap<T>(payload: unknown): T {
|
|
63
|
-
if (payload && typeof payload === "object") {
|
|
64
|
-
const p = payload as Record<string, unknown>;
|
|
65
|
-
for (const k of ["data", "integrations", "catalog", "items"]) {
|
|
66
|
-
if (k in p) return p[k] as T;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return payload as T;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function listItems<T>(payload: unknown): T[] {
|
|
73
|
-
const result = unwrap<T[] | unknown>(payload);
|
|
74
|
-
if (Array.isArray(result)) return result;
|
|
75
|
-
return [];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function stripUndefined(
|
|
79
|
-
input: Record<string, unknown>,
|
|
80
|
-
): Record<string, unknown> {
|
|
81
|
-
return Object.fromEntries(
|
|
82
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
87
|
-
|
|
88
|
-
export class Integrations {
|
|
89
|
-
constructor(private readonly http: HttpClient) {}
|
|
90
|
-
|
|
91
|
-
/** List active OAuth integrations for the tenant. */
|
|
92
|
-
async list(): Promise<IntegrationData[]> {
|
|
93
|
-
const data = await this.http.get<unknown>("/integrations");
|
|
94
|
-
return listItems<IntegrationData>(data);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** List available providers in the integration catalog. */
|
|
98
|
-
async catalog(): Promise<IntegrationCatalogEntry[]> {
|
|
99
|
-
const data = await this.http.get<unknown>("/integrations/catalog");
|
|
100
|
-
return listItems<IntegrationCatalogEntry>(data);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Begin the OAuth flow for a provider — returns an authorize URL. */
|
|
104
|
-
async start(provider: string): Promise<Record<string, unknown>> {
|
|
105
|
-
const data = await this.http.get<unknown>(
|
|
106
|
-
`/integrations/${provider}/start`,
|
|
107
|
-
);
|
|
108
|
-
return unwrap<Record<string, unknown>>(data);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** Force-refresh the access token for a provider. */
|
|
112
|
-
async refresh(provider: string): Promise<Record<string, unknown>> {
|
|
113
|
-
const data = await this.http.post<unknown>(
|
|
114
|
-
`/integrations/${provider}/refresh`,
|
|
115
|
-
);
|
|
116
|
-
return unwrap<Record<string, unknown>>(data);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/** Disconnect (revoke) an integration. */
|
|
120
|
-
async disconnect(provider: string): Promise<void> {
|
|
121
|
-
await this.http.delete<unknown>(`/integrations/${provider}`);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ── GitHub-specific capabilities ───────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
/** List GitHub repositories accessible to this integration. */
|
|
127
|
-
async githubRepos(): Promise<GithubRepo[]> {
|
|
128
|
-
const data = await this.http.get<unknown>("/integrations/github/repos");
|
|
129
|
-
return listItems<GithubRepo>(data);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/** List configured GitHub deploy keys. */
|
|
133
|
-
async githubSshKeys(): Promise<GithubSshKey[]> {
|
|
134
|
-
const data = await this.http.get<unknown>("/integrations/github/ssh-keys");
|
|
135
|
-
return listItems<GithubSshKey>(data);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ── Test hooks ─────────────────────────────────────────────────────────────
|
|
139
|
-
|
|
140
|
-
/** Send a test message to the connected Slack channel. */
|
|
141
|
-
async slackSendTest(
|
|
142
|
-
params: SlackSendTestParams = {},
|
|
143
|
-
): Promise<Record<string, unknown>> {
|
|
144
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
145
|
-
const data = await this.http.post<unknown>(
|
|
146
|
-
"/integrations/slack/send-test",
|
|
147
|
-
body,
|
|
148
|
-
);
|
|
149
|
-
return unwrap<Record<string, unknown>>(data);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/** Send a test message to the connected Discord channel. */
|
|
153
|
-
async discordSendTest(
|
|
154
|
-
params: DiscordSendTestParams = {},
|
|
155
|
-
): Promise<Record<string, unknown>> {
|
|
156
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
157
|
-
const data = await this.http.post<unknown>(
|
|
158
|
-
"/integrations/discord/send-test",
|
|
159
|
-
body,
|
|
160
|
-
);
|
|
161
|
-
return unwrap<Record<string, unknown>>(data);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// ── Linear dedicated controller ────────────────────────────────────────────
|
|
165
|
-
|
|
166
|
-
/** Begin Linear OAuth — Linear has provider-specific error shapes. */
|
|
167
|
-
async linearStart(): Promise<Record<string, unknown>> {
|
|
168
|
-
const data = await this.http.get<unknown>("/integrations/linear/start");
|
|
169
|
-
return unwrap<Record<string, unknown>>(data);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** Create a Linear issue via the connected workspace. */
|
|
173
|
-
async linearCreateIssue(
|
|
174
|
-
params: LinearCreateIssueParams = {},
|
|
175
|
-
): Promise<Record<string, unknown>> {
|
|
176
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
177
|
-
const data = await this.http.post<unknown>(
|
|
178
|
-
"/integrations/linear/create-issue",
|
|
179
|
-
body,
|
|
180
|
-
);
|
|
181
|
-
return unwrap<Record<string, unknown>>(data);
|
|
182
|
-
}
|
|
183
|
-
}
|
package/src/resources/mcp.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mcp — Model Context Protocol streamable-HTTP transport.
|
|
3
|
-
*
|
|
4
|
-
* Clients (Claude Code, Cursor, Gemini CLI, Copilot) point at /api/v1/mcp
|
|
5
|
-
* with a msk_* Bearer token and discover the MIOSA tool-belt.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { HttpClient } from "../http.js";
|
|
9
|
-
|
|
10
|
-
// ── Request payloads ─────────────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
export interface McpDispatchParams {
|
|
13
|
-
method?: string;
|
|
14
|
-
params?: Record<string, unknown>;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
19
|
-
|
|
20
|
-
function unwrap<T>(payload: unknown): T {
|
|
21
|
-
if (payload && typeof payload === "object") {
|
|
22
|
-
const p = payload as Record<string, unknown>;
|
|
23
|
-
for (const k of ["data", "mcp", "result", "items"]) {
|
|
24
|
-
if (k in p) return p[k] as T;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return payload as T;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function stripUndefined(
|
|
31
|
-
input: Record<string, unknown>,
|
|
32
|
-
): Record<string, unknown> {
|
|
33
|
-
return Object.fromEntries(
|
|
34
|
-
Object.entries(input).filter(([, v]) => v !== undefined),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// ── Main resource ─────────────────────────────────────────────────────────────
|
|
39
|
-
|
|
40
|
-
export class Mcp {
|
|
41
|
-
constructor(private readonly http: HttpClient) {}
|
|
42
|
-
|
|
43
|
-
/** Send a JSON-RPC request to the MCP endpoint. */
|
|
44
|
-
async dispatch(
|
|
45
|
-
params: McpDispatchParams = {},
|
|
46
|
-
): Promise<Record<string, unknown>> {
|
|
47
|
-
const body = stripUndefined(params as Record<string, unknown>);
|
|
48
|
-
const data = await this.http.post<unknown>(
|
|
49
|
-
"/mcp",
|
|
50
|
-
Object.keys(body).length > 0 ? body : undefined,
|
|
51
|
-
);
|
|
52
|
-
return unwrap<Record<string, unknown>>(data);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Open the MCP listen channel (GET).
|
|
57
|
-
*
|
|
58
|
-
* Returns whatever the server returns. For true SSE streaming, use
|
|
59
|
-
* `http.stream("/mcp")` directly.
|
|
60
|
-
*/
|
|
61
|
-
async listen(): Promise<unknown> {
|
|
62
|
-
const data = await this.http.get<unknown>("/mcp");
|
|
63
|
-
return unwrap(data);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/** Close (terminate) the MCP session. */
|
|
67
|
-
async close(): Promise<void> {
|
|
68
|
-
await this.http.delete<unknown>("/mcp");
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/resources/models.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Models — list available LLMs across providers.
|
|
3
|
-
*
|
|
4
|
-
* Routes: GET /intelligence/models
|
|
5
|
-
* Requires an mki_* intelligence key or JWT.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { HttpClient } from "../http.js";
|
|
9
|
-
|
|
10
|
-
function unwrap(data: unknown): unknown[] {
|
|
11
|
-
if (Array.isArray(data)) return data;
|
|
12
|
-
if (data && typeof data === "object") {
|
|
13
|
-
const d = data as Record<string, unknown>;
|
|
14
|
-
for (const k of ["data", "models", "items"]) {
|
|
15
|
-
if (Array.isArray(d[k])) return d[k] as unknown[];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return [];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class Models {
|
|
22
|
-
constructor(private readonly http: HttpClient) {}
|
|
23
|
-
|
|
24
|
-
/** List all models available to the calling tenant (OpenAI-compatible shape). */
|
|
25
|
-
async list(
|
|
26
|
-
filters: Record<string, string | number | boolean | undefined> = {},
|
|
27
|
-
): Promise<Record<string, unknown>[]> {
|
|
28
|
-
const query = Object.fromEntries(
|
|
29
|
-
Object.entries(filters).filter(([, v]) => v !== undefined),
|
|
30
|
-
) as Record<string, string | number | boolean | undefined>;
|
|
31
|
-
const data = await this.http.get<unknown>("/intelligence/models", query);
|
|
32
|
-
return unwrap(data) as Record<string, unknown>[];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Get a single model by id.
|
|
37
|
-
*
|
|
38
|
-
* The platform router does not expose a per-model GET; this filters
|
|
39
|
-
* the list payload client-side.
|
|
40
|
-
*/
|
|
41
|
-
async get(modelId: string): Promise<Record<string, unknown>> {
|
|
42
|
-
const all = await this.list();
|
|
43
|
-
return all.find((m) => (m as Record<string, unknown>).id === modelId) ?? {};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -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
|
-
}
|