@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
package/README.md
CHANGED
|
@@ -29,8 +29,11 @@ import { Miosa } from "@miosa/sdk";
|
|
|
29
29
|
|
|
30
30
|
const miosa = new Miosa({ apiKey: "msk_live_..." });
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
const sbx = await miosa.sandboxes.
|
|
32
|
+
// Create or resume a persistent sandbox workspace, then work inside it.
|
|
33
|
+
const sbx = await miosa.sandboxes.createAgentWorkspace({
|
|
34
|
+
name: "my-build",
|
|
35
|
+
externalWorkspaceId: "customer-workspace-123",
|
|
36
|
+
});
|
|
34
37
|
|
|
35
38
|
await sbx.files.write("/workspace/hello.ts", `console.log("hello from miosa")`);
|
|
36
39
|
const result = await sbx.exec("npx tsx /workspace/hello.ts");
|
|
@@ -38,16 +41,17 @@ console.log(result.stdout); // hello from miosa
|
|
|
38
41
|
|
|
39
42
|
// Expose a live preview URL
|
|
40
43
|
const url = await sbx.expose(3000);
|
|
41
|
-
console.log(url); // https://3000-<slug>.sandbox
|
|
44
|
+
console.log(url); // https://3000-<slug>.sandbox.miosa.ai
|
|
42
45
|
|
|
43
|
-
|
|
46
|
+
// Keep progress. Pause preserves the workspace so the next session can resume.
|
|
47
|
+
await sbx.snapshots.create("after-hello-world");
|
|
48
|
+
await sbx.pause();
|
|
44
49
|
```
|
|
45
50
|
|
|
46
51
|
## What's included
|
|
47
52
|
|
|
48
53
|
| Resource | Description |
|
|
49
54
|
|---|---|
|
|
50
|
-
| `miosa.devices` | Agent device facade for routing work across sandboxes, computers, local devices, and Docker Deploy hosts |
|
|
51
55
|
| `miosa.sandboxes` | Lightweight code-execution VMs — exec, files, snapshots, previews |
|
|
52
56
|
| `miosa.computers` | Full Linux desktop VMs for computer-use agents |
|
|
53
57
|
| `miosa.deployments` | Versioned production releases with rollback |
|
|
@@ -62,29 +66,53 @@ await sbx.destroy();
|
|
|
62
66
|
| `miosa.completions` | OpenAI-compatible chat completions with SSE streaming |
|
|
63
67
|
| `miosa.embeddings` | OpenAI-compatible embedding vectors |
|
|
64
68
|
|
|
65
|
-
## Agent
|
|
69
|
+
## Agent workspaces
|
|
66
70
|
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
For AI builders, code assistants, and white-label agent products, the sandbox
|
|
72
|
+
is the development machine. Do not run builds on the user's laptop and upload
|
|
73
|
+
the result as the primary flow. Create or resume a stable sandbox workspace,
|
|
74
|
+
write files under `/workspace`, run package installs/tests/builds inside the
|
|
75
|
+
sandbox, expose previews from the sandbox, and publish from that sandbox.
|
|
69
76
|
|
|
70
77
|
```ts
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const sbx = await miosa.sandboxes.getOrCreate({
|
|
79
|
+
name: "acme-marketing-page",
|
|
80
|
+
templateId: "miosa-sandbox",
|
|
81
|
+
persistent: true,
|
|
82
|
+
timeoutSec: 86_400,
|
|
83
|
+
idleTimeoutSec: 1800,
|
|
84
|
+
snapshotExpirationDays: 30,
|
|
85
|
+
keepLastSnapshots: 1,
|
|
86
|
+
externalWorkspaceId: "acme",
|
|
87
|
+
externalUserId: "jane",
|
|
88
|
+
waitUntilReady: true,
|
|
82
89
|
});
|
|
83
90
|
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
await sbx.files.writeMany([
|
|
92
|
+
{ path: "/workspace/package.json", content: `{"scripts":{"dev":"vite --host 0.0.0.0"}}` },
|
|
93
|
+
{ path: "/workspace/index.html", content: `<main id="app"></main>` },
|
|
94
|
+
]);
|
|
95
|
+
|
|
96
|
+
for await (const event of sbx.exec.stream("cd /workspace && npm install && npm run dev -- --port 3000")) {
|
|
97
|
+
console.log(event);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const preview = await sbx.previews.create(3000);
|
|
101
|
+
console.log(preview.url);
|
|
86
102
|
```
|
|
87
103
|
|
|
104
|
+
`createAgentWorkspace()` is a convenience wrapper around `getOrCreate()` with
|
|
105
|
+
builder defaults: a 24-hour activity cap, thirty-minute idle snapshot/pause,
|
|
106
|
+
readiness waiting, 30-day snapshot-retention metadata, keep-last-snapshot
|
|
107
|
+
metadata, and metadata that marks the sandbox as an agent workspace.
|
|
108
|
+
|
|
109
|
+
That mirrors the Vercel-style persistent-sandbox model without keeping CPU
|
|
110
|
+
running forever: activity extends the running session, idle workspaces are
|
|
111
|
+
checkpointed and paused, and later sessions resume from the checkpoint. Use
|
|
112
|
+
`extend(86_400)` before long builds, `pause()` when the user is done for now,
|
|
113
|
+
`resume()` for the next session, `snapshots.create()` for manual checkpoints,
|
|
114
|
+
and `destroy()` only when the workspace should be permanently deleted.
|
|
115
|
+
|
|
88
116
|
## Sandbox sub-resources
|
|
89
117
|
|
|
90
118
|
Every `Sandbox` instance exposes composable sub-resources:
|
|
@@ -123,6 +151,56 @@ await sbx.pause();
|
|
|
123
151
|
await sbx.resume();
|
|
124
152
|
```
|
|
125
153
|
|
|
154
|
+
## Publish from sandbox
|
|
155
|
+
|
|
156
|
+
Preview is mutable; publish creates a durable deployment version. Static output
|
|
157
|
+
is served by MIOSA's artifact plane. Dynamic apps run in reconciled runtime VMs.
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
const deployment = await sbx.deploy({
|
|
161
|
+
name: "clinic-intake",
|
|
162
|
+
outputPath: "/workspace/dist",
|
|
163
|
+
entrypoint: "index.html",
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
console.log(deployment.url ?? deployment.deployment?.public_url);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
For dynamic/full-stack apps:
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
const deployment = await sbx.deploy({
|
|
173
|
+
name: "clinic-intake-api",
|
|
174
|
+
outputPath: "/workspace",
|
|
175
|
+
runCommand: "npm start",
|
|
176
|
+
port: 3000,
|
|
177
|
+
domain: "intake.apps.cliniciq.com",
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
For workspace Docker Deploy, publish from the same sandbox but choose the
|
|
182
|
+
Docker Deploy target:
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
const deployment = await sbx.deployDocker({
|
|
186
|
+
name: "lead-magnet",
|
|
187
|
+
path: "/workspace",
|
|
188
|
+
buildCommand: "npm run build",
|
|
189
|
+
runCommand: "npm start",
|
|
190
|
+
port: 3000,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
console.log(deployment.url ?? deployment.public_url);
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Docker Deploy runs app containers inside the workspace's dedicated MIOSA
|
|
197
|
+
Docker Deploy appliance VM. It is separate from normal MIOSA dynamic runtime
|
|
198
|
+
VMs and is useful when a workspace needs many small apps, funnels, lead
|
|
199
|
+
magnets, APIs, or client sites.
|
|
200
|
+
|
|
201
|
+
Always display the server-returned `url` / `public_url`. Do not hardcode
|
|
202
|
+
`preview.miosa.app`, `api.miosa.app`, or `<tenant>.miosa.app`.
|
|
203
|
+
|
|
126
204
|
## Desktop control (Computers)
|
|
127
205
|
|
|
128
206
|
```ts
|
|
@@ -160,47 +238,17 @@ const sandboxes = await miosa.sandboxes.list({
|
|
|
160
238
|
});
|
|
161
239
|
```
|
|
162
240
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Use Docker Deploy when a sandbox-built app should run as a container on the
|
|
166
|
-
workspace Docker appliance.
|
|
167
|
-
|
|
168
|
-
```ts
|
|
169
|
-
const templates = await miosa.deployments.listDockerDeployTemplates({
|
|
170
|
-
framework: "nextjs",
|
|
171
|
-
includePreview: true,
|
|
172
|
-
});
|
|
173
|
-
const template = templates[0];
|
|
174
|
-
|
|
175
|
-
await miosa.deployments.ensureDockerDeployHost({
|
|
176
|
-
workspaceId: "workspace-uuid",
|
|
177
|
-
size: "small",
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const sbx = await miosa.sandboxes.create({ templateId: "nextjs" });
|
|
181
|
-
// Build or sync the app into /workspace...
|
|
182
|
-
|
|
183
|
-
const published = await sbx.deployDocker({
|
|
184
|
-
name: "customer-site",
|
|
185
|
-
outputPath: "/workspace",
|
|
186
|
-
port: 3000,
|
|
187
|
-
dockerDeployTemplateId: template.id,
|
|
188
|
-
});
|
|
241
|
+
White-label domain layers are separate:
|
|
189
242
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (!proof.ok) {
|
|
196
|
-
throw new Error(JSON.stringify(proof.checks, null, 2));
|
|
197
|
-
}
|
|
243
|
+
```text
|
|
244
|
+
sandbox preview: https://<port>-<slug>.sandbox.<preview-domain>
|
|
245
|
+
durable deployment: https://<slug>.<deployment-domain>
|
|
246
|
+
custom domain: https://app.customer.com
|
|
198
247
|
```
|
|
199
248
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
Docker Deploy publish.
|
|
249
|
+
Tenant preview-domain management is available through `miosa.tenant.previewDomain`.
|
|
250
|
+
Tenant deployment-domain routing exists server-side; SDKs should consume
|
|
251
|
+
deployment `public_url` instead of reconstructing it.
|
|
204
252
|
|
|
205
253
|
## Error handling
|
|
206
254
|
|