@miosa/sdk 0.3.0

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 (81) hide show
  1. package/README.md +181 -0
  2. package/dist/index.d.ts +4689 -0
  3. package/dist/index.js +6045 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +63 -0
  6. package/src/client.ts +249 -0
  7. package/src/errors.ts +136 -0
  8. package/src/http.test.ts +374 -0
  9. package/src/http.ts +390 -0
  10. package/src/index.ts +452 -0
  11. package/src/resources/admin.ts +348 -0
  12. package/src/resources/analytics.ts +60 -0
  13. package/src/resources/api-keys.ts +119 -0
  14. package/src/resources/audit-log.ts +64 -0
  15. package/src/resources/benchmarks.ts +104 -0
  16. package/src/resources/builder-sessions.ts +75 -0
  17. package/src/resources/channels.ts +143 -0
  18. package/src/resources/checkpoints.ts +225 -0
  19. package/src/resources/command-center.ts +73 -0
  20. package/src/resources/community.ts +103 -0
  21. package/src/resources/completions.ts +104 -0
  22. package/src/resources/computer-auto-stop.ts +43 -0
  23. package/src/resources/computer-env.ts +76 -0
  24. package/src/resources/computer-logs.ts +50 -0
  25. package/src/resources/computer-osa.ts +76 -0
  26. package/src/resources/computer-ports.ts +91 -0
  27. package/src/resources/computer-terminal.ts +61 -0
  28. package/src/resources/computer-volumes.ts +64 -0
  29. package/src/resources/computer.ts +530 -0
  30. package/src/resources/computers.ts +75 -0
  31. package/src/resources/credits.ts +43 -0
  32. package/src/resources/cron-jobs.ts +191 -0
  33. package/src/resources/custom_domains.ts +123 -0
  34. package/src/resources/dashboard.ts +49 -0
  35. package/src/resources/databases.ts +218 -0
  36. package/src/resources/deployments.ts +777 -0
  37. package/src/resources/desktop.ts +134 -0
  38. package/src/resources/email.ts +212 -0
  39. package/src/resources/embeddings.ts +36 -0
  40. package/src/resources/events.ts +296 -0
  41. package/src/resources/exec.ts +319 -0
  42. package/src/resources/external-keys.ts +79 -0
  43. package/src/resources/files.test.ts +339 -0
  44. package/src/resources/files.ts +220 -0
  45. package/src/resources/flat-custom-domains.ts +127 -0
  46. package/src/resources/functions.ts +178 -0
  47. package/src/resources/health-checks.ts +165 -0
  48. package/src/resources/integrations.ts +183 -0
  49. package/src/resources/mcp.ts +70 -0
  50. package/src/resources/models.ts +45 -0
  51. package/src/resources/network_policy.ts +73 -0
  52. package/src/resources/open-computers/agents.ts +91 -0
  53. package/src/resources/open-computers/apps.ts +102 -0
  54. package/src/resources/open-computers/clusters.ts +88 -0
  55. package/src/resources/open-computers/desktop.ts +34 -0
  56. package/src/resources/open-computers/files.ts +97 -0
  57. package/src/resources/open-computers/hosts.ts +85 -0
  58. package/src/resources/open-computers/index.ts +98 -0
  59. package/src/resources/open-computers/jobs.ts +75 -0
  60. package/src/resources/open-computers/open_computers.test.ts +288 -0
  61. package/src/resources/open-computers/secrets.ts +115 -0
  62. package/src/resources/open-computers/terminal.ts +33 -0
  63. package/src/resources/open-computers/tunnels.ts +87 -0
  64. package/src/resources/open-computers/types.ts +343 -0
  65. package/src/resources/open-computers/workspaces.ts +135 -0
  66. package/src/resources/project-auth.ts +142 -0
  67. package/src/resources/project-integrations.ts +133 -0
  68. package/src/resources/provider-defaults.ts +89 -0
  69. package/src/resources/regions.ts +94 -0
  70. package/src/resources/sandbox-templates.ts +195 -0
  71. package/src/resources/sandboxes.live.test.ts +92 -0
  72. package/src/resources/sandboxes.test.ts +624 -0
  73. package/src/resources/sandboxes.ts +1173 -0
  74. package/src/resources/settings.ts +143 -0
  75. package/src/resources/snapshots-standalone.ts +51 -0
  76. package/src/resources/storage.ts +221 -0
  77. package/src/resources/tenant.ts +39 -0
  78. package/src/resources/usage.ts +85 -0
  79. package/src/resources/volumes.ts +117 -0
  80. package/src/resources/webhooks.ts +171 -0
  81. package/src/types.ts +460 -0
package/README.md ADDED
@@ -0,0 +1,181 @@
1
+ # @miosa/sdk (TypeScript)
2
+
3
+ > Official TypeScript / JavaScript SDK for MIOSA — the AI cloud platform for sandboxes, computers, deployments, and managed data.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@miosa/sdk.svg)](https://www.npmjs.com/package/@miosa/sdk)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@miosa/sdk.svg)](https://www.npmjs.com/package/@miosa/sdk)
7
+ [![Types](https://img.shields.io/badge/types-included-blue)](https://www.npmjs.com/package/@miosa/sdk)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
+ [![Docs](https://img.shields.io/badge/docs-miosa.ai%2Fdocs-blue)](https://miosa.ai/docs/sdks/typescript)
10
+
11
+ Ships ESM + CJS. Full TypeScript types included — no `@types/` package needed. Node.js 18+.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install @miosa/sdk
17
+ # or
18
+ pnpm add @miosa/sdk
19
+ # or
20
+ yarn add @miosa/sdk
21
+ # or
22
+ bun add @miosa/sdk
23
+ ```
24
+
25
+ ## Quickstart
26
+
27
+ ```ts
28
+ import { Miosa } from "@miosa/sdk";
29
+
30
+ const miosa = new Miosa({ apiKey: "msk_live_..." });
31
+
32
+ // Boot a sandbox, write a file, run a command
33
+ const sbx = await miosa.sandboxes.create({ name: "my-build" });
34
+
35
+ await sbx.files.write("/workspace/hello.ts", `console.log("hello from miosa")`);
36
+ const result = await sbx.exec("npx tsx /workspace/hello.ts");
37
+ console.log(result.stdout); // hello from miosa
38
+
39
+ // Expose a live preview URL
40
+ const url = await sbx.expose(3000);
41
+ console.log(url); // https://3000-<slug>.sandbox.miosa.ai
42
+
43
+ await sbx.destroy();
44
+ ```
45
+
46
+ ## What's included
47
+
48
+ | Resource | Description |
49
+ |---|---|
50
+ | `miosa.sandboxes` | Lightweight code-execution VMs — exec, files, snapshots, previews |
51
+ | `miosa.computers` | Full Linux desktop VMs for computer-use agents |
52
+ | `miosa.deployments` | Versioned production releases with rollback |
53
+ | `miosa.databases` | Managed Postgres / Redis lifecycle |
54
+ | `miosa.storage` | S3-compatible object storage |
55
+ | `miosa.volumes` | Persistent block storage |
56
+ | `miosa.apiKeys` | Programmatic API key management |
57
+ | `miosa.usage` | Usage reports per workspace, per external tenant |
58
+ | `miosa.settings` | Workspace config, branding, BYOK provider keys |
59
+ | `miosa.webhooks` | Outgoing tenant webhooks — CRUD, test, delivery history |
60
+ | `miosa.openComputers` | BYOC host management — register your own machines |
61
+ | `miosa.completions` | OpenAI-compatible chat completions with SSE streaming |
62
+ | `miosa.embeddings` | OpenAI-compatible embedding vectors |
63
+
64
+ ## Sandbox sub-resources
65
+
66
+ Every `Sandbox` instance exposes composable sub-resources:
67
+
68
+ ```ts
69
+ const sbx = await miosa.sandboxes.create();
70
+
71
+ // Files
72
+ await sbx.files.write("/workspace/app.py", "print('hi')");
73
+ const text = await sbx.files.readText("/workspace/app.py");
74
+ const entries = await sbx.files.list("/workspace");
75
+ const stat = await sbx.files.stat("/workspace/app.py");
76
+
77
+ // Exec — callable directly, or via .exec.run / .exec.stream
78
+ const result = await sbx.exec.run("python /workspace/app.py");
79
+ for await (const event of sbx.exec.stream("tail -f /var/log/app.log")) {
80
+ if ("line" in event) console.log(event.line);
81
+ }
82
+
83
+ // Snapshots
84
+ const snap = await sbx.snapshots.create("pre-migration");
85
+ const restored = await sbx.snapshots.restore(snap.id);
86
+ await sbx.snapshots.delete(snap.id);
87
+
88
+ // Previews
89
+ const preview = await sbx.previews.create(8000);
90
+ console.log(preview.url);
91
+
92
+ // Live SSE event stream
93
+ for await (const event of sbx.events.stream()) {
94
+ console.log(event.type, event.data);
95
+ }
96
+
97
+ // Pause / resume
98
+ await sbx.pause();
99
+ await sbx.resume();
100
+ ```
101
+
102
+ ## Desktop control (Computers)
103
+
104
+ ```ts
105
+ const computer = await miosa.computers.create({
106
+ name: "agent-desktop",
107
+ template_type: "miosa-desktop",
108
+ size: "medium",
109
+ });
110
+ await computer.start();
111
+ await computer.wait(5);
112
+
113
+ const png = await computer.screenshot(); // Uint8Array
114
+ await computer.click(640, 400);
115
+ await computer.type("hello world");
116
+ await computer.key("Return");
117
+ await computer.scroll("down", 3);
118
+ await computer.drag(100, 100, 400, 400);
119
+
120
+ const result = await computer.bash("ls -la /home/user");
121
+ console.log(result.output);
122
+
123
+ await computer.destroy();
124
+ ```
125
+
126
+ ## White-label / multi-tenant
127
+
128
+ ```ts
129
+ const sbx = await miosa.sandboxes.create({
130
+ externalWorkspaceId: "dental-office-123",
131
+ externalUserId: "dr-smith-456",
132
+ });
133
+
134
+ const sandboxes = await miosa.sandboxes.list({
135
+ externalWorkspaceId: "dental-office-123",
136
+ });
137
+ ```
138
+
139
+ ## Error handling
140
+
141
+ ```ts
142
+ import { MiosaError } from "@miosa/sdk";
143
+
144
+ try {
145
+ await miosa.sandboxes.get("sbx_doesnt_exist");
146
+ } catch (e) {
147
+ if (e instanceof MiosaError) {
148
+ console.error(`${e.status} ${e.code}: ${e.message}`);
149
+ }
150
+ }
151
+ ```
152
+
153
+ The SDK retries `429` and `5xx` automatically (3 retries, exponential backoff + jitter). Set `maxRetries: 0` to disable.
154
+
155
+ ## Configuration
156
+
157
+ | Option | Env var | Default |
158
+ |---|---|---|
159
+ | `apiKey` | `MIOSA_API_KEY` | — |
160
+ | `baseUrl` | `MIOSA_BASE_URL` | `https://api.miosa.ai/api/v1` |
161
+ | `timeout` | — | 30 000 ms |
162
+ | `maxRetries` | — | 3 |
163
+
164
+ ```ts
165
+ const miosa = new Miosa({
166
+ apiKey: process.env.MIOSA_API_KEY!,
167
+ timeout: 60_000,
168
+ maxRetries: 5,
169
+ });
170
+ ```
171
+
172
+ ## Links
173
+
174
+ - [Full documentation](https://miosa.ai/docs/sdks/typescript)
175
+ - [Quickstart](https://miosa.ai/docs/quickstart)
176
+ - [GitHub](https://github.com/miosa-ai/miosa-js)
177
+ - [Contact](mailto:platform@miosa.ai)
178
+
179
+ ## License
180
+
181
+ MIT