Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add route for creating streams
Vasek Mlejnsky15c52349ac69
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 40344d7cc..4c46128f7 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -18,6 +18,7 @@"@headlessui/tailwindcss": "^0.2.0","@mdx-js/loader": "^2.1.5","@mdx-js/react": "^2.1.5",+ "@mux/mux-node": "^9.0.1","@next/mdx": "^14.2.5","@nivo/line": "^0.87.0","@radix-ui/react-alert-dialog": "^1.0.5",diff --git a/apps/web/src/app/(docs)/docs/api-reference/js-sdk/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/page.mdxindex 10f6b374a..4c579f40c 100644--- a/apps/web/src/app/(docs)/docs/api-reference/js-sdk/page.mdx+++ b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/page.mdx@@ -3,6 +3,7 @@<a href="/docs/api-reference/js-sdk/v1.0.2" class="version-link">[v1.0.2]</a><a href="/docs/api-reference/js-sdk/v1.0.3" class="version-link">[v1.0.3]</a><a href="/docs/api-reference/js-sdk/v1.0.4" class="version-link">[v1.0.4]</a>+ <a href="/docs/api-reference/js-sdk/v1.0.5" class="version-link">[v1.0.5]</a># js-sdkdiff --git a/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/page.mdx b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/page.mdxnew file mode 100644index 000000000..61e14ae2f--- /dev/null+++ b/apps/web/src/app/(docs)/docs/api-reference/js-sdk/v1.0.5/page.mdx@@ -0,0 +1,5 @@+# JS-SDK v1.0.5++- [Errors](./v1.0.5/errors)+- [Filesystem](./v1.0.5/filesystem)+- [Sandbox](./v1.0.5/sandbox)\ No newline at end of filediff --git a/apps/web/src/app/api/desktop/stream/route.ts b/apps/web/src/app/api/desktop/stream/route.tsnew file mode 100644index 000000000..8c0b73306--- /dev/null+++ b/apps/web/src/app/api/desktop/stream/route.ts@@ -0,0 +1,46 @@+import Mux from '@mux/mux-node'+import { NextResponse } from 'next/server'++import { createClient } from '@supabase/supabase-js'++const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL!+const supabaseServiceKey = process.env.SUPABASE_SERVICE_ROLE_KEY!++const supabase = createClient(supabaseUrl, supabaseServiceKey)++const mux = new Mux({+ tokenId: process.env.MUX_TOKEN_ID,+ tokenSecret: process.env.MUX_TOKEN_SECRET+})++export async function POST(request: Request) {+ // TODO: UseG apiKey+ // const apiKey = request.headers.get('X-API-Key')+ const { sandboxId } = await request.json()+ console.log('sandboxId', sandboxId)++ // if (!apiKey) {+ // return NextResponse.json({ error: 'Missing X-API-Key' }, { status: 400 })+ // }++ if (!sandboxId) {+ return NextResponse.json({ error: 'Missing sandboxId' }, { status: 400 })+ }++ const liveStream = await mux.video.liveStreams.create({+ latency_mode: 'low',+ reconnect_window: 60,+ playback_policy: ['public'],+ new_asset_settings: { playback_policy: ['public'] },+ })++ if (!liveStream.playback_ids?.[0]?.id) {+ return NextResponse.json({ error: 'Failed to create live stream' }, { status: 500 })+ }++ await supabase+ .from('sandbox_streams')+ .insert([{ sandbox_id: sandboxId, playback_id: liveStream.playback_ids[0].id }])++ return NextResponse.json({ streamKey: liveStream.stream_key, playbackId: liveStream.playback_ids[0].id }, { status: 201 })+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a547a05d7..f04772721 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -48,6 +48,9 @@ importers:'@mdx-js/react':specifier: ^2.1.5version: 2.3.0([email protected])+ '@mux/mux-node':+ specifier: ^9.0.1+ version: 9.0.1([email protected])'@next/mdx':specifier: ^14.2.5version: 14.2.5(@mdx-js/[email protected]([email protected]))(@mdx-js/[email protected]([email protected]))@@ -395,7 +398,7 @@ importers:version: 2.1.2(@types/[email protected])(@vitest/[email protected])([email protected]([email protected]))([email protected])vitest-browser-react:specifier: ^0.0.1- version: 0.0.1(@types/[email protected])(@types/[email protected])(@vitest/[email protected](@vitest/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]([email protected]))([email protected]))+ version: 0.0.1(@types/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected]([email protected]))([email protected])([email protected])packages/python-sdk: {}@@ -1355,6 +1358,9 @@ packages:resolution: {integrity: sha512-SSnyl/4ni/2ViHKkiZb8eajA/eN1DNFaHjhGiLUdZvDz6PKF4COSf/17xqSz64nOo2Ia29SA6B2KNCsyCbVmaQ==}engines: {node: '>=18'}+ '@mux/[email protected]':+ resolution: {integrity: sha512-+wSqwCkb3/RplJkhd35R44+Ov1pQTzXDJSCLF8yxBRodUL2uqG/ajCSix+miIiPNY+v/tx0rJ9+t6dxe2ZR/Dg==}+'@next/[email protected]':resolution: {integrity: sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==}@@ -2706,6 +2712,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-wK1pzsJVVAjYCSZWQoWHziQZbNggXFDUEIGf54g4ZM/ERuP86uGdWeKZWMYlqTPMZfHJJvLPyogXGvCOg87yLQ==}+ '@types/[email protected]':+ resolution: {integrity: sha512-8nneRWKCg3rMtF69nLQJnOYUcbafYeFSjqkw3jCRLsqkWFlHaoQrr5mXmofFGOx3DKn7UfmBMyov8ySvLRVldA==}+'@types/[email protected]':resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}@@ -3080,6 +3089,10 @@ packages:resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}+ resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}+ engines: {node: '>=6.5'}+resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==}deprecated: package has been renamed to acorn-import-attributes@@ -3254,6 +3267,9 @@ packages:resolution: {integrity: sha512-wwHYEIS0Q80f5mosx3L/dfG5t5rjEa9Ft51GTaNt862EnpyGHpgz2RkZvLPp1oF5TnAiTohkEKVEu8pQPJI7Vg==}+ resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==}+resolution: {integrity: sha512-KCuPB8ZCIqFdA4HwKXsvz7j6gvSDNhDP7WnUjBleRkKjPdvCmHFuQ77ocavI8FT6NdvlBnE2UFr2H4Mycn8Vew==}engines: {node: ^10 || ^12 || >=14}@@ -3600,6 +3616,10 @@ packages:resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}engines: {node: '>=12.5.0'}+ resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}+ engines: {node: '>= 0.8'}+resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==}@@ -3869,6 +3889,10 @@ packages:resolution: {integrity: sha512-8nvh+XBe96aCESrGOqMp/84b13H9cdKbG5P2ejQCh4d4sK9RL4371qou9drQjMhvnPmhWl5hnmqbEE0fXr9Xnw==}+ resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==}+ engines: {node: '>=0.4.0'}+resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==}@@ -4229,6 +4253,10 @@ packages:resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}+ engines: {node: '>=6'}+resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}engines: {node: '>=0.8.x'}@@ -4361,10 +4389,21 @@ packages:resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==}engines: {node: '>=14'}+ resolution: {integrity: sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==}+resolution: {integrity: sha512-yDYSgNMraqvnxiEXO4hi88+YZxaHC6QKzb5N84iRCTDeRO7ZALpir/lVmf/uXUhnwUr2O4HU8s/n6x+yNjQkHw==}engines: {node: '>= 14.17'}+ resolution: {integrity: sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==}+ engines: {node: '>= 6'}++ resolution: {integrity: sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==}+ engines: {node: '>= 12.20'}+resolution: {integrity: sha512-+yRYRhpnFPWXSly/6V4Lw9IfOV26uu30kynGJ03PW+MnjOEQe45RZ141QcS0aJehYBYA50GfCDnsRbFJdhssRw==}engines: {node: '>=10'}@@ -5775,6 +5814,10 @@ packages:resolution: {integrity: sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==}+ resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}+ engines: {node: '>=10.5.0'}+resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}engines: {node: 4.x || >=6.0.0}@@ -7678,6 +7721,10 @@ packages:resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==}+ resolution: {integrity: sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==}+ engines: {node: '>= 14'}+resolution: {integrity: sha512-nYfoOqb4EmElljyXU2qdeE76KsvoHdftQKY4DzA9Aw8DervCg2bG634pHLrJ/d6+B4mE3nWTSJv8Mo7B2mbZkw==}@@ -8971,6 +9018,19 @@ snapshots:outvariant: 1.4.3strict-event-emitter: 0.5.1+ '@mux/[email protected]([email protected])':+ dependencies:+ '@types/node': 18.18.6+ '@types/node-fetch': 2.6.12+ abort-controller: 3.0.0+ agentkeepalive: 4.5.0+ form-data-encoder: 1.7.2+ formdata-node: 4.4.1+ jose: 4.14.6+ node-fetch: 2.7.0([email protected])+ transitivePeerDependencies:+ - encoding+'@next/[email protected]': {}'@next/[email protected]':@@ -10615,6 +10675,11 @@ snapshots:dependencies:'@types/node': 18.18.6+ '@types/[email protected]':+ dependencies:+ '@types/node': 18.18.6+ form-data: 4.0.1+'@types/[email protected]': {}'@types/[email protected]': {}@@ -11108,6 +11173,10 @@ snapshots:+ dependencies:+ event-target-shim: 5.0.1+dependencies:acorn: 8.11.3@@ -11303,6 +11372,8 @@ snapshots:dependencies:has-symbols: 1.0.3+ [email protected]: {}+dependencies:browserslist: 4.21.10@@ -11683,6 +11754,10 @@ snapshots:color-convert: 2.0.1color-string: 1.9.1+ dependencies:+ delayed-stream: 1.0.0+@@ -11929,6 +12004,8 @@ snapshots:dependencies:robust-predicates: 3.0.2+ [email protected]: {}+@@ -12271,7 +12348,7 @@ snapshots:debug: 4.3.4enhanced-resolve: 5.15.0eslint: 8.57.1- eslint-module-utils: 2.8.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])+ eslint-module-utils: 2.8.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected])eslint-plugin-import: 2.28.1(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])fast-glob: 3.3.1get-tsconfig: 4.7.0@@ -12283,7 +12360,17 @@ snapshots:- eslint-import-resolver-webpack- supports-color- [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected]):+ [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected]):+ dependencies:+ debug: 3.2.7+ optionalDependencies:+ '@typescript-eslint/parser': 6.7.2([email protected])([email protected])+ eslint: 8.57.1+ eslint-import-resolver-node: 0.3.9+ transitivePeerDependencies:+ - supports-color++ [email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]):dependencies:debug: 3.2.7optionalDependencies:@@ -12304,7 +12391,7 @@ snapshots:doctrine: 2.1.0eslint: 8.57.1eslint-import-resolver-node: 0.3.9- eslint-module-utils: 2.8.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])([email protected]))([email protected])+ eslint-module-utils: 2.8.0(@typescript-eslint/[email protected]([email protected])([email protected]))([email protected])([email protected])has: 1.0.3is-core-module: 2.13.0is-glob: 4.0.3@@ -12522,6 +12609,8 @@ snapshots:+ [email protected]: {}+@@ -12661,8 +12750,21 @@ snapshots:cross-spawn: 7.0.3signal-exit: 4.1.0+ [email protected]: {}++ dependencies:+ asynckit: 0.4.0+ combined-stream: 1.0.8+ mime-types: 2.1.35++ dependencies:+ node-domexception: 1.0.0+ web-streams-polyfill: 4.0.0-beta.3+@@ -14361,6 +14463,8 @@ snapshots:+ [email protected]: {}+dependencies:whatwg-url: 5.0.0@@ -16449,7 +16553,7 @@ snapshots:fsevents: 2.3.3terser: 5.20.0- [email protected](@types/[email protected])(@types/[email protected])(@vitest/[email protected](@vitest/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected]))([email protected]))([email protected]([email protected]))([email protected])([email protected](@types/[email protected])(@vitest/[email protected])([email protected]([email protected]))([email protected])):+ [email protected](@types/[email protected])(@types/[email protected])(@vitest/[email protected])([email protected]([email protected]))([email protected])([email protected]):dependencies:'@vitest/browser': 2.1.2(@vitest/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected](@types/[email protected])([email protected]))([email protected])react: 18.3.1@@ -16509,6 +16613,8 @@ snapshots:dependencies:defaults: 1.0.4+ [email protected]: {}+