withruntime 0.49.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 -574
- 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/keys.js
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { privateDecrypt } from "node:crypto";
|
|
3
|
-
import { hostname } from "node:os";
|
|
4
|
-
import { promisify } from "node:util";
|
|
5
|
-
import { connectionOrigins } from "./credentials.js";
|
|
6
|
-
import { RuntimeError } from "./errors.js";
|
|
7
|
-
import { named } from "./cli-name.js";
|
|
8
|
-
import { sandboxIdentityHeaders } from "./identity.js";
|
|
9
|
-
import { describeRoute, envFetch } from "./proxy.js";
|
|
10
|
-
import { sealing } from "./sealing.js";
|
|
11
|
-
const KEY = /^rtcloud_([a-f0-9-]{36})_[A-Za-z0-9_-]{43}$/;
|
|
12
|
-
/** How often to ask whether the owner has answered. The website answers
|
|
13
|
-
* "pending" to anything faster than every 4.5 seconds. */
|
|
14
|
-
const POLL_MS = 5000;
|
|
15
|
-
/** Whole microdollars from a daily limit typed in dollars ("25", "7.5",
|
|
16
|
-
* "$1,000.10"), read as digits rather than through a float, from $0.01 to
|
|
17
|
-
* $1,000,000: the keys page's own rule (apps/cloud-web/src/app/account/keys/limit.ts). */
|
|
18
|
-
export function dailyLimitMicros(typed) {
|
|
19
|
-
const text = typed.trim().replace(/^\$/, "").replace(/,/g, "");
|
|
20
|
-
const parts = text.match(/^(\d{1,7})(?:\.(\d{1,2}))?$/);
|
|
21
|
-
const cents = parts ? Number(parts[1]) * 100 + Number((parts[2] ?? "").padEnd(2, "0")) : 0;
|
|
22
|
-
if (cents < 1 || cents > 100_000_000)
|
|
23
|
-
throw new RuntimeError({
|
|
24
|
-
code: "usage",
|
|
25
|
-
status: 0,
|
|
26
|
-
message: "--daily-limit is an amount in US dollars from 0.01 to 1000000, such as 25.",
|
|
27
|
-
});
|
|
28
|
-
return cents * 10_000;
|
|
29
|
-
}
|
|
30
|
-
function failure(code, message, status = 0, hint) {
|
|
31
|
-
return new RuntimeError({ code, status, message, ...(hint ? { hint } : {}) });
|
|
32
|
-
}
|
|
33
|
-
async function browser(url) {
|
|
34
|
-
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
|
|
35
|
-
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
36
|
-
await promisify(execFile)(command, args, { timeout: 10_000 });
|
|
37
|
-
}
|
|
38
|
-
function interrupted(cancel) {
|
|
39
|
-
const handler = () => {
|
|
40
|
-
process.stderr.write("\nCanceling the key request.\n");
|
|
41
|
-
void cancel()
|
|
42
|
-
.catch(() => undefined)
|
|
43
|
-
.finally(() => process.exit(130));
|
|
44
|
-
};
|
|
45
|
-
process.once("SIGINT", handler);
|
|
46
|
-
return () => void process.off("SIGINT", handler);
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Asks for a key, waits for an owner to approve it in the browser, and hands
|
|
50
|
-
* it back with `confirm`, which tells the website it arrived. Call `confirm`
|
|
51
|
-
* after the key is shown: it clears the sealed copy the website held for
|
|
52
|
-
* delivery and turns the owner's page to "Key created".
|
|
53
|
-
*/
|
|
54
|
-
export async function createKey(request, env, options = {}) {
|
|
55
|
-
const name = request.name.trim();
|
|
56
|
-
if (!name ||
|
|
57
|
-
request.name.length > 80 ||
|
|
58
|
-
[...request.name].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
|
|
59
|
-
throw failure("usage", "Give the key a name of up to 80 characters.");
|
|
60
|
-
if (request.access === "read" && request.dailyLimitMicros !== null)
|
|
61
|
-
throw failure("usage", "A read-only key cannot spend, so it takes no --daily-limit.");
|
|
62
|
-
if (request.access === "read" && request.reach === "account")
|
|
63
|
-
throw failure("usage", "A read-only key already sees the whole account, so it takes no --account-wide.");
|
|
64
|
-
const limited = request.sandboxes !== undefined || request.actions !== undefined;
|
|
65
|
-
if (limited && (!request.sandboxes?.length || !request.actions?.length))
|
|
66
|
-
throw failure("usage", "A key limited to sandboxes names at least one sandbox and one action.");
|
|
67
|
-
if (limited && (request.access !== "full" || request.reach !== undefined))
|
|
68
|
-
throw failure("usage", "A key limited to sandboxes reaches only them, so it takes no --read-only or --account-wide.");
|
|
69
|
-
if (limited && !request.actions.includes("create") && request.dailyLimitMicros !== null)
|
|
70
|
-
throw failure("usage", "A key without create cannot spend, so it takes no --daily-limit.");
|
|
71
|
-
const origins = connectionOrigins(env);
|
|
72
|
-
const fetcher = options.fetch ?? envFetch;
|
|
73
|
-
const notify = options.notify ?? ((message) => process.stderr.write(`${message}\n`));
|
|
74
|
-
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
75
|
-
// A key asked for here is approved on the page this address serves: only
|
|
76
|
-
// Runtime's own website, or one on this computer for testing.
|
|
77
|
-
const local = (origin) => ["localhost", "127.0.0.1", "[::1]"].includes(new URL(origin).hostname);
|
|
78
|
-
if (!(origins.auth === "https://withruntime.com" || local(origins.auth)))
|
|
79
|
-
throw failure("usage", "Keys are approved at https://withruntime.com, or at a local test address. Check RUNTIME_AUTH_URL.");
|
|
80
|
-
async function post(path, body, key) {
|
|
81
|
-
const address = `${origins.auth}/api/connect/${path}`;
|
|
82
|
-
let response;
|
|
83
|
-
// The sandbox's identity first: its own lookup has its own deadline, and
|
|
84
|
-
// the call's 20 s start when the call does.
|
|
85
|
-
const identity = await sandboxIdentityHeaders();
|
|
86
|
-
try {
|
|
87
|
-
response = await fetcher(address, {
|
|
88
|
-
method: "POST",
|
|
89
|
-
redirect: "error",
|
|
90
|
-
headers: {
|
|
91
|
-
"content-type": "application/json",
|
|
92
|
-
...(key ? { authorization: `Bearer ${key}` } : {}),
|
|
93
|
-
...identity,
|
|
94
|
-
},
|
|
95
|
-
signal: AbortSignal.timeout(20_000),
|
|
96
|
-
body: JSON.stringify(body),
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
catch (cause) {
|
|
100
|
-
const route = options.fetch ? { via: "" } : describeRoute(address, cause, env);
|
|
101
|
-
throw failure("network_error", `Runtime could not be reached at ${origins.auth}${route.via}.`, 0, route.hint);
|
|
102
|
-
}
|
|
103
|
-
const result = (await response.json().catch(() => ({})));
|
|
104
|
-
if (!response.ok)
|
|
105
|
-
throw failure(response.status === 429 ? "rate_limited" : "key_request_failed", typeof result.error === "string" ? result.error : "Runtime could not take this request.", response.status);
|
|
106
|
-
return result;
|
|
107
|
-
}
|
|
108
|
-
const pair = await sealing.pair();
|
|
109
|
-
const started = await post("start", {
|
|
110
|
-
purpose: "key",
|
|
111
|
-
agentName: name,
|
|
112
|
-
access: request.access,
|
|
113
|
-
...(request.reach === "account" ? { reach: "account" } : {}),
|
|
114
|
-
dailyLimitMicros: request.dailyLimitMicros,
|
|
115
|
-
...(limited ? { sandboxes: request.sandboxes, actions: request.actions } : {}),
|
|
116
|
-
machine: options.machine ?? hostname(),
|
|
117
|
-
publicKey: pair.publicKey,
|
|
118
|
-
});
|
|
119
|
-
if (typeof started.verificationUri !== "string" ||
|
|
120
|
-
typeof started.deviceCode !== "string" ||
|
|
121
|
-
!/^[A-Za-z0-9_-]{43}$/.test(started.deviceCode) ||
|
|
122
|
-
typeof started.userCode !== "string" ||
|
|
123
|
-
!/^[A-F0-9]{4}(-[A-F0-9]{4}){2}$/.test(started.userCode) ||
|
|
124
|
-
typeof started.expiresAt !== "number" ||
|
|
125
|
-
!Number.isFinite(started.expiresAt))
|
|
126
|
-
throw failure("key_request_failed", "Runtime returned an invalid key request.");
|
|
127
|
-
const link = new URL(started.verificationUri);
|
|
128
|
-
if (link.origin !== origins.auth ||
|
|
129
|
-
link.pathname !== "/connect" ||
|
|
130
|
-
link.username ||
|
|
131
|
-
link.password ||
|
|
132
|
-
link.hash ||
|
|
133
|
-
[...link.searchParams.keys()].some((key) => key !== "code") ||
|
|
134
|
-
link.searchParams.get("code") !== started.userCode)
|
|
135
|
-
throw failure("key_request_failed", "Runtime returned an unexpected approval address.");
|
|
136
|
-
const deviceCode = started.deviceCode;
|
|
137
|
-
const expiresAt = Math.min(started.expiresAt, Date.now() + 15 * 60_000);
|
|
138
|
-
notify(`Approve this key in your browser: ${link.href}\nCheck that the page shows code ${started.userCode}. An account ${limited ? "owner or admin" : "owner"} chooses Create key.\nWaiting for the approval, up to 15 minutes. Stopping this cancels the request.`);
|
|
139
|
-
if (options.interactive ?? Boolean(process.stderr.isTTY))
|
|
140
|
-
await (options.openBrowser ?? browser)(link.href).catch(() => notify("Open the link in a browser where an account owner is signed in."));
|
|
141
|
-
const stop = (options.onInterrupt ?? interrupted)(async () => {
|
|
142
|
-
await post("token", { deviceCode, action: "cancel" });
|
|
143
|
-
});
|
|
144
|
-
try {
|
|
145
|
-
// One poll past the expiry, because an approval given in its last seconds
|
|
146
|
-
// is still delivered.
|
|
147
|
-
for (;;) {
|
|
148
|
-
await sleep(POLL_MS);
|
|
149
|
-
const last = Date.now() >= expiresAt;
|
|
150
|
-
let result;
|
|
151
|
-
try {
|
|
152
|
-
result = await post("token", { deviceCode });
|
|
153
|
-
}
|
|
154
|
-
catch (error) {
|
|
155
|
-
// A dropped connection or a busy website is not an answer: ask again.
|
|
156
|
-
if (!last &&
|
|
157
|
-
error instanceof RuntimeError &&
|
|
158
|
-
(error.code === "network_error" || error.status >= 500))
|
|
159
|
-
continue;
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
if (result.status === "pending") {
|
|
163
|
-
if (last)
|
|
164
|
-
break;
|
|
165
|
-
continue;
|
|
166
|
-
}
|
|
167
|
-
if (result.status === "denied")
|
|
168
|
-
throw failure("key_request_declined", "The key request was declined. No key was created.");
|
|
169
|
-
if (result.status === "canceled")
|
|
170
|
-
throw failure("key_request_canceled", "The key request was canceled. No key was issued.");
|
|
171
|
-
if (result.status === "expired")
|
|
172
|
-
break;
|
|
173
|
-
if (result.status !== "connected" ||
|
|
174
|
-
typeof result.encryptedKey !== "string" ||
|
|
175
|
-
typeof result.agentId !== "string" ||
|
|
176
|
-
typeof result.orgId !== "string")
|
|
177
|
-
throw failure("key_request_failed", "Runtime returned an invalid key.");
|
|
178
|
-
let key;
|
|
179
|
-
try {
|
|
180
|
-
key = privateDecrypt({ key: pair.privateKey, oaepHash: "sha256" }, Buffer.from(result.encryptedKey, "base64")).toString("utf8");
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
throw failure("key_request_failed", "Could not open the key Runtime returned. Start again.");
|
|
184
|
-
}
|
|
185
|
-
const match = KEY.exec(key);
|
|
186
|
-
if (!match)
|
|
187
|
-
throw failure("key_request_failed", "Runtime returned an invalid key.");
|
|
188
|
-
// From here the key is this command's: an interruption must not revoke it.
|
|
189
|
-
stop();
|
|
190
|
-
return {
|
|
191
|
-
name,
|
|
192
|
-
access: request.access,
|
|
193
|
-
reach: request.reach ?? "agent",
|
|
194
|
-
dailyLimitMicros: request.dailyLimitMicros,
|
|
195
|
-
...(limited ? { sandboxes: request.sandboxes, actions: request.actions } : {}),
|
|
196
|
-
key,
|
|
197
|
-
keyId: match[1],
|
|
198
|
-
agentId: result.agentId,
|
|
199
|
-
orgId: result.orgId,
|
|
200
|
-
expires: null,
|
|
201
|
-
confirm: async () => {
|
|
202
|
-
await post("confirm", {}, key).catch(() => notify("The key works, but Runtime did not hear that it arrived. The approval page may still say Approved."));
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
finally {
|
|
208
|
-
stop();
|
|
209
|
-
}
|
|
210
|
-
throw failure("key_request_expired", named("The key request expired before it was approved. Run `runtime keys create` again."));
|
|
211
|
-
}
|
package/dist/login.d.ts
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { me, named } from "./cli-name.js";
|
|
2
|
-
export { me, named };
|
|
3
|
-
type LoginOptions = {
|
|
4
|
-
readKey?: () => Promise<string>;
|
|
5
|
-
fetch?: typeof fetch;
|
|
6
|
-
sleep?: (ms: number) => Promise<void>;
|
|
7
|
-
notify?: (message: string) => void;
|
|
8
|
-
openBrowser?: (url: string) => Promise<void>;
|
|
9
|
-
/** A person at a terminal, who can wait out the approval; an agent's tool
|
|
10
|
-
* call is not. Defaults to whether standard input and error are terminals. */
|
|
11
|
-
interactive?: boolean;
|
|
12
|
-
};
|
|
13
|
-
/** How long a login run by an agent waits for the approval before it hands
|
|
14
|
-
* back the link: inside the common tool timeouts, long enough for a person
|
|
15
|
-
* at the same machine to press Connect agent. */
|
|
16
|
-
export declare const AGENT_WAIT_MS = 50000;
|
|
17
|
-
export declare function authenticationCommand(args: string[], env: NodeJS.ProcessEnv, options?: LoginOptions): Promise<{
|
|
18
|
-
disconnected: boolean;
|
|
19
|
-
connected?: undefined;
|
|
20
|
-
agentName?: undefined;
|
|
21
|
-
orgId?: undefined;
|
|
22
|
-
source?: undefined;
|
|
23
|
-
pending?: undefined;
|
|
24
|
-
url?: undefined;
|
|
25
|
-
userCode?: undefined;
|
|
26
|
-
expiresAt?: undefined;
|
|
27
|
-
} | {
|
|
28
|
-
connected: boolean;
|
|
29
|
-
agentName: string;
|
|
30
|
-
orgId: string;
|
|
31
|
-
source: string;
|
|
32
|
-
disconnected?: undefined;
|
|
33
|
-
pending?: undefined;
|
|
34
|
-
url?: undefined;
|
|
35
|
-
userCode?: undefined;
|
|
36
|
-
expiresAt?: undefined;
|
|
37
|
-
} | {
|
|
38
|
-
connected: boolean;
|
|
39
|
-
source: string;
|
|
40
|
-
disconnected?: undefined;
|
|
41
|
-
agentName?: undefined;
|
|
42
|
-
orgId?: undefined;
|
|
43
|
-
pending?: undefined;
|
|
44
|
-
url?: undefined;
|
|
45
|
-
userCode?: undefined;
|
|
46
|
-
expiresAt?: undefined;
|
|
47
|
-
} | {
|
|
48
|
-
connected: boolean;
|
|
49
|
-
agentName: string;
|
|
50
|
-
orgId: string;
|
|
51
|
-
disconnected?: undefined;
|
|
52
|
-
source?: undefined;
|
|
53
|
-
pending?: undefined;
|
|
54
|
-
url?: undefined;
|
|
55
|
-
userCode?: undefined;
|
|
56
|
-
expiresAt?: undefined;
|
|
57
|
-
} | {
|
|
58
|
-
connected: false;
|
|
59
|
-
pending: true;
|
|
60
|
-
url: string;
|
|
61
|
-
userCode: string;
|
|
62
|
-
expiresAt: string;
|
|
63
|
-
disconnected?: undefined;
|
|
64
|
-
agentName?: undefined;
|
|
65
|
-
orgId?: undefined;
|
|
66
|
-
source?: undefined;
|
|
67
|
-
}>;
|
|
68
|
-
export type PendingLogin = {
|
|
69
|
-
/** Open this in a browser, where the account owner approves the agent. */
|
|
70
|
-
url: string;
|
|
71
|
-
/** The code the browser shows, to check it is this request. */
|
|
72
|
-
userCode: string;
|
|
73
|
-
expiresAt: number;
|
|
74
|
-
/** An earlier request from this machine, still waiting: its link is already
|
|
75
|
-
* open or shown, so it is not opened again. */
|
|
76
|
-
resumed: boolean;
|
|
77
|
-
/** Asks once whether it was approved: pending, expired, or connected (the
|
|
78
|
-
* key is then saved and confirmed). Throws when it was declined. */
|
|
79
|
-
check(): Promise<"pending" | "expired" | {
|
|
80
|
-
connected: true;
|
|
81
|
-
agentName: string;
|
|
82
|
-
orgId: string;
|
|
83
|
-
}>;
|
|
84
|
-
};
|
|
85
|
-
/** Starts a browser-approved connection and hands back its link, without
|
|
86
|
-
* waiting: `runtime login` waits on it, and the MCP bridge gives the link to
|
|
87
|
-
* the agent, which shows it to the person it works for. */
|
|
88
|
-
export declare function beginDeviceLogin(env: NodeJS.ProcessEnv, agentName: string, options?: LoginOptions): Promise<PendingLogin>;
|
package/dist/login.js
DELETED
|
@@ -1,369 +0,0 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
2
|
-
import { privateDecrypt } from "node:crypto";
|
|
3
|
-
import { hostname } from "node:os";
|
|
4
|
-
import { promisify } from "node:util";
|
|
5
|
-
import { me, named } from "./cli-name.js";
|
|
6
|
-
import { Runtime } from "./client.js";
|
|
7
|
-
import { checkBrowserOrigins, connectionOrigins, connectionStore } from "./credentials.js";
|
|
8
|
-
import { sandboxIdentityHeaders } from "./identity.js";
|
|
9
|
-
import { describeRoute, envFetch } from "./proxy.js";
|
|
10
|
-
import { sealing } from "./sealing.js";
|
|
11
|
-
class ConnectionError extends Error {
|
|
12
|
-
status;
|
|
13
|
-
constructor(status, message) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.status = status;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export { me, named };
|
|
19
|
-
/** The connection id recorded for a key pasted with `login --with-key`. */
|
|
20
|
-
const PASTED = "pasted";
|
|
21
|
-
/** A key from standard input: piped, or typed at a prompt that does not echo. */
|
|
22
|
-
async function readKey() {
|
|
23
|
-
const stdin = process.stdin;
|
|
24
|
-
if (!stdin.isTTY) {
|
|
25
|
-
const chunks = [];
|
|
26
|
-
for await (const chunk of stdin)
|
|
27
|
-
chunks.push(chunk);
|
|
28
|
-
return Buffer.concat(chunks).toString("utf8");
|
|
29
|
-
}
|
|
30
|
-
process.stderr.write("Paste a key from https://withruntime.com/account/keys (it is not shown): ");
|
|
31
|
-
stdin.setRawMode(true);
|
|
32
|
-
stdin.resume();
|
|
33
|
-
return new Promise((resolve, reject) => {
|
|
34
|
-
let typed = "";
|
|
35
|
-
const done = (value) => {
|
|
36
|
-
stdin.off("data", onData);
|
|
37
|
-
stdin.setRawMode(false);
|
|
38
|
-
stdin.pause();
|
|
39
|
-
process.stderr.write("\n");
|
|
40
|
-
if (value instanceof Error)
|
|
41
|
-
reject(value);
|
|
42
|
-
else
|
|
43
|
-
resolve(value);
|
|
44
|
-
};
|
|
45
|
-
const onData = (chunk) => {
|
|
46
|
-
for (const char of chunk.toString("utf8")) {
|
|
47
|
-
if (char === "\r" || char === "\n")
|
|
48
|
-
return done(typed);
|
|
49
|
-
if (char === "\u0003")
|
|
50
|
-
return done(new Error("Cancelled."));
|
|
51
|
-
if (char === "\u007f")
|
|
52
|
-
typed = typed.slice(0, -1);
|
|
53
|
-
else
|
|
54
|
-
typed += char;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
stdin.on("data", onData);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
/** How long a login run by an agent waits for the approval before it hands
|
|
61
|
-
* back the link: inside the common tool timeouts, long enough for a person
|
|
62
|
-
* at the same machine to press Connect agent. */
|
|
63
|
-
export const AGENT_WAIT_MS = 50_000;
|
|
64
|
-
async function browser(url) {
|
|
65
|
-
const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
|
|
66
|
-
const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
|
|
67
|
-
await promisify(execFile)(command, args, { timeout: 10_000 });
|
|
68
|
-
}
|
|
69
|
-
/** The origins, the saved-connection store and the website's connect API. */
|
|
70
|
-
function connection(env, options) {
|
|
71
|
-
const origins = connectionOrigins(env);
|
|
72
|
-
const store = connectionStore(env);
|
|
73
|
-
const fetcher = options.fetch ?? envFetch;
|
|
74
|
-
async function request(path, body, key) {
|
|
75
|
-
let response;
|
|
76
|
-
const address = `${origins.auth}/api/connect/${path}`;
|
|
77
|
-
// The sandbox's identity first: its own lookup has its own deadline, and
|
|
78
|
-
// the call's 20 s start when the call does.
|
|
79
|
-
const identity = await sandboxIdentityHeaders();
|
|
80
|
-
try {
|
|
81
|
-
response = await fetcher(address, {
|
|
82
|
-
method: "POST",
|
|
83
|
-
redirect: "error",
|
|
84
|
-
headers: {
|
|
85
|
-
"content-type": "application/json",
|
|
86
|
-
...(key ? { authorization: `Bearer ${key}` } : {}),
|
|
87
|
-
...identity,
|
|
88
|
-
},
|
|
89
|
-
signal: AbortSignal.timeout(20_000),
|
|
90
|
-
body: JSON.stringify(body ?? {}),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
catch (cause) {
|
|
94
|
-
const route = options.fetch ? { via: "" } : describeRoute(address, cause, env);
|
|
95
|
-
throw new ConnectionError(503, route.hint
|
|
96
|
-
? `Runtime could not be reached at ${origins.auth}${route.via}. ${route.hint}`
|
|
97
|
-
: "Runtime could not be reached. Retry the connection.");
|
|
98
|
-
}
|
|
99
|
-
if (response.status === 407 && !options.fetch) {
|
|
100
|
-
const route = describeRoute(address, 407, env);
|
|
101
|
-
throw new ConnectionError(503, `Runtime could not be reached at ${origins.auth}${route.via}. ${route.hint ?? ""}`.trim());
|
|
102
|
-
}
|
|
103
|
-
if (!response.ok)
|
|
104
|
-
throw new ConnectionError(response.status, response.status === 401
|
|
105
|
-
? named("This connection is no longer active. Run `runtime login`.")
|
|
106
|
-
: response.status === 429
|
|
107
|
-
? "Too many connection attempts. Try again later."
|
|
108
|
-
: "Runtime could not complete this connection. Try again.");
|
|
109
|
-
try {
|
|
110
|
-
return (await response.json());
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
// A complete malformed answer remains terminal. A failed body read can
|
|
114
|
-
// hide an issued token, so keep its private key and retry the same request.
|
|
115
|
-
if (error instanceof SyntaxError)
|
|
116
|
-
throw error;
|
|
117
|
-
throw new ConnectionError(503, "Runtime's connection response was interrupted. Retry the connection.");
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return { origins, store, request, fetcher };
|
|
121
|
-
}
|
|
122
|
-
export async function authenticationCommand(args, env, options = {}) {
|
|
123
|
-
const { origins, store, request, fetcher } = connection(env, options);
|
|
124
|
-
const notify = options.notify ?? ((message) => process.stderr.write(`${message}\n`));
|
|
125
|
-
const sleep = options.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
126
|
-
const [command, ...rest] = args;
|
|
127
|
-
if (command === "logout" && rest.length === 0) {
|
|
128
|
-
if (env.RUNTIME_API_KEY)
|
|
129
|
-
throw new Error("This shell uses RUNTIME_API_KEY. Remove that override before disconnecting the saved connection.");
|
|
130
|
-
const saved = await store.read();
|
|
131
|
-
if (!saved)
|
|
132
|
-
return { disconnected: true };
|
|
133
|
-
// A pasted key belongs to the website's key list: forget it here, and
|
|
134
|
-
// revoke it there if it should stop working everywhere.
|
|
135
|
-
if (saved.connectionId === PASTED) {
|
|
136
|
-
await store.remove(saved.key);
|
|
137
|
-
return { disconnected: true };
|
|
138
|
-
}
|
|
139
|
-
try {
|
|
140
|
-
await request("disconnect", undefined, saved.key);
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
if (!(error instanceof ConnectionError && error.status === 401))
|
|
144
|
-
throw error;
|
|
145
|
-
}
|
|
146
|
-
await store.remove(saved.key);
|
|
147
|
-
return { disconnected: true };
|
|
148
|
-
}
|
|
149
|
-
if (command !== "login")
|
|
150
|
-
throw new Error(named("Use `runtime login`, `runtime whoami` or `runtime logout`."));
|
|
151
|
-
let agentName = "My coding agent";
|
|
152
|
-
let noBrowser = false;
|
|
153
|
-
let withKey = false;
|
|
154
|
-
let wait;
|
|
155
|
-
// `runtime account add`: connect another account even though this machine
|
|
156
|
-
// is connected already; the one in use is kept among the saved accounts.
|
|
157
|
-
let another = false;
|
|
158
|
-
for (let i = 0; i < rest.length; i++) {
|
|
159
|
-
if (rest[i] === "--no-browser")
|
|
160
|
-
noBrowser = true;
|
|
161
|
-
else if (rest[i] === "--another-account")
|
|
162
|
-
another = true;
|
|
163
|
-
else if (rest[i] === "--with-key")
|
|
164
|
-
withKey = true;
|
|
165
|
-
else if (rest[i] === "--wait")
|
|
166
|
-
wait = true;
|
|
167
|
-
else if (rest[i] === "--no-wait")
|
|
168
|
-
wait = false;
|
|
169
|
-
else if (rest[i] === "--agent-name" && rest[i + 1])
|
|
170
|
-
agentName = rest[++i];
|
|
171
|
-
else
|
|
172
|
-
throw new Error(named("Use `runtime login [--agent-name <name>] [--no-browser] [--wait]`, or `runtime login --with-key` to paste a key."));
|
|
173
|
-
}
|
|
174
|
-
if (!agentName.trim() ||
|
|
175
|
-
agentName.length > 80 ||
|
|
176
|
-
[...agentName].some((char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127))
|
|
177
|
-
throw new Error("Give the agent a name of up to 80 characters.");
|
|
178
|
-
checkBrowserOrigins(origins);
|
|
179
|
-
if (withKey) {
|
|
180
|
-
// The fallback to a browser approval: a key from the website, read from
|
|
181
|
-
// standard input so it never sits in a command line or shell history.
|
|
182
|
-
const key = (await (options.readKey ?? readKey)()).trim();
|
|
183
|
-
if (!/^rtcloud_[a-f0-9-]{36}_[A-Za-z0-9_-]{43}$/.test(key))
|
|
184
|
-
throw new Error("That is not a Runtime key: keys start with rtcloud_. Create one at https://withruntime.com/account/keys.");
|
|
185
|
-
const account = await new Runtime({ apiKey: key, baseUrl: origins.api, fetch: fetcher }).me();
|
|
186
|
-
await store.save({
|
|
187
|
-
version: 1,
|
|
188
|
-
apiOrigin: origins.api,
|
|
189
|
-
authOrigin: origins.auth,
|
|
190
|
-
key,
|
|
191
|
-
connectionId: PASTED,
|
|
192
|
-
orgId: account.orgId,
|
|
193
|
-
agentName: "pasted key",
|
|
194
|
-
});
|
|
195
|
-
return { connected: true, agentName: "pasted key", orgId: account.orgId, source: "key" };
|
|
196
|
-
}
|
|
197
|
-
if (env.RUNTIME_API_KEY) {
|
|
198
|
-
await new Runtime({
|
|
199
|
-
apiKey: env.RUNTIME_API_KEY,
|
|
200
|
-
baseUrl: origins.api,
|
|
201
|
-
fetch: fetcher,
|
|
202
|
-
}).usage();
|
|
203
|
-
return { connected: true, source: "environment" };
|
|
204
|
-
}
|
|
205
|
-
const saved = another ? null : await store.read();
|
|
206
|
-
if (saved) {
|
|
207
|
-
try {
|
|
208
|
-
await request("confirm", undefined, saved.key);
|
|
209
|
-
return { connected: true, agentName: saved.agentName, orgId: saved.orgId };
|
|
210
|
-
}
|
|
211
|
-
catch (error) {
|
|
212
|
-
if (!(error instanceof ConnectionError && error.status === 401))
|
|
213
|
-
throw error;
|
|
214
|
-
await store.remove(saved.key);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
const pending = await beginDeviceLogin(env, agentName, options);
|
|
218
|
-
// A person at a terminal waits for the approval. An agent's tool call waits
|
|
219
|
-
// briefly and then hands back the link, and --no-browser (the person is on
|
|
220
|
-
// another device) hands it back at once: the request is saved, so the next
|
|
221
|
-
// command, or `login --wait`, finishes it.
|
|
222
|
-
const interactive = options.interactive ?? Boolean(process.stdin.isTTY && process.stderr.isTTY);
|
|
223
|
-
const budget = wait === true || (wait === undefined && interactive && !noBrowser)
|
|
224
|
-
? Infinity
|
|
225
|
-
: wait === false || noBrowser
|
|
226
|
-
? 0
|
|
227
|
-
: AGENT_WAIT_MS;
|
|
228
|
-
const until = Math.min(pending.expiresAt, Date.now() + budget);
|
|
229
|
-
notify(`Connect your agent: ${pending.url}\nCheck that the browser shows code ${pending.userCode}, then choose Connect agent.${budget > 0 ? "\nWaiting for the approval. Stopping this is safe: running it again keeps the same link." : ""}`);
|
|
230
|
-
if (!noBrowser && !pending.resumed)
|
|
231
|
-
await (options.openBrowser ?? browser)(pending.url).catch(() => notify("Open the connection link in your browser to continue."));
|
|
232
|
-
for (let first = true; first || Date.now() < until; first = false) {
|
|
233
|
-
if (!first || !pending.resumed) {
|
|
234
|
-
if (budget === 0)
|
|
235
|
-
break;
|
|
236
|
-
await sleep(3000);
|
|
237
|
-
}
|
|
238
|
-
const outcome = await pending.check();
|
|
239
|
-
if (outcome === "expired")
|
|
240
|
-
throw new Error(named("The connection expired. Run `runtime login` again."));
|
|
241
|
-
if (outcome !== "pending")
|
|
242
|
-
return outcome;
|
|
243
|
-
}
|
|
244
|
-
if (Date.now() >= pending.expiresAt)
|
|
245
|
-
throw new Error(named("The connection expired. Run `runtime login` again."));
|
|
246
|
-
return {
|
|
247
|
-
connected: false,
|
|
248
|
-
pending: true,
|
|
249
|
-
url: pending.url,
|
|
250
|
-
userCode: pending.userCode,
|
|
251
|
-
expiresAt: new Date(pending.expiresAt).toISOString(),
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
/** Starts a browser-approved connection and hands back its link, without
|
|
255
|
-
* waiting: `runtime login` waits on it, and the MCP bridge gives the link to
|
|
256
|
-
* the agent, which shows it to the person it works for. */
|
|
257
|
-
export async function beginDeviceLogin(env, agentName, options = {}) {
|
|
258
|
-
const { origins, store, request } = connection(env, options);
|
|
259
|
-
checkBrowserOrigins(origins);
|
|
260
|
-
// A request this machine already started and nobody has answered yet: pick
|
|
261
|
-
// it up, so a command stopped while it waited (an agent's tool timing out)
|
|
262
|
-
// shows the same link and code again rather than a new one to approve.
|
|
263
|
-
let pending = await store.readPending();
|
|
264
|
-
const resumed = pending !== null;
|
|
265
|
-
if (!pending) {
|
|
266
|
-
const pair = await sealing.pair();
|
|
267
|
-
// The computer's own name goes to the approval page beside the code, so an
|
|
268
|
-
// owner can tell this request from a link somebody else started.
|
|
269
|
-
const started = await request("start", {
|
|
270
|
-
agentName,
|
|
271
|
-
publicKey: pair.publicKey,
|
|
272
|
-
machine: hostname(),
|
|
273
|
-
});
|
|
274
|
-
if (typeof started.verificationUri !== "string" ||
|
|
275
|
-
typeof started.deviceCode !== "string" ||
|
|
276
|
-
!/^[A-Za-z0-9_-]{43}$/.test(started.deviceCode) ||
|
|
277
|
-
typeof started.userCode !== "string" ||
|
|
278
|
-
!/^[A-F0-9]{4}(-[A-F0-9]{4}){2}$/.test(started.userCode) ||
|
|
279
|
-
typeof started.expiresAt !== "number" ||
|
|
280
|
-
!Number.isFinite(started.expiresAt))
|
|
281
|
-
throw new Error("Runtime returned an invalid connection request.");
|
|
282
|
-
const verification = new URL(started.verificationUri);
|
|
283
|
-
if (verification.origin !== origins.auth ||
|
|
284
|
-
verification.pathname !== "/connect" ||
|
|
285
|
-
verification.username ||
|
|
286
|
-
verification.password ||
|
|
287
|
-
verification.hash ||
|
|
288
|
-
[...verification.searchParams.keys()].some((name) => name !== "code") ||
|
|
289
|
-
verification.searchParams.get("code") !== started.userCode)
|
|
290
|
-
throw new Error("Runtime returned an unexpected connection address.");
|
|
291
|
-
pending = {
|
|
292
|
-
version: 1,
|
|
293
|
-
apiOrigin: origins.api,
|
|
294
|
-
authOrigin: origins.auth,
|
|
295
|
-
privateKey: pair.privateKey,
|
|
296
|
-
deviceCode: started.deviceCode,
|
|
297
|
-
url: verification.href,
|
|
298
|
-
userCode: started.userCode,
|
|
299
|
-
agentName,
|
|
300
|
-
expiresAt: Math.min(started.expiresAt, Date.now() + 15 * 60_000),
|
|
301
|
-
};
|
|
302
|
-
await store.savePending(pending);
|
|
303
|
-
}
|
|
304
|
-
const { deviceCode, privateKey } = pending;
|
|
305
|
-
const name = pending.agentName;
|
|
306
|
-
return {
|
|
307
|
-
url: pending.url,
|
|
308
|
-
userCode: pending.userCode,
|
|
309
|
-
expiresAt: pending.expiresAt,
|
|
310
|
-
resumed,
|
|
311
|
-
async check() {
|
|
312
|
-
let result;
|
|
313
|
-
try {
|
|
314
|
-
result = await request("token", { deviceCode });
|
|
315
|
-
}
|
|
316
|
-
catch (error) {
|
|
317
|
-
if (error instanceof ConnectionError && error.status >= 500)
|
|
318
|
-
return "pending";
|
|
319
|
-
await store.removePending();
|
|
320
|
-
throw error;
|
|
321
|
-
}
|
|
322
|
-
if (result.status === "pending")
|
|
323
|
-
return "pending";
|
|
324
|
-
// Answered either way: the next attempt starts afresh. An approval
|
|
325
|
-
// forgets the request only once its key is saved.
|
|
326
|
-
if (result.status === "denied") {
|
|
327
|
-
await store.removePending();
|
|
328
|
-
throw new Error("The connection was declined.");
|
|
329
|
-
}
|
|
330
|
-
if (result.status === "expired") {
|
|
331
|
-
await store.removePending();
|
|
332
|
-
return "expired";
|
|
333
|
-
}
|
|
334
|
-
if (result.status !== "connected" ||
|
|
335
|
-
typeof result.encryptedKey !== "string" ||
|
|
336
|
-
typeof result.connectionId !== "string" ||
|
|
337
|
-
typeof result.orgId !== "string") {
|
|
338
|
-
await store.removePending();
|
|
339
|
-
throw new Error("Runtime returned an invalid connection result.");
|
|
340
|
-
}
|
|
341
|
-
let key;
|
|
342
|
-
try {
|
|
343
|
-
key = privateDecrypt({ key: privateKey, oaepHash: "sha256" }, Buffer.from(result.encryptedKey, "base64")).toString("utf8");
|
|
344
|
-
}
|
|
345
|
-
catch {
|
|
346
|
-
await store.removePending();
|
|
347
|
-
throw new Error("Could not verify Runtime's connection result. Start again.");
|
|
348
|
-
}
|
|
349
|
-
if (!/^rtcloud_[a-f0-9-]{36}_[A-Za-z0-9_-]{43}$/.test(key)) {
|
|
350
|
-
await store.removePending();
|
|
351
|
-
throw new Error("Runtime returned an invalid credential.");
|
|
352
|
-
}
|
|
353
|
-
// Persist before confirmation: losing the response must never lose access
|
|
354
|
-
// or make onboarding falsely report that the agent is connected.
|
|
355
|
-
await store.save({
|
|
356
|
-
version: 1,
|
|
357
|
-
apiOrigin: origins.api,
|
|
358
|
-
authOrigin: origins.auth,
|
|
359
|
-
key,
|
|
360
|
-
connectionId: result.connectionId,
|
|
361
|
-
orgId: result.orgId,
|
|
362
|
-
agentName: name,
|
|
363
|
-
});
|
|
364
|
-
await store.removePending();
|
|
365
|
-
await request("confirm", undefined, key);
|
|
366
|
-
return { connected: true, agentName: name, orgId: result.orgId };
|
|
367
|
-
},
|
|
368
|
-
};
|
|
369
|
-
}
|