@miosa/sdk 1.2.5 → 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 +107 -59
- package/dist/index.d.ts +331 -202
- package/dist/index.js +572 -603
- 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,92 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { Miosa } from "../client.js";
|
|
3
|
-
import type { Sandbox } from "./sandboxes.js";
|
|
4
|
-
|
|
5
|
-
const liveApiKey = process.env.MIOSA_API_KEY;
|
|
6
|
-
const liveBaseUrl = process.env.MIOSA_BASE_URL ?? "https://api.miosa.ai/api/v1";
|
|
7
|
-
const describeLive = liveApiKey ? describe : describe.skip;
|
|
8
|
-
|
|
9
|
-
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
-
|
|
11
|
-
async function waitReady(sandbox: Sandbox, timeoutMs = 60_000): Promise<Sandbox> {
|
|
12
|
-
const deadline = Date.now() + timeoutMs;
|
|
13
|
-
while (Date.now() < deadline) {
|
|
14
|
-
await sandbox.refresh();
|
|
15
|
-
if (sandbox.state === "running" && sandbox.ready) return sandbox;
|
|
16
|
-
await sleep(500);
|
|
17
|
-
}
|
|
18
|
-
throw new Error(`sandbox ${sandbox.id} was not ready within ${timeoutMs}ms`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
describeLive("live native sandbox API", () => {
|
|
22
|
-
it(
|
|
23
|
-
"creates, execs, writes files, exposes preview, and destroys",
|
|
24
|
-
async () => {
|
|
25
|
-
const client = new Miosa({
|
|
26
|
-
apiKey: liveApiKey!,
|
|
27
|
-
baseUrl: liveBaseUrl,
|
|
28
|
-
timeout: 60_000,
|
|
29
|
-
maxRetries: 1,
|
|
30
|
-
});
|
|
31
|
-
let sandbox: Sandbox | undefined;
|
|
32
|
-
const marker = `miosa-ts-live-${Date.now()}`;
|
|
33
|
-
const port = 32_173;
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
sandbox = await client.sandboxes.create({
|
|
37
|
-
name: `sdk-ts-live-${Date.now()}`,
|
|
38
|
-
templateId: "miosa-sandbox",
|
|
39
|
-
timeoutSec: 600,
|
|
40
|
-
metadata: { test: "typescript-live-e2e" },
|
|
41
|
-
});
|
|
42
|
-
await waitReady(sandbox);
|
|
43
|
-
|
|
44
|
-
const exec = await sandbox.commands.run("python3 -c 'print(21 * 2)'", {
|
|
45
|
-
timeoutSec: 30,
|
|
46
|
-
});
|
|
47
|
-
expect(exec.exitCode).toBe(0);
|
|
48
|
-
expect(exec.stdout.trim()).toBe("42");
|
|
49
|
-
|
|
50
|
-
await sandbox.files.write("/workspace/index.html", `<h1>${marker}</h1>`);
|
|
51
|
-
expect(await sandbox.files.readText("/workspace/index.html")).toContain(marker);
|
|
52
|
-
const list = await sandbox.files.list("/workspace");
|
|
53
|
-
expect(JSON.stringify(list)).toContain("index.html");
|
|
54
|
-
const stat = await sandbox.files.stat("/workspace/index.html");
|
|
55
|
-
expect(Number(stat.size ?? 0)).toBeGreaterThan(0);
|
|
56
|
-
|
|
57
|
-
await sandbox.commands.run(
|
|
58
|
-
[
|
|
59
|
-
"cd /workspace",
|
|
60
|
-
`nohup python3 -m http.server ${port} --bind 0.0.0.0 >/tmp/miosa-ts-live.log 2>&1 &`,
|
|
61
|
-
].join(" && "),
|
|
62
|
-
{ timeoutSec: 10 },
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
let reachable = false;
|
|
66
|
-
for (let attempt = 0; attempt < 20; attempt += 1) {
|
|
67
|
-
const probe = await sandbox.commands.run(
|
|
68
|
-
`python3 - <<'PY'\nimport urllib.request\nprint(urllib.request.urlopen('http://127.0.0.1:${port}', timeout=2).read().decode())\nPY`,
|
|
69
|
-
{ timeoutSec: 5 },
|
|
70
|
-
);
|
|
71
|
-
if (probe.exitCode === 0 && probe.stdout.includes(marker)) {
|
|
72
|
-
reachable = true;
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
await sleep(500);
|
|
76
|
-
}
|
|
77
|
-
expect(reachable).toBe(true);
|
|
78
|
-
|
|
79
|
-
const previewUrl = await sandbox.preview.expose(port);
|
|
80
|
-
expect(previewUrl).toMatch(/^https:\/\//);
|
|
81
|
-
const preview = await fetch(previewUrl);
|
|
82
|
-
expect(preview.status).toBe(200);
|
|
83
|
-
expect(await preview.text()).toContain(marker);
|
|
84
|
-
} finally {
|
|
85
|
-
if (sandbox) {
|
|
86
|
-
await sandbox.destroy().catch(() => undefined);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
120_000,
|
|
91
|
-
);
|
|
92
|
-
});
|