Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Prepare streaming page for desktop sandbox
Vasek Mlejnskyb390945b4ee6
diff --git a/apps/web/package.json b/apps/web/package.jsonindex 4c46128f7..0a6df6d40 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -19,6 +19,7 @@"@mdx-js/loader": "^2.1.5","@mdx-js/react": "^2.1.5","@mux/mux-node": "^9.0.1",+ "@mux/mux-player-react": "^3.1.0","@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/api/desktop/stream/route.ts b/apps/web/src/app/api/stream/sandbox/route.tssimilarity index 70%rename from apps/web/src/app/api/desktop/stream/route.tsrename to apps/web/src/app/api/stream/sandbox/route.tsindex af875e079..999c7b30b 100644--- a/apps/web/src/app/api/desktop/stream/route.ts+++ b/apps/web/src/app/api/stream/sandbox/route.ts@@ -44,3 +44,24 @@ export async function POST(request: Request) {return NextResponse.json({ streamKey: liveStream.stream_key }, { status: 201 })}++export async function GET(request: Request) {+ const url = new URL(request.url)+ const sandboxId = url.searchParams.get('sandboxId')++ if (!sandboxId) {+ return NextResponse.json({ error: 'Missing sandboxId' }, { status: 400 })+ }++ const { data, error } = await supabase+ .from('sandbox_streams')+ .select('playback_id')+ .eq('sandbox_id', sandboxId)+ .single()++ if (error || !data) {+ return NextResponse.json({ error: 'Playback ID not found' }, { status: 404 })+ }++ return NextResponse.json({ playbackId: data.playback_id }, { status: 200 })+}diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsxindex f16556055..712e03eea 100644--- a/apps/web/src/app/layout.tsx+++ b/apps/web/src/app/layout.tsx@@ -13,8 +13,6 @@ import { Section } from '@/components/SectionProvider'import { Layout } from '@/components/Layout'export const metadata: Metadata = {- // TODO: Add metadataBase- // metadataBase: ''title: {template: '%s - E2B',default: 'E2B - Code Interpreting for AI apps',diff --git a/apps/web/src/app/not-found.tsx b/apps/web/src/app/not-found.tsxnew file mode 100644index 000000000..b2a8d2f44--- /dev/null+++ b/apps/web/src/app/not-found.tsx@@ -0,0 +1,11 @@+import Link from 'next/link'++export default function NotFound() {+ return (+ <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100vh' }}>+ <h2>Not Found</h2>+ <p>Could not find requested resource</p>+ <Link href="/" style={{ textDecoration: 'underline', color: '#ff8800' }}>Return Home</Link>+ </div>+ )+}diff --git a/apps/web/src/app/stream/sandbox/page.tsx b/apps/web/src/app/stream/sandbox/page.tsxnew file mode 100644index 000000000..b4b1574b3--- /dev/null+++ b/apps/web/src/app/stream/sandbox/page.tsx@@ -0,0 +1,65 @@+'use client'++import { useSearchParams } from 'next/navigation'+import { useEffect, useState } from 'react'+import MuxPlayer from '@mux/mux-player-react'++++interface SandboxStream {+ sandboxId: string+ playbackId: string+}++export default function StreamPage() {+ const searchParams = useSearchParams()+ const sandboxId = searchParams.get('sandboxId')+ const [stream, setStream] = useState<SandboxStream | null>(null)+ const [error, setError] = useState<string | null>(null)++ useEffect(() => {+ const fetchStream = async () => {+ if (sandboxId) {+ try {+ const response = await fetch(`/api/stream/sandbox?sandboxId=${sandboxId}`)+ if (!response.ok) {+ throw new Error('Network response was not ok')+ }+ const data = await response.json()+ setStream(data)+ } catch (err) {+ setError(err.message)+ }+ }+ }++ fetchStream()+ }, [sandboxId])++ if (error) {+ return <div>Error loading stream: {error}</div>+ }++ if (!stream) {+ return <div>Stream not found</div>+ }+ console.log('stream', stream)++ return (+ <div>+ hello+ <h1>Stream Details</h1>+ <div>Sandbox ID: {stream.sandboxId}</div>+ <div>Playback ID: {stream.playbackId}</div>++ <MuxPlayer+ playbackId={stream.playbackId}+ metadata={{+ video_id: 'video-id-54321',+ video_title: 'Test video title',+ viewer_user_id: 'user-id-007',+ }}+ />+ </div>+ )+}\ No newline at end of filediff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.tsindex b9b8f317d..1b6aa0d0c 100644--- a/apps/web/src/middleware.ts+++ b/apps/web/src/middleware.ts@@ -5,6 +5,7 @@ export async function middleware(req: NextRequest): Promise<NextResponse> {if (req.method !== 'GET') return NextResponse.next()const url = new URL(req.nextUrl.toString())+ console.log('url', url)url.protocol = 'https'url.port = ''diff --git a/apps/web/src/pages/_404/[...path].tsx b/apps/web/src/pages/_404/[...path].tsxdeleted file mode 100644index 3be8c9c6f..000000000--- a/apps/web/src/pages/_404/[...path].tsx+++ /dev/null@@ -1,15 +0,0 @@-import { GetServerSideProps } from 'next'--// https://github.com/vercel/next.js/discussions/16749#discussioncomment-2992732-export const getServerSideProps: GetServerSideProps = async () => {- return {- redirect: {- destination: '/',- permanent: false,- },- }-}--export default function Custom404() {- return null-}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f04772721..514984756 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -51,6 +51,9 @@ importers:'@mux/mux-node':specifier: ^9.0.1version: 9.0.1([email protected])+ '@mux/mux-player-react':+ specifier: ^3.1.0+ version: 3.1.0(@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])'@next/mdx':specifier: ^14.2.5version: 14.2.5(@mdx-js/[email protected]([email protected]))(@mdx-js/[email protected]([email protected]))@@ -1361,6 +1364,28 @@ packages:'@mux/[email protected]':resolution: {integrity: sha512-+wSqwCkb3/RplJkhd35R44+Ov1pQTzXDJSCLF8yxBRodUL2uqG/ajCSix+miIiPNY+v/tx0rJ9+t6dxe2ZR/Dg==}+ '@mux/[email protected]':+ resolution: {integrity: sha512-oJWcRtDNE84KKSi/5tz7CKGHBLA34V9XlLnv30qqVMAvfifa3S0lY82gP41YA0OfYANwp5Sg29bbh3quekusPg==}+ peerDependencies:+ '@types/react': ^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0+ '@types/react-dom': '*'+ react: ^17.0.2 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0+ react-dom: ^17.0.2 || ^17.0.2-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0+ peerDependenciesMeta:+ '@types/react':+ optional: true+ '@types/react-dom':+ optional: true++ '@mux/[email protected]':+ resolution: {integrity: sha512-vU7HjvM3KLDfMwMfjbotlhjQrakwm9A4zixxtzBdxwDMLKf0FUKiFOGyTGOdsIKNBRVlS5Ffz9ERU+3Hh+XcBQ==}++ '@mux/[email protected]':+ resolution: {integrity: sha512-VrY4AVc6KkQcG0EPOtHf7aGXFwO1DTLZKtRRdPCx0KWSAlwR1II5YnHcEAwPbi1Uv94Hykq3Lbjt5dLqRNXKtA==}++ '@mux/[email protected]':+ resolution: {integrity: sha512-9kzpGRJNXLNMfFV6hvOde2+Uy3HyllwwEt9H5r4gYXOmrivQ6IWIGr9nXrUy7fmNkx6H05W+96zt1GhtBTlSDQ==}+'@next/[email protected]':resolution: {integrity: sha512-/zZGkrTOsraVfYjGP8uM0p6r0BDT6xWpkjdVbcz66PJVSpwXX3yNiRycxAuDfBKGWBrZBXRuK/YVlkNgxHGwmA==}@@ -3454,6 +3479,9 @@ packages:resolution: {integrity: sha512-7LTwJjcRkzKFmtqGsibMeuXmvFDfZq/nzIjnmgCGzKKRVzjD72selLDK1oPF/Oxzmt4fNcPvTDvGqSDG4tCALw==}+ resolution: {integrity: sha512-64/roq+vieXz8aOEvSs5bohHRym1fxhvHQMZXPn8/s8z0oi7XD5B67fnt9gFyCsfzH8RnuYJ0PxMSYjbMPHOtw==}+resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==}@@ -3720,6 +3748,9 @@ packages:resolution: {integrity: sha512-QTaY0XjjhTQOdguARF0lGKm5/mEq9PD9/VhZZegHDIBq2tQwgNpHc3dneD4mGo2iJs+fTKv5Bp0fZ+BRuY3Z0g==}engines: {node: '>= 0.1.90'}+ resolution: {integrity: sha512-nDyMobZgoAVqz7mA8rsn7i1/6bjH6N9ab2Ge7LyyNxrvxAq7zQJPg8i3u2VH7wEB+Y1T1+C3/h1G774/D+ZLag==}+resolution: {integrity: sha512-B0ErZK/66mHtEsR1TkPEEkwdy+WDesimkM5gpZr5Dsg54BiTA5RXtYW5qTLIAcekaS9xfZrzBLF/OAkB3Qn1YQ==}@@ -4664,6 +4695,9 @@ packages:resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==}+ resolution: {integrity: sha512-wA66nnYFvQa1o4DO/BFgLNRKnBTVXpNeldGRBJ2Y0SvFtdwvFKCbqa9zhHoZLoxHhZ+jYsj3aIBkWQQCPNOhMw==}+resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==}@@ -5451,6 +5485,12 @@ packages:resolution: {integrity: sha512-2XrOlQeBDUa8GirNHy/Y7BR1h/P+vzk+1G2rzAfqJ+lg6JcEOKMCqsVkpVFSw0hdzpVuj9BnoNeA+aU1XPTkoA==}+ resolution: {integrity: sha512-gzwFy2b+RLsEtnPzUzqzf2L5XkaTLQr8POOyLOcoebWSAWg31cPy2vfXNiUnd93sc5IxwJ8OAwkKxnaJNZ8Gjg==}++ resolution: {integrity: sha512-9P2FuUHnZZ3iji+2RQk7Zkh5AmZTnOG5fODACnjhCVveX1McY3jmCRHofIEI+yTBqplz7LXy48c7fQ3Uigp88w==}+resolution: {integrity: sha512-Ci6bIfq/UgcxPTYa8dQQ5FY3BzKkT894bwXWXxC/zqs0XgMO2cT20CGkOqda7gZNkmK5VP4x89IGZ6K7hfbn3Q==}engines: {node: '>=8'}@@ -5748,6 +5788,9 @@ packages:resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==}engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}+ resolution: {integrity: sha512-WsBV/K5tXiXi5pg1Ex65rO8gbHqljdbwfNuDNYVYsV8jZ1pe9leFe9ElSYfVa2nsooCBB196X+FKXlZs9KPYog==}+resolution: {integrity: sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==}@@ -6227,6 +6270,9 @@ packages:resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}+ resolution: {integrity: sha512-ScmFzio3634eEn+ejpkEw13F5xYvnPghtaZz/Kg7QQP78ECrxdjRVqwVPZhUwbYxmg5OIScByOgHfrHpzTtR1Q==}+resolution: {integrity: sha512-RBvzjM9rdpP7UUFrQzRwR8L/xR4HyC1QXMzGYTbf1vjw25/ya9NRAVnXi/0fvFopjebvyPzsmoK58xxeEOaVvA==}engines: {node: '>=18'}@@ -9031,6 +9077,36 @@ snapshots:transitivePeerDependencies:- encoding+ '@mux/[email protected](@types/[email protected])(@types/[email protected])([email protected]([email protected]))([email protected])':+ dependencies:+ '@mux/mux-player': 3.1.0+ '@mux/playback-core': 0.27.0+ prop-types: 15.8.1+ react: 18.2.0+ react-dom: 18.2.0([email protected])+ optionalDependencies:+ '@types/react': 18.2.48+ '@types/react-dom': 18.2.7++ '@mux/[email protected]':+ dependencies:+ '@mux/mux-video': 0.22.0+ '@mux/playback-core': 0.27.0+ media-chrome: 4.2.3+ player.style: 0.0.8++ '@mux/[email protected]':+ dependencies:+ '@mux/playback-core': 0.27.0+ castable-video: 1.1.0+ custom-media-element: 1.3.2+ media-tracks: 0.3.3++ '@mux/[email protected]':+ dependencies:+ hls.js: 1.5.17+ mux-embed: 5.4.1+'@next/[email protected]': {}'@next/[email protected]':@@ -11586,6 +11662,10 @@ snapshots:+ dependencies:+ custom-media-element: 1.3.2+@@ -11855,6 +11935,8 @@ snapshots:csv-stringify: 5.6.5stream-transform: 2.1.3+ [email protected]: {}+dependencies:internmap: 1.0.1@@ -13080,6 +13162,8 @@ snapshots:+ [email protected]: {}+dependencies:react-is: 16.13.1@@ -13949,6 +14033,10 @@ snapshots:estree-util-visit: 1.2.1unist-util-visit: 4.1.2+ [email protected]: {}++ [email protected]: {}+dependencies:map-age-cleaner: 0.1.3@@ -14397,6 +14485,8 @@ snapshots:+ [email protected]: {}+dependencies:any-promise: 1.3.0@@ -14978,6 +15068,10 @@ snapshots:+ dependencies:+ media-chrome: 4.2.3+