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/tar.js
DELETED
|
@@ -1,526 +0,0 @@
|
|
|
1
|
-
import { chmod, copyFile, link as hardLink, lstat, mkdir, mkdtemp, open, readdir, readFile, readlink, realpath, rename, rm, symlink, unlink, } from "node:fs/promises";
|
|
2
|
-
import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
-
import { Readable } from "node:stream";
|
|
4
|
-
import { createGunzip, gzipSync } from "node:zlib";
|
|
5
|
-
import { RuntimeError } from "./errors.js";
|
|
6
|
-
/* A small tar writer and reader for directory uploads and downloads, so the
|
|
7
|
-
SDK needs no dependency. Regular files, directories, symbolic links and,
|
|
8
|
-
reading, hard links. A name that does not fit the ustar name and prefix
|
|
9
|
-
fields, or a link target longer than 100 bytes, travels in a GNU long-name
|
|
10
|
-
or long-link entry, which GNU tar, BusyBox tar and every SDK's reader
|
|
11
|
-
take; nothing is cut short. */
|
|
12
|
-
const encode = (value) => new TextEncoder().encode(value);
|
|
13
|
-
/** The ustar prefix and name of `name`, split at a slash so that each fits
|
|
14
|
-
* its field in bytes, or null when no split fits. */
|
|
15
|
-
function ustarName(name) {
|
|
16
|
-
const bytes = encode(name);
|
|
17
|
-
if (bytes.length <= 100)
|
|
18
|
-
return { prefix: new Uint8Array(), short: bytes };
|
|
19
|
-
for (let split = name.lastIndexOf("/"); split > 0; split = name.lastIndexOf("/", split - 1)) {
|
|
20
|
-
const prefix = encode(name.slice(0, split));
|
|
21
|
-
const short = encode(name.slice(split + 1));
|
|
22
|
-
if (short.length > 100)
|
|
23
|
-
return null;
|
|
24
|
-
if (prefix.length <= 155)
|
|
25
|
-
return { prefix, short };
|
|
26
|
-
}
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
function headerBlock(short, prefix, size, mode, type, link, mtime) {
|
|
30
|
-
const block = new Uint8Array(512);
|
|
31
|
-
const put = (offset, value, length) => {
|
|
32
|
-
const data = typeof value === "string" ? encode(value) : value;
|
|
33
|
-
block.set(data.subarray(0, length), offset);
|
|
34
|
-
};
|
|
35
|
-
const octal = (value, length) => value.toString(8).padStart(length - 1, "0") + "\0";
|
|
36
|
-
put(0, short, 100);
|
|
37
|
-
put(100, octal(mode & 0o7777, 8), 8);
|
|
38
|
-
put(108, octal(0, 8), 8);
|
|
39
|
-
put(116, octal(0, 8), 8);
|
|
40
|
-
put(124, octal(size, 12), 12);
|
|
41
|
-
put(136, octal(mtime, 12), 12);
|
|
42
|
-
put(148, " ", 8);
|
|
43
|
-
put(156, type, 1);
|
|
44
|
-
put(157, link, 100);
|
|
45
|
-
put(257, "ustar\u000000", 8);
|
|
46
|
-
put(345, prefix, 155);
|
|
47
|
-
let sum = 0;
|
|
48
|
-
for (const byte of block)
|
|
49
|
-
sum += byte;
|
|
50
|
-
put(148, sum.toString(8).padStart(6, "0") + "\0 ", 8);
|
|
51
|
-
return block;
|
|
52
|
-
}
|
|
53
|
-
/** A GNU long-name ("L") or long-link ("K") entry carrying `value`. */
|
|
54
|
-
function longEntry(type, value) {
|
|
55
|
-
const size = value.length + 1;
|
|
56
|
-
const out = new Uint8Array(512 + Math.ceil(size / 512) * 512);
|
|
57
|
-
out.set(headerBlock(encode("././@LongLink"), new Uint8Array(), size, 0o644, type, new Uint8Array(), 0));
|
|
58
|
-
out.set(value, 512);
|
|
59
|
-
return out;
|
|
60
|
-
}
|
|
61
|
-
/** One entry's header: the ustar block, after the long-name and long-link
|
|
62
|
-
* entries it needs. A whole number of 512-byte blocks. */
|
|
63
|
-
export function tarHeader(name, size, mode, type, link = "", mtime = 0) {
|
|
64
|
-
const parts = [];
|
|
65
|
-
let fitted = ustarName(name);
|
|
66
|
-
if (!fitted) {
|
|
67
|
-
parts.push(longEntry("L", encode(name)));
|
|
68
|
-
fitted = { prefix: new Uint8Array(), short: encode(name).subarray(0, 100) };
|
|
69
|
-
}
|
|
70
|
-
const target = encode(link);
|
|
71
|
-
if (target.length > 100)
|
|
72
|
-
parts.push(longEntry("K", target));
|
|
73
|
-
parts.push(headerBlock(fitted.short, fitted.prefix, size, mode, type, target, mtime));
|
|
74
|
-
return parts.length === 1 ? parts[0] : new Uint8Array(Buffer.concat(parts));
|
|
75
|
-
}
|
|
76
|
-
export async function packDirectory(root) {
|
|
77
|
-
const parts = [];
|
|
78
|
-
const base = resolve(root);
|
|
79
|
-
async function walk(directory) {
|
|
80
|
-
for (const name of (await readdir(directory)).sort()) {
|
|
81
|
-
const full = join(directory, name);
|
|
82
|
-
const path = relative(base, full).split(sep).join("/");
|
|
83
|
-
const info = await lstat(full);
|
|
84
|
-
const mtime = Math.floor(info.mtimeMs / 1000);
|
|
85
|
-
if (info.isDirectory()) {
|
|
86
|
-
parts.push(tarHeader(`${path}/`, 0, info.mode, "5", "", mtime));
|
|
87
|
-
await walk(full);
|
|
88
|
-
}
|
|
89
|
-
else if (info.isSymbolicLink()) {
|
|
90
|
-
const { readlink } = await import("node:fs/promises");
|
|
91
|
-
parts.push(tarHeader(path, 0, info.mode, "2", await readlink(full), mtime));
|
|
92
|
-
}
|
|
93
|
-
else if (info.isFile()) {
|
|
94
|
-
const data = await readFile(full);
|
|
95
|
-
parts.push(tarHeader(path, data.length, info.mode, "0", "", mtime), data);
|
|
96
|
-
const pad = (512 - (data.length % 512)) % 512;
|
|
97
|
-
if (pad)
|
|
98
|
-
parts.push(new Uint8Array(pad));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
await walk(base);
|
|
103
|
-
parts.push(new Uint8Array(1024));
|
|
104
|
-
return gzipSync(Buffer.concat(parts));
|
|
105
|
-
}
|
|
106
|
-
/* The archive comes from a sandbox, whose contents the customer's untrusted code
|
|
107
|
-
controls, so nothing in it may write outside `target`. A lexical check on each
|
|
108
|
-
name is not enough: a link `x -> ../outside` followed by `x/file` passes it and
|
|
109
|
-
writes through the link. So no write ever passes through a link, links are made
|
|
110
|
-
only after every file and directory is in place, and each link is then walked
|
|
111
|
-
through the finished tree and removed, failing the unpack, if it leads out. */
|
|
112
|
-
async function linkAt(path) {
|
|
113
|
-
try {
|
|
114
|
-
return (await lstat(path)).isSymbolicLink();
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/** Throws unless `destination` is inside `root` and no part of the way to it,
|
|
121
|
-
itself included, is a link. */
|
|
122
|
-
async function assertPlain(root, destination, name) {
|
|
123
|
-
if (destination !== root && !destination.startsWith(root + sep))
|
|
124
|
-
throw new Error(`Refusing an archive entry outside the target: ${name}`);
|
|
125
|
-
let path = root;
|
|
126
|
-
for (const part of relative(root, destination).split(sep).filter(Boolean)) {
|
|
127
|
-
path = join(path, part);
|
|
128
|
-
if (await linkAt(path))
|
|
129
|
-
throw new Error(`Refusing an archive entry that passes through a link: ${name}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/** Where following `link` from `directory` leads, or undefined when the way
|
|
133
|
-
leaves `root` or turns at a link before its last step. The last step may
|
|
134
|
-
be a link; that link is checked on its own. */
|
|
135
|
-
async function linkStaysInside(root, directory, link) {
|
|
136
|
-
if (isAbsolute(link))
|
|
137
|
-
return false;
|
|
138
|
-
const parts = link.split("/").filter((part) => part && part !== ".");
|
|
139
|
-
let path = directory;
|
|
140
|
-
for (const [index, part] of parts.entries()) {
|
|
141
|
-
path = part === ".." ? dirname(path) : join(path, part);
|
|
142
|
-
if (path !== root && !path.startsWith(root + sep))
|
|
143
|
-
return false;
|
|
144
|
-
if (index < parts.length - 1 && part !== ".." && (await linkAt(path)))
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
/** A folder that did not arrive whole: tar in the sandbox stopped part way
|
|
150
|
-
* (a file it may not read, one that changed as it was read), which ends the
|
|
151
|
-
* gzip stream short, or the connection was lost (ARCHITECTURE.md section 10,
|
|
152
|
-
* "Folders over HTTP"). */
|
|
153
|
-
function cutShort(cause) {
|
|
154
|
-
return new RuntimeError({
|
|
155
|
-
message: "The folder's archive arrived cut short: tar in the sandbox stopped part way, or the connection was lost. Nothing was written.",
|
|
156
|
-
hint: "Try again. If it fails the same way, a file in the folder cannot be read by the sandbox user or changes as it is read.",
|
|
157
|
-
code: "download_incomplete",
|
|
158
|
-
status: 0,
|
|
159
|
-
...(cause === undefined ? {} : { cause }),
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
function checkSignal(signal) {
|
|
163
|
-
if (signal?.aborted)
|
|
164
|
-
throw new RuntimeError({
|
|
165
|
-
message: "The download was cancelled or ran past its deadline.",
|
|
166
|
-
code: "timeout",
|
|
167
|
-
status: 0,
|
|
168
|
-
cause: signal.reason,
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
/** Linux path names fit well below this generous metadata-only memory bound. */
|
|
172
|
-
const MAX_LONG_NAME_BYTES = 65_536;
|
|
173
|
-
function archiveSize(field) {
|
|
174
|
-
const text = field.trim();
|
|
175
|
-
if (text !== "" && !/^[0-7]+$/.test(text))
|
|
176
|
-
throw new Error("The archive contains an invalid file size.");
|
|
177
|
-
const size = text === "" ? 0 : parseInt(text, 8);
|
|
178
|
-
if (!Number.isSafeInteger(size) || size < 0 || size > Number.MAX_SAFE_INTEGER - 511)
|
|
179
|
-
throw new Error("The archive contains an invalid file size.");
|
|
180
|
-
return size;
|
|
181
|
-
}
|
|
182
|
-
/** The gzip check protects the compressed bytes; tar's own checksum also
|
|
183
|
-
* protects the header that determines each file's name, kind and length. */
|
|
184
|
-
function checkHeader(header, field) {
|
|
185
|
-
const text = field.trim();
|
|
186
|
-
let unsigned = 0;
|
|
187
|
-
let signed = 0;
|
|
188
|
-
for (let index = 0; index < header.length; index++) {
|
|
189
|
-
const byte = index >= 148 && index < 156 ? 32 : header[index];
|
|
190
|
-
unsigned += byte;
|
|
191
|
-
signed += byte < 128 ? byte : byte - 256;
|
|
192
|
-
}
|
|
193
|
-
const expected = /^[0-7]+$/.test(text) ? parseInt(text, 8) : NaN;
|
|
194
|
-
// Older tar implementations used signed bytes for non-ASCII path names.
|
|
195
|
-
if (expected !== unsigned && expected !== signed)
|
|
196
|
-
throw new Error("The archive contains an invalid header checksum.");
|
|
197
|
-
}
|
|
198
|
-
/** Validate links against the tree a merge will produce. Staged entries
|
|
199
|
-
* take precedence; paths absent there retain the existing target's entry.
|
|
200
|
-
* A link safe in staging may otherwise lead through an old escaping link. */
|
|
201
|
-
async function mergedLinkStaysInside(staging, root, destination, link) {
|
|
202
|
-
let path = dirname(join(root, relative(staging, destination)));
|
|
203
|
-
const pending = link.split("/");
|
|
204
|
-
const followed = new Set();
|
|
205
|
-
while (pending.length) {
|
|
206
|
-
const part = pending.shift();
|
|
207
|
-
if (!part || part === ".")
|
|
208
|
-
continue;
|
|
209
|
-
path = part === ".." ? dirname(path) : join(path, part);
|
|
210
|
-
if (path !== root && !path.startsWith(root + sep))
|
|
211
|
-
return false;
|
|
212
|
-
const staged = join(staging, relative(root, path));
|
|
213
|
-
const stagedKind = await lstat(staged).catch((error) => {
|
|
214
|
-
if (error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
215
|
-
return undefined;
|
|
216
|
-
throw error;
|
|
217
|
-
});
|
|
218
|
-
const actual = stagedKind ? staged : path;
|
|
219
|
-
const kind = stagedKind ??
|
|
220
|
-
(await lstat(actual).catch((error) => {
|
|
221
|
-
if (error.code === "ENOENT" || error.code === "ENOTDIR")
|
|
222
|
-
return undefined;
|
|
223
|
-
throw error;
|
|
224
|
-
}));
|
|
225
|
-
if (!kind?.isSymbolicLink())
|
|
226
|
-
continue;
|
|
227
|
-
if (followed.has(path))
|
|
228
|
-
return false;
|
|
229
|
-
followed.add(path);
|
|
230
|
-
const next = await readlink(actual);
|
|
231
|
-
if (isAbsolute(next)) {
|
|
232
|
-
// An existing absolute link is safe only when it stays in this root.
|
|
233
|
-
if (next !== root && !next.startsWith(root + sep))
|
|
234
|
-
return false;
|
|
235
|
-
path = root;
|
|
236
|
-
pending.unshift(...relative(root, next).split(sep));
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
path = dirname(path);
|
|
240
|
-
pending.unshift(...next.split("/"));
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
return true;
|
|
244
|
-
}
|
|
245
|
-
/** The gzip stream's bytes, decompressed as they arrive. */
|
|
246
|
-
function gunzipped(source, signal) {
|
|
247
|
-
const input = Readable.from(source, { objectMode: false });
|
|
248
|
-
const output = createGunzip();
|
|
249
|
-
// A filesystem await may precede async iteration; retain early stream
|
|
250
|
-
// errors for that iterator without an unhandled EventEmitter error.
|
|
251
|
-
output.on("error", () => undefined);
|
|
252
|
-
input.on("error", (error) => output.destroy(error));
|
|
253
|
-
input.pipe(output);
|
|
254
|
-
const abort = () => {
|
|
255
|
-
try {
|
|
256
|
-
checkSignal(signal);
|
|
257
|
-
}
|
|
258
|
-
catch (error) {
|
|
259
|
-
output.destroy(error);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
signal?.addEventListener("abort", abort, { once: true });
|
|
263
|
-
output.on("close", () => {
|
|
264
|
-
signal?.removeEventListener("abort", abort);
|
|
265
|
-
input.destroy();
|
|
266
|
-
});
|
|
267
|
-
return output;
|
|
268
|
-
}
|
|
269
|
-
/** Exact byte counts from a stream of chunks, holding at most one chunk. */
|
|
270
|
-
class Bytes {
|
|
271
|
-
#chunks;
|
|
272
|
-
#held = new Uint8Array(0);
|
|
273
|
-
constructor(source) {
|
|
274
|
-
this.#chunks = source[Symbol.asyncIterator]();
|
|
275
|
-
}
|
|
276
|
-
async #more() {
|
|
277
|
-
let next;
|
|
278
|
-
try {
|
|
279
|
-
next = await this.#chunks.next();
|
|
280
|
-
}
|
|
281
|
-
catch (error) {
|
|
282
|
-
throw error instanceof RuntimeError ? error : cutShort(error);
|
|
283
|
-
}
|
|
284
|
-
if (next.done)
|
|
285
|
-
return false;
|
|
286
|
-
this.#held = this.#held.length ? Buffer.concat([this.#held, next.value]) : next.value;
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
/** `n` bytes, or undefined at a clean end before any of them. */
|
|
290
|
-
async exactly(n) {
|
|
291
|
-
while (this.#held.length < n) {
|
|
292
|
-
if (await this.#more())
|
|
293
|
-
continue;
|
|
294
|
-
if (this.#held.length === 0)
|
|
295
|
-
return undefined;
|
|
296
|
-
throw cutShort();
|
|
297
|
-
}
|
|
298
|
-
const out = this.#held.subarray(0, n);
|
|
299
|
-
this.#held = this.#held.subarray(n);
|
|
300
|
-
return out;
|
|
301
|
-
}
|
|
302
|
-
/** The next `n` bytes as they arrive. */
|
|
303
|
-
async *take(n) {
|
|
304
|
-
while (n > 0) {
|
|
305
|
-
if (this.#held.length === 0 && !(await this.#more()))
|
|
306
|
-
throw cutShort();
|
|
307
|
-
const out = this.#held.subarray(0, n);
|
|
308
|
-
this.#held = this.#held.subarray(out.length);
|
|
309
|
-
n -= out.length;
|
|
310
|
-
yield out;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
/** Reads to the end, so the gzip stream's own check has run. */
|
|
314
|
-
async drain() {
|
|
315
|
-
this.#held = new Uint8Array(0);
|
|
316
|
-
while (await this.#more())
|
|
317
|
-
this.#held = new Uint8Array(0);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
/** Unpacks a tar stream into `root`, a fresh folder: files and folders as they
|
|
321
|
-
* arrive, links noted to make at the end. Throws unless the archive's end
|
|
322
|
-
* arrived. */
|
|
323
|
-
async function unpackEntries(bytes, root, signal) {
|
|
324
|
-
const links = [];
|
|
325
|
-
const decode = (slice) => {
|
|
326
|
-
const end = slice.indexOf(0);
|
|
327
|
-
return new TextDecoder().decode(end < 0 ? slice : slice.subarray(0, end));
|
|
328
|
-
};
|
|
329
|
-
let longName;
|
|
330
|
-
let longLink;
|
|
331
|
-
for (;;) {
|
|
332
|
-
checkSignal(signal);
|
|
333
|
-
const header = await bytes.exactly(512);
|
|
334
|
-
if (!header)
|
|
335
|
-
throw cutShort();
|
|
336
|
-
if (header.every((byte) => byte === 0)) {
|
|
337
|
-
const terminator = await bytes.exactly(512);
|
|
338
|
-
if (!terminator || !terminator.every((byte) => byte === 0))
|
|
339
|
-
throw cutShort();
|
|
340
|
-
await bytes.drain();
|
|
341
|
-
return links;
|
|
342
|
-
}
|
|
343
|
-
const text = (start, length) => decode(header.subarray(start, start + length));
|
|
344
|
-
const size = archiveSize(text(124, 12));
|
|
345
|
-
checkHeader(header, text(148, 8));
|
|
346
|
-
const type = String.fromCharCode(header[156] ?? 48);
|
|
347
|
-
const prefix = text(345, 155);
|
|
348
|
-
let name = longName ?? (prefix ? `${prefix}/${text(0, 100)}` : text(0, 100));
|
|
349
|
-
const link = longLink ?? text(157, 100);
|
|
350
|
-
longName = undefined;
|
|
351
|
-
longLink = undefined;
|
|
352
|
-
const mode = parseInt(text(100, 8).trim() || "644", 8);
|
|
353
|
-
const padding = Math.ceil(size / 512) * 512 - size;
|
|
354
|
-
const skip = async () => {
|
|
355
|
-
for await (const _ of bytes.take(size + padding))
|
|
356
|
-
;
|
|
357
|
-
};
|
|
358
|
-
if (type === "L" || type === "K") {
|
|
359
|
-
if (size > MAX_LONG_NAME_BYTES)
|
|
360
|
-
throw new Error("The archive contains oversized path metadata.");
|
|
361
|
-
const parts = [];
|
|
362
|
-
for await (const part of bytes.take(size))
|
|
363
|
-
parts.push(Uint8Array.from(part));
|
|
364
|
-
for await (const _ of bytes.take(padding))
|
|
365
|
-
;
|
|
366
|
-
const value = new TextDecoder().decode(Buffer.concat(parts)).replace(/\0.*$/s, "");
|
|
367
|
-
if (type === "L")
|
|
368
|
-
longName = value;
|
|
369
|
-
else
|
|
370
|
-
longLink = value;
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
name = name.replace(/^\.\//, "");
|
|
374
|
-
if (!name || name === "." || name === "./") {
|
|
375
|
-
await skip();
|
|
376
|
-
continue;
|
|
377
|
-
}
|
|
378
|
-
const destination = resolve(root, name);
|
|
379
|
-
await assertPlain(root, destination, name);
|
|
380
|
-
if (type === "5") {
|
|
381
|
-
await mkdir(destination, { recursive: true });
|
|
382
|
-
await skip();
|
|
383
|
-
}
|
|
384
|
-
else if (type === "2") {
|
|
385
|
-
links.push({ destination, link, name });
|
|
386
|
-
await skip();
|
|
387
|
-
}
|
|
388
|
-
else if (type === "1") {
|
|
389
|
-
await hardLinkEntry(root, destination, link, name);
|
|
390
|
-
await skip();
|
|
391
|
-
}
|
|
392
|
-
else if (type === "0" || type === "\0" || type === "7") {
|
|
393
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
394
|
-
// A name already unpacked may share its file with a hard link; writing
|
|
395
|
-
// through it would change the link's copy too.
|
|
396
|
-
await unlink(destination).catch(() => undefined);
|
|
397
|
-
const file = await open(destination, "w");
|
|
398
|
-
try {
|
|
399
|
-
for await (const part of bytes.take(size)) {
|
|
400
|
-
let written = 0;
|
|
401
|
-
while (written < part.length) {
|
|
402
|
-
checkSignal(signal);
|
|
403
|
-
const result = await file.write(part.subarray(written));
|
|
404
|
-
if (result.bytesWritten === 0)
|
|
405
|
-
throw new Error("The local file accepted no bytes.");
|
|
406
|
-
written += result.bytesWritten;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
finally {
|
|
411
|
-
await file.close();
|
|
412
|
-
}
|
|
413
|
-
await chmod(destination, mode & 0o777);
|
|
414
|
-
for await (const _ of bytes.take(padding))
|
|
415
|
-
;
|
|
416
|
-
}
|
|
417
|
-
else
|
|
418
|
-
await skip();
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
/** A second name for a file the archive already carried: tar writes the
|
|
422
|
-
* first name as a file and every other as a hard link to it. The link names
|
|
423
|
-
* a plain file unpacked earlier in this archive, or the unpack fails; it
|
|
424
|
-
* never reaches outside, through a link or ahead. */
|
|
425
|
-
async function hardLinkEntry(root, destination, link, name) {
|
|
426
|
-
const named = link.replace(/^(\.\/)+/, "");
|
|
427
|
-
const source = resolve(root, named);
|
|
428
|
-
if (!named || isAbsolute(named) || source === root || !source.startsWith(root + sep))
|
|
429
|
-
throw new Error(`Refusing an archive hard link that leads outside the target: ${name} -> ${link}`);
|
|
430
|
-
await assertPlain(root, source, named);
|
|
431
|
-
if (!(await lstat(source).catch(() => undefined))?.isFile())
|
|
432
|
-
throw new Error(`Refusing an archive hard link to a file it does not carry: ${name} -> ${link}`);
|
|
433
|
-
if (source === destination)
|
|
434
|
-
return;
|
|
435
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
436
|
-
await unlink(destination).catch(() => undefined);
|
|
437
|
-
await hardLink(source, destination).catch(() => copyFile(source, destination));
|
|
438
|
-
}
|
|
439
|
-
/** Moves what was unpacked in `from` into `to`, merging with what is there
|
|
440
|
-
* and replacing files of the same name, never through a link in `to`. */
|
|
441
|
-
async function merge(from, to, root, signal) {
|
|
442
|
-
for (const name of await readdir(from)) {
|
|
443
|
-
checkSignal(signal);
|
|
444
|
-
const source = join(from, name);
|
|
445
|
-
const destination = join(to, name);
|
|
446
|
-
await assertPlain(root, destination, relative(root, destination));
|
|
447
|
-
const [kind, there] = await Promise.all([
|
|
448
|
-
lstat(source),
|
|
449
|
-
lstat(destination).catch(() => undefined),
|
|
450
|
-
]);
|
|
451
|
-
checkSignal(signal);
|
|
452
|
-
if (kind.isDirectory() && there?.isDirectory())
|
|
453
|
-
await merge(source, destination, root, signal);
|
|
454
|
-
else
|
|
455
|
-
await rename(source, destination);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
/** A web stream's chunks, read through its reader. The SDK is built with
|
|
459
|
-
* TypeScript 5, whose DOM types do not make a ReadableStream async iterable
|
|
460
|
-
* (TypeScript 7's do), so a download's body is read this way in both. */
|
|
461
|
-
async function* chunksOf(stream) {
|
|
462
|
-
const reader = stream.getReader();
|
|
463
|
-
try {
|
|
464
|
-
for (;;) {
|
|
465
|
-
const { done, value } = await reader.read();
|
|
466
|
-
if (done)
|
|
467
|
-
return;
|
|
468
|
-
yield value;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
finally {
|
|
472
|
-
reader.releaseLock();
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
/** Unpacks a gzipped tar that arrives as a stream into `target`, refusing any
|
|
476
|
-
* entry that would land outside it, holding no more than a chunk at a time.
|
|
477
|
-
* It unpacks into a folder beside the target and moves it into place only
|
|
478
|
-
* once the whole archive arrived, so an archive cut short leaves nothing
|
|
479
|
-
* behind that could pass for the folder. A target that exists is merged
|
|
480
|
-
* into, files of the same name replaced. */
|
|
481
|
-
export async function unpackStream(from, target, options = {}) {
|
|
482
|
-
checkSignal(options.signal);
|
|
483
|
-
const source = from instanceof ReadableStream ? chunksOf(from) : from;
|
|
484
|
-
const final = resolve(target);
|
|
485
|
-
await mkdir(dirname(final), { recursive: true });
|
|
486
|
-
const staging = await mkdtemp(`${final}.runtime-partial-`);
|
|
487
|
-
const stream = gunzipped(source, options.signal);
|
|
488
|
-
try {
|
|
489
|
-
const root = await realpath(staging);
|
|
490
|
-
const links = await unpackEntries(new Bytes(stream), root, options.signal);
|
|
491
|
-
for (const { destination, link, name } of links) {
|
|
492
|
-
checkSignal(options.signal);
|
|
493
|
-
await assertPlain(root, destination, name);
|
|
494
|
-
await mkdir(dirname(destination), { recursive: true });
|
|
495
|
-
await symlink(link, destination).catch(() => undefined);
|
|
496
|
-
}
|
|
497
|
-
for (const { destination, link, name } of links) {
|
|
498
|
-
checkSignal(options.signal);
|
|
499
|
-
if (await linkStaysInside(root, dirname(destination), link))
|
|
500
|
-
continue;
|
|
501
|
-
await unlink(destination).catch(() => undefined);
|
|
502
|
-
throw new Error(`Refusing an archive link that leads outside the target: ${name} -> ${link}`);
|
|
503
|
-
}
|
|
504
|
-
const there = await lstat(final).catch(() => undefined);
|
|
505
|
-
checkSignal(options.signal);
|
|
506
|
-
if (!there)
|
|
507
|
-
await rename(staging, final);
|
|
508
|
-
else {
|
|
509
|
-
const targetRoot = await realpath(final);
|
|
510
|
-
for (const { destination, link, name } of links) {
|
|
511
|
-
checkSignal(options.signal);
|
|
512
|
-
if (!(await mergedLinkStaysInside(root, targetRoot, destination, link)))
|
|
513
|
-
throw new Error(`Refusing an archive link that leads outside the target: ${name} -> ${link}`);
|
|
514
|
-
}
|
|
515
|
-
await merge(root, targetRoot, targetRoot, options.signal);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
finally {
|
|
519
|
-
stream.destroy();
|
|
520
|
-
await rm(staging, { recursive: true, force: true });
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
/** Unpacks a whole gzipped tar held in memory, by the same rules. */
|
|
524
|
-
export function unpackArchive(archive, target) {
|
|
525
|
-
return unpackStream([archive], target);
|
|
526
|
-
}
|
package/dist/terminal.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text that came from someone else's program, made safe to print on a
|
|
3
|
-
* terminal: log lines, labels, anything a customer's code wrote. Printed raw,
|
|
4
|
-
* an escape sequence in it could clear or rewrite the screen, set the
|
|
5
|
-
* clipboard (OSC 52), forge a link (OSC 8) or reorder what is read (Unicode
|
|
6
|
-
* direction overrides). Each such character is shown as its \uXXXX escape
|
|
7
|
-
* instead, so nothing is hidden and nothing acts. Tab stays; a newline inside
|
|
8
|
-
* one value is escaped too, so a line on screen is always one value.
|
|
9
|
-
*
|
|
10
|
-
* Only for a terminal: a pipe or a file gets the bytes as they are.
|
|
11
|
-
*/
|
|
12
|
-
export declare function terminalSafe(text: string): string;
|
|
13
|
-
/** As {@link terminalSafe}, for a stream of lines: its newlines stay. */
|
|
14
|
-
export declare function terminalSafeLines(text: string): string;
|
|
15
|
-
/**
|
|
16
|
-
* Writes a log stream (a sandbox process's, an image build's, a job run's) to
|
|
17
|
-
* `to`: escaped on a terminal, as written to a pipe or a file, or with `raw`.
|
|
18
|
-
* Not for `exec` or an attached process, whose output is the customer's own
|
|
19
|
-
* terminal session.
|
|
20
|
-
*/
|
|
21
|
-
export declare function logStream(to: {
|
|
22
|
-
isTTY?: boolean;
|
|
23
|
-
write(text: string): unknown;
|
|
24
|
-
}, raw: boolean): (text: string) => void;
|
package/dist/terminal.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Text that came from someone else's program, made safe to print on a
|
|
3
|
-
* terminal: log lines, labels, anything a customer's code wrote. Printed raw,
|
|
4
|
-
* an escape sequence in it could clear or rewrite the screen, set the
|
|
5
|
-
* clipboard (OSC 52), forge a link (OSC 8) or reorder what is read (Unicode
|
|
6
|
-
* direction overrides). Each such character is shown as its \uXXXX escape
|
|
7
|
-
* instead, so nothing is hidden and nothing acts. Tab stays; a newline inside
|
|
8
|
-
* one value is escaped too, so a line on screen is always one value.
|
|
9
|
-
*
|
|
10
|
-
* Only for a terminal: a pipe or a file gets the bytes as they are.
|
|
11
|
-
*/
|
|
12
|
-
export function terminalSafe(text) {
|
|
13
|
-
return text.replace(UNSAFE, escaped);
|
|
14
|
-
}
|
|
15
|
-
/** As {@link terminalSafe}, for a stream of lines: its newlines stay. */
|
|
16
|
-
export function terminalSafeLines(text) {
|
|
17
|
-
return text.replace(UNSAFE_BUT_NEWLINE, escaped);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Writes a log stream (a sandbox process's, an image build's, a job run's) to
|
|
21
|
-
* `to`: escaped on a terminal, as written to a pipe or a file, or with `raw`.
|
|
22
|
-
* Not for `exec` or an attached process, whose output is the customer's own
|
|
23
|
-
* terminal session.
|
|
24
|
-
*/
|
|
25
|
-
export function logStream(to, raw) {
|
|
26
|
-
return (text) => void to.write(to.isTTY && !raw ? terminalSafeLines(text) : text);
|
|
27
|
-
}
|
|
28
|
-
const escaped = (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`;
|
|
29
|
-
// C0 but tab, DEL, C1, and the Unicode marks and overrides that reorder text.
|
|
30
|
-
const CONTROLS = String.raw `\x00-\x08\x0b-\x1f\x7f-\x9f--`;
|
|
31
|
-
const UNSAFE = new RegExp(String.raw `[\n${CONTROLS}]`, "g");
|
|
32
|
-
const UNSAFE_BUT_NEWLINE = new RegExp(`[${CONTROLS}]`, "g");
|
package/dist/tools/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import type { Sandbox } from "../sandbox.js";
|
|
2
|
-
export type ToolInputSchema = {
|
|
3
|
-
type: "object";
|
|
4
|
-
properties: Record<string, {
|
|
5
|
-
type: "string" | "integer";
|
|
6
|
-
description: string;
|
|
7
|
-
minimum?: number;
|
|
8
|
-
}>;
|
|
9
|
-
required: string[];
|
|
10
|
-
additionalProperties: false;
|
|
11
|
-
};
|
|
12
|
-
export type SandboxTool<Input, Output> = {
|
|
13
|
-
name: string;
|
|
14
|
-
description: string;
|
|
15
|
-
inputSchema: ToolInputSchema;
|
|
16
|
-
execute(input: Input): Promise<Output>;
|
|
17
|
-
};
|
|
18
|
-
export type ExecInput = {
|
|
19
|
-
command: string;
|
|
20
|
-
cwd?: string;
|
|
21
|
-
timeoutSeconds?: number;
|
|
22
|
-
};
|
|
23
|
-
export type ExecOutput = {
|
|
24
|
-
exitCode: number | null;
|
|
25
|
-
stdout: string;
|
|
26
|
-
stderr: string;
|
|
27
|
-
timedOut: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type ListEntry = {
|
|
30
|
-
path: string;
|
|
31
|
-
type: "file" | "directory" | "symlink" | "other";
|
|
32
|
-
size: number;
|
|
33
|
-
};
|
|
34
|
-
export type SandboxToolOptions = {
|
|
35
|
-
/** Where relative paths resolve. Default /workspace. */
|
|
36
|
-
root?: string;
|
|
37
|
-
/** For a command that names no timeout. Default 300. */
|
|
38
|
-
timeoutSeconds?: number;
|
|
39
|
-
/** Characters kept from each of stdout, stderr and a file read; the rest is cut from the front. Default 20 000. */
|
|
40
|
-
maxOutputChars?: number;
|
|
41
|
-
};
|
|
42
|
-
export type SandboxTools = [
|
|
43
|
-
SandboxTool<ExecInput, ExecOutput>,
|
|
44
|
-
SandboxTool<{
|
|
45
|
-
path: string;
|
|
46
|
-
}, string>,
|
|
47
|
-
SandboxTool<{
|
|
48
|
-
path: string;
|
|
49
|
-
content: string;
|
|
50
|
-
}, string>,
|
|
51
|
-
SandboxTool<{
|
|
52
|
-
path?: string;
|
|
53
|
-
depth?: number;
|
|
54
|
-
}, ListEntry[] | {
|
|
55
|
-
error: string;
|
|
56
|
-
}>
|
|
57
|
-
];
|
|
58
|
-
/** A POSIX path joined and normalized: `..` cannot climb past `/`. */
|
|
59
|
-
export declare function resolvePath(root: string, path: string | undefined): string;
|
|
60
|
-
export declare function clip(text: string, limit: number): string;
|
|
61
|
-
/** runtime_exec, runtime_read_file, runtime_write_file and runtime_list_files, bound to `sandbox`. */
|
|
62
|
-
export declare function sandboxTools(sandbox: Sandbox, options?: SandboxToolOptions): SandboxTools;
|