Spaces:
Running

pi-web-runtime / sandbox /AGENTS.md
Mike0021's picture
Only hf-cli on by default; the user's skill choices kept across machines
314746a verified
|
Raw History Blame Contribute Delete
2.96 kB

Environment: Hugging Face Sandbox

You run inside a disposable Hugging Face Sandbox (a container on HF Jobs, in the signed-in user's own account) driven from Pi Web in a browser.

  • You are root on Debian 12 with Node 22, npm, Python 3 (python), uv, git, git-lfs, gcc/make, ripgrep, fd, jq and zstd. You can apt-get install more, but system packages are gone after a restart.
  • Hardware: see $ACCELERATOR, $CPU_CORES and $MEMORY. Internet access is available.
  • Projects live in /workspace/<name>. Only /workspace is saved: every project is archived to a private bucket in the user's account every couple of minutes while it changes, and when the machine stops. Anything outside /workspace (global installs, ~/.cache, /tmp) is lost on restart.
  • Dependency and build directories are not saved: node_modules, Python virtualenvs, __pycache__, .next and folders with a CACHEDIR.TAG (such as Rust target/). After a restart, reinstall before running anything (npm ci, uv sync, pip install -r requirements.txt, ...).
  • Nobody can open a server you start here in their browser. To check a web app, start it in the background (nohup ... > /tmp/app.log 2>&1 &) and query it with curl. To show the user a running app, deploy it to a Hugging Face Space.
  • The machine stops after a period without user activity; an agent turn in progress keeps it alive.

Hugging Face

  • The Hugging Face CLI hf is installed, with its skill hf-cli: use it for anything on the Hub. More Hugging Face skills (Spaces, datasets, training, Gradio, ...) are installed but off unless the user turned them on in Settings > Skills; the ones that are on are among your skills.
  • The Space lends the token of the user's sign-in to this machine: ~/.cache/huggingface/token holds their scoped, expiring token, so hf, huggingface_hub and git (clone and push on huggingface.co) act as that user, within the permissions they granted. Check with hf auth whoami. The token is renewed in place; read the file when you need it rather than copying it.
  • If there is no token, the user has taken it back or their sign-in lapsed: do the rest of the work, then tell them to choose Sign in again or Lend my token in the Workspace menu (bottom of the sidebar), after which the token appears within seconds. Do not run hf auth login and never ask for a token in the chat.
  • Never print, log, copy or commit the token. For tools that only read HF_TOKEN, pass it for that command: HF_TOKEN=$(cat ~/.cache/huggingface/token) node script.mjs.
  • What you do with it is real and billed to the user: Jobs, Inference Providers calls, new repos, pushes, pull requests. Ask before starting paid hardware or long Jobs, deleting or overwriting anything on the Hub, or publishing to a public repo; prefer a pull request over pushing to someone's main branch.
  • There is no GitHub token: commit locally; the user can download a patch from the dashboard.