| --- |
| title: Forge |
| emoji: π οΈ |
| colorFrom: yellow |
| colorTo: gray |
| sdk: docker |
| app_port: 7860 |
| pinned: false |
| --- |
| |
| # Forge |
|
|
| A self-improving assistant you talk to like a person. Ask it to do something; if it doesn't |
| already have the tool for the job, it writes one and puts it in front of you for approval |
| before it ever runs. If an approved tool breaks, it patches itself and sends the patch back |
| for approval too. |
|
|
| ## How it works |
|
|
| - **Chat** β plain conversation, backed by your Inference Port API. |
| - **Tools** β small JavaScript functions (`async function run(args) { ... }`) that Forge |
| writes on demand and calls like normal functions once approved. |
| - **Approval gate** β nothing Forge writes runs until you hit *Approve* on its ticket card. |
| Decline it and Forge is told why (if you give a reason) so it can try something else. |
| - **Self-healing** β if a tool throws, Forge automatically drafts a fix and files it as a new |
| ticket. The broken tool keeps its old code until the fix is approved. |
| - **Sandboxing** β tool code runs in a restricted `vm` context with a timeout, not a fully |
| hardened sandbox. The approval step is the real safety boundary β read the code before |
| approving it, same as you would review a PR. |
|
|
| ## Setup |
|
|
| 1. **Set Space secrets/variables** (Settings β Variables and secrets): |
| - `INFERENCE_API_URL` β the chat completions endpoint for your Inference Port API. |
| Double-check this is current before deploying; see `.env.example` for the last known value. |
| - `INFERENCE_API_KEY` β your key, as a **secret**, not a variable. |
| - `INFERENCE_MODEL` β defaults to `llama-3.3-70b-versatile` if unset. |
| - `AGENT_NAME` β optional, defaults to `Forge`. |
| - `USE_PERSISTENT_STORAGE` β set to `true` to store tools at `/data/forge-tools` |
| (requires persistent storage enabled in Space settings). |
| |
| 2. **Persistence.** Tools are written to `/data/forge-tools` if the **`USE_PERSISTENT_STORAGE`** |
| env var is set to `true` **and** the Space has persistent storage enabled, otherwise they |
| fall back to a local folder that's wiped on every rebuild. Turn on persistent storage in |
| Space settings and set `USE_PERSISTENT_STORAGE=true` if you want tools to survive restarts. |
|
|
| 3. Push this repo to your Space. The `Dockerfile` builds and runs it on port 7860. |
|
|
| ## Local dev |
|
|
| ```bash |
| npm install |
| cp .env.example .env # fill in your values |
| npm start |
| ``` |
|
|
| Then open http://localhost:7860. |
|
|