withruntime 0.50.0 → 1.0.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.
- package/dist/generated/apps.d.ts +309 -0
- package/dist/generated/apps.js +333 -0
- package/dist/generated/audit.d.ts +47 -0
- package/dist/generated/audit.js +14 -0
- package/dist/generated/browsers.d.ts +309 -0
- package/dist/generated/browsers.js +333 -0
- package/dist/generated/builds.d.ts +309 -0
- package/dist/generated/builds.js +333 -0
- package/dist/generated/ci.d.ts +309 -0
- package/dist/generated/ci.js +333 -0
- package/dist/generated/containers.d.ts +309 -0
- package/dist/generated/containers.js +333 -0
- package/dist/generated/desktops.d.ts +309 -0
- package/dist/generated/desktops.js +333 -0
- package/dist/generated/domains.d.ts +80 -0
- package/dist/generated/domains.js +58 -0
- package/dist/generated/egressIps.d.ts +36 -0
- package/dist/generated/egressIps.js +14 -0
- package/dist/generated/events.d.ts +37 -0
- package/dist/generated/events.js +14 -0
- package/dist/generated/feedback.d.ts +44 -0
- package/dist/generated/feedback.js +13 -0
- package/dist/generated/functions.d.ts +309 -0
- package/dist/generated/functions.js +333 -0
- package/dist/generated/identities.d.ts +36 -0
- package/dist/generated/identities.js +22 -0
- package/dist/generated/images.d.ts +200 -0
- package/dist/generated/images.js +65 -0
- package/dist/generated/index.d.ts +143 -0
- package/dist/generated/index.js +184 -0
- package/dist/generated/jobRuns.d.ts +68 -0
- package/dist/generated/jobRuns.js +22 -0
- package/dist/generated/jobs.d.ts +144 -0
- package/dist/generated/jobs.js +85 -0
- package/dist/generated/keys.d.ts +105 -0
- package/dist/generated/keys.js +26 -0
- package/dist/generated/me.d.ts +33 -0
- package/dist/generated/me.js +13 -0
- package/dist/generated/networks.d.ts +32 -0
- package/dist/generated/networks.js +14 -0
- package/dist/generated/notebooks.d.ts +309 -0
- package/dist/generated/notebooks.js +333 -0
- package/dist/generated/otel.d.ts +46 -0
- package/dist/generated/otel.js +22 -0
- package/dist/generated/ports.d.ts +55 -0
- package/dist/generated/ports.js +22 -0
- package/dist/generated/previews.d.ts +86 -0
- package/dist/generated/previews.js +67 -0
- package/dist/generated/projects.d.ts +47 -0
- package/dist/generated/projects.js +26 -0
- package/dist/generated/roles.d.ts +36 -0
- package/dist/generated/roles.js +22 -0
- package/dist/generated/routes.d.ts +3 -0
- package/dist/generated/routes.js +4 -0
- package/dist/generated/runtime.d.ts +176 -0
- package/dist/generated/runtime.js +416 -0
- package/dist/generated/sandboxes.d.ts +952 -0
- package/dist/generated/sandboxes.js +342 -0
- package/dist/generated/secrets.d.ts +116 -0
- package/dist/generated/secrets.js +54 -0
- package/dist/generated/sessions.d.ts +47 -0
- package/dist/generated/sessions.js +17 -0
- package/dist/generated/signing.d.ts +68 -0
- package/dist/generated/signing.js +187 -0
- package/dist/generated/sites.d.ts +309 -0
- package/dist/generated/sites.js +333 -0
- package/dist/generated/snapshots.d.ts +27 -0
- package/dist/generated/snapshots.js +22 -0
- package/dist/generated/tunnels.d.ts +68 -0
- package/dist/generated/tunnels.js +14 -0
- package/dist/generated/usage.d.ts +155 -0
- package/dist/generated/usage.js +17 -0
- package/dist/generated/volumes.d.ts +36 -0
- package/dist/generated/volumes.js +26 -0
- package/dist/generated/webhooks.d.ts +44 -0
- package/dist/generated/webhooks.js +22 -0
- package/dist/generated/workspaces.d.ts +309 -0
- package/dist/generated/workspaces.js +333 -0
- package/dist/v2/cli.d.ts +7 -0
- package/dist/v2/cli.js +283 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +4 -0
- package/dist/v2/login.d.ts +35 -0
- package/dist/v2/login.js +225 -0
- package/dist/v2/mcp.d.ts +1 -0
- package/dist/v2/mcp.js +49 -0
- package/dist/v2/openapi.json +75750 -0
- package/dist/v2/shims/base.d.ts +33 -0
- package/dist/v2/shims/base.js +54 -0
- package/dist/v2/shims/blaxel.d.ts +60 -0
- package/dist/v2/shims/blaxel.js +71 -0
- package/dist/v2/shims/cloudflare.d.ts +52 -0
- package/dist/v2/shims/cloudflare.js +55 -0
- package/dist/v2/shims/daytona.d.ts +58 -0
- package/dist/v2/shims/daytona.js +74 -0
- package/dist/v2/shims/e2b.d.ts +142 -0
- package/dist/v2/shims/e2b.js +238 -0
- package/dist/v2/shims/fly.d.ts +6 -0
- package/dist/v2/shims/fly.js +91 -0
- package/dist/v2/shims/modal.d.ts +54 -0
- package/dist/v2/shims/modal.js +79 -0
- package/dist/v2/shims/morph.d.ts +60 -0
- package/dist/v2/shims/morph.js +87 -0
- package/dist/v2/shims/vercel.d.ts +53 -0
- package/dist/v2/shims/vercel.js +90 -0
- package/dist/v2/table.d.ts +53 -0
- package/dist/v2/table.js +122 -0
- package/package.json +20 -310
- package/BLAXEL.md +0 -290
- package/COMPATIBILITY.md +0 -447
- package/DAYTONA.md +0 -237
- package/E2B.md +0 -314
- package/README.md +0 -331
- package/README.src.md +0 -333
- package/VERCEL.md +0 -230
- package/agent-platforms-inventory.json +0 -387
- package/compatibility-lock.json +0 -305
- package/dist/agents/browser.d.ts +0 -12
- package/dist/agents/browser.js +0 -12
- package/dist/agents/index.d.ts +0 -11
- package/dist/agents/index.js +0 -11
- package/dist/agents-cli.d.ts +0 -16
- package/dist/agents-cli.js +0 -1237
- package/dist/agents-deploy.d.ts +0 -196
- package/dist/agents-deploy.js +0 -872
- package/dist/agents-file.d.ts +0 -19
- package/dist/agents-file.js +0 -135
- package/dist/ai/index.d.ts +0 -49
- package/dist/ai/index.js +0 -31
- package/dist/ai-harness/index.d.ts +0 -194
- package/dist/ai-harness/index.js +0 -522
- package/dist/api-defaults.d.ts +0 -17
- package/dist/api-defaults.js +0 -22
- package/dist/apps/index.d.ts +0 -10
- package/dist/apps/index.js +0 -11
- package/dist/apps-cli.d.ts +0 -16
- package/dist/apps-cli.js +0 -1021
- package/dist/billing-cli.d.ts +0 -23
- package/dist/billing-cli.js +0 -264
- package/dist/blaxel/client.d.ts +0 -59
- package/dist/blaxel/client.js +0 -86
- package/dist/blaxel/context.d.ts +0 -59
- package/dist/blaxel/context.js +0 -162
- package/dist/blaxel/errors.d.ts +0 -130
- package/dist/blaxel/errors.js +0 -315
- package/dist/blaxel/filesystem.d.ts +0 -147
- package/dist/blaxel/filesystem.js +0 -585
- package/dist/blaxel/index.d.ts +0 -287
- package/dist/blaxel/index.js +0 -351
- package/dist/blaxel/interpreter.d.ts +0 -71
- package/dist/blaxel/interpreter.js +0 -256
- package/dist/blaxel/lookup.d.ts +0 -39
- package/dist/blaxel/lookup.js +0 -84
- package/dist/blaxel/pagination.d.ts +0 -39
- package/dist/blaxel/pagination.js +0 -88
- package/dist/blaxel/preview.d.ts +0 -136
- package/dist/blaxel/preview.js +0 -304
- package/dist/blaxel/process.d.ts +0 -126
- package/dist/blaxel/process.js +0 -581
- package/dist/blaxel/sandbox.d.ts +0 -198
- package/dist/blaxel/sandbox.js +0 -856
- package/dist/blaxel/session.d.ts +0 -31
- package/dist/blaxel/session.js +0 -136
- package/dist/blaxel/snapshot.d.ts +0 -123
- package/dist/blaxel/snapshot.js +0 -199
- package/dist/blaxel/types.d.ts +0 -145
- package/dist/blaxel/types.js +0 -60
- package/dist/blaxel/unsupported.d.ts +0 -20
- package/dist/blaxel/unsupported.js +0 -32
- package/dist/browser-stub.d.ts +0 -1
- package/dist/browser-stub.js +0 -1
- package/dist/browsers/index.d.ts +0 -9
- package/dist/browsers/index.js +0 -10
- package/dist/browsers-cli.d.ts +0 -13
- package/dist/browsers-cli.js +0 -279
- package/dist/builds/index.d.ts +0 -10
- package/dist/builds/index.js +0 -11
- package/dist/ci/index.d.ts +0 -13
- package/dist/ci/index.js +0 -14
- package/dist/ci-cli.d.ts +0 -20
- package/dist/ci-cli.js +0 -537
- package/dist/ci-import.d.ts +0 -23
- package/dist/ci-import.js +0 -565
- package/dist/claude-agent-sdk/index.d.ts +0 -7
- package/dist/claude-agent-sdk/index.js +0 -65
- package/dist/cli/logs.d.ts +0 -21
- package/dist/cli/logs.js +0 -188
- package/dist/cli-extras.d.ts +0 -39
- package/dist/cli-extras.js +0 -267
- package/dist/cli-name.d.ts +0 -6
- package/dist/cli-name.js +0 -8
- package/dist/cli-update.d.ts +0 -11
- package/dist/cli-update.js +0 -46
- package/dist/cli-words.d.ts +0 -36
- package/dist/cli-words.js +0 -167
- package/dist/cli.d.ts +0 -92
- package/dist/cli.js +0 -5463
- package/dist/client.d.ts +0 -189
- package/dist/client.js +0 -205
- package/dist/cloudflare/errors.d.ts +0 -166
- package/dist/cloudflare/errors.js +0 -183
- package/dist/cloudflare/identity.d.ts +0 -7
- package/dist/cloudflare/identity.js +0 -13
- package/dist/cloudflare/index.d.ts +0 -545
- package/dist/cloudflare/index.js +0 -1106
- package/dist/cloudflare/interpreter.d.ts +0 -119
- package/dist/cloudflare/interpreter.js +0 -232
- package/dist/cloudflare/mime.d.ts +0 -1
- package/dist/cloudflare/mime.js +0 -66
- package/dist/cloudflare/streams.d.ts +0 -46
- package/dist/cloudflare/streams.js +0 -175
- package/dist/cloudflare/types.d.ts +0 -338
- package/dist/cloudflare/types.js +0 -80
- package/dist/cloudflare/watch.d.ts +0 -9
- package/dist/cloudflare/watch.js +0 -24
- package/dist/cloudflare/worker.d.ts +0 -706
- package/dist/cloudflare/worker.js +0 -633
- package/dist/codesandbox/guest-service.d.ts +0 -31
- package/dist/codesandbox/guest-service.js +0 -490
- package/dist/codesandbox/index.d.ts +0 -574
- package/dist/codesandbox/index.js +0 -1747
- package/dist/compat/core.d.ts +0 -58
- package/dist/compat/core.js +0 -267
- package/dist/compat/files.d.ts +0 -27
- package/dist/compat/files.js +0 -157
- package/dist/compat/lease.d.ts +0 -37
- package/dist/compat/lease.js +0 -93
- package/dist/compat/shell.d.ts +0 -4
- package/dist/compat/shell.js +0 -165
- package/dist/containers/index.d.ts +0 -10
- package/dist/containers/index.js +0 -11
- package/dist/credentials.d.ts +0 -71
- package/dist/credentials.js +0 -340
- package/dist/daytona/client.d.ts +0 -48
- package/dist/daytona/client.js +0 -45
- package/dist/daytona/computer-use.d.ts +0 -171
- package/dist/daytona/computer-use.js +0 -382
- package/dist/daytona/context.d.ts +0 -41
- package/dist/daytona/context.js +0 -50
- package/dist/daytona/daytona.d.ts +0 -213
- package/dist/daytona/daytona.js +0 -578
- package/dist/daytona/errors.d.ts +0 -117
- package/dist/daytona/errors.js +0 -201
- package/dist/daytona/filesystem.d.ts +0 -99
- package/dist/daytona/filesystem.js +0 -300
- package/dist/daytona/git.d.ts +0 -33
- package/dist/daytona/git.js +0 -128
- package/dist/daytona/image.d.ts +0 -49
- package/dist/daytona/image.js +0 -146
- package/dist/daytona/index.d.ts +0 -87
- package/dist/daytona/index.js +0 -102
- package/dist/daytona/process.d.ts +0 -143
- package/dist/daytona/process.js +0 -565
- package/dist/daytona/sandbox.d.ts +0 -222
- package/dist/daytona/sandbox.js +0 -505
- package/dist/desktops/index.d.ts +0 -9
- package/dist/desktops/index.js +0 -10
- package/dist/domains/index.d.ts +0 -9
- package/dist/domains/index.js +0 -10
- package/dist/e2b/client.d.ts +0 -76
- package/dist/e2b/client.js +0 -124
- package/dist/e2b/code-interpreter.d.ts +0 -134
- package/dist/e2b/code-interpreter.js +0 -239
- package/dist/e2b/commands.d.ts +0 -135
- package/dist/e2b/commands.js +0 -452
- package/dist/e2b/errors.d.ts +0 -125
- package/dist/e2b/errors.js +0 -247
- package/dist/e2b/filesystem.d.ts +0 -111
- package/dist/e2b/filesystem.js +0 -374
- package/dist/e2b/index.d.ts +0 -35
- package/dist/e2b/index.js +0 -69
- package/dist/e2b/pty.d.ts +0 -24
- package/dist/e2b/pty.js +0 -83
- package/dist/e2b/sandbox.d.ts +0 -248
- package/dist/e2b/sandbox.js +0 -781
- package/dist/e2b/unsupported.d.ts +0 -38
- package/dist/e2b/unsupported.js +0 -48
- package/dist/e2b/users.d.ts +0 -39
- package/dist/e2b/users.js +0 -207
- package/dist/errors.d.ts +0 -100
- package/dist/errors.js +0 -198
- package/dist/file-source.d.ts +0 -16
- package/dist/file-source.js +0 -162
- package/dist/fly/index.d.ts +0 -102
- package/dist/fly/index.js +0 -930
- package/dist/freestyle/index.d.ts +0 -629
- package/dist/freestyle/index.js +0 -1187
- package/dist/functions/index.d.ts +0 -10
- package/dist/functions/index.js +0 -11
- package/dist/identity.d.ts +0 -30
- package/dist/identity.js +0 -141
- package/dist/image-context.d.ts +0 -39
- package/dist/image-context.js +0 -176
- package/dist/images/index.d.ts +0 -9
- package/dist/images/index.js +0 -10
- package/dist/index.d.ts +0 -87
- package/dist/index.js +0 -51
- package/dist/inngest/index.d.ts +0 -96
- package/dist/inngest/index.js +0 -183
- package/dist/ips/index.d.ts +0 -9
- package/dist/ips/index.js +0 -10
- package/dist/jobs/index.d.ts +0 -9
- package/dist/jobs/index.js +0 -10
- package/dist/jobs-code/cron.d.ts +0 -12
- package/dist/jobs-code/cron.js +0 -93
- package/dist/jobs-code/registry.d.ts +0 -31
- package/dist/jobs-code/registry.js +0 -30
- package/dist/jobs-code/runner.d.ts +0 -1
- package/dist/jobs-code/runner.js +0 -74
- package/dist/jobs-deploy.d.ts +0 -22
- package/dist/jobs-deploy.js +0 -247
- package/dist/jobs-import.d.ts +0 -15
- package/dist/jobs-import.js +0 -231
- package/dist/keys.d.ts +0 -55
- package/dist/keys.js +0 -211
- package/dist/login.d.ts +0 -88
- package/dist/login.js +0 -369
- package/dist/machine.d.ts +0 -222
- package/dist/machine.js +0 -578
- package/dist/mcp.d.ts +0 -16
- package/dist/mcp.js +0 -377
- package/dist/modal/index.d.ts +0 -532
- package/dist/modal/index.js +0 -1284
- package/dist/morph/index.d.ts +0 -255
- package/dist/morph/index.js +0 -641
- package/dist/network-cli.d.ts +0 -17
- package/dist/network-cli.js +0 -523
- package/dist/networks/index.d.ts +0 -11
- package/dist/networks/index.js +0 -10
- package/dist/openai-agents/index.d.ts +0 -132
- package/dist/openai-agents/index.js +0 -738
- package/dist/page.d.ts +0 -13
- package/dist/page.js +0 -39
- package/dist/ports/index.d.ts +0 -9
- package/dist/ports/index.js +0 -10
- package/dist/product-names.d.ts +0 -52
- package/dist/product-names.js +0 -174
- package/dist/product-renames.d.ts +0 -103
- package/dist/product-renames.js +0 -189
- package/dist/products/agents.d.ts +0 -935
- package/dist/products/agents.js +0 -581
- package/dist/products/api-keys.d.ts +0 -113
- package/dist/products/api-keys.js +0 -32
- package/dist/products/apps.d.ts +0 -409
- package/dist/products/apps.js +0 -231
- package/dist/products/audit.d.ts +0 -51
- package/dist/products/audit.js +0 -10
- package/dist/products/balancers.d.ts +0 -87
- package/dist/products/balancers.js +0 -8
- package/dist/products/billing.d.ts +0 -76
- package/dist/products/billing.js +0 -26
- package/dist/products/browser.d.ts +0 -73
- package/dist/products/browser.js +0 -29
- package/dist/products/browsers.d.ts +0 -184
- package/dist/products/browsers.js +0 -180
- package/dist/products/builds.d.ts +0 -175
- package/dist/products/builds.js +0 -234
- package/dist/products/ci.d.ts +0 -406
- package/dist/products/ci.js +0 -133
- package/dist/products/containers.d.ts +0 -71
- package/dist/products/containers.js +0 -6
- package/dist/products/desktop.d.ts +0 -141
- package/dist/products/desktop.js +0 -83
- package/dist/products/desktops.d.ts +0 -71
- package/dist/products/desktops.js +0 -27
- package/dist/products/functions.d.ts +0 -2
- package/dist/products/functions.js +0 -5
- package/dist/products/images.d.ts +0 -229
- package/dist/products/images.js +0 -235
- package/dist/products/index.d.ts +0 -84
- package/dist/products/index.js +0 -105
- package/dist/products/interpreter.d.ts +0 -97
- package/dist/products/interpreter.js +0 -106
- package/dist/products/jobs.d.ts +0 -408
- package/dist/products/jobs.js +0 -256
- package/dist/products/limits.d.ts +0 -61
- package/dist/products/limits.js +0 -10
- package/dist/products/logs.d.ts +0 -245
- package/dist/products/logs.js +0 -274
- package/dist/products/mcp.d.ts +0 -88
- package/dist/products/mcp.js +0 -58
- package/dist/products/mounts.d.ts +0 -49
- package/dist/products/mounts.js +0 -21
- package/dist/products/network-products.d.ts +0 -268
- package/dist/products/network-products.js +0 -127
- package/dist/products/network.d.ts +0 -62
- package/dist/products/network.js +0 -19
- package/dist/products/observability.d.ts +0 -264
- package/dist/products/observability.js +0 -123
- package/dist/products/plans.d.ts +0 -133
- package/dist/products/plans.js +0 -24
- package/dist/products/previews.d.ts +0 -70
- package/dist/products/previews.js +0 -39
- package/dist/products/private-network.d.ts +0 -22
- package/dist/products/private-network.js +0 -10
- package/dist/products/queues.d.ts +0 -149
- package/dist/products/queues.js +0 -213
- package/dist/products/referrals.d.ts +0 -50
- package/dist/products/referrals.js +0 -8
- package/dist/products/reservations.d.ts +0 -108
- package/dist/products/reservations.js +0 -41
- package/dist/products/resources.d.ts +0 -55
- package/dist/products/resources.js +0 -122
- package/dist/products/secrets.d.ts +0 -316
- package/dist/products/secrets.js +0 -333
- package/dist/products/signed-requests.d.ts +0 -21
- package/dist/products/signed-requests.js +0 -11
- package/dist/products/sso.d.ts +0 -44
- package/dist/products/sso.js +0 -8
- package/dist/products/streams.d.ts +0 -73
- package/dist/products/streams.js +0 -17
- package/dist/products/switching.d.ts +0 -123
- package/dist/products/switching.js +0 -26
- package/dist/products/tailscale.d.ts +0 -57
- package/dist/products/tailscale.js +0 -17
- package/dist/products/uptime.d.ts +0 -97
- package/dist/products/uptime.js +0 -42
- package/dist/products/volumes.d.ts +0 -190
- package/dist/products/volumes.js +0 -114
- package/dist/products/watch.d.ts +0 -112
- package/dist/products/watch.js +0 -249
- package/dist/proxy.d.ts +0 -30
- package/dist/proxy.js +0 -200
- package/dist/record-cli.d.ts +0 -23
- package/dist/record-cli.js +0 -308
- package/dist/renamed-products.d.ts +0 -38
- package/dist/renamed-products.js +0 -34
- package/dist/resumable.d.ts +0 -32
- package/dist/resumable.js +0 -201
- package/dist/runloop/index.d.ts +0 -333
- package/dist/runloop/index.js +0 -560
- package/dist/runloop/pagination.d.ts +0 -46
- package/dist/runloop/pagination.js +0 -82
- package/dist/runloop/sdk.d.ts +0 -131
- package/dist/runloop/sdk.js +0 -167
- package/dist/runloop/snapshots.d.ts +0 -52
- package/dist/runloop/snapshots.js +0 -244
- package/dist/sandbox.d.ts +0 -371
- package/dist/sandbox.js +0 -1500
- package/dist/sandboxes/index.d.ts +0 -11
- package/dist/sandboxes/index.js +0 -12
- package/dist/sealing.d.ts +0 -6
- package/dist/sealing.js +0 -14
- package/dist/snapshots/index.d.ts +0 -9
- package/dist/snapshots/index.js +0 -11
- package/dist/snapshots.d.ts +0 -82
- package/dist/snapshots.js +0 -65
- package/dist/sprites/index.d.ts +0 -563
- package/dist/sprites/index.js +0 -1370
- package/dist/ssh.d.ts +0 -56
- package/dist/ssh.js +0 -416
- package/dist/switched-off.d.ts +0 -5
- package/dist/switched-off.js +0 -8
- package/dist/tar.d.ts +0 -15
- package/dist/tar.js +0 -526
- package/dist/terminal.d.ts +0 -24
- package/dist/terminal.js +0 -32
- package/dist/tools/index.d.ts +0 -62
- package/dist/tools/index.js +0 -181
- package/dist/transport.d.ts +0 -165
- package/dist/transport.js +0 -883
- package/dist/trigger/index.d.ts +0 -202
- package/dist/trigger/index.js +0 -244
- package/dist/tunnel.d.ts +0 -70
- package/dist/tunnel.js +0 -316
- package/dist/types.d.ts +0 -585
- package/dist/types.js +0 -1
- package/dist/vercel/client.d.ts +0 -40
- package/dist/vercel/client.js +0 -39
- package/dist/vercel/command.d.ts +0 -117
- package/dist/vercel/command.js +0 -391
- package/dist/vercel/errors.d.ts +0 -53
- package/dist/vercel/errors.js +0 -131
- package/dist/vercel/filesystem.d.ts +0 -153
- package/dist/vercel/filesystem.js +0 -297
- package/dist/vercel/index.d.ts +0 -24
- package/dist/vercel/index.js +0 -36
- package/dist/vercel/sandbox-user.d.ts +0 -70
- package/dist/vercel/sandbox-user.js +0 -207
- package/dist/vercel/sandbox.d.ts +0 -372
- package/dist/vercel/sandbox.js +0 -1037
- package/dist/vercel/snapshot.d.ts +0 -94
- package/dist/vercel/snapshot.js +0 -137
- package/dist/volumes/index.d.ts +0 -9
- package/dist/volumes/index.js +0 -10
- package/dist/wait.d.ts +0 -12
- package/dist/wait.js +0 -47
- package/dist/wallet.d.ts +0 -45
- package/dist/wallet.js +0 -56
- package/dist/wireguard.d.ts +0 -7
- package/dist/wireguard.js +0 -13
package/dist/blaxel/session.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Runtime } from "../client.js";
|
|
2
|
-
import type { RuntimeSandbox } from "./client.js";
|
|
3
|
-
import type { SessionCreateOptions, SessionWithToken } from "./types.js";
|
|
4
|
-
/** Blaxel's `sandbox.sessions`. */
|
|
5
|
-
export declare class SandboxSessions {
|
|
6
|
-
#private;
|
|
7
|
-
constructor(sandbox: {
|
|
8
|
-
id: string;
|
|
9
|
-
run: <T>(work: (runtime: RuntimeSandbox) => Promise<T>) => Promise<T>;
|
|
10
|
-
apiUrl: () => string;
|
|
11
|
-
});
|
|
12
|
-
/** A new session, for a day unless `expiresAt` says sooner. */
|
|
13
|
-
create(options?: SessionCreateOptions): Promise<SessionWithToken>;
|
|
14
|
-
/** Blaxel's: the session made last, if it lasts at least `delta` ms more
|
|
15
|
-
* (an hour unless given), else a new one, and the old one ends. A token is
|
|
16
|
-
* shown only when its session is made, so "the session made last" is the
|
|
17
|
-
* one this process made for this sandbox; a new process makes a new one. */
|
|
18
|
-
createIfExpired(options?: SessionCreateOptions, delta?: number): Promise<SessionWithToken>;
|
|
19
|
-
/** Active sessions, newest first. A token is shown only when its session is
|
|
20
|
-
* made, so these carry an empty `token`: keep the one `create` gave. */
|
|
21
|
-
list(): Promise<SessionWithToken[]>;
|
|
22
|
-
get(name: string): Promise<Omit<SessionWithToken, "name">>;
|
|
23
|
-
/** Blaxel's delete: the session ends at once. */
|
|
24
|
-
delete(name: string): Promise<SessionWithToken>;
|
|
25
|
-
}
|
|
26
|
-
/** The client and sandbox a session reaches, for `SandboxInstance.fromSession`.
|
|
27
|
-
* The sandbox is read once with the session, which may read it. */
|
|
28
|
-
export declare function sessionSandbox(session: SessionWithToken): Promise<{
|
|
29
|
-
client: Runtime;
|
|
30
|
-
runtime: RuntimeSandbox;
|
|
31
|
-
}>;
|
package/dist/blaxel/session.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { Runtime } from "../client.js";
|
|
2
|
-
import { guard, NotSupportedError, responseError } from "./errors.js";
|
|
3
|
-
/* Blaxel's sandbox sessions over Runtime's (ARCHITECTURE.md section 3.12).
|
|
4
|
-
*
|
|
5
|
-
* In Blaxel a session is a private preview of the sandbox's own API with a
|
|
6
|
-
* token: a frontend holding it drives the sandbox without the workspace key.
|
|
7
|
-
* On Runtime it is a sandbox session: a token that runs commands, reads and
|
|
8
|
-
* writes files and reaches previews of that one sandbox, and nothing else.
|
|
9
|
-
*
|
|
10
|
-
* What maps, and how:
|
|
11
|
-
* - `expiresAt`: Blaxel's default is a day from now, which is Runtime's most.
|
|
12
|
-
* Later than a day is refused rather than quietly shortened.
|
|
13
|
-
* - `responseHeaders["Access-Control-Allow-Origin"]`: the page that may use it,
|
|
14
|
-
* which is how Runtime limits a session to origins. One origin, or several
|
|
15
|
-
* separated by commas; `*` is refused, because a session names its pages.
|
|
16
|
-
* Runtime answers the other CORS headers itself, so Access-Control-Allow-*
|
|
17
|
-
* headers are accepted and need nothing; any other response header is not
|
|
18
|
-
* supported.
|
|
19
|
-
* - `requestHeaders`: headers Blaxel adds to each request into the sandbox.
|
|
20
|
-
* Runtime's session reaches the sandbox's commands and files, not a server
|
|
21
|
-
* in it, so there is nothing to add them to.
|
|
22
|
-
* - `url`: the sandbox's address in Runtime's API, which fromSession reads the
|
|
23
|
-
* sandbox from. `name`: `session-<id>`. */
|
|
24
|
-
const DAY_MS = 86_400_000;
|
|
25
|
-
const PREFIX = "session-";
|
|
26
|
-
const SANDBOX_URL = /^(https?:\/\/[^/]+)\/v1\/sandboxes\/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
27
|
-
function origins(headers = {}) {
|
|
28
|
-
const found = [];
|
|
29
|
-
for (const [name, value] of Object.entries(headers)) {
|
|
30
|
-
const lower = name.toLowerCase();
|
|
31
|
-
if (lower === "access-control-allow-origin") {
|
|
32
|
-
for (const origin of value
|
|
33
|
-
.split(",")
|
|
34
|
-
.map((one) => one.trim())
|
|
35
|
-
.filter(Boolean)) {
|
|
36
|
-
if (origin === "*")
|
|
37
|
-
throw new NotSupportedError('A session for every origin (Access-Control-Allow-Origin: "*")', 'Name the page that uses it: responseHeaders: { "Access-Control-Allow-Origin": "https://app.example.com" }.');
|
|
38
|
-
found.push(origin.replace(/\/$/, ""));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (!lower.startsWith("access-control-"))
|
|
42
|
-
throw new NotSupportedError(`Session response header ${name}`, "Runtime answers a session's CORS headers itself; set other headers in the server your page talks to.");
|
|
43
|
-
}
|
|
44
|
-
return found;
|
|
45
|
-
}
|
|
46
|
-
function seconds(expiresAt) {
|
|
47
|
-
// Blaxel's default is a day; counted from a moment ago it would be a second short.
|
|
48
|
-
if (!expiresAt)
|
|
49
|
-
return DAY_MS / 1000;
|
|
50
|
-
const left = Math.floor((expiresAt.getTime() - Date.now()) / 1000);
|
|
51
|
-
if (!Number.isFinite(left) || left < 60)
|
|
52
|
-
throw responseError(400, "A session must last at least a minute.");
|
|
53
|
-
if (left > DAY_MS / 1000 + 5)
|
|
54
|
-
throw new NotSupportedError("A session lasting more than a day", "Make one for a day at most, and createIfExpired() again before it ends.");
|
|
55
|
-
return Math.min(left, DAY_MS / 1000);
|
|
56
|
-
}
|
|
57
|
-
function withToken(session, apiUrl, token = "") {
|
|
58
|
-
return {
|
|
59
|
-
name: `${PREFIX}${session.id}`,
|
|
60
|
-
url: `${apiUrl}/v1/sandboxes/${session.sandboxId}`,
|
|
61
|
-
token: session.token ?? token,
|
|
62
|
-
expiresAt: new Date(session.expiresAt),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
/** The session createIfExpired made last, per sandbox, in this process. */
|
|
66
|
-
const made = new Map();
|
|
67
|
-
/** Blaxel's `sandbox.sessions`. */
|
|
68
|
-
export class SandboxSessions {
|
|
69
|
-
#run;
|
|
70
|
-
#apiUrl;
|
|
71
|
-
#id;
|
|
72
|
-
constructor(sandbox) {
|
|
73
|
-
this.#id = sandbox.id;
|
|
74
|
-
this.#run = sandbox.run;
|
|
75
|
-
this.#apiUrl = sandbox.apiUrl;
|
|
76
|
-
}
|
|
77
|
-
/** A new session, for a day unless `expiresAt` says sooner. */
|
|
78
|
-
async create(options = {}) {
|
|
79
|
-
if (options.requestHeaders && Object.keys(options.requestHeaders).length)
|
|
80
|
-
throw new NotSupportedError("Session request headers (requestHeaders)", "A Runtime session drives the sandbox's commands and files directly; pass what the headers carried as the command's env or a file.");
|
|
81
|
-
const made = await this.#run((runtime) => guard(() => runtime.sessions.create({
|
|
82
|
-
ttlSeconds: seconds(options.expiresAt),
|
|
83
|
-
origins: origins(options.responseHeaders),
|
|
84
|
-
})));
|
|
85
|
-
return withToken(made, made.apiUrl || this.#apiUrl());
|
|
86
|
-
}
|
|
87
|
-
/** Blaxel's: the session made last, if it lasts at least `delta` ms more
|
|
88
|
-
* (an hour unless given), else a new one, and the old one ends. A token is
|
|
89
|
-
* shown only when its session is made, so "the session made last" is the
|
|
90
|
-
* one this process made for this sandbox; a new process makes a new one. */
|
|
91
|
-
async createIfExpired(options = {}, delta = 60 * 60 * 1000) {
|
|
92
|
-
const kept = made.get(this.#id);
|
|
93
|
-
if (kept) {
|
|
94
|
-
const live = (await this.list()).some((session) => session.name === kept.name);
|
|
95
|
-
if (live && kept.expiresAt.getTime() >= Date.now() + delta)
|
|
96
|
-
return kept;
|
|
97
|
-
if (live)
|
|
98
|
-
await this.delete(kept.name).catch(() => undefined);
|
|
99
|
-
}
|
|
100
|
-
const fresh = await this.create(options);
|
|
101
|
-
made.set(this.#id, fresh);
|
|
102
|
-
return fresh;
|
|
103
|
-
}
|
|
104
|
-
/** Active sessions, newest first. A token is shown only when its session is
|
|
105
|
-
* made, so these carry an empty `token`: keep the one `create` gave. */
|
|
106
|
-
async list() {
|
|
107
|
-
const sessions = await this.#run((runtime) => guard(() => runtime.sessions.list()));
|
|
108
|
-
return sessions
|
|
109
|
-
.filter((session) => session.state === "active")
|
|
110
|
-
.map((session) => withToken(session, this.#apiUrl()));
|
|
111
|
-
}
|
|
112
|
-
async get(name) {
|
|
113
|
-
const id = name.startsWith(PREFIX) ? name.slice(PREFIX.length) : name;
|
|
114
|
-
const found = (await this.#run((runtime) => guard(() => runtime.sessions.list()))).find((session) => session.id === id);
|
|
115
|
-
if (!found)
|
|
116
|
-
throw responseError(404, `Session ${name} not found.`);
|
|
117
|
-
const { name: _name, ...rest } = withToken(found, this.#apiUrl());
|
|
118
|
-
return rest;
|
|
119
|
-
}
|
|
120
|
-
/** Blaxel's delete: the session ends at once. */
|
|
121
|
-
async delete(name) {
|
|
122
|
-
const id = name.startsWith(PREFIX) ? name.slice(PREFIX.length) : name;
|
|
123
|
-
const revoked = await this.#run((runtime) => guard(() => runtime.sessions.revoke(id)));
|
|
124
|
-
return withToken(revoked, this.#apiUrl());
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
/** The client and sandbox a session reaches, for `SandboxInstance.fromSession`.
|
|
128
|
-
* The sandbox is read once with the session, which may read it. */
|
|
129
|
-
export async function sessionSandbox(session) {
|
|
130
|
-
const found = SANDBOX_URL.exec(session.url ?? "");
|
|
131
|
-
if (!found || !session.token?.startsWith("rtsess_"))
|
|
132
|
-
throw new NotSupportedError("A session Runtime did not make", "Make the session with sandbox.sessions.create() on your backend, where a Runtime key is set, and pass what it returns.");
|
|
133
|
-
const client = new Runtime({ apiKey: session.token, baseUrl: found[1] });
|
|
134
|
-
const runtime = await guard(() => client.sandboxes.get(found[2]));
|
|
135
|
-
return { client, runtime };
|
|
136
|
-
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type { Runtime } from "../client.js";
|
|
2
|
-
import type { Snapshot as RuntimeSnapshot } from "../snapshots.js";
|
|
3
|
-
import { type RuntimeOptions, type RuntimeSandbox } from "./client.js";
|
|
4
|
-
import { type PaginatedList } from "./pagination.js";
|
|
5
|
-
export type SandboxSnapshotSource = {
|
|
6
|
-
readonly deleted?: boolean;
|
|
7
|
-
kind?: "sandbox";
|
|
8
|
-
name: string;
|
|
9
|
-
};
|
|
10
|
-
export type SandboxSnapshotSpec = {
|
|
11
|
-
image?: string;
|
|
12
|
-
memory?: number;
|
|
13
|
-
region?: string;
|
|
14
|
-
};
|
|
15
|
-
export type SandboxSnapshot = {
|
|
16
|
-
createdAt: string;
|
|
17
|
-
createdBy?: string;
|
|
18
|
-
readonly id: string;
|
|
19
|
-
name: string;
|
|
20
|
-
sandboxName?: string;
|
|
21
|
-
source?: SandboxSnapshotSource;
|
|
22
|
-
spec?: SandboxSnapshotSpec;
|
|
23
|
-
status: string;
|
|
24
|
-
workspace: string;
|
|
25
|
-
};
|
|
26
|
-
export type SandboxForkResponse = {
|
|
27
|
-
name?: string;
|
|
28
|
-
snapshotId?: string;
|
|
29
|
-
type?: "sandbox" | "application";
|
|
30
|
-
};
|
|
31
|
-
export type SandboxRestoreResponse = {
|
|
32
|
-
name: string;
|
|
33
|
-
snapshotId: string;
|
|
34
|
-
};
|
|
35
|
-
export type Env = {
|
|
36
|
-
name?: string;
|
|
37
|
-
secret?: boolean;
|
|
38
|
-
value?: string;
|
|
39
|
-
};
|
|
40
|
-
export type SnapshotCreateConfiguration = {
|
|
41
|
-
name?: string;
|
|
42
|
-
source: {
|
|
43
|
-
name: string;
|
|
44
|
-
kind?: "sandbox";
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export type SnapshotForkOptions = {
|
|
48
|
-
targetType?: "sandbox" | "application";
|
|
49
|
-
port?: number;
|
|
50
|
-
traffic?: number;
|
|
51
|
-
customDomain?: string;
|
|
52
|
-
prefix?: string;
|
|
53
|
-
envs?: Env[];
|
|
54
|
-
};
|
|
55
|
-
export type SnapshotListQuery = {
|
|
56
|
-
cursor?: string;
|
|
57
|
-
limit?: number;
|
|
58
|
-
sort?: string;
|
|
59
|
-
q?: string;
|
|
60
|
-
anchor?: "end";
|
|
61
|
-
};
|
|
62
|
-
/** Paused sandboxes are kept this long when no TTL says otherwise. */
|
|
63
|
-
export declare const KEEP_DAYS = 365;
|
|
64
|
-
export declare function snapshotModel(snapshot: RuntimeSnapshot, sandboxName?: string): SandboxSnapshot;
|
|
65
|
-
/** Envs as a record; a nameless one is refused. */
|
|
66
|
-
export declare function envRecord(envs: Env[] | undefined): Record<string, string>;
|
|
67
|
-
/** Appends envs to a sandbox's env file: they win over the ones it has. */
|
|
68
|
-
export declare function appendEnvs(runtime: RuntimeSandbox, envs: Record<string, string>): Promise<void>;
|
|
69
|
-
/** A new sandbox named `name`, started from a snapshot, behaving as a Blaxel
|
|
70
|
-
* sandbox. */
|
|
71
|
-
export declare function startFromSnapshot(client: Runtime, snapshotId: string, name: string, labels: Record<string, string>, envs: Record<string, string>): Promise<RuntimeSandbox>;
|
|
72
|
-
declare function refuseApplication(options?: {
|
|
73
|
-
targetType?: string;
|
|
74
|
-
port?: number;
|
|
75
|
-
traffic?: number;
|
|
76
|
-
customDomain?: string;
|
|
77
|
-
prefix?: string;
|
|
78
|
-
}): void;
|
|
79
|
-
/** A snapshot, as Blaxel's Snapshot class. */
|
|
80
|
-
export declare class Snapshot {
|
|
81
|
-
#private;
|
|
82
|
-
constructor(snapshot: SandboxSnapshot, client: Runtime);
|
|
83
|
-
get name(): string;
|
|
84
|
-
get id(): string;
|
|
85
|
-
get status(): string;
|
|
86
|
-
get workspace(): string;
|
|
87
|
-
get createdAt(): string;
|
|
88
|
-
get source(): SandboxSnapshotSource | undefined;
|
|
89
|
-
get spec(): SandboxSnapshotSpec | undefined;
|
|
90
|
-
/** Takes a snapshot of the sandbox named in `source`. */
|
|
91
|
-
static create(config: SnapshotCreateConfiguration, options?: RuntimeOptions): Promise<Snapshot>;
|
|
92
|
-
/** A snapshot by its id. */
|
|
93
|
-
static get(snapshotId: string, options?: RuntimeOptions): Promise<Snapshot>;
|
|
94
|
-
/** The account's snapshots, a page at a time; `for await` walks them all. */
|
|
95
|
-
static list(query?: SnapshotListQuery, options?: RuntimeOptions): Promise<PaginatedList<Snapshot>>;
|
|
96
|
-
static delete(snapshotId: string, options?: RuntimeOptions): Promise<void>;
|
|
97
|
-
delete(): Promise<void>;
|
|
98
|
-
/** A new sandbox named `targetName`, started from this snapshot. */
|
|
99
|
-
fork(targetName: string, options?: SnapshotForkOptions): Promise<SandboxForkResponse>;
|
|
100
|
-
}
|
|
101
|
-
/** What `sandbox.snapshots` needs from its sandbox. */
|
|
102
|
-
export interface SnapshotContext {
|
|
103
|
-
readonly sandboxName: string;
|
|
104
|
-
readonly sandboxId: string;
|
|
105
|
-
readonly client: Runtime;
|
|
106
|
-
run<T>(work: (runtime: RuntimeSandbox) => Promise<T>): Promise<T>;
|
|
107
|
-
labels(): Record<string, string>;
|
|
108
|
-
}
|
|
109
|
-
/** `sandbox.snapshots`: this sandbox's snapshots, by name. */
|
|
110
|
-
export declare class SandboxSnapshotsResource {
|
|
111
|
-
#private;
|
|
112
|
-
constructor(ctx: SnapshotContext);
|
|
113
|
-
get sandboxName(): string;
|
|
114
|
-
create(name?: string): Promise<Snapshot>;
|
|
115
|
-
list(): Promise<Snapshot[]>;
|
|
116
|
-
/** This sandbox's newest snapshot with that name, or with that id. */
|
|
117
|
-
get(snapshotName: string): Promise<Snapshot>;
|
|
118
|
-
/** The id of a snapshot named, or given by id, for a fork. */
|
|
119
|
-
idOf(nameOrId: string): Promise<string>;
|
|
120
|
-
delete(snapshotName: string): Promise<void>;
|
|
121
|
-
restore(_snapshotName: string): Promise<never>;
|
|
122
|
-
}
|
|
123
|
-
export { refuseApplication };
|
package/dist/blaxel/snapshot.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { clientFor, } from "./client.js";
|
|
2
|
-
import { envFileCommand, envFileLines } from "./context.js";
|
|
3
|
-
import { guard, isNotFound, NotSupportedError, responseError } from "./errors.js";
|
|
4
|
-
import { findSandbox, LEASE_SECONDS, STANDBY, userLabels, whenNameFree } from "./lookup.js";
|
|
5
|
-
import { paginate } from "./pagination.js";
|
|
6
|
-
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
|
-
/** A Blaxel snapshot is kept until deleted: Runtime's longest. */
|
|
8
|
-
const SNAPSHOT_DAYS = 365;
|
|
9
|
-
/** Paused sandboxes are kept this long when no TTL says otherwise. */
|
|
10
|
-
export const KEEP_DAYS = 365;
|
|
11
|
-
export function snapshotModel(snapshot, sandboxName) {
|
|
12
|
-
return {
|
|
13
|
-
id: snapshot.id,
|
|
14
|
-
name: snapshot.name ?? snapshot.id,
|
|
15
|
-
createdAt: snapshot.createdAt,
|
|
16
|
-
status: snapshot.state.toUpperCase(),
|
|
17
|
-
workspace: "",
|
|
18
|
-
...(sandboxName ? { sandboxName } : {}),
|
|
19
|
-
source: { kind: "sandbox", name: sandboxName ?? snapshot.sourceSandboxId },
|
|
20
|
-
spec: { memory: snapshot.shape?.memoryMiB, region: "us-was-1" },
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
/** Envs as a record; a nameless one is refused. */
|
|
24
|
-
export function envRecord(envs) {
|
|
25
|
-
return Object.fromEntries((envs ?? []).map((env) => {
|
|
26
|
-
if (!env.name)
|
|
27
|
-
throw responseError(400, "every env needs a name");
|
|
28
|
-
return [env.name, env.value ?? ""];
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
/** Appends envs to a sandbox's env file: they win over the ones it has. */
|
|
32
|
-
export async function appendEnvs(runtime, envs) {
|
|
33
|
-
if (!Object.keys(envs).length)
|
|
34
|
-
return;
|
|
35
|
-
const result = await guard(() => runtime.exec(envFileCommand(true), { stdin: envFileLines(envs) }));
|
|
36
|
-
if (result.exitCode !== 0)
|
|
37
|
-
throw responseError(500, `Setting the sandbox's envs failed: ${result.stderr.trim()}`);
|
|
38
|
-
}
|
|
39
|
-
/** A new sandbox named `name`, started from a snapshot, behaving as a Blaxel
|
|
40
|
-
* sandbox. */
|
|
41
|
-
export async function startFromSnapshot(client, snapshotId, name, labels, envs) {
|
|
42
|
-
const input = {
|
|
43
|
-
snapshot: snapshotId,
|
|
44
|
-
name,
|
|
45
|
-
labels,
|
|
46
|
-
...STANDBY,
|
|
47
|
-
timeoutSeconds: LEASE_SECONDS,
|
|
48
|
-
onLeaseEnd: "pause",
|
|
49
|
-
};
|
|
50
|
-
const runtime = await guard(() => whenNameFree(client, () => client.sandboxes.create(input)));
|
|
51
|
-
try {
|
|
52
|
-
await Promise.all([
|
|
53
|
-
appendEnvs(runtime, envs),
|
|
54
|
-
runtime.info.funding === "paid" ? guard(() => runtime.setRetention(KEEP_DAYS)) : undefined,
|
|
55
|
-
]);
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
await runtime.stop({ wait: false }).catch(() => undefined);
|
|
59
|
-
throw error;
|
|
60
|
-
}
|
|
61
|
-
return runtime;
|
|
62
|
-
}
|
|
63
|
-
function refuseApplication(options = {}) {
|
|
64
|
-
if (options.targetType === "application")
|
|
65
|
-
throw new NotSupportedError("Forking into an application", "Fork into a sandbox and share its port with sandbox.previews.create.");
|
|
66
|
-
// Blaxel's application-fork routing: a sandbox fork has no use for them.
|
|
67
|
-
for (const key of ["port", "traffic", "customDomain", "prefix"])
|
|
68
|
-
if (options[key] !== undefined)
|
|
69
|
-
throw new NotSupportedError(`A fork's ${key}`, "Fork without it, then share a port of the copy with sandbox.previews.create({ metadata: { name }, spec: { port } }).");
|
|
70
|
-
}
|
|
71
|
-
/** A snapshot, as Blaxel's Snapshot class. */
|
|
72
|
-
export class Snapshot {
|
|
73
|
-
#snapshot;
|
|
74
|
-
#client;
|
|
75
|
-
constructor(snapshot, client) {
|
|
76
|
-
this.#snapshot = snapshot;
|
|
77
|
-
this.#client = client;
|
|
78
|
-
}
|
|
79
|
-
get name() {
|
|
80
|
-
return this.#snapshot.name;
|
|
81
|
-
}
|
|
82
|
-
get id() {
|
|
83
|
-
return this.#snapshot.id;
|
|
84
|
-
}
|
|
85
|
-
get status() {
|
|
86
|
-
return this.#snapshot.status;
|
|
87
|
-
}
|
|
88
|
-
get workspace() {
|
|
89
|
-
return this.#snapshot.workspace;
|
|
90
|
-
}
|
|
91
|
-
get createdAt() {
|
|
92
|
-
return this.#snapshot.createdAt;
|
|
93
|
-
}
|
|
94
|
-
get source() {
|
|
95
|
-
return this.#snapshot.source;
|
|
96
|
-
}
|
|
97
|
-
get spec() {
|
|
98
|
-
return this.#snapshot.spec;
|
|
99
|
-
}
|
|
100
|
-
/** Takes a snapshot of the sandbox named in `source`. */
|
|
101
|
-
static async create(config, options = {}) {
|
|
102
|
-
if (config.source.kind !== undefined && config.source.kind !== "sandbox")
|
|
103
|
-
throw new NotSupportedError(`A snapshot of a ${String(config.source.kind)}`, "Snapshot a sandbox.");
|
|
104
|
-
const client = clientFor(options);
|
|
105
|
-
const runtime = await guard(() => findSandbox(client, config.source.name));
|
|
106
|
-
const taken = await guard(() => runtime.snapshot({
|
|
107
|
-
...(config.name ? { name: config.name } : {}),
|
|
108
|
-
labels: userLabels(runtime.info.labels),
|
|
109
|
-
retentionDays: SNAPSHOT_DAYS,
|
|
110
|
-
}));
|
|
111
|
-
return new Snapshot(snapshotModel(taken, config.source.name), client);
|
|
112
|
-
}
|
|
113
|
-
/** A snapshot by its id. */
|
|
114
|
-
static async get(snapshotId, options = {}) {
|
|
115
|
-
const client = clientFor(options);
|
|
116
|
-
return new Snapshot(snapshotModel(await guard(() => client.snapshots.get(snapshotId))), client);
|
|
117
|
-
}
|
|
118
|
-
/** The account's snapshots, a page at a time; `for await` walks them all. */
|
|
119
|
-
static async list(query = {}, options = {}) {
|
|
120
|
-
for (const field of ["cursor", "q", "anchor"])
|
|
121
|
-
if (query[field] !== undefined)
|
|
122
|
-
throw new NotSupportedError(`Listing snapshots by ${field}`, "List them (oldest first) and filter the result yourself; nextPage() walks the pages.");
|
|
123
|
-
if (query.sort !== undefined && query.sort !== "createdAt:asc")
|
|
124
|
-
throw new NotSupportedError(`Listing snapshots sorted by ${query.sort}`, "Runtime lists them oldest first: sort the result yourself.");
|
|
125
|
-
const client = clientFor(options);
|
|
126
|
-
const page = await guard(() => client.snapshots.list(query.limit ? { limit: Math.min(query.limit, 100) } : {}));
|
|
127
|
-
return paginate(page, (one) => new Snapshot(snapshotModel(one), client));
|
|
128
|
-
}
|
|
129
|
-
static async delete(snapshotId, options = {}) {
|
|
130
|
-
const client = clientFor(options);
|
|
131
|
-
await guard(() => client.snapshots.delete(snapshotId));
|
|
132
|
-
}
|
|
133
|
-
async delete() {
|
|
134
|
-
await guard(() => this.#client.snapshots.delete(this.id));
|
|
135
|
-
}
|
|
136
|
-
/** A new sandbox named `targetName`, started from this snapshot. */
|
|
137
|
-
async fork(targetName, options = {}) {
|
|
138
|
-
refuseApplication(options);
|
|
139
|
-
await startFromSnapshot(this.#client, this.id, targetName, {}, envRecord(options.envs));
|
|
140
|
-
return { name: targetName, snapshotId: this.id, type: "sandbox" };
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/** `sandbox.snapshots`: this sandbox's snapshots, by name. */
|
|
144
|
-
export class SandboxSnapshotsResource {
|
|
145
|
-
#ctx;
|
|
146
|
-
constructor(ctx) {
|
|
147
|
-
this.#ctx = ctx;
|
|
148
|
-
}
|
|
149
|
-
get sandboxName() {
|
|
150
|
-
return this.#ctx.sandboxName;
|
|
151
|
-
}
|
|
152
|
-
async create(name) {
|
|
153
|
-
const taken = await this.#ctx.run((runtime) => runtime.snapshot({
|
|
154
|
-
...(name ? { name } : {}),
|
|
155
|
-
labels: userLabels(this.#ctx.labels()),
|
|
156
|
-
retentionDays: SNAPSHOT_DAYS,
|
|
157
|
-
}));
|
|
158
|
-
return new Snapshot(snapshotModel(taken, this.sandboxName), this.#ctx.client);
|
|
159
|
-
}
|
|
160
|
-
async list() {
|
|
161
|
-
const page = await guard(() => this.#ctx.client.snapshots.list({ sandboxId: this.#ctx.sandboxId }));
|
|
162
|
-
const all = await guard(() => page.toArray());
|
|
163
|
-
return all.map((one) => new Snapshot(snapshotModel(one, this.sandboxName), this.#ctx.client));
|
|
164
|
-
}
|
|
165
|
-
/** This sandbox's newest snapshot with that name, or with that id. */
|
|
166
|
-
async get(snapshotName) {
|
|
167
|
-
return new Snapshot(snapshotModel(await this.#find(snapshotName), this.sandboxName), this.#ctx.client);
|
|
168
|
-
}
|
|
169
|
-
async #find(nameOrId) {
|
|
170
|
-
const client = this.#ctx.client;
|
|
171
|
-
const page = await guard(() => client.snapshots.list({ sandboxId: this.#ctx.sandboxId, name: nameOrId }));
|
|
172
|
-
const named = page.data.filter((one) => one.name === nameOrId).at(-1);
|
|
173
|
-
if (named)
|
|
174
|
-
return named;
|
|
175
|
-
if (UUID.test(nameOrId))
|
|
176
|
-
try {
|
|
177
|
-
const byId = await guard(() => client.snapshots.get(nameOrId));
|
|
178
|
-
if (byId.sourceSandboxId === this.#ctx.sandboxId)
|
|
179
|
-
return byId;
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
if (!isNotFound(error))
|
|
183
|
-
throw error;
|
|
184
|
-
}
|
|
185
|
-
throw responseError(404, `snapshot ${nameOrId} not found`);
|
|
186
|
-
}
|
|
187
|
-
/** The id of a snapshot named, or given by id, for a fork. */
|
|
188
|
-
async idOf(nameOrId) {
|
|
189
|
-
return (await this.#find(nameOrId)).id;
|
|
190
|
-
}
|
|
191
|
-
async delete(snapshotName) {
|
|
192
|
-
const found = await this.#find(snapshotName);
|
|
193
|
-
await guard(() => this.#ctx.client.snapshots.delete(found.id));
|
|
194
|
-
}
|
|
195
|
-
restore(_snapshotName) {
|
|
196
|
-
return Promise.reject(new NotSupportedError("Restoring a sandbox to its snapshot in place", "Start a new sandbox from it: sandbox.fork(newName, { snapshotId }) or snapshot.fork(newName). The new sandbox has its own name and preview addresses."));
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
export { refuseApplication };
|
package/dist/blaxel/types.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { WithRuntime } from "./client.js";
|
|
2
|
-
import type { Env } from "./snapshot.js";
|
|
3
|
-
export type Status = "DELETING" | "TERMINATED" | "FAILED" | "DEACTIVATED" | "DEACTIVATING" | "UPLOADING" | "BUILDING" | "DEPLOYING" | "DEPLOYED" | "BUILT" | "ARCHIVING" | "ARCHIVED" | "UNARCHIVING";
|
|
4
|
-
export type Port = {
|
|
5
|
-
name?: string;
|
|
6
|
-
protocol?: "HTTP" | "TCP" | "UDP" | "TLS";
|
|
7
|
-
target: number;
|
|
8
|
-
};
|
|
9
|
-
export type EnvVar = {
|
|
10
|
-
name: string;
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
export type ExpirationPolicy = {
|
|
14
|
-
action?: "delete";
|
|
15
|
-
type?: "ttl-idle" | "ttl-max-age" | "date";
|
|
16
|
-
value?: string;
|
|
17
|
-
};
|
|
18
|
-
export type SandboxLifecycle = {
|
|
19
|
-
expirationPolicies?: Array<ExpirationPolicy>;
|
|
20
|
-
terminatedRetention?: string;
|
|
21
|
-
};
|
|
22
|
-
export type SandboxNetwork = {
|
|
23
|
-
allowedDomains?: Array<string>;
|
|
24
|
-
egress?: unknown;
|
|
25
|
-
firewall?: unknown;
|
|
26
|
-
forbiddenDomains?: Array<string>;
|
|
27
|
-
proxy?: unknown;
|
|
28
|
-
subnet?: string;
|
|
29
|
-
};
|
|
30
|
-
export type VolumeBinding = {
|
|
31
|
-
name: string;
|
|
32
|
-
mountPath: string;
|
|
33
|
-
readOnly?: boolean;
|
|
34
|
-
type?: "persistent" | "ephemeral";
|
|
35
|
-
sizeMb?: number;
|
|
36
|
-
};
|
|
37
|
-
export type VolumeAttachment = {
|
|
38
|
-
mountPath?: string;
|
|
39
|
-
name?: string;
|
|
40
|
-
readOnly?: boolean;
|
|
41
|
-
sizeMb?: number;
|
|
42
|
-
type?: "persistent" | "ephemeral";
|
|
43
|
-
};
|
|
44
|
-
export type Metadata = {
|
|
45
|
-
name: string;
|
|
46
|
-
displayName?: string;
|
|
47
|
-
externalId?: string;
|
|
48
|
-
labels?: Record<string, string>;
|
|
49
|
-
createdAt?: string;
|
|
50
|
-
updatedAt?: string;
|
|
51
|
-
createdBy?: string;
|
|
52
|
-
updatedBy?: string;
|
|
53
|
-
readonly plan?: string;
|
|
54
|
-
readonly url?: string;
|
|
55
|
-
readonly workspace?: string;
|
|
56
|
-
};
|
|
57
|
-
export type SandboxRuntime = {
|
|
58
|
-
envs?: Array<Env>;
|
|
59
|
-
expires?: string;
|
|
60
|
-
extraArgs?: {
|
|
61
|
-
[key: string]: string;
|
|
62
|
-
};
|
|
63
|
-
image?: string;
|
|
64
|
-
memory?: number;
|
|
65
|
-
ports?: Array<Port>;
|
|
66
|
-
terminationGracePeriodSeconds?: number;
|
|
67
|
-
ttl?: string;
|
|
68
|
-
};
|
|
69
|
-
export type SandboxSpec = {
|
|
70
|
-
enabled?: boolean;
|
|
71
|
-
lifecycle?: SandboxLifecycle;
|
|
72
|
-
network?: SandboxNetwork;
|
|
73
|
-
region?: string;
|
|
74
|
-
runtime?: SandboxRuntime;
|
|
75
|
-
volumes?: Array<VolumeAttachment>;
|
|
76
|
-
vpc?: string;
|
|
77
|
-
};
|
|
78
|
-
export type CoreEvent = {
|
|
79
|
-
canaryRevision?: string;
|
|
80
|
-
message?: string;
|
|
81
|
-
revision?: string;
|
|
82
|
-
status?: string;
|
|
83
|
-
time?: string;
|
|
84
|
-
type?: string;
|
|
85
|
-
};
|
|
86
|
-
export type Sandbox = {
|
|
87
|
-
events?: Array<CoreEvent>;
|
|
88
|
-
readonly expiresIn?: number;
|
|
89
|
-
readonly lastUsedAt?: string;
|
|
90
|
-
metadata: Metadata;
|
|
91
|
-
spec: SandboxSpec;
|
|
92
|
-
state?: "RUNNING" | "STANDBY";
|
|
93
|
-
status?: Status;
|
|
94
|
-
};
|
|
95
|
-
export type SandboxConfiguration = {
|
|
96
|
-
forceUrl?: string;
|
|
97
|
-
headers?: Record<string, string>;
|
|
98
|
-
params?: Record<string, string>;
|
|
99
|
-
} & Sandbox;
|
|
100
|
-
export type SandboxCreateConfiguration = {
|
|
101
|
-
name?: string;
|
|
102
|
-
/** A Blaxel stock image (Runtime's stock image) or a ready Runtime image's name. */
|
|
103
|
-
image?: string;
|
|
104
|
-
/** MB; vCPUs follow as memory / 2048, at least 1. */
|
|
105
|
-
memory?: number;
|
|
106
|
-
ports?: (Port | Record<string, unknown>)[];
|
|
107
|
-
envs?: EnvVar[];
|
|
108
|
-
volumes?: (VolumeBinding | VolumeAttachment)[];
|
|
109
|
-
ttl?: string;
|
|
110
|
-
expires?: Date;
|
|
111
|
-
region?: string;
|
|
112
|
-
lifecycle?: SandboxLifecycle;
|
|
113
|
-
network?: SandboxNetwork;
|
|
114
|
-
snapshotEnabled?: boolean;
|
|
115
|
-
labels?: Record<string, string>;
|
|
116
|
-
extraArgs?: Record<string, string>;
|
|
117
|
-
externalId?: string;
|
|
118
|
-
/** Runtime-only: an explicit client, or fields for the create. */
|
|
119
|
-
withruntime?: WithRuntime;
|
|
120
|
-
};
|
|
121
|
-
export type SandboxUpdateMetadata = {
|
|
122
|
-
labels?: Record<string, string>;
|
|
123
|
-
displayName?: string;
|
|
124
|
-
externalId?: string;
|
|
125
|
-
};
|
|
126
|
-
export type SandboxUpdateNetwork = {
|
|
127
|
-
network?: SandboxNetwork;
|
|
128
|
-
};
|
|
129
|
-
export interface SessionCreateOptions {
|
|
130
|
-
expiresAt?: Date;
|
|
131
|
-
responseHeaders?: Record<string, string>;
|
|
132
|
-
requestHeaders?: Record<string, string>;
|
|
133
|
-
}
|
|
134
|
-
export interface SessionWithToken {
|
|
135
|
-
name: string;
|
|
136
|
-
url: string;
|
|
137
|
-
token: string;
|
|
138
|
-
expiresAt: Date;
|
|
139
|
-
}
|
|
140
|
-
/** Ports as Port objects, HTTP by default. */
|
|
141
|
-
export declare function normalizePorts(ports?: (Port | Record<string, unknown>)[]): Port[] | undefined;
|
|
142
|
-
/** Envs checked for a string name and value. */
|
|
143
|
-
export declare function normalizeEnvs(envs?: EnvVar[]): EnvVar[] | undefined;
|
|
144
|
-
/** Volume bindings as attachments. */
|
|
145
|
-
export declare function normalizeVolumes(volumes?: (VolumeBinding | VolumeAttachment)[]): VolumeAttachment[] | undefined;
|