-
Notifications
You must be signed in to change notification settings - Fork 270
feat: integrate openclaw/crabbox as AgentENV sandbox client #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zozo123
wants to merge
4
commits into
kvcache-ai:main
Choose a base branch
from
zozo123:docs/add-crabbox-sandbox-client
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
26be07d
feat: integrate openclaw/crabbox as AgentENV sandbox client
zozo123 0d464cf
fix: make Crabbox integration production-ready
zozo123 f759985
docs: add short Crabbox configuration section, drop integration CI
zozo123 0d268b7
Reduce Crabbox docs to E2B subsection
zozo123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| name: crabbox | ||
|
|
||
| # Validates the openclaw/crabbox integration (https://crabbox.sh). | ||
| # - Installs a pinned, checksum-verified upstream Crabbox release. | ||
| # - Loads config/crabbox.example.yaml through Crabbox itself. | ||
| # - Exercises E2B lifecycle, archive sync, and process streaming against a strict mock. | ||
| # - Builds mdBook so the Crabbox integration page stays linked. | ||
| # - Optional Islo smoke when repository secret ISLO_API_KEY is set | ||
| # (mint with: islo api-key create …). Forks without the secret no-op cleanly. | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - "README.md" | ||
| - "config/crabbox.example.yaml" | ||
| - "docs/src/integration/crabbox.md" | ||
| - "docs/src/integration/e2b.md" | ||
| - "docs/src/SUMMARY.md" | ||
| - "docs/src/configuration/env-vars.md" | ||
| - "docs/src/getting-started/**" | ||
| - "docs/src/troubleshooting/common-issues.md" | ||
| - "scripts/tests/crabbox-e2b-contract-server.py" | ||
| - ".github/workflows/crabbox.yml" | ||
| pull_request: | ||
| paths: | ||
| - "README.md" | ||
| - "config/crabbox.example.yaml" | ||
| - "docs/src/integration/crabbox.md" | ||
| - "docs/src/integration/e2b.md" | ||
| - "docs/src/SUMMARY.md" | ||
| - "docs/src/configuration/env-vars.md" | ||
| - "docs/src/getting-started/**" | ||
| - "docs/src/troubleshooting/common-issues.md" | ||
| - "scripts/tests/crabbox-e2b-contract-server.py" | ||
| - ".github/workflows/crabbox.yml" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| env: | ||
| CRABBOX_VERSION: "0.40.0" | ||
| CRABBOX_LINUX_AMD64_SHA256: "3bcd7c48b9866e3ac05b35bb67afa3282e831d1b9f749c5998c102944c1a5cfe" | ||
|
|
||
| concurrency: | ||
| group: crabbox-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| integrate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install openclaw/crabbox | ||
| run: | | ||
| set -euo pipefail | ||
| install_dir="${RUNNER_TEMP}/crabbox/bin" | ||
| archive="crabbox_${CRABBOX_VERSION}_linux_amd64.tar.gz" | ||
| mkdir -p "${install_dir}" | ||
| curl --fail --location --silent --show-error \ | ||
| "https://github.com/openclaw/crabbox/releases/download/v${CRABBOX_VERSION}/${archive}" \ | ||
| --output "${RUNNER_TEMP}/${archive}" | ||
| ( | ||
| cd "${RUNNER_TEMP}" | ||
| printf '%s %s\n' "${CRABBOX_LINUX_AMD64_SHA256}" "${archive}" | sha256sum --check - | ||
| ) | ||
| tar -xzf "${RUNNER_TEMP}/${archive}" -C "${install_dir}" crabbox | ||
| echo "${install_dir}" >> "${GITHUB_PATH}" | ||
| "${install_dir}/crabbox" --version | ||
|
|
||
| - name: Validate AgentENV E2B control and data-plane contract | ||
| env: | ||
| CRABBOX_E2B_API_URL: http://127.0.0.1:18080 | ||
| CRABBOX_E2B_API_KEY: agentenv-ci-placeholder | ||
| run: | | ||
| set -euo pipefail | ||
| config_path="${RUNNER_TEMP}/crabbox.example.yaml" | ||
| install -m 600 config/crabbox.example.yaml "${config_path}" | ||
| export CRABBOX_CONFIG="${config_path}" | ||
| export XDG_CONFIG_HOME="${RUNNER_TEMP}/crabbox-xdg" | ||
|
|
||
| cert_dir="${RUNNER_TEMP}/crabbox-contract-tls" | ||
| mkdir -p "${cert_dir}" | ||
| openssl req -x509 -newkey rsa:2048 -nodes \ | ||
| -keyout "${cert_dir}/key.pem" \ | ||
| -out "${cert_dir}/cert.pem" \ | ||
| -days 1 \ | ||
| -subj "/CN=*.localhost" \ | ||
| -addext "subjectAltName=DNS:*.localhost" \ | ||
| >/dev/null 2>&1 | ||
| export SSL_CERT_FILE="${cert_dir}/cert.pem" | ||
|
|
||
| python3 scripts/tests/crabbox-e2b-contract-server.py \ | ||
| --cert "${cert_dir}/cert.pem" \ | ||
| --key "${cert_dir}/key.pem" \ | ||
| >"${RUNNER_TEMP}/crabbox-contract-server.log" 2>&1 & | ||
| server_pid=$! | ||
| cleanup() { | ||
| kill "${server_pid}" 2>/dev/null || true | ||
| wait "${server_pid}" 2>/dev/null || true | ||
| cat "${RUNNER_TEMP}/crabbox-contract-server.log" | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| for _ in {1..50}; do | ||
| if curl --fail --silent --output /dev/null http://127.0.0.1:18080/health; then | ||
| break | ||
| fi | ||
| sleep 0.1 | ||
| done | ||
| curl --fail --silent --output /dev/null http://127.0.0.1:18080/health | ||
|
|
||
| crabbox providers | grep -E '^e2b$' | ||
| crabbox config show --json > "${RUNNER_TEMP}/crabbox-config.json" | ||
| python3 - "${RUNNER_TEMP}/crabbox-config.json" <<'PY' | ||
| import json | ||
| import sys | ||
|
|
||
| with open(sys.argv[1], encoding="utf-8") as handle: | ||
| config = json.load(handle) | ||
| assert config["provider"] == "e2b", config["provider"] | ||
| assert config["target"] == "linux", config["target"] | ||
| assert config["e2b"]["template"] == "ubuntu", config["e2b"] | ||
| assert config["e2b"]["workdir"] == "crabbox", config["e2b"] | ||
| assert config["e2b"]["apiUrl"] == "http://127.0.0.1:18080", config["e2b"] | ||
| PY | ||
| crabbox doctor --provider e2b | ||
|
|
||
| contract_repo="${RUNNER_TEMP}/crabbox-contract-repo" | ||
| git init --quiet "${contract_repo}" | ||
| git -C "${contract_repo}" config user.name "AgentENV CI" | ||
| git -C "${contract_repo}" config user.email "ci@agentenv.invalid" | ||
| printf 'archive-sync-contract\n' > "${contract_repo}/contract.txt" | ||
| git -C "${contract_repo}" add contract.txt | ||
| git -C "${contract_repo}" commit --quiet -m "test fixture" | ||
| ( | ||
| cd "${contract_repo}" | ||
| crabbox run --provider e2b -- echo crabbox-agentenv-contract-ok | ||
| ) 2>&1 | tee "${RUNNER_TEMP}/crabbox-run.log" | ||
| grep -Fx "crabbox-agentenv-contract-ok" "${RUNNER_TEMP}/crabbox-run.log" | ||
|
|
||
| curl --fail --silent http://127.0.0.1:18080/contract-state \ | ||
| > "${RUNNER_TEMP}/crabbox-contract-state.json" | ||
| python3 - "${RUNNER_TEMP}/crabbox-contract-state.json" <<'PY' | ||
| import json | ||
| import sys | ||
|
|
||
| with open(sys.argv[1], encoding="utf-8") as handle: | ||
| state = json.load(handle) | ||
| assert state["errors"] == [], state | ||
| assert state["list"] >= 1, state | ||
| assert state["create"] == 1, state | ||
| assert state["connect"] == 1, state | ||
| assert state["upload"] == 1, state | ||
| assert state["process"] >= 3, state | ||
| assert state["marker_commands"] == 1, state | ||
| assert state["delete"] == 1, state | ||
| PY | ||
|
|
||
| - uses: taiki-e/install-action@mdbook | ||
|
zozo123 marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Build docs (mdBook) | ||
| run: | | ||
| set -euo pipefail | ||
| ln -sf ../../src/api/openapi.yml docs/src/openapi.yml | ||
| mdbook build docs | ||
|
|
||
| - name: Guard — optional Islo smoke | ||
| id: guard | ||
| env: | ||
| ISLO_API_KEY: ${{ secrets.ISLO_API_KEY }} | ||
|
zozo123 marked this conversation as resolved.
Outdated
|
||
| run: | | ||
| if [ -z "${ISLO_API_KEY}" ]; then | ||
| echo "ISLO_API_KEY not configured — skipping islo smoke." | ||
| echo "run=false" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "run=true" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: crabbox run --provider islo | ||
| if: steps.guard.outputs.run == 'true' | ||
| env: | ||
| ISLO_API_KEY: ${{ secrets.ISLO_API_KEY }} | ||
| run: | | ||
| set -euo pipefail | ||
| # Prefer Islo tenant defaults (omit --islo-image); keep the lease small. | ||
| crabbox run \ | ||
| --provider islo \ | ||
| --islo-vcpus 2 \ | ||
| --islo-memory-mb 2048 \ | ||
| --islo-disk-gb 10 \ | ||
| --no-sync \ | ||
| -- echo crabbox-islo-ok | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Example openclaw/crabbox config for AgentENV. | ||
| # Install with mode 0600 at the repo root as `.crabbox.yaml`, or merge it into | ||
| # your user Crabbox config. | ||
| # Docs: https://crabbox.sh/ · Provider: https://crabbox.sh/providers/e2b.html | ||
| # | ||
| # Endpoint and auth stay in the environment (never commit destinations or keys): | ||
| # export CRABBOX_E2B_API_URL=https://agentenv.example.com | ||
| # export CRABBOX_E2B_API_KEY=e2b_000000 | ||
| # | ||
| # `crabbox run` also requires AgentENV to advertise an HTTPS wildcard sandbox | ||
| # proxy domain. See docs/src/integration/crabbox.md before running this config. | ||
| # | ||
| # Then: | ||
| # brew install openclaw/tap/crabbox | ||
| # install -m 600 config/crabbox.example.yaml .crabbox.yaml | ||
| # crabbox doctor --provider e2b | ||
| # crabbox run --provider e2b -- make test-unit | ||
|
|
||
| provider: e2b | ||
| target: linux | ||
| e2b: | ||
| # AgentENV template id or name (aenv pull … / aenv template list) | ||
| template: ubuntu | ||
| # Dedicated subdirectory inside the sandbox (not /, /tmp, …) | ||
| workdir: crabbox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ | |
|
|
||
| # Integration | ||
|
|
||
| - [Crabbox](./integration/crabbox.md) | ||
| - [E2B](./integration/e2b.md) | ||
|
|
||
| # Troubleshooting | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.