Prepare repository for Amp orbs (#18)
* Prepare repository for Amp orbs Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Declare Amp preview service and portal Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Allow E2B portal hosts in Vite preview Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Enable WebGPU for agent-browser Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Install virtual display for WebGPU captures Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Revert Amp orb setup pending review Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Prepare repository for Amp orbs Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Declare Amp preview service and portal Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Allow E2B portal hosts in Vite preview Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Enable WebGPU for agent-browser Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Install virtual display for WebGPU captures Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> * Address orb portal review feedback Amp-Thread-ID: https://ampcode.com/threads/T-019f8509-6815-71df-b137-f40075cd06f8 Co-authored-by: Akash Shakdwipeea <ashakdwipeea@gmail.com> --------- Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||||
|
|
||||||
|
for command in node npm cargo wasm-pack rsw; do
|
||||||
|
if ! command -v "$command" >/dev/null 2>&1; then
|
||||||
|
echo "Missing required command after orb resume: $command" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Orb environment ready."
|
||||||
Executable
+124
@@ -0,0 +1,124 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
NODE_VERSION="22.23.1"
|
||||||
|
WASM_PACK_VERSION="0.15.0"
|
||||||
|
RSW_VERSION="0.8.0"
|
||||||
|
|
||||||
|
export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH"
|
||||||
|
mkdir -p "$HOME/.local/bin" "$HOME/.cargo/bin"
|
||||||
|
|
||||||
|
missing_packages=()
|
||||||
|
for package in libvulkan1 mesa-vulkan-drivers xauth xvfb; do
|
||||||
|
if ! dpkg-query -W -f='${Status}' "$package" 2>/dev/null | grep -Fq "install ok installed"; then
|
||||||
|
missing_packages+=("$package")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ((${#missing_packages[@]})); then
|
||||||
|
echo "Installing WebGPU runtime dependencies..."
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y "${missing_packages[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_node() {
|
||||||
|
local machine node_arch archive install_dir tmp_dir
|
||||||
|
machine="$(uname -m)"
|
||||||
|
case "$machine" in
|
||||||
|
x86_64) node_arch="x64" ;;
|
||||||
|
aarch64) node_arch="arm64" ;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture for Node.js: $machine" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
archive="node-v${NODE_VERSION}-linux-${node_arch}.tar.xz"
|
||||||
|
install_dir="$HOME/.local/node-v${NODE_VERSION}-linux-${node_arch}"
|
||||||
|
if [[ ! -x "$install_dir/bin/node" ]]; then
|
||||||
|
echo "Installing Node.js v${NODE_VERSION}..."
|
||||||
|
tmp_dir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmp_dir"' RETURN
|
||||||
|
curl --fail --location --silent --show-error \
|
||||||
|
"https://nodejs.org/dist/v${NODE_VERSION}/${archive}" \
|
||||||
|
--output "$tmp_dir/$archive"
|
||||||
|
curl --fail --location --silent --show-error \
|
||||||
|
"https://nodejs.org/dist/v${NODE_VERSION}/SHASUMS256.txt" \
|
||||||
|
--output "$tmp_dir/SHASUMS256.txt"
|
||||||
|
(
|
||||||
|
cd "$tmp_dir"
|
||||||
|
grep " ${archive}$" SHASUMS256.txt | sha256sum --check --strict
|
||||||
|
)
|
||||||
|
tar -xJf "$tmp_dir/$archive" -C "$HOME/.local"
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
trap - RETURN
|
||||||
|
fi
|
||||||
|
|
||||||
|
for command in node npm npx corepack; do
|
||||||
|
ln -sfn "$install_dir/bin/$command" "$HOME/.local/bin/$command"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
install_wasm_pack() {
|
||||||
|
local machine target archive tmp_dir
|
||||||
|
machine="$(uname -m)"
|
||||||
|
case "$machine" in
|
||||||
|
x86_64) target="x86_64-unknown-linux-musl" ;;
|
||||||
|
aarch64) target="aarch64-unknown-linux-musl" ;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported architecture for wasm-pack: $machine" >&2
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if ! wasm-pack --version 2>/dev/null | grep -Fq "${WASM_PACK_VERSION}"; then
|
||||||
|
echo "Installing wasm-pack ${WASM_PACK_VERSION}..."
|
||||||
|
archive="wasm-pack-v${WASM_PACK_VERSION}-${target}.tar.gz"
|
||||||
|
tmp_dir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmp_dir"' RETURN
|
||||||
|
curl --fail --location --silent --show-error \
|
||||||
|
"https://github.com/wasm-bindgen/wasm-pack/releases/download/v${WASM_PACK_VERSION}/${archive}" \
|
||||||
|
--output "$tmp_dir/$archive"
|
||||||
|
tar -xzf "$tmp_dir/$archive" -C "$tmp_dir"
|
||||||
|
install -m 0755 \
|
||||||
|
"$tmp_dir/wasm-pack-v${WASM_PACK_VERSION}-${target}/wasm-pack" \
|
||||||
|
"$HOME/.cargo/bin/wasm-pack"
|
||||||
|
rm -rf "$tmp_dir"
|
||||||
|
trap - RETURN
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_node
|
||||||
|
|
||||||
|
if ! command -v rustup >/dev/null 2>&1; then
|
||||||
|
echo "Installing rustup..."
|
||||||
|
curl --proto '=https' --tlsv1.2 --fail --silent --show-error \
|
||||||
|
https://sh.rustup.rs | sh -s -- -y --profile minimal --no-modify-path \
|
||||||
|
--default-toolchain none
|
||||||
|
fi
|
||||||
|
source "$HOME/.cargo/env"
|
||||||
|
|
||||||
|
toolchain="$(sed -n 's/^channel = "\([^"]*\)"/\1/p' rust-toolchain.toml)"
|
||||||
|
echo "Installing Rust toolchain ${toolchain}..."
|
||||||
|
rustup toolchain install "$toolchain" --profile minimal \
|
||||||
|
--component rust-src \
|
||||||
|
--target wasm32-unknown-unknown
|
||||||
|
|
||||||
|
install_wasm_pack
|
||||||
|
|
||||||
|
if ! rsw --version 2>/dev/null | grep -Fq "${RSW_VERSION}"; then
|
||||||
|
echo "Installing rsw ${RSW_VERSION}..."
|
||||||
|
cargo install rsw --version "$RSW_VERSION" --locked
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Amp shells include ~/.local/bin, while setup's PATH changes do not persist.
|
||||||
|
for command in cargo rustc rustdoc rustfmt rustup wasm-pack rsw; do
|
||||||
|
ln -sfn "$HOME/.cargo/bin/$command" "$HOME/.local/bin/$command"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Installing JavaScript dependencies..."
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
echo "Building the application..."
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
echo "Orb setup complete."
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
services:
|
||||||
|
yawn-preview:
|
||||||
|
command: npm start -- --host 0.0.0.0 --port "$PORT"
|
||||||
|
portal:
|
||||||
|
title: Yawn
|
||||||
|
description: WebGPU level editor preview.
|
||||||
@@ -46,3 +46,7 @@ target/
|
|||||||
# WASM build artifacts
|
# WASM build artifacts
|
||||||
.rsw/
|
.rsw/
|
||||||
static/level-editor/
|
static/level-editor/
|
||||||
|
|
||||||
|
# Amp runtime artifacts
|
||||||
|
.amp/in/
|
||||||
|
.amp/portals/
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://agent-browser.dev/schema.json",
|
||||||
|
"webgpu": true,
|
||||||
|
"args": "--enable-unsafe-webgpu,--enable-features=Vulkan,--use-angle=vulkan,--use-vulkan=swiftshader,--use-webgpu-adapter=swiftshader,--disable-vulkan-surface"
|
||||||
|
}
|
||||||
@@ -7,6 +7,9 @@ import copy from "rollup-plugin-copy";
|
|||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname = path.dirname(__filename);
|
||||||
|
const portalHost = process.env.PUBLIC_URL
|
||||||
|
? new URL(process.env.PUBLIC_URL).hostname
|
||||||
|
: undefined;
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
build: {
|
build: {
|
||||||
@@ -54,6 +57,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
port: 8080,
|
port: 8080,
|
||||||
|
allowedHosts: portalHost ? [portalHost, ".e2b.app"] : [],
|
||||||
headers: {
|
headers: {
|
||||||
"Cross-Origin-Embedder-Policy": "require-corp",
|
"Cross-Origin-Embedder-Policy": "require-corp",
|
||||||
"Cross-Origin-Opener-Policy": "same-origin",
|
"Cross-Origin-Opener-Policy": "same-origin",
|
||||||
|
|||||||
Reference in New Issue
Block a user