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/compat/core.d.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Runtime, type CreateOptions, type RuntimeOptions } from "../client.js";
|
|
2
|
-
import type { Sandbox } from "../sandbox.js";
|
|
3
|
-
import type { CreateSandbox, ExecOptions } from "../types.js";
|
|
4
|
-
import type { RequestOptions } from "../transport.js";
|
|
5
|
-
export type ClientOptions = RuntimeOptions & {
|
|
6
|
-
client?: Runtime;
|
|
7
|
-
};
|
|
8
|
-
export declare const client: ({ client: supplied, ...options }?: ClientOptions) => Runtime;
|
|
9
|
-
/** Reject before allocation: accepting an option that does nothing is not compatibility. */
|
|
10
|
-
export declare class CompatibilityError extends Error {
|
|
11
|
-
readonly provider: string;
|
|
12
|
-
readonly feature: string;
|
|
13
|
-
readonly code = "unsupported_compatibility_option";
|
|
14
|
-
constructor(provider: string, feature: string);
|
|
15
|
-
}
|
|
16
|
-
/** The error for a vendor feature an adapter does not provide, naming
|
|
17
|
-
* Runtime's alternative. */
|
|
18
|
-
export declare function refusal(provider: string, feature: string, alternative: string): CompatibilityError;
|
|
19
|
-
/** A vendor method an adapter does not provide: declare it on the class as
|
|
20
|
-
* `declare readonly name: Refused` (or `RefusedAsync` where the vendor's
|
|
21
|
-
* method returns a promise), and `refuse` installs it. A call fails with a
|
|
22
|
-
* CompatibilityError naming Runtime's alternative, never "is not a function". */
|
|
23
|
-
export type Refused = (...args: unknown[]) => never;
|
|
24
|
-
export type RefusedAsync = (...args: unknown[]) => Promise<never>;
|
|
25
|
-
export declare function refuse(provider: string, owner: string, target: {
|
|
26
|
-
prototype: object;
|
|
27
|
-
}, members: Record<string, string>, { sync }?: {
|
|
28
|
-
sync?: boolean;
|
|
29
|
-
}): void;
|
|
30
|
-
/** A vendor export (a function, or a class nobody can obtain here) that an
|
|
31
|
-
* adapter does not provide: `export const Name: Refused = refused(...)`.
|
|
32
|
-
* Calling it, or `new` on it, throws. */
|
|
33
|
-
export declare function refused(provider: string, name: string, alternative: string): Refused;
|
|
34
|
-
export declare function only(provider: string, value: object, keys: readonly string[]): void;
|
|
35
|
-
export declare function region(provider: string, value?: string | null): string | undefined;
|
|
36
|
-
export declare const quote: (value: string) => string;
|
|
37
|
-
export declare const pathAt: (path: string, cwd?: string) => string;
|
|
38
|
-
export declare function environment(sandbox: Sandbox, options?: RequestOptions): Promise<Record<string, string>>;
|
|
39
|
-
export declare function saveEnvironment(sandbox: Sandbox, env: Record<string, string>, options?: RequestOptions): Promise<void>;
|
|
40
|
-
export declare function validateEnvironment(env: Record<string, string>): void;
|
|
41
|
-
export declare function execOptions(sandbox: Sandbox, options?: ExecOptions, request?: RequestOptions): Promise<ExecOptions>;
|
|
42
|
-
export declare function create(runtime: Runtime, provider: string, input: CreateSandbox, env?: Record<string, string> | undefined, setup?: (sandbox: Sandbox) => Promise<void>, options?: CreateOptions): Promise<Sandbox>;
|
|
43
|
-
export declare function destroy(sandbox: Sandbox, options?: RequestOptions): Promise<void>;
|
|
44
|
-
export declare function ready(sandbox: Sandbox): Promise<Sandbox>;
|
|
45
|
-
export declare function lookup(runtime: Runtime, id: string, options?: RequestOptions): Promise<Sandbox>;
|
|
46
|
-
export declare function all(runtime: Runtime, provider: string): Promise<Sandbox[]>;
|
|
47
|
-
export declare function image(runtime: Runtime, ref: string): Promise<string>;
|
|
48
|
-
export declare function checked(sandbox: Sandbox, argv: string[], options?: ExecOptions): Promise<void>;
|
|
49
|
-
export declare function missing(path: string): never;
|
|
50
|
-
/** Foreground commands share a resident Bash process. Background commands start
|
|
51
|
-
* from the last completed exported environment/cwd snapshot without blocking it. */
|
|
52
|
-
export declare function shellCommand(sandbox: Sandbox, command: string, name?: string | null, overrides?: {
|
|
53
|
-
env?: Record<string, string>;
|
|
54
|
-
cwd?: string;
|
|
55
|
-
persist?: boolean;
|
|
56
|
-
}, request?: RequestOptions): Promise<string | string[]>;
|
|
57
|
-
export declare function closeShell(sandbox: Sandbox, name: string): Promise<void>;
|
|
58
|
-
export declare function shellRoot(name: string): Promise<string>;
|
package/dist/compat/core.js
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { Runtime } from "../client.js";
|
|
2
|
-
import { RuntimeError, NotFoundError } from "../errors.js";
|
|
3
|
-
import { SHELL_BROKER } from "./shell.js";
|
|
4
|
-
export const client = ({ client: supplied, ...options } = {}) => {
|
|
5
|
-
if (supplied)
|
|
6
|
-
return supplied;
|
|
7
|
-
if (options.baseUrl && !options.fetch) {
|
|
8
|
-
const host = new URL(options.baseUrl).hostname;
|
|
9
|
-
if (host !== "withruntime.com" &&
|
|
10
|
-
!host.endsWith(".withruntime.com") &&
|
|
11
|
-
!["localhost", "127.0.0.1", "[::1]"].includes(host))
|
|
12
|
-
throw new CompatibilityError("Runtime", "a competitor API endpoint; configure the Runtime endpoint or inject a native Runtime client");
|
|
13
|
-
}
|
|
14
|
-
// Vendor credentials must never leave the caller's machine for Runtime.
|
|
15
|
-
const apiKey = options.apiKey?.startsWith("rtcloud_") ? options.apiKey : undefined;
|
|
16
|
-
return new Runtime({ ...options, apiKey });
|
|
17
|
-
};
|
|
18
|
-
/** Reject before allocation: accepting an option that does nothing is not compatibility. */
|
|
19
|
-
export class CompatibilityError extends Error {
|
|
20
|
-
provider;
|
|
21
|
-
feature;
|
|
22
|
-
code = "unsupported_compatibility_option";
|
|
23
|
-
constructor(provider, feature) {
|
|
24
|
-
super(`${provider}: ${feature} is not supported by this Runtime compatibility adapter.`);
|
|
25
|
-
this.provider = provider;
|
|
26
|
-
this.feature = feature;
|
|
27
|
-
this.name = "CompatibilityError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
/** The error for a vendor feature an adapter does not provide, naming
|
|
31
|
-
* Runtime's alternative. */
|
|
32
|
-
export function refusal(provider, feature, alternative) {
|
|
33
|
-
const error = new CompatibilityError(provider, feature);
|
|
34
|
-
error.message = `${error.message.slice(0, -1)}; ${alternative}.`;
|
|
35
|
-
return error;
|
|
36
|
-
}
|
|
37
|
-
export function refuse(provider, owner, target, members, { sync = false } = {}) {
|
|
38
|
-
for (const [member, alternative] of Object.entries(members)) {
|
|
39
|
-
const error = () => refusal(provider, `${owner}.${member}`, alternative);
|
|
40
|
-
Object.defineProperty(target.prototype, member, {
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: sync
|
|
44
|
-
? () => {
|
|
45
|
-
throw error();
|
|
46
|
-
}
|
|
47
|
-
: () => Promise.reject(error()),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
/** A vendor export (a function, or a class nobody can obtain here) that an
|
|
52
|
-
* adapter does not provide: `export const Name: Refused = refused(...)`.
|
|
53
|
-
* Calling it, or `new` on it, throws. */
|
|
54
|
-
export function refused(provider, name, alternative) {
|
|
55
|
-
return function refusedExport() {
|
|
56
|
-
throw refusal(provider, name, alternative);
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
export function only(provider, value, keys) {
|
|
60
|
-
for (const [key, item] of Object.entries(value))
|
|
61
|
-
if (item !== undefined && item !== null && !keys.includes(key))
|
|
62
|
-
throw new CompatibilityError(provider, key);
|
|
63
|
-
}
|
|
64
|
-
export function region(provider, value) {
|
|
65
|
-
if (value && value !== "us-east")
|
|
66
|
-
throw new CompatibilityError(provider, `region ${value}; select Runtime's us-east region`);
|
|
67
|
-
return value ?? undefined;
|
|
68
|
-
}
|
|
69
|
-
export const quote = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
70
|
-
export const pathAt = (path, cwd = "/workspace") => path.startsWith("/") ? path : `${cwd.replace(/\/$/, "")}/${path}`;
|
|
71
|
-
const ENV_PATH = "/workspace/.runtime-compat/environment.json";
|
|
72
|
-
export async function environment(sandbox, options = {}) {
|
|
73
|
-
options.signal?.throwIfAborted();
|
|
74
|
-
try {
|
|
75
|
-
const text = await sandbox.files.readText(ENV_PATH, options);
|
|
76
|
-
options.signal?.throwIfAborted();
|
|
77
|
-
return JSON.parse(text);
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
if (error instanceof NotFoundError)
|
|
81
|
-
return {};
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export async function saveEnvironment(sandbox, env, options = {}) {
|
|
86
|
-
options.signal?.throwIfAborted();
|
|
87
|
-
validateEnvironment(env);
|
|
88
|
-
await sandbox.files.write(ENV_PATH, JSON.stringify(env), {
|
|
89
|
-
mode: 0o600,
|
|
90
|
-
signal: options.signal,
|
|
91
|
-
timeoutMs: options.timeoutMs,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
export function validateEnvironment(env) {
|
|
95
|
-
for (const key of Object.keys(env))
|
|
96
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
|
|
97
|
-
throw new TypeError(`Invalid environment variable: ${key}`);
|
|
98
|
-
for (const value of Object.values(env))
|
|
99
|
-
if (typeof value !== "string" || value.includes("\0"))
|
|
100
|
-
throw new TypeError("Environment values must be strings without NUL bytes");
|
|
101
|
-
}
|
|
102
|
-
export async function execOptions(sandbox, options = {}, request = {}) {
|
|
103
|
-
const requestOptions = { ...request, signal: request.signal ?? options.signal };
|
|
104
|
-
return { ...options, env: { ...(await environment(sandbox, requestOptions)), ...options.env } };
|
|
105
|
-
}
|
|
106
|
-
export async function create(runtime, provider, input, env = undefined, setup, options = {}) {
|
|
107
|
-
options.signal?.throwIfAborted();
|
|
108
|
-
if (env !== undefined)
|
|
109
|
-
validateEnvironment(env);
|
|
110
|
-
const sandbox = await runtime.sandboxes.create({
|
|
111
|
-
...input,
|
|
112
|
-
labels: { ...input.labels, "compat.provider": provider },
|
|
113
|
-
}, options);
|
|
114
|
-
try {
|
|
115
|
-
options.signal?.throwIfAborted();
|
|
116
|
-
if (env !== undefined || !input.snapshot)
|
|
117
|
-
await saveEnvironment(sandbox, env ?? {}, options);
|
|
118
|
-
options.signal?.throwIfAborted();
|
|
119
|
-
await setup?.(sandbox);
|
|
120
|
-
options.signal?.throwIfAborted();
|
|
121
|
-
return sandbox;
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
// Cancellation cannot authorize deleting a remote resource: the response
|
|
125
|
-
// may be a retry/reuse of a sandbox that already has somebody's work.
|
|
126
|
-
// Legacy failed-initialization rollback is limited to an ordinary create
|
|
127
|
-
// with a new SDK-generated mutation key and no replay/reuse marker.
|
|
128
|
-
if (options.signal?.aborted ||
|
|
129
|
-
(error instanceof RuntimeError && error.code === "timeout") ||
|
|
130
|
-
input.getOrCreate === true ||
|
|
131
|
-
options.idempotencyKey !== undefined ||
|
|
132
|
-
sandbox.info.replayed === true ||
|
|
133
|
-
sandbox.info.reused === true)
|
|
134
|
-
throw error;
|
|
135
|
-
try {
|
|
136
|
-
await destroy(sandbox);
|
|
137
|
-
}
|
|
138
|
-
catch (cleanup) {
|
|
139
|
-
throw new AggregateError([error, cleanup], `Initialization failed and sandbox ${sandbox.id} could not be cleaned up.`);
|
|
140
|
-
}
|
|
141
|
-
throw error;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export async function destroy(sandbox, options = {}) {
|
|
145
|
-
// Stop before releasing persistence: a paused sandbox cannot change its disk
|
|
146
|
-
// meter, and must never be woken solely to delete it. The stopped update queues
|
|
147
|
-
// disk destruction; see ARCHITECTURE.md section 10 and migration 0181.
|
|
148
|
-
options.signal?.throwIfAborted();
|
|
149
|
-
if (options.idempotencyKey !== undefined)
|
|
150
|
-
throw new CompatibilityError("Runtime", "caller idempotency keys for compound sandbox deletion");
|
|
151
|
-
await sandbox.stop(options);
|
|
152
|
-
if (sandbox.info.persistent)
|
|
153
|
-
await sandbox.update({ persistent: false }, options);
|
|
154
|
-
}
|
|
155
|
-
export async function ready(sandbox) {
|
|
156
|
-
if (sandbox.state === "paused")
|
|
157
|
-
await sandbox.wake();
|
|
158
|
-
else if (sandbox.state === "stopped")
|
|
159
|
-
await sandbox.restart();
|
|
160
|
-
else if (sandbox.state !== "running")
|
|
161
|
-
await sandbox.waitFor("running");
|
|
162
|
-
return sandbox;
|
|
163
|
-
}
|
|
164
|
-
export async function lookup(runtime, id, options = {}) {
|
|
165
|
-
options.signal?.throwIfAborted();
|
|
166
|
-
if (/^[a-f0-9-]{36}$/i.test(id))
|
|
167
|
-
return runtime.sandboxes.get(id, options);
|
|
168
|
-
const page = await runtime.sandboxes.list({ name: id, includeStopped: true }, options);
|
|
169
|
-
for await (const sandbox of page) {
|
|
170
|
-
options.signal?.throwIfAborted();
|
|
171
|
-
if (sandbox.info.name === id)
|
|
172
|
-
return sandbox;
|
|
173
|
-
}
|
|
174
|
-
// IDs are not necessarily UUIDs in local or self-hosted servers.
|
|
175
|
-
return runtime.sandboxes.get(id, options);
|
|
176
|
-
}
|
|
177
|
-
export async function all(runtime, provider) {
|
|
178
|
-
const result = [];
|
|
179
|
-
for await (const sandbox of await runtime.sandboxes.list({
|
|
180
|
-
labels: { "compat.provider": provider },
|
|
181
|
-
includeStopped: true,
|
|
182
|
-
}))
|
|
183
|
-
result.push(sandbox);
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
export async function image(runtime, ref) {
|
|
187
|
-
if (ref.startsWith("runtime:"))
|
|
188
|
-
return (await runtime.images.resolve(ref.slice(8))).id;
|
|
189
|
-
return (await runtime.images.build({ image: ref })).id;
|
|
190
|
-
}
|
|
191
|
-
export async function checked(sandbox, argv, options = {}) {
|
|
192
|
-
await sandbox.exec(argv, { ...options, check: true });
|
|
193
|
-
}
|
|
194
|
-
export function missing(path) {
|
|
195
|
-
throw new RuntimeError({
|
|
196
|
-
message: `${path} does not exist`,
|
|
197
|
-
code: "file_not_found",
|
|
198
|
-
status: 404,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
/** Foreground commands share a resident Bash process. Background commands start
|
|
202
|
-
* from the last completed exported environment/cwd snapshot without blocking it. */
|
|
203
|
-
export async function shellCommand(sandbox, command, name, overrides = {}, request = {}) {
|
|
204
|
-
request.signal?.throwIfAborted();
|
|
205
|
-
if (!name)
|
|
206
|
-
return command;
|
|
207
|
-
const root = await shellRoot(name);
|
|
208
|
-
await sandbox.files.mkdir(root, {
|
|
209
|
-
parents: true,
|
|
210
|
-
signal: request.signal,
|
|
211
|
-
timeoutMs: request.timeoutMs,
|
|
212
|
-
});
|
|
213
|
-
if (overrides.persist !== false) {
|
|
214
|
-
const script = "/workspace/.runtime-compat/shell.py";
|
|
215
|
-
await sandbox.files.write(script, SHELL_BROKER, {
|
|
216
|
-
mode: 0o600,
|
|
217
|
-
signal: request.signal,
|
|
218
|
-
timeoutMs: request.timeoutMs,
|
|
219
|
-
});
|
|
220
|
-
return [
|
|
221
|
-
"python3",
|
|
222
|
-
script,
|
|
223
|
-
"client",
|
|
224
|
-
root,
|
|
225
|
-
JSON.stringify({
|
|
226
|
-
command,
|
|
227
|
-
env: overrides.env ?? {},
|
|
228
|
-
cwd: overrides.cwd,
|
|
229
|
-
baseEnv: await environment(sandbox, request),
|
|
230
|
-
}),
|
|
231
|
-
];
|
|
232
|
-
}
|
|
233
|
-
return [
|
|
234
|
-
...(overrides.persist === false ? [] : ["flock", `${root}/lock`]),
|
|
235
|
-
"bash",
|
|
236
|
-
"-c",
|
|
237
|
-
'readonly __runtime_state="$1" __runtime_command="$2" __runtime_cwd="$3" __runtime_persist="$4"; shift 4; __runtime_env=(); for __runtime_key in "$@"; do __runtime_env+=("$__runtime_key=${!__runtime_key}"); done; if [ -f "$__runtime_state" ]; then source "$__runtime_state"; fi; for __runtime_entry in "${__runtime_env[@]}"; do export "$__runtime_entry"; done; if [ -n "$__runtime_cwd" ]; then cd -- "$__runtime_cwd" || exit; fi; if [ "$__runtime_persist" = yes ]; then trap \'__runtime_status=$?; (umask 077; export -p | sed "/^declare -x __runtime_/d" > "$__runtime_state.next"; printf "cd -- %q\\n" "$PWD" >> "$__runtime_state.next"; mv -- "$__runtime_state.next" "$__runtime_state"); exit "$__runtime_status"\' EXIT; fi; eval "$__runtime_command"',
|
|
238
|
-
"bash",
|
|
239
|
-
`${root}/state`,
|
|
240
|
-
command,
|
|
241
|
-
overrides.cwd ?? "",
|
|
242
|
-
overrides.persist === false ? "no" : "yes",
|
|
243
|
-
...Object.keys(overrides.env ?? {}),
|
|
244
|
-
];
|
|
245
|
-
}
|
|
246
|
-
export async function closeShell(sandbox, name) {
|
|
247
|
-
const root = await shellRoot(name);
|
|
248
|
-
const script = "/workspace/.runtime-compat/shell.py";
|
|
249
|
-
if (await sandbox.files.exists(script)) {
|
|
250
|
-
const result = await sandbox.exec([
|
|
251
|
-
"python3",
|
|
252
|
-
script,
|
|
253
|
-
"client",
|
|
254
|
-
root,
|
|
255
|
-
JSON.stringify({ action: "destroy" }),
|
|
256
|
-
]);
|
|
257
|
-
if (result.exitCode !== 0)
|
|
258
|
-
throw new Error(`Could not close named shell: ${result.stderr}`);
|
|
259
|
-
}
|
|
260
|
-
if (await sandbox.files.exists(root))
|
|
261
|
-
await sandbox.files.remove(root, { recursive: true });
|
|
262
|
-
}
|
|
263
|
-
export async function shellRoot(name) {
|
|
264
|
-
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(name));
|
|
265
|
-
const key = Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
|
|
266
|
-
return `/workspace/.runtime-compat/shells/${key}`;
|
|
267
|
-
}
|
package/dist/compat/files.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Sandbox } from "../sandbox.js";
|
|
2
|
-
/** Guest operations use argv, never interpolated shell paths. */
|
|
3
|
-
export declare class GuestFiles {
|
|
4
|
-
#private;
|
|
5
|
-
private readonly get;
|
|
6
|
-
readonly cwd: string;
|
|
7
|
-
constructor(get: () => Promise<Sandbox>, cwd?: string);
|
|
8
|
-
path(path: string): string;
|
|
9
|
-
readFile(path: string): Promise<Uint8Array>;
|
|
10
|
-
readTextFile(path: string): Promise<string>;
|
|
11
|
-
writeFile(path: string, content: string | Uint8Array, options?: {
|
|
12
|
-
mode?: number;
|
|
13
|
-
signal?: AbortSignal;
|
|
14
|
-
}): Promise<void>;
|
|
15
|
-
writeTextFile(path: string, content: string): Promise<void>;
|
|
16
|
-
mkdir(path: string, recursive?: boolean): Promise<void>;
|
|
17
|
-
remove(path: string, recursive?: boolean): Promise<void>;
|
|
18
|
-
rename(from: string, to: string, overwrite?: boolean): Promise<void>;
|
|
19
|
-
copy(from: string, to: string, recursive?: boolean, overwrite?: boolean): Promise<void>;
|
|
20
|
-
exists(path: string): Promise<boolean>;
|
|
21
|
-
stat(path: string): Promise<import("../types.js").FileEntry & {
|
|
22
|
-
exists: true;
|
|
23
|
-
}>;
|
|
24
|
-
readdir(path: string): Promise<import("../types.js").FileEntry[]>;
|
|
25
|
-
chmod(path: string, mode: number, recursive?: boolean): Promise<void>;
|
|
26
|
-
appendFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
27
|
-
}
|
package/dist/compat/files.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { checked, missing, pathAt } from "./core.js";
|
|
2
|
-
/** Guest operations use argv, never interpolated shell paths. */
|
|
3
|
-
export class GuestFiles {
|
|
4
|
-
get;
|
|
5
|
-
cwd;
|
|
6
|
-
/** Staging copies whose removal failed; the next staged write or
|
|
7
|
-
* append tries them again. */
|
|
8
|
-
#leftover = new Set();
|
|
9
|
-
constructor(get, cwd = "/workspace") {
|
|
10
|
-
this.get = get;
|
|
11
|
-
this.cwd = cwd;
|
|
12
|
-
}
|
|
13
|
-
path(path) {
|
|
14
|
-
return pathAt(path, this.cwd);
|
|
15
|
-
}
|
|
16
|
-
/** Removes a staging copy, and remembers it for the next staged call if the
|
|
17
|
-
* removal fails. It never throws: the write's outcome, including its
|
|
18
|
-
* original failure, stands, and a successful destination write must not
|
|
19
|
-
* invite a replay. */
|
|
20
|
-
async #discard(sandbox, staging) {
|
|
21
|
-
try {
|
|
22
|
-
await sandbox.files.remove(staging);
|
|
23
|
-
this.#leftover.delete(staging);
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
this.#leftover.add(staging);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/** Tries again every staging copy an earlier call could not remove. */
|
|
30
|
-
async #sweep(sandbox) {
|
|
31
|
-
for (const staging of [...this.#leftover])
|
|
32
|
-
await this.#discard(sandbox, staging);
|
|
33
|
-
}
|
|
34
|
-
async readFile(path) {
|
|
35
|
-
return (await this.get()).files.read(this.path(path));
|
|
36
|
-
}
|
|
37
|
-
async readTextFile(path) {
|
|
38
|
-
return (await this.get()).files.readText(this.path(path));
|
|
39
|
-
}
|
|
40
|
-
async writeFile(path, content, options = {}) {
|
|
41
|
-
const sandbox = await this.get();
|
|
42
|
-
const target = this.path(path);
|
|
43
|
-
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
44
|
-
if (bytes.length <= 1_048_576 || target.startsWith("/workspace/")) {
|
|
45
|
-
await sandbox.files.write(target, content, options);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
await this.#sweep(sandbox);
|
|
49
|
-
const staging = `/workspace/.runtime-compat/write-${crypto.randomUUID()}`;
|
|
50
|
-
try {
|
|
51
|
-
await sandbox.files.write(staging, bytes, { mode: 0o600, signal: options.signal });
|
|
52
|
-
await checked(sandbox, [
|
|
53
|
-
"bash",
|
|
54
|
-
"-c",
|
|
55
|
-
'set -e; mkdir -p -- "$(dirname -- "$2")"; temp="$2.runtime-$4"; trap \'rm -f -- "$temp"\' EXIT; cp -- "$1" "$temp"; chmod "$3" "$temp"; mv -f -- "$temp" "$2"',
|
|
56
|
-
"bash",
|
|
57
|
-
staging,
|
|
58
|
-
target,
|
|
59
|
-
(options.mode ?? 0o644).toString(8),
|
|
60
|
-
crypto.randomUUID(),
|
|
61
|
-
], { signal: options.signal });
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
await this.#discard(sandbox, staging);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
writeTextFile(path, content) {
|
|
68
|
-
return this.writeFile(path, content);
|
|
69
|
-
}
|
|
70
|
-
async mkdir(path, recursive = false) {
|
|
71
|
-
await (await this.get()).files.mkdir(this.path(path), { parents: recursive });
|
|
72
|
-
}
|
|
73
|
-
async remove(path, recursive = false) {
|
|
74
|
-
await (await this.get()).files.remove(this.path(path), { recursive });
|
|
75
|
-
}
|
|
76
|
-
async rename(from, to, overwrite = false) {
|
|
77
|
-
await (await this.get()).files.rename(this.path(from), this.path(to), { overwrite });
|
|
78
|
-
}
|
|
79
|
-
async copy(from, to, recursive = false, overwrite = false) {
|
|
80
|
-
const sandbox = await this.get();
|
|
81
|
-
if (!overwrite && (await sandbox.files.exists(this.path(to))))
|
|
82
|
-
throw new Error(`Destination exists: ${to}`);
|
|
83
|
-
if (!overwrite) {
|
|
84
|
-
// cp -n alone reports success when it skips a raced destination. Stage
|
|
85
|
-
// privately, then publish without replacement and verify it moved.
|
|
86
|
-
// mv -n that skips succeeds before coreutils 9.2 and fails from it on
|
|
87
|
-
// (the guest's 9.4 says "not replacing"), so a skip is told by the
|
|
88
|
-
// staged copy still being there beside a destination; with none there,
|
|
89
|
-
// mv's own error stands.
|
|
90
|
-
await checked(sandbox, [
|
|
91
|
-
"bash",
|
|
92
|
-
"-c",
|
|
93
|
-
'set -e; parent=$(dirname -- "$2"); stage="$parent/.runtime-copy-$4"; mkdir -m 700 -- "$stage"; trap \'rm -rf -- "$stage"\' EXIT; if [ "$3" = true ]; then cp -R -- "$1" "$stage/item"; else cp -- "$1" "$stage/item"; fi; mv -n -T -- "$stage/item" "$2" 2>"$stage/mv.err" || :; if [ -e "$stage/item" ] || [ -L "$stage/item" ]; then if [ -e "$2" ] || [ -L "$2" ]; then printf "Destination exists: %s\\n" "$2" >&2; exit 73; fi; cat -- "$stage/mv.err" >&2; exit 1; fi',
|
|
94
|
-
"bash",
|
|
95
|
-
this.path(from),
|
|
96
|
-
this.path(to),
|
|
97
|
-
String(recursive),
|
|
98
|
-
crypto.randomUUID(),
|
|
99
|
-
]);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
await checked(sandbox, [
|
|
103
|
-
"cp",
|
|
104
|
-
...(recursive ? ["-R"] : []),
|
|
105
|
-
"--",
|
|
106
|
-
this.path(from),
|
|
107
|
-
this.path(to),
|
|
108
|
-
]);
|
|
109
|
-
}
|
|
110
|
-
async exists(path) {
|
|
111
|
-
return (await this.get()).files.exists(this.path(path));
|
|
112
|
-
}
|
|
113
|
-
async stat(path) {
|
|
114
|
-
const entry = await (await this.get()).files.stat(this.path(path));
|
|
115
|
-
if (!entry.exists)
|
|
116
|
-
missing(path);
|
|
117
|
-
return entry;
|
|
118
|
-
}
|
|
119
|
-
async readdir(path) {
|
|
120
|
-
return (await this.get()).files.list(this.path(path), { hidden: true });
|
|
121
|
-
}
|
|
122
|
-
async chmod(path, mode, recursive = false) {
|
|
123
|
-
await checked(await this.get(), [
|
|
124
|
-
"chmod",
|
|
125
|
-
...(recursive ? ["-R"] : []),
|
|
126
|
-
(mode & 0o7777).toString(8),
|
|
127
|
-
"--",
|
|
128
|
-
this.path(path),
|
|
129
|
-
]);
|
|
130
|
-
}
|
|
131
|
-
async appendFile(path, content) {
|
|
132
|
-
const sandbox = await this.get();
|
|
133
|
-
const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
|
|
134
|
-
if (bytes.byteLength <= 1_048_576) {
|
|
135
|
-
await checked(sandbox, ["bash", "-c", 'cat >> "$1"', "bash", this.path(path)], {
|
|
136
|
-
stdin: bytes,
|
|
137
|
-
});
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
await this.#sweep(sandbox);
|
|
141
|
-
const staging = `/workspace/.runtime-compat/append-${crypto.randomUUID()}`;
|
|
142
|
-
try {
|
|
143
|
-
await sandbox.files.write(staging, bytes, { mode: 0o600 });
|
|
144
|
-
await checked(sandbox, [
|
|
145
|
-
"bash",
|
|
146
|
-
"-c",
|
|
147
|
-
'cat -- "$1" >> "$2"',
|
|
148
|
-
"bash",
|
|
149
|
-
staging,
|
|
150
|
-
this.path(path),
|
|
151
|
-
]);
|
|
152
|
-
}
|
|
153
|
-
finally {
|
|
154
|
-
await this.#discard(sandbox, staging);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
package/dist/compat/lease.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** The most one lease runs ahead of now. */
|
|
2
|
-
export declare const LEASE_MAX_SECONDS = 3600;
|
|
3
|
-
/** What the keeper needs of a Runtime sandbox. */
|
|
4
|
-
export interface Leased {
|
|
5
|
-
readonly state: string;
|
|
6
|
-
readonly info: {
|
|
7
|
-
expiresAt: string;
|
|
8
|
-
endsAt?: string | null;
|
|
9
|
-
};
|
|
10
|
-
extend(seconds: number): Promise<unknown>;
|
|
11
|
-
refresh(): Promise<unknown>;
|
|
12
|
-
}
|
|
13
|
-
/** Whole seconds to add to a lease ending at `expiresAt` (epoch ms) so it
|
|
14
|
-
* reaches toward `until`, at most an hour ahead of `now`; 0 when more than
|
|
15
|
-
* `marginMs` is left or there is nothing to add. */
|
|
16
|
-
export declare function extensionSeconds(expiresAt: number, until: number, now: number, marginMs: number): number;
|
|
17
|
-
/** Keeps a running sandbox's lease reaching toward `until()`: on `check()`,
|
|
18
|
-
* and once a minute on a timer that never keeps a Node or Bun process alive.
|
|
19
|
-
* When the process ends, the lease runs out within the hour and the sandbox
|
|
20
|
-
* pauses or stops as it was told to at create. A paused or stopped sandbox is
|
|
21
|
-
* left alone; the adapter wakes it on its next call. */
|
|
22
|
-
export declare class LeaseKeeper {
|
|
23
|
-
#private;
|
|
24
|
-
constructor(options: {
|
|
25
|
-
sandbox: () => Leased;
|
|
26
|
-
/** Epoch ms the lease should reach; Infinity for as long as this lives. */
|
|
27
|
-
until: () => number;
|
|
28
|
-
/** Extend only when less than this is left. */
|
|
29
|
-
marginMs: () => number;
|
|
30
|
-
everyMs?: number;
|
|
31
|
-
});
|
|
32
|
-
/** Extends the lease if it is near its end and should go further; `now`
|
|
33
|
-
* extends it as far as it may go whatever is left. One call at a time. */
|
|
34
|
-
check(now?: boolean): Promise<void>;
|
|
35
|
-
/** Stops extending: after stop() or delete(). */
|
|
36
|
-
end(): void;
|
|
37
|
-
}
|
package/dist/compat/lease.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { RuntimeError } from "../errors.js";
|
|
2
|
-
/* A rival's sandbox may be asked to live longer than one Runtime time limit
|
|
3
|
-
(an hour at most, ARCHITECTURE.md section 10): Vercel's `timeout` over an
|
|
4
|
-
hour, Daytona's `autoStopInterval` over an hour. The drop-ins keep the
|
|
5
|
-
limit reaching toward the time asked for while their sandbox object lives,
|
|
6
|
-
one extension at a time, never past that time. A sandbox created with no
|
|
7
|
-
time limit renews itself on the server (0300; `endsAt` null) and is left
|
|
8
|
-
alone. */
|
|
9
|
-
/** The most one lease runs ahead of now. */
|
|
10
|
-
export const LEASE_MAX_SECONDS = 3600;
|
|
11
|
-
/** Whole seconds to add to a lease ending at `expiresAt` (epoch ms) so it
|
|
12
|
-
* reaches toward `until`, at most an hour ahead of `now`; 0 when more than
|
|
13
|
-
* `marginMs` is left or there is nothing to add. */
|
|
14
|
-
export function extensionSeconds(expiresAt, until, now, marginMs) {
|
|
15
|
-
// A lease with no readable end (one that never ends) is left alone.
|
|
16
|
-
if (!Number.isFinite(expiresAt) || expiresAt - now > marginMs)
|
|
17
|
-
return 0;
|
|
18
|
-
const target = Math.min(until, now + LEASE_MAX_SECONDS * 1000);
|
|
19
|
-
return Math.max(0, Math.floor((target - expiresAt) / 1000));
|
|
20
|
-
}
|
|
21
|
-
/** Keeps a running sandbox's lease reaching toward `until()`: on `check()`,
|
|
22
|
-
* and once a minute on a timer that never keeps a Node or Bun process alive.
|
|
23
|
-
* When the process ends, the lease runs out within the hour and the sandbox
|
|
24
|
-
* pauses or stops as it was told to at create. A paused or stopped sandbox is
|
|
25
|
-
* left alone; the adapter wakes it on its next call. */
|
|
26
|
-
export class LeaseKeeper {
|
|
27
|
-
#sandbox;
|
|
28
|
-
#until;
|
|
29
|
-
#marginMs;
|
|
30
|
-
#everyMs;
|
|
31
|
-
#timer;
|
|
32
|
-
#pending;
|
|
33
|
-
#ended = false;
|
|
34
|
-
constructor(options) {
|
|
35
|
-
this.#sandbox = options.sandbox;
|
|
36
|
-
this.#until = options.until;
|
|
37
|
-
this.#marginMs = options.marginMs;
|
|
38
|
-
this.#everyMs = options.everyMs ?? 60_000;
|
|
39
|
-
}
|
|
40
|
-
/** Starts the timer when the lease must outlive the next extension. */
|
|
41
|
-
#schedule() {
|
|
42
|
-
if (this.#ended || this.#timer)
|
|
43
|
-
return;
|
|
44
|
-
const info = this.#sandbox().info;
|
|
45
|
-
if (info.endsAt === null)
|
|
46
|
-
return;
|
|
47
|
-
const expiresAt = Date.parse(info.endsAt ?? info.expiresAt);
|
|
48
|
-
if (!Number.isFinite(expiresAt) || this.#until() <= expiresAt)
|
|
49
|
-
return;
|
|
50
|
-
this.#timer = setTimeout(() => {
|
|
51
|
-
this.#timer = undefined;
|
|
52
|
-
void this.check().catch(() => undefined);
|
|
53
|
-
}, this.#everyMs);
|
|
54
|
-
this.#timer.unref?.();
|
|
55
|
-
}
|
|
56
|
-
/** Extends the lease if it is near its end and should go further; `now`
|
|
57
|
-
* extends it as far as it may go whatever is left. One call at a time. */
|
|
58
|
-
check(now = false) {
|
|
59
|
-
if (this.#ended)
|
|
60
|
-
return Promise.resolve();
|
|
61
|
-
this.#pending ??= this.#extend(now).finally(() => {
|
|
62
|
-
this.#pending = undefined;
|
|
63
|
-
this.#schedule();
|
|
64
|
-
});
|
|
65
|
-
return this.#pending;
|
|
66
|
-
}
|
|
67
|
-
async #extend(now) {
|
|
68
|
-
const sandbox = this.#sandbox();
|
|
69
|
-
// No time limit: the server renews it, and an extension would change nothing.
|
|
70
|
-
if (sandbox.state !== "running" || sandbox.info.endsAt === null)
|
|
71
|
-
return;
|
|
72
|
-
const seconds = extensionSeconds(Date.parse(sandbox.info.endsAt ?? sandbox.info.expiresAt), this.#until(), Date.now(), now ? Infinity : this.#marginMs());
|
|
73
|
-
if (seconds < 1)
|
|
74
|
-
return;
|
|
75
|
-
try {
|
|
76
|
-
await sandbox.extend(seconds);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
// The lease may have ended since the sandbox was last read; the next
|
|
80
|
-
// call through the adapter says what state it is in.
|
|
81
|
-
if (!(error instanceof RuntimeError && error.status === 409))
|
|
82
|
-
throw error;
|
|
83
|
-
await sandbox.refresh().catch(() => undefined);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/** Stops extending: after stop() or delete(). */
|
|
87
|
-
end() {
|
|
88
|
-
this.#ended = true;
|
|
89
|
-
if (this.#timer)
|
|
90
|
-
clearTimeout(this.#timer);
|
|
91
|
-
this.#timer = undefined;
|
|
92
|
-
}
|
|
93
|
-
}
|
package/dist/compat/shell.d.ts
DELETED