#81 Assistant : préparer une sandbox sbx pour Claude (claude-agent-acp)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3f937ea parent: b89b7e0 modified
.tickets/issues/0081-simplifier-l-ajout-d-une-sbx-avec-claude-acp.yaml +36 -8 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 81 |
| 3 | 3 | title: "Simplifier l'ajout d'une sbx avec Claude ACP" |
| 4 | -state: open | |
| 4 | +state: closed | |
| 5 | 5 | author: |
| 6 | 6 | name: k33g |
| 7 | 7 | email: ph.charriere@gmail.com |
| 8 | 8 | createdAt: 2026-11-09T06:11:54.000Z |
| 9 | -updatedAt: 2026-11-09T06:50:18.000Z | |
| 9 | +updatedAt: 2026-11-09T06:56:37.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - kind::feature |
| 12 | 12 | - area::config |
| @@ -50,42 +50,70 @@ body: | | ||
| 50 | 50 | tasks: |
| 51 | 51 | - id: 1 |
| 52 | 52 | title: "Proposer claude-agent-acp dans la liste des programmes en mode sbx (seulement en sbx)" |
| 53 | - state: open | |
| 53 | + state: closed | |
| 54 | 54 | priority: high |
| 55 | 55 | author: |
| 56 | 56 | name: k33g |
| 57 | 57 | email: ph.charriere@gmail.com |
| 58 | 58 | createdAt: 2026-11-09T06:50:18.000Z |
| 59 | + updatedAt: 2026-11-09T06:56:37.000Z | |
| 60 | + closedAt: 2026-11-09T06:56:37.000Z | |
| 59 | 61 | - id: 2 |
| 60 | 62 | title: "Go : générer le sbxenv.yaml Claude (modèle de agents/snippets/claude-acp) et le dossier workspace/, sans écraser un fichier existant" |
| 61 | - state: open | |
| 63 | + state: closed | |
| 62 | 64 | priority: high |
| 63 | 65 | author: |
| 64 | 66 | name: k33g |
| 65 | 67 | email: ph.charriere@gmail.com |
| 66 | 68 | createdAt: 2026-11-09T06:50:18.000Z |
| 69 | + updatedAt: 2026-11-09T06:56:37.000Z | |
| 70 | + closedAt: 2026-11-09T06:56:37.000Z | |
| 67 | 71 | - id: 3 |
| 68 | 72 | title: "Assistant : remplir sandbox, dossier de l'agent et commandes lifecycle à partir du fichier généré" |
| 69 | - state: open | |
| 73 | + state: closed | |
| 70 | 74 | priority: high |
| 71 | 75 | author: |
| 72 | 76 | name: k33g |
| 73 | 77 | email: ph.charriere@gmail.com |
| 74 | 78 | createdAt: 2026-11-09T06:50:18.000Z |
| 79 | + updatedAt: 2026-11-09T06:56:37.000Z | |
| 80 | + closedAt: 2026-11-09T06:56:37.000Z | |
| 75 | 81 | - id: 4 |
| 76 | 82 | title: "Rappeler d'enregistrer la clé Anthropic dans sbx (lien vers le guide #83)" |
| 77 | - state: open | |
| 83 | + state: closed | |
| 78 | 84 | priority: medium |
| 79 | 85 | author: |
| 80 | 86 | name: k33g |
| 81 | 87 | email: ph.charriere@gmail.com |
| 82 | 88 | createdAt: 2026-11-09T06:50:18.000Z |
| 89 | + updatedAt: 2026-11-09T06:56:37.000Z | |
| 90 | + closedAt: 2026-11-09T06:56:37.000Z | |
| 83 | 91 | - id: 5 |
| 84 | 92 | title: "Tests Go + vitest ; textes EN + FR ; guides « ajouter un agent » et #83 mis à jour" |
| 85 | - state: open | |
| 93 | + state: closed | |
| 86 | 94 | priority: medium |
| 87 | 95 | author: |
| 88 | 96 | name: k33g |
| 89 | 97 | email: ph.charriere@gmail.com |
| 90 | 98 | createdAt: 2026-11-09T06:50:18.000Z |
| 91 | -comments: [] | |
| 99 | + updatedAt: 2026-11-09T06:56:37.000Z | |
| 100 | + closedAt: 2026-11-09T06:56:37.000Z | |
| 101 | +comments: | |
| 102 | + - id: 1 | |
| 103 | + author: | |
| 104 | + name: k33g | |
| 105 | + email: ph.charriere@gmail.com | |
| 106 | + createdAt: 2026-11-09T06:56:37.000Z | |
| 107 | + body: | | |
| 108 | + Fait, selon l'approche retenue. | |
| 109 | + - Go : `ConfigService.PrepareClaudeSandbox(folder, sandbox)` ([claudesandbox.go](internal/app/claudesandbox.go)) écrit | |
| 110 | + le `sbxenv.yaml` de [agents/snippets/claude-acp](agents/snippets/claude-acp/README.md) (nom de sandbox remplacé), | |
| 111 | + sans jamais écraser un fichier existant, crée `workspace/`, et renvoie ce que `ReadSandboxEnv` renvoie. Un test | |
| 112 | + vérifie que le fichier généré reste identique à l'exemple (hors `name`). | |
| 113 | + - Assistant : en mode sbx, `claude-agent-acp` est proposé dans **Programme** (`programsFor`, [agentform.ts](frontend/src/lib/agentform.ts)) ; | |
| 114 | + une zone **Claude dans une sandbox sbx** propose le dossier (`~/agents/<nom>`) et le nom de sandbox (`<nom>-sbx`), | |
| 115 | + **Préparer la sandbox** remplit le formulaire (`withPreparedSandbox`) ; **Ajouter l'agent** prépare d'abord si besoin. | |
| 116 | + Le bloc « fichier de configuration de l'agent » est caché pour Claude. Rappel de la clé Anthropic et mention du kit tiers. | |
| 117 | + - Vérifié dans l'application (Xvfb) : l'entrée écrite est celle du README de l'exemple. | |
| 118 | + - Docs EN + FR : guide #83 (voie « assistant » en premier, section « Un kit fourni par un tiers »), « Ajouter un agent », référence. | |
| 119 | + - Non vérifié : démarrage réel de Claude (pas de sbx ici). | |
| @@ -1,12 +1,12 @@ | |||
| 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | id: 81 | 2 | id: 81 |
| 3 | title: "Simplifier l'ajout d'une sbx avec Claude ACP" | 3 | title: "Simplifier l'ajout d'une sbx avec Claude ACP" |
| 4 | -state: open | 4 | +state: closed |
| 5 | author: | 5 | author: |
| 6 | name: k33g | 6 | name: k33g |
| 7 | email: ph.charriere@gmail.com | 7 | email: ph.charriere@gmail.com |
| 8 | createdAt: 2026-11-09T06:11:54.000Z | 8 | createdAt: 2026-11-09T06:11:54.000Z |
| 9 | -updatedAt: 2026-11-09T06:50:18.000Z | 9 | +updatedAt: 2026-11-09T06:56:37.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - kind::feature | 11 | - kind::feature |
| 12 | - area::config | 12 | - area::config |
| @@ -50,42 +50,70 @@ body: | | |||
| 50 | tasks: | 50 | tasks: |
| 51 | - id: 1 | 51 | - id: 1 |
| 52 | title: "Proposer claude-agent-acp dans la liste des programmes en mode sbx (seulement en sbx)" | 52 | title: "Proposer claude-agent-acp dans la liste des programmes en mode sbx (seulement en sbx)" |
| 53 | - state: open | 53 | + state: closed |
| 54 | priority: high | 54 | priority: high |
| 55 | author: | 55 | author: |
| 56 | name: k33g | 56 | name: k33g |
| 57 | email: ph.charriere@gmail.com | 57 | email: ph.charriere@gmail.com |
| 58 | createdAt: 2026-11-09T06:50:18.000Z | 58 | createdAt: 2026-11-09T06:50:18.000Z |
| 59 | + updatedAt: 2026-11-09T06:56:37.000Z | ||
| 60 | + closedAt: 2026-11-09T06:56:37.000Z | ||
| 59 | - id: 2 | 61 | - id: 2 |
| 60 | title: "Go : générer le sbxenv.yaml Claude (modèle de agents/snippets/claude-acp) et le dossier workspace/, sans écraser un fichier existant" | 62 | title: "Go : générer le sbxenv.yaml Claude (modèle de agents/snippets/claude-acp) et le dossier workspace/, sans écraser un fichier existant" |
| 61 | - state: open | 63 | + state: closed |
| 62 | priority: high | 64 | priority: high |
| 63 | author: | 65 | author: |
| 64 | name: k33g | 66 | name: k33g |
| 65 | email: ph.charriere@gmail.com | 67 | email: ph.charriere@gmail.com |
| 66 | createdAt: 2026-11-09T06:50:18.000Z | 68 | createdAt: 2026-11-09T06:50:18.000Z |
| 69 | + updatedAt: 2026-11-09T06:56:37.000Z | ||
| 70 | + closedAt: 2026-11-09T06:56:37.000Z | ||
| 67 | - id: 3 | 71 | - id: 3 |
| 68 | title: "Assistant : remplir sandbox, dossier de l'agent et commandes lifecycle à partir du fichier généré" | 72 | title: "Assistant : remplir sandbox, dossier de l'agent et commandes lifecycle à partir du fichier généré" |
| 69 | - state: open | 73 | + state: closed |
| 70 | priority: high | 74 | priority: high |
| 71 | author: | 75 | author: |
| 72 | name: k33g | 76 | name: k33g |
| 73 | email: ph.charriere@gmail.com | 77 | email: ph.charriere@gmail.com |
| 74 | createdAt: 2026-11-09T06:50:18.000Z | 78 | createdAt: 2026-11-09T06:50:18.000Z |
| 79 | + updatedAt: 2026-11-09T06:56:37.000Z | ||
| 80 | + closedAt: 2026-11-09T06:56:37.000Z | ||
| 75 | - id: 4 | 81 | - id: 4 |
| 76 | title: "Rappeler d'enregistrer la clé Anthropic dans sbx (lien vers le guide #83)" | 82 | title: "Rappeler d'enregistrer la clé Anthropic dans sbx (lien vers le guide #83)" |
| 77 | - state: open | 83 | + state: closed |
| 78 | priority: medium | 84 | priority: medium |
| 79 | author: | 85 | author: |
| 80 | name: k33g | 86 | name: k33g |
| 81 | email: ph.charriere@gmail.com | 87 | email: ph.charriere@gmail.com |
| 82 | createdAt: 2026-11-09T06:50:18.000Z | 88 | createdAt: 2026-11-09T06:50:18.000Z |
| 89 | + updatedAt: 2026-11-09T06:56:37.000Z | ||
| 90 | + closedAt: 2026-11-09T06:56:37.000Z | ||
| 83 | - id: 5 | 91 | - id: 5 |
| 84 | title: "Tests Go + vitest ; textes EN + FR ; guides « ajouter un agent » et #83 mis à jour" | 92 | title: "Tests Go + vitest ; textes EN + FR ; guides « ajouter un agent » et #83 mis à jour" |
| 85 | - state: open | 93 | + state: closed |
| 86 | priority: medium | 94 | priority: medium |
| 87 | author: | 95 | author: |
| 88 | name: k33g | 96 | name: k33g |
| 89 | email: ph.charriere@gmail.com | 97 | email: ph.charriere@gmail.com |
| 90 | createdAt: 2026-11-09T06:50:18.000Z | 98 | createdAt: 2026-11-09T06:50:18.000Z |
| 91 | -comments: [] | 99 | + updatedAt: 2026-11-09T06:56:37.000Z |
| 100 | + closedAt: 2026-11-09T06:56:37.000Z | ||
| 101 | +comments: | ||
| 102 | + - id: 1 | ||
| 103 | + author: | ||
| 104 | + name: k33g | ||
| 105 | + email: ph.charriere@gmail.com | ||
| 106 | + createdAt: 2026-11-09T06:56:37.000Z | ||
| 107 | + body: | | ||
| 108 | + Fait, selon l'approche retenue. | ||
| 109 | + - Go : `ConfigService.PrepareClaudeSandbox(folder, sandbox)` ([claudesandbox.go](internal/app/claudesandbox.go)) écrit | ||
| 110 | + le `sbxenv.yaml` de [agents/snippets/claude-acp](agents/snippets/claude-acp/README.md) (nom de sandbox remplacé), | ||
| 111 | + sans jamais écraser un fichier existant, crée `workspace/`, et renvoie ce que `ReadSandboxEnv` renvoie. Un test | ||
| 112 | + vérifie que le fichier généré reste identique à l'exemple (hors `name`). | ||
| 113 | + - Assistant : en mode sbx, `claude-agent-acp` est proposé dans **Programme** (`programsFor`, [agentform.ts](frontend/src/lib/agentform.ts)) ; | ||
| 114 | + une zone **Claude dans une sandbox sbx** propose le dossier (`~/agents/<nom>`) et le nom de sandbox (`<nom>-sbx`), | ||
| 115 | + **Préparer la sandbox** remplit le formulaire (`withPreparedSandbox`) ; **Ajouter l'agent** prépare d'abord si besoin. | ||
| 116 | + Le bloc « fichier de configuration de l'agent » est caché pour Claude. Rappel de la clé Anthropic et mention du kit tiers. | ||
| 117 | + - Vérifié dans l'application (Xvfb) : l'entrée écrite est celle du README de l'exemple. | ||
| 118 | + - Docs EN + FR : guide #83 (voie « assistant » en premier, section « Un kit fourni par un tiers »), « Ajouter un agent », référence. | ||
| 119 | + - Non vérifié : démarrage réel de Claude (pas de sbx ici). | ||
modified
docs/en/how-to/add-a-claude-agent-in-a-sandbox.md +16 -1 | @@ -4,6 +4,10 @@ This guide shows how to add Claude (Claude Code, through its ACP adapter `claude | ||
| 4 | 4 | |
| 5 | 5 | A ready-made example is in the repository: [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). |
| 6 | 6 | |
| 7 | +## A kit provided by a third party | |
| 8 | + | |
| 9 | +The sandbox is built from the `docker.io/sbx/claude-acp` kit. This kit is provided by a third party, **not by Sidekicks**: what it contains (Claude Code, `claude-agent-acp`), its updates (the sandbox pulls `latest` each time it is created) and whether it stays available depend on that third party. Sidekicks only writes the `sbxenv.yaml` that names it and starts `claude-agent-acp` inside the sandbox. If the kit changes or disappears, the sandbox may no longer be created, or Claude may no longer start: the **Log** tab then shows what sbx said. | |
| 10 | + | |
| 7 | 11 | ## What you need |
| 8 | 12 | |
| 9 | 13 | | | Role | |
| @@ -12,7 +16,18 @@ A ready-made example is in the repository: [`agents/snippets/claude-acp`](../../ | ||
| 12 | 16 | | The `docker.io/sbx/claude-acp` kit | the sandbox's image, with Claude Code and `claude-agent-acp` installed. | |
| 13 | 17 | | Your Anthropic API key, stored in sbx | sbx adds it to Claude's requests to Anthropic: it is written neither in the sandbox nor in Sidekicks' configuration. | |
| 14 | 18 | |
| 15 | -## Steps | |
| 19 | +## The simplest way: let the assistant prepare the sandbox | |
| 20 | + | |
| 21 | +1. In the **Agents** panel, click **+ Add an agent**. Fill in **Name shown** (`Claude`) and, if you like, an icon (📙). | |
| 22 | +2. **Where does it run?** Choose **In an sbx sandbox**. | |
| 23 | +3. **Program**: choose `claude-agent-acp` in the list (it is offered in an sbx sandbox only). A **Claude in an sbx sandbox** area appears. | |
| 24 | +4. Check the **Folder of the sandbox** (`~/agents/<name>` by default, or **Choose…**) and the **Name of the sandbox** (`<name>-sbx` by default), then click **Prepare the sandbox**. Sidekicks writes `sbxenv.yaml` (the one of step 2 below) and an empty `workspace/` in that folder — an `sbxenv.yaml` already there is kept as it is — and fills in the rest of the form: the sandbox, the agent's folder (`…/workspace`), the `sbx env` commands, no arguments. | |
| 25 | +5. Click **Add the agent**. (If you click it without preparing, Sidekicks prepares the sandbox first, with the folder shown.) | |
| 26 | +6. Give your Anthropic API key to sbx (step 3 below), then start Claude (step 5 below). | |
| 27 | + | |
| 28 | +## By hand | |
| 29 | + | |
| 30 | +The same result, step by step — or to adapt an existing sandbox. | |
| 16 | 31 | |
| 17 | 32 | 1. **Create the agent's folder** with an empty `workspace/` inside: |
| 18 | 33 | |
| @@ -4,6 +4,10 @@ This guide shows how to add Claude (Claude Code, through its ACP adapter `claude | |||
| 4 | 4 | ||
| 5 | A ready-made example is in the repository: [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). | 5 | A ready-made example is in the repository: [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). |
| 6 | 6 | ||
| 7 | +## A kit provided by a third party | ||
| 8 | + | ||
| 9 | +The sandbox is built from the `docker.io/sbx/claude-acp` kit. This kit is provided by a third party, **not by Sidekicks**: what it contains (Claude Code, `claude-agent-acp`), its updates (the sandbox pulls `latest` each time it is created) and whether it stays available depend on that third party. Sidekicks only writes the `sbxenv.yaml` that names it and starts `claude-agent-acp` inside the sandbox. If the kit changes or disappears, the sandbox may no longer be created, or Claude may no longer start: the **Log** tab then shows what sbx said. | ||
| 10 | + | ||
| 7 | ## What you need | 11 | ## What you need |
| 8 | 12 | ||
| 9 | | | Role | | 13 | | | Role | |
| @@ -12,7 +16,18 @@ A ready-made example is in the repository: [`agents/snippets/claude-acp`](../../ | |||
| 12 | | The `docker.io/sbx/claude-acp` kit | the sandbox's image, with Claude Code and `claude-agent-acp` installed. | | 16 | | The `docker.io/sbx/claude-acp` kit | the sandbox's image, with Claude Code and `claude-agent-acp` installed. | |
| 13 | | Your Anthropic API key, stored in sbx | sbx adds it to Claude's requests to Anthropic: it is written neither in the sandbox nor in Sidekicks' configuration. | | 17 | | Your Anthropic API key, stored in sbx | sbx adds it to Claude's requests to Anthropic: it is written neither in the sandbox nor in Sidekicks' configuration. | |
| 14 | 18 | ||
| 15 | -## Steps | 19 | +## The simplest way: let the assistant prepare the sandbox |
| 20 | + | ||
| 21 | +1. In the **Agents** panel, click **+ Add an agent**. Fill in **Name shown** (`Claude`) and, if you like, an icon (📙). | ||
| 22 | +2. **Where does it run?** Choose **In an sbx sandbox**. | ||
| 23 | +3. **Program**: choose `claude-agent-acp` in the list (it is offered in an sbx sandbox only). A **Claude in an sbx sandbox** area appears. | ||
| 24 | +4. Check the **Folder of the sandbox** (`~/agents/<name>` by default, or **Choose…**) and the **Name of the sandbox** (`<name>-sbx` by default), then click **Prepare the sandbox**. Sidekicks writes `sbxenv.yaml` (the one of step 2 below) and an empty `workspace/` in that folder — an `sbxenv.yaml` already there is kept as it is — and fills in the rest of the form: the sandbox, the agent's folder (`…/workspace`), the `sbx env` commands, no arguments. | ||
| 25 | +5. Click **Add the agent**. (If you click it without preparing, Sidekicks prepares the sandbox first, with the folder shown.) | ||
| 26 | +6. Give your Anthropic API key to sbx (step 3 below), then start Claude (step 5 below). | ||
| 27 | + | ||
| 28 | +## By hand | ||
| 29 | + | ||
| 30 | +The same result, step by step — or to adapt an existing sandbox. | ||
| 16 | 31 | ||
| 17 | 1. **Create the agent's folder** with an empty `workspace/` inside: | 32 | 1. **Create the agent's folder** with an empty `workspace/` inside: |
| 18 | 33 | ||
modified
docs/en/how-to/add-an-agent.md +2 -1 | @@ -7,7 +7,7 @@ This guide shows how to add an agent from the Sidekicks window, with the "Add an | ||
| 7 | 7 | 1. Open the assistant: **+ Add my first agent** on the welcome screen, **+ Add an agent** under the agents list, or **⇧⌘N** (Ctrl+Shift+N on Linux and Windows). |
| 8 | 8 | 2. **Who is it?** Fill in **Name shown** (e.g. `Garfield (translator)`). **Name used with @** follows it; change it if you want a shorter one (lowercase letters, digits, `-` and `_`, starting with a letter). The icon and the description are optional: the icon is an emoji, or a letter shown in a coloured circle; left empty, the circle holds the first letter of the name shown. |
| 9 | 9 | 3. **Where does it run?** Choose the environment, then fill in what it asks for (see below). |
| 10 | -4. **How is it started?** Fill in **Program** (choose `mm`, `docker-agent` or `docker agent` in the list, or type another), **Arguments** (on one line, as in a terminal; quotes group words) and **Agent's folder**. The folder is created when it does not exist. | |
| 10 | +4. **How is it started?** Fill in **Program** (choose `mm`, `docker-agent` or `docker agent` in the list — plus `claude-agent-acp` in an sbx sandbox — or type another), **Arguments** (on one line, as in a terminal; quotes group words) and **Agent's folder**. The folder is created when it does not exist. | |
| 11 | 11 | 5. Click **Add the agent**. Its direct conversation opens once the configuration is reloaded. |
| 12 | 12 | |
| 13 | 13 | When the agent cannot be added (a name already used, for instance), the assistant says why and writes nothing. |
| @@ -18,6 +18,7 @@ When the agent cannot be added (a name already used, for instance), the assistan | ||
| 18 | 18 | - **On this computer**: the program runs here, in the agent's folder. If Sidekicks was opened from the Finder and does not find the program, write its full path (`which mm` in a terminal gives it). Sidekicks reads your shell's `PATH` at startup, so this is rarely needed. |
| 19 | 19 | - **In a Docker container**: give the **Container name**. The container must exist (Sidekicks starts it if it is stopped), with the agent's folder mounted at the same path, and contain the program: see [How to run an agent in a Docker container](run-an-agent-in-docker.md). Sidekicks starts the agent with `docker exec -i <container> <program> <arguments>`. To have the container recreated when it is gone, drop its `compose.yaml` on **Recreate the container when it is gone** and pick the service, or type the commands: see [Restart or recreate the container](run-an-agent-in-docker.md#restart-or-recreate-the-container). |
| 20 | 20 | - **In an sbx sandbox**: give the **Sandbox name**. The sandbox must exist, with the agent's folder at the same path: see [How to run an agent in an sbx sandbox](run-an-agent-in-a-sandbox.md). Sidekicks starts the agent with `sbx exec -i <sandbox> <program> <arguments>`. To have the sandbox recreated when it is gone, drop its `sbxenv.yaml` on **Recreate the sandbox when it is gone**, or type the commands: see [Recreate the sandbox when it is gone](run-an-agent-in-a-sandbox.md#recreate-the-sandbox-when-it-is-gone). |
| 21 | +- **Claude in an sbx sandbox**: choose **In an sbx sandbox**, then the program `claude-agent-acp`, and click **Prepare the sandbox**: Sidekicks writes the sandbox's `sbxenv.yaml` and its `workspace/` folder, and fills in the rest. It relies on the `docker.io/sbx/claude-acp` kit, provided by a third party, not by Sidekicks. See [How to add a Claude agent in an sbx sandbox](add-a-claude-agent-in-a-sandbox.md). | |
| 21 | 22 | - **Options the assistant does not ask for** (`env`, `afterStop`, a different `workspacePath`): add the agent with the assistant, then complete its entry in **Settings**. |
| 22 | 23 | |
| 23 | 24 | ## See also |
| @@ -7,7 +7,7 @@ This guide shows how to add an agent from the Sidekicks window, with the "Add an | |||
| 7 | 1. Open the assistant: **+ Add my first agent** on the welcome screen, **+ Add an agent** under the agents list, or **⇧⌘N** (Ctrl+Shift+N on Linux and Windows). | 7 | 1. Open the assistant: **+ Add my first agent** on the welcome screen, **+ Add an agent** under the agents list, or **⇧⌘N** (Ctrl+Shift+N on Linux and Windows). |
| 8 | 2. **Who is it?** Fill in **Name shown** (e.g. `Garfield (translator)`). **Name used with @** follows it; change it if you want a shorter one (lowercase letters, digits, `-` and `_`, starting with a letter). The icon and the description are optional: the icon is an emoji, or a letter shown in a coloured circle; left empty, the circle holds the first letter of the name shown. | 8 | 2. **Who is it?** Fill in **Name shown** (e.g. `Garfield (translator)`). **Name used with @** follows it; change it if you want a shorter one (lowercase letters, digits, `-` and `_`, starting with a letter). The icon and the description are optional: the icon is an emoji, or a letter shown in a coloured circle; left empty, the circle holds the first letter of the name shown. |
| 9 | 3. **Where does it run?** Choose the environment, then fill in what it asks for (see below). | 9 | 3. **Where does it run?** Choose the environment, then fill in what it asks for (see below). |
| 10 | -4. **How is it started?** Fill in **Program** (choose `mm`, `docker-agent` or `docker agent` in the list, or type another), **Arguments** (on one line, as in a terminal; quotes group words) and **Agent's folder**. The folder is created when it does not exist. | 10 | +4. **How is it started?** Fill in **Program** (choose `mm`, `docker-agent` or `docker agent` in the list — plus `claude-agent-acp` in an sbx sandbox — or type another), **Arguments** (on one line, as in a terminal; quotes group words) and **Agent's folder**. The folder is created when it does not exist. |
| 11 | 5. Click **Add the agent**. Its direct conversation opens once the configuration is reloaded. | 11 | 5. Click **Add the agent**. Its direct conversation opens once the configuration is reloaded. |
| 12 | 12 | ||
| 13 | When the agent cannot be added (a name already used, for instance), the assistant says why and writes nothing. | 13 | When the agent cannot be added (a name already used, for instance), the assistant says why and writes nothing. |
| @@ -18,6 +18,7 @@ When the agent cannot be added (a name already used, for instance), the assistan | |||
| 18 | - **On this computer**: the program runs here, in the agent's folder. If Sidekicks was opened from the Finder and does not find the program, write its full path (`which mm` in a terminal gives it). Sidekicks reads your shell's `PATH` at startup, so this is rarely needed. | 18 | - **On this computer**: the program runs here, in the agent's folder. If Sidekicks was opened from the Finder and does not find the program, write its full path (`which mm` in a terminal gives it). Sidekicks reads your shell's `PATH` at startup, so this is rarely needed. |
| 19 | - **In a Docker container**: give the **Container name**. The container must exist (Sidekicks starts it if it is stopped), with the agent's folder mounted at the same path, and contain the program: see [How to run an agent in a Docker container](run-an-agent-in-docker.md). Sidekicks starts the agent with `docker exec -i <container> <program> <arguments>`. To have the container recreated when it is gone, drop its `compose.yaml` on **Recreate the container when it is gone** and pick the service, or type the commands: see [Restart or recreate the container](run-an-agent-in-docker.md#restart-or-recreate-the-container). | 19 | - **In a Docker container**: give the **Container name**. The container must exist (Sidekicks starts it if it is stopped), with the agent's folder mounted at the same path, and contain the program: see [How to run an agent in a Docker container](run-an-agent-in-docker.md). Sidekicks starts the agent with `docker exec -i <container> <program> <arguments>`. To have the container recreated when it is gone, drop its `compose.yaml` on **Recreate the container when it is gone** and pick the service, or type the commands: see [Restart or recreate the container](run-an-agent-in-docker.md#restart-or-recreate-the-container). |
| 20 | - **In an sbx sandbox**: give the **Sandbox name**. The sandbox must exist, with the agent's folder at the same path: see [How to run an agent in an sbx sandbox](run-an-agent-in-a-sandbox.md). Sidekicks starts the agent with `sbx exec -i <sandbox> <program> <arguments>`. To have the sandbox recreated when it is gone, drop its `sbxenv.yaml` on **Recreate the sandbox when it is gone**, or type the commands: see [Recreate the sandbox when it is gone](run-an-agent-in-a-sandbox.md#recreate-the-sandbox-when-it-is-gone). | 20 | - **In an sbx sandbox**: give the **Sandbox name**. The sandbox must exist, with the agent's folder at the same path: see [How to run an agent in an sbx sandbox](run-an-agent-in-a-sandbox.md). Sidekicks starts the agent with `sbx exec -i <sandbox> <program> <arguments>`. To have the sandbox recreated when it is gone, drop its `sbxenv.yaml` on **Recreate the sandbox when it is gone**, or type the commands: see [Recreate the sandbox when it is gone](run-an-agent-in-a-sandbox.md#recreate-the-sandbox-when-it-is-gone). |
| 21 | +- **Claude in an sbx sandbox**: choose **In an sbx sandbox**, then the program `claude-agent-acp`, and click **Prepare the sandbox**: Sidekicks writes the sandbox's `sbxenv.yaml` and its `workspace/` folder, and fills in the rest. It relies on the `docker.io/sbx/claude-acp` kit, provided by a third party, not by Sidekicks. See [How to add a Claude agent in an sbx sandbox](add-a-claude-agent-in-a-sandbox.md). | ||
| 21 | - **Options the assistant does not ask for** (`env`, `afterStop`, a different `workspacePath`): add the agent with the assistant, then complete its entry in **Settings**. | 22 | - **Options the assistant does not ask for** (`env`, `afterStop`, a different `workspacePath`): add the agent with the assistant, then complete its entry in **Settings**. |
| 22 | 23 | ||
| 23 | ## See also | 24 | ## See also |
modified
docs/en/reference/agents-and-events.md +1 -0 | @@ -225,6 +225,7 @@ A file opened for editing has `path, content, version`; `version` identifies the | ||
| 225 | 225 | | `Choose()` | Shows the native file dialog and opens the chosen file; returns `""` when cancelled. | |
| 226 | 226 | | `Recent()` | The configuration files opened from the application, most recent first (8 at most). | |
| 227 | 227 | | `ReadSandboxEnv(path)` | Reads an sbx environment file for the assistant: `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commands on one line). A file that is not one is an error. | |
| 228 | +| `PrepareClaudeSandbox(folder, sandbox)` | Prepares Claude in an sbx sandbox (issue #81): in `folder` (created; `~` is the home folder; a relative folder is refused) writes `sbxenv.yaml` for the sandbox `sandbox` — the content of `agents/snippets/claude-acp`, kit `docker.io/sbx/claude-acp` (third party) — unless one is there, and creates `workspace/`. Returns what `ReadSandboxEnv` returns for it, plus `file` and `written` (false: an existing file was kept). | | |
| 228 | 229 | | `ChooseSandboxEnv()` | Shows the native file dialog, from the home folder, for an sbx environment file; returns its path, or `""` when cancelled. | |
| 229 | 230 | | `ChooseAgentConfig()` | The same, for an agent's configuration file (YAML). | |
| 230 | 231 | | `ReadCompose(path)` | Reads a Docker Compose file for the assistant: `folder`, and each service's `name, container, createCommand, stopCommand, removeCommand`. A file without services is an error. | |
| @@ -225,6 +225,7 @@ A file opened for editing has `path, content, version`; `version` identifies the | |||
| 225 | | `Choose()` | Shows the native file dialog and opens the chosen file; returns `""` when cancelled. | | 225 | | `Choose()` | Shows the native file dialog and opens the chosen file; returns `""` when cancelled. | |
| 226 | | `Recent()` | The configuration files opened from the application, most recent first (8 at most). | | 226 | | `Recent()` | The configuration files opened from the application, most recent first (8 at most). | |
| 227 | | `ReadSandboxEnv(path)` | Reads an sbx environment file for the assistant: `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commands on one line). A file that is not one is an error. | | 227 | | `ReadSandboxEnv(path)` | Reads an sbx environment file for the assistant: `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commands on one line). A file that is not one is an error. | |
| 228 | +| `PrepareClaudeSandbox(folder, sandbox)` | Prepares Claude in an sbx sandbox (issue #81): in `folder` (created; `~` is the home folder; a relative folder is refused) writes `sbxenv.yaml` for the sandbox `sandbox` — the content of `agents/snippets/claude-acp`, kit `docker.io/sbx/claude-acp` (third party) — unless one is there, and creates `workspace/`. Returns what `ReadSandboxEnv` returns for it, plus `file` and `written` (false: an existing file was kept). | | ||
| 228 | | `ChooseSandboxEnv()` | Shows the native file dialog, from the home folder, for an sbx environment file; returns its path, or `""` when cancelled. | | 229 | | `ChooseSandboxEnv()` | Shows the native file dialog, from the home folder, for an sbx environment file; returns its path, or `""` when cancelled. | |
| 229 | | `ChooseAgentConfig()` | The same, for an agent's configuration file (YAML). | | 230 | | `ChooseAgentConfig()` | The same, for an agent's configuration file (YAML). | |
| 230 | | `ReadCompose(path)` | Reads a Docker Compose file for the assistant: `folder`, and each service's `name, container, createCommand, stopCommand, removeCommand`. A file without services is an error. | | 231 | | `ReadCompose(path)` | Reads a Docker Compose file for the assistant: `folder`, and each service's `name, container, createCommand, stopCommand, removeCommand`. A file without services is an error. | |
modified
docs/fr/how-to/ajouter-un-agent-claude-dans-une-sandbox.md +16 -1 | @@ -4,6 +4,10 @@ Ce guide montre comment ajouter Claude (Claude Code, via son adaptateur ACP `cla | ||
| 4 | 4 | |
| 5 | 5 | Un exemple prêt à l'emploi est dans le dépôt : [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). |
| 6 | 6 | |
| 7 | +## Un kit fourni par un tiers | |
| 8 | + | |
| 9 | +La sandbox est construite à partir du kit `docker.io/sbx/claude-acp`. Ce kit est fourni par un tiers, **pas par Sidekicks** : son contenu (Claude Code, `claude-agent-acp`), ses mises à jour (la sandbox télécharge `latest` à chaque création) et sa disponibilité dépendent de ce tiers. Sidekicks se contente d'écrire le `sbxenv.yaml` qui le nomme et de lancer `claude-agent-acp` dans la sandbox. Si le kit change ou disparaît, la sandbox peut ne plus pouvoir être créée, ou Claude ne plus démarrer : l'onglet **Log** montre alors ce que sbx a répondu. | |
| 10 | + | |
| 7 | 11 | ## Ce qu'il faut |
| 8 | 12 | |
| 9 | 13 | | | Rôle | |
| @@ -12,7 +16,18 @@ Un exemple prêt à l'emploi est dans le dépôt : [`agents/snippets/claude-acp` | ||
| 12 | 16 | | Le kit `docker.io/sbx/claude-acp` | l'image de la sandbox, avec Claude Code et `claude-agent-acp` installés. | |
| 13 | 17 | | Votre clé d'API Anthropic, enregistrée dans sbx | sbx l'ajoute aux requêtes de Claude vers Anthropic : elle n'est écrite ni dans la sandbox, ni dans la configuration de Sidekicks. | |
| 14 | 18 | |
| 15 | -## Étapes | |
| 19 | +## Le plus simple : laisser l'assistant préparer la sandbox | |
| 20 | + | |
| 21 | +1. Dans le panneau **Agents**, cliquez sur **+ Ajouter un agent**. Remplissez **Nom affiché** (`Claude`) et, si vous voulez, une icône (📙). | |
| 22 | +2. **Où tourne-t-il ?** Choisissez **Dans une sandbox sbx**. | |
| 23 | +3. **Programme** : choisissez `claude-agent-acp` dans la liste (il n'est proposé que dans une sandbox sbx). Une zone **Claude dans une sandbox sbx** apparaît. | |
| 24 | +4. Vérifiez le **Dossier de la sandbox** (`~/agents/<nom>` par défaut, ou **Choisir…**) et le **Nom de la sandbox** (`<nom>-sbx` par défaut), puis cliquez sur **Préparer la sandbox**. Sidekicks écrit `sbxenv.yaml` (celui de l'étape 2 ci-dessous) et un `workspace/` vide dans ce dossier — un `sbxenv.yaml` déjà présent est gardé tel quel — et remplit le reste du formulaire : la sandbox, le dossier de l'agent (`…/workspace`), les commandes `sbx env`, aucun argument. | |
| 25 | +5. Cliquez sur **Ajouter l'agent**. (Si vous cliquez sans avoir préparé, Sidekicks prépare d'abord la sandbox, avec le dossier affiché.) | |
| 26 | +6. Donnez votre clé d'API Anthropic à sbx (étape 3 ci-dessous), puis démarrez Claude (étape 5 ci-dessous). | |
| 27 | + | |
| 28 | +## À la main | |
| 29 | + | |
| 30 | +Le même résultat, étape par étape — ou pour adapter une sandbox existante. | |
| 16 | 31 | |
| 17 | 32 | 1. **Créez le dossier de l'agent**, avec un `workspace/` vide dedans : |
| 18 | 33 | |
| @@ -4,6 +4,10 @@ Ce guide montre comment ajouter Claude (Claude Code, via son adaptateur ACP `cla | |||
| 4 | 4 | ||
| 5 | Un exemple prêt à l'emploi est dans le dépôt : [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). | 5 | Un exemple prêt à l'emploi est dans le dépôt : [`agents/snippets/claude-acp`](../../../agents/snippets/claude-acp/README.md). |
| 6 | 6 | ||
| 7 | +## Un kit fourni par un tiers | ||
| 8 | + | ||
| 9 | +La sandbox est construite à partir du kit `docker.io/sbx/claude-acp`. Ce kit est fourni par un tiers, **pas par Sidekicks** : son contenu (Claude Code, `claude-agent-acp`), ses mises à jour (la sandbox télécharge `latest` à chaque création) et sa disponibilité dépendent de ce tiers. Sidekicks se contente d'écrire le `sbxenv.yaml` qui le nomme et de lancer `claude-agent-acp` dans la sandbox. Si le kit change ou disparaît, la sandbox peut ne plus pouvoir être créée, ou Claude ne plus démarrer : l'onglet **Log** montre alors ce que sbx a répondu. | ||
| 10 | + | ||
| 7 | ## Ce qu'il faut | 11 | ## Ce qu'il faut |
| 8 | 12 | ||
| 9 | | | Rôle | | 13 | | | Rôle | |
| @@ -12,7 +16,18 @@ Un exemple prêt à l'emploi est dans le dépôt : [`agents/snippets/claude-acp` | |||
| 12 | | Le kit `docker.io/sbx/claude-acp` | l'image de la sandbox, avec Claude Code et `claude-agent-acp` installés. | | 16 | | Le kit `docker.io/sbx/claude-acp` | l'image de la sandbox, avec Claude Code et `claude-agent-acp` installés. | |
| 13 | | Votre clé d'API Anthropic, enregistrée dans sbx | sbx l'ajoute aux requêtes de Claude vers Anthropic : elle n'est écrite ni dans la sandbox, ni dans la configuration de Sidekicks. | | 17 | | Votre clé d'API Anthropic, enregistrée dans sbx | sbx l'ajoute aux requêtes de Claude vers Anthropic : elle n'est écrite ni dans la sandbox, ni dans la configuration de Sidekicks. | |
| 14 | 18 | ||
| 15 | -## Étapes | 19 | +## Le plus simple : laisser l'assistant préparer la sandbox |
| 20 | + | ||
| 21 | +1. Dans le panneau **Agents**, cliquez sur **+ Ajouter un agent**. Remplissez **Nom affiché** (`Claude`) et, si vous voulez, une icône (📙). | ||
| 22 | +2. **Où tourne-t-il ?** Choisissez **Dans une sandbox sbx**. | ||
| 23 | +3. **Programme** : choisissez `claude-agent-acp` dans la liste (il n'est proposé que dans une sandbox sbx). Une zone **Claude dans une sandbox sbx** apparaît. | ||
| 24 | +4. Vérifiez le **Dossier de la sandbox** (`~/agents/<nom>` par défaut, ou **Choisir…**) et le **Nom de la sandbox** (`<nom>-sbx` par défaut), puis cliquez sur **Préparer la sandbox**. Sidekicks écrit `sbxenv.yaml` (celui de l'étape 2 ci-dessous) et un `workspace/` vide dans ce dossier — un `sbxenv.yaml` déjà présent est gardé tel quel — et remplit le reste du formulaire : la sandbox, le dossier de l'agent (`…/workspace`), les commandes `sbx env`, aucun argument. | ||
| 25 | +5. Cliquez sur **Ajouter l'agent**. (Si vous cliquez sans avoir préparé, Sidekicks prépare d'abord la sandbox, avec le dossier affiché.) | ||
| 26 | +6. Donnez votre clé d'API Anthropic à sbx (étape 3 ci-dessous), puis démarrez Claude (étape 5 ci-dessous). | ||
| 27 | + | ||
| 28 | +## À la main | ||
| 29 | + | ||
| 30 | +Le même résultat, étape par étape — ou pour adapter une sandbox existante. | ||
| 16 | 31 | ||
| 17 | 1. **Créez le dossier de l'agent**, avec un `workspace/` vide dedans : | 32 | 1. **Créez le dossier de l'agent**, avec un `workspace/` vide dedans : |
| 18 | 33 | ||
modified
docs/fr/how-to/ajouter-un-agent.md +2 -1 | @@ -7,7 +7,7 @@ Ce guide montre comment ajouter un agent depuis la fenêtre de Sidekicks, avec l | ||
| 7 | 7 | 1. Ouvrez l'assistant : **+ Ajouter mon premier agent** sur l'écran d'accueil, **+ Ajouter un agent** sous la liste des agents, ou **⇧⌘N** (Ctrl+Maj+N sous Linux et Windows). |
| 8 | 8 | 2. **Qui est-ce ?** Remplissez **Nom affiché** (par exemple `Garfield (traducteur)`). **Nom utilisé avec @** le suit ; changez-le si vous en voulez un plus court (minuscules, chiffres, `-` et `_`, en commençant par une lettre). L'icône et la description sont facultatives : l'icône est un emoji, ou une lettre affichée dans un rond coloré ; laissée vide, le rond contient la première lettre du nom affiché. |
| 9 | 9 | 3. **Où tourne-t-il ?** Choisissez l'environnement, puis remplissez ce qu'il demande (voir plus bas). |
| 10 | -4. **Comment le démarrer ?** Remplissez **Programme** (choisissez `mm`, `docker-agent` ou `docker agent` dans la liste, ou tapez-en un autre), **Arguments** (sur une ligne, comme dans un terminal ; les guillemets regroupent des mots) et **Dossier de l'agent**. Le dossier est créé s'il n'existe pas. | |
| 10 | +4. **Comment le démarrer ?** Remplissez **Programme** (choisissez `mm`, `docker-agent` ou `docker agent` dans la liste — plus `claude-agent-acp` dans une sandbox sbx — ou tapez-en un autre), **Arguments** (sur une ligne, comme dans un terminal ; les guillemets regroupent des mots) et **Dossier de l'agent**. Le dossier est créé s'il n'existe pas. | |
| 11 | 11 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation directe s'ouvre dès que la configuration est rechargée. |
| 12 | 12 | |
| 13 | 13 | Quand l'agent ne peut pas être ajouté (un nom déjà pris, par exemple), l'assistant dit pourquoi et n'écrit rien. |
| @@ -18,6 +18,7 @@ Quand l'agent ne peut pas être ajouté (un nom déjà pris, par exemple), l'ass | ||
| 18 | 18 | - **Sur cet ordinateur** : le programme tourne ici, dans le dossier de l'agent. Si Sidekicks, ouvert depuis le Finder, ne trouve pas le programme, indiquez son chemin complet (`which mm` dans un terminal le donne). Sidekicks lit le `PATH` de votre shell au démarrage : c'est rarement nécessaire. |
| 19 | 19 | - **Dans un conteneur Docker** : indiquez le **Nom du conteneur**. Le conteneur doit exister (Sidekicks le démarre s'il est arrêté), avec le dossier de l'agent monté au même chemin, et contenir le programme : voir [Lancer un agent dans un conteneur Docker](lancer-un-agent-dans-docker.md). Sidekicks démarre l'agent avec `docker exec -i <conteneur> <programme> <arguments>`. Pour que le conteneur soit recréé quand il a disparu, déposez son `compose.yaml` sur **Recréer le conteneur s'il a disparu** et choisissez le service, ou tapez les commandes : voir [Redémarrer ou recréer le conteneur](lancer-un-agent-dans-docker.md#redémarrer-ou-recréer-le-conteneur). |
| 20 | 20 | - **Dans une sandbox sbx** : indiquez le **Nom de la sandbox**. Elle doit exister, avec le dossier de l'agent au même chemin : voir [Lancer un agent dans une sandbox sbx](lancer-un-agent-dans-une-sandbox.md). Sidekicks démarre l'agent avec `sbx exec -i <sandbox> <programme> <arguments>`. Pour que la sandbox soit recréée quand elle a disparu, déposez son `sbxenv.yaml` sur **Recréer la sandbox si elle a disparu**, ou tapez les commandes : voir [Recréer la sandbox quand elle a disparu](lancer-un-agent-dans-une-sandbox.md#recréer-la-sandbox-quand-elle-a-disparu). |
| 21 | +- **Claude dans une sandbox sbx** : choisissez **Dans une sandbox sbx**, puis le programme `claude-agent-acp`, et cliquez sur **Préparer la sandbox** : Sidekicks écrit le `sbxenv.yaml` de la sandbox et son dossier `workspace/`, et remplit le reste. Cela repose sur le kit `docker.io/sbx/claude-acp`, fourni par un tiers et non par Sidekicks. Voir [Ajouter un agent Claude dans une sandbox sbx](ajouter-un-agent-claude-dans-une-sandbox.md). | |
| 21 | 22 | - **Les options que l'assistant ne demande pas** (`env`, `afterStop`, un autre `workspacePath`) : ajoutez l'agent avec l'assistant, puis complétez son entrée dans **Settings**. |
| 22 | 23 | |
| 23 | 24 | ## Voir aussi |
| @@ -7,7 +7,7 @@ Ce guide montre comment ajouter un agent depuis la fenêtre de Sidekicks, avec l | |||
| 7 | 1. Ouvrez l'assistant : **+ Ajouter mon premier agent** sur l'écran d'accueil, **+ Ajouter un agent** sous la liste des agents, ou **⇧⌘N** (Ctrl+Maj+N sous Linux et Windows). | 7 | 1. Ouvrez l'assistant : **+ Ajouter mon premier agent** sur l'écran d'accueil, **+ Ajouter un agent** sous la liste des agents, ou **⇧⌘N** (Ctrl+Maj+N sous Linux et Windows). |
| 8 | 2. **Qui est-ce ?** Remplissez **Nom affiché** (par exemple `Garfield (traducteur)`). **Nom utilisé avec @** le suit ; changez-le si vous en voulez un plus court (minuscules, chiffres, `-` et `_`, en commençant par une lettre). L'icône et la description sont facultatives : l'icône est un emoji, ou une lettre affichée dans un rond coloré ; laissée vide, le rond contient la première lettre du nom affiché. | 8 | 2. **Qui est-ce ?** Remplissez **Nom affiché** (par exemple `Garfield (traducteur)`). **Nom utilisé avec @** le suit ; changez-le si vous en voulez un plus court (minuscules, chiffres, `-` et `_`, en commençant par une lettre). L'icône et la description sont facultatives : l'icône est un emoji, ou une lettre affichée dans un rond coloré ; laissée vide, le rond contient la première lettre du nom affiché. |
| 9 | 3. **Où tourne-t-il ?** Choisissez l'environnement, puis remplissez ce qu'il demande (voir plus bas). | 9 | 3. **Où tourne-t-il ?** Choisissez l'environnement, puis remplissez ce qu'il demande (voir plus bas). |
| 10 | -4. **Comment le démarrer ?** Remplissez **Programme** (choisissez `mm`, `docker-agent` ou `docker agent` dans la liste, ou tapez-en un autre), **Arguments** (sur une ligne, comme dans un terminal ; les guillemets regroupent des mots) et **Dossier de l'agent**. Le dossier est créé s'il n'existe pas. | 10 | +4. **Comment le démarrer ?** Remplissez **Programme** (choisissez `mm`, `docker-agent` ou `docker agent` dans la liste — plus `claude-agent-acp` dans une sandbox sbx — ou tapez-en un autre), **Arguments** (sur une ligne, comme dans un terminal ; les guillemets regroupent des mots) et **Dossier de l'agent**. Le dossier est créé s'il n'existe pas. |
| 11 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation directe s'ouvre dès que la configuration est rechargée. | 11 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation directe s'ouvre dès que la configuration est rechargée. |
| 12 | 12 | ||
| 13 | Quand l'agent ne peut pas être ajouté (un nom déjà pris, par exemple), l'assistant dit pourquoi et n'écrit rien. | 13 | Quand l'agent ne peut pas être ajouté (un nom déjà pris, par exemple), l'assistant dit pourquoi et n'écrit rien. |
| @@ -18,6 +18,7 @@ Quand l'agent ne peut pas être ajouté (un nom déjà pris, par exemple), l'ass | |||
| 18 | - **Sur cet ordinateur** : le programme tourne ici, dans le dossier de l'agent. Si Sidekicks, ouvert depuis le Finder, ne trouve pas le programme, indiquez son chemin complet (`which mm` dans un terminal le donne). Sidekicks lit le `PATH` de votre shell au démarrage : c'est rarement nécessaire. | 18 | - **Sur cet ordinateur** : le programme tourne ici, dans le dossier de l'agent. Si Sidekicks, ouvert depuis le Finder, ne trouve pas le programme, indiquez son chemin complet (`which mm` dans un terminal le donne). Sidekicks lit le `PATH` de votre shell au démarrage : c'est rarement nécessaire. |
| 19 | - **Dans un conteneur Docker** : indiquez le **Nom du conteneur**. Le conteneur doit exister (Sidekicks le démarre s'il est arrêté), avec le dossier de l'agent monté au même chemin, et contenir le programme : voir [Lancer un agent dans un conteneur Docker](lancer-un-agent-dans-docker.md). Sidekicks démarre l'agent avec `docker exec -i <conteneur> <programme> <arguments>`. Pour que le conteneur soit recréé quand il a disparu, déposez son `compose.yaml` sur **Recréer le conteneur s'il a disparu** et choisissez le service, ou tapez les commandes : voir [Redémarrer ou recréer le conteneur](lancer-un-agent-dans-docker.md#redémarrer-ou-recréer-le-conteneur). | 19 | - **Dans un conteneur Docker** : indiquez le **Nom du conteneur**. Le conteneur doit exister (Sidekicks le démarre s'il est arrêté), avec le dossier de l'agent monté au même chemin, et contenir le programme : voir [Lancer un agent dans un conteneur Docker](lancer-un-agent-dans-docker.md). Sidekicks démarre l'agent avec `docker exec -i <conteneur> <programme> <arguments>`. Pour que le conteneur soit recréé quand il a disparu, déposez son `compose.yaml` sur **Recréer le conteneur s'il a disparu** et choisissez le service, ou tapez les commandes : voir [Redémarrer ou recréer le conteneur](lancer-un-agent-dans-docker.md#redémarrer-ou-recréer-le-conteneur). |
| 20 | - **Dans une sandbox sbx** : indiquez le **Nom de la sandbox**. Elle doit exister, avec le dossier de l'agent au même chemin : voir [Lancer un agent dans une sandbox sbx](lancer-un-agent-dans-une-sandbox.md). Sidekicks démarre l'agent avec `sbx exec -i <sandbox> <programme> <arguments>`. Pour que la sandbox soit recréée quand elle a disparu, déposez son `sbxenv.yaml` sur **Recréer la sandbox si elle a disparu**, ou tapez les commandes : voir [Recréer la sandbox quand elle a disparu](lancer-un-agent-dans-une-sandbox.md#recréer-la-sandbox-quand-elle-a-disparu). | 20 | - **Dans une sandbox sbx** : indiquez le **Nom de la sandbox**. Elle doit exister, avec le dossier de l'agent au même chemin : voir [Lancer un agent dans une sandbox sbx](lancer-un-agent-dans-une-sandbox.md). Sidekicks démarre l'agent avec `sbx exec -i <sandbox> <programme> <arguments>`. Pour que la sandbox soit recréée quand elle a disparu, déposez son `sbxenv.yaml` sur **Recréer la sandbox si elle a disparu**, ou tapez les commandes : voir [Recréer la sandbox quand elle a disparu](lancer-un-agent-dans-une-sandbox.md#recréer-la-sandbox-quand-elle-a-disparu). |
| 21 | +- **Claude dans une sandbox sbx** : choisissez **Dans une sandbox sbx**, puis le programme `claude-agent-acp`, et cliquez sur **Préparer la sandbox** : Sidekicks écrit le `sbxenv.yaml` de la sandbox et son dossier `workspace/`, et remplit le reste. Cela repose sur le kit `docker.io/sbx/claude-acp`, fourni par un tiers et non par Sidekicks. Voir [Ajouter un agent Claude dans une sandbox sbx](ajouter-un-agent-claude-dans-une-sandbox.md). | ||
| 21 | - **Les options que l'assistant ne demande pas** (`env`, `afterStop`, un autre `workspacePath`) : ajoutez l'agent avec l'assistant, puis complétez son entrée dans **Settings**. | 22 | - **Les options que l'assistant ne demande pas** (`env`, `afterStop`, un autre `workspacePath`) : ajoutez l'agent avec l'assistant, puis complétez son entrée dans **Settings**. |
| 22 | 23 | ||
| 23 | ## Voir aussi | 24 | ## Voir aussi |
modified
docs/fr/reference/agents-et-evenements.md +1 -0 | @@ -225,6 +225,7 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | ||
| 225 | 225 | | `Choose()` | Affiche le sélecteur de fichier natif et ouvre le fichier choisi ; renvoie `""` en cas d'annulation. | |
| 226 | 226 | | `Recent()` | Les fichiers de configuration ouverts depuis l'application, du plus récent au plus ancien (8 au plus). | |
| 227 | 227 | | `ReadSandboxEnv(path)` | Lit un fichier d'environnement sbx pour l'assistant : `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commandes sur une ligne). Un fichier qui n'en est pas un est une erreur. | |
| 228 | +| `PrepareClaudeSandbox(folder, sandbox)` | Prépare Claude dans une sandbox sbx (issue #81) : dans `folder` (créé ; `~` est le dossier personnel ; un dossier relatif est refusé) écrit le `sbxenv.yaml` de la sandbox `sandbox` — le contenu de `agents/snippets/claude-acp`, kit `docker.io/sbx/claude-acp` (fourni par un tiers) — sauf s'il en existe déjà un, et crée `workspace/`. Renvoie ce que `ReadSandboxEnv` renvoie pour lui, plus `file` et `written` (false : un fichier existant a été gardé). | | |
| 228 | 229 | | `ChooseSandboxEnv()` | Affiche le sélecteur de fichier natif, depuis le dossier personnel, pour un fichier d'environnement sbx ; renvoie son chemin, ou `""` en cas d'annulation. | |
| 229 | 230 | | `ChooseAgentConfig()` | De même, pour le fichier de configuration d'un agent (YAML). | |
| 230 | 231 | | `ReadCompose(path)` | Lit un fichier Docker Compose pour l'assistant : `folder`, et pour chaque service `name, container, createCommand, stopCommand, removeCommand`. Un fichier sans services est une erreur. | |
| @@ -225,6 +225,7 @@ Un fichier ouvert pour modification a `path, content, version` ; `version` ident | |||
| 225 | | `Choose()` | Affiche le sélecteur de fichier natif et ouvre le fichier choisi ; renvoie `""` en cas d'annulation. | | 225 | | `Choose()` | Affiche le sélecteur de fichier natif et ouvre le fichier choisi ; renvoie `""` en cas d'annulation. | |
| 226 | | `Recent()` | Les fichiers de configuration ouverts depuis l'application, du plus récent au plus ancien (8 au plus). | | 226 | | `Recent()` | Les fichiers de configuration ouverts depuis l'application, du plus récent au plus ancien (8 au plus). | |
| 227 | | `ReadSandboxEnv(path)` | Lit un fichier d'environnement sbx pour l'assistant : `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commandes sur une ligne). Un fichier qui n'en est pas un est une erreur. | | 227 | | `ReadSandboxEnv(path)` | Lit un fichier d'environnement sbx pour l'assistant : `name, workspace, sandboxFolder, createCommand, stopCommand, removeCommand` (commandes sur une ligne). Un fichier qui n'en est pas un est une erreur. | |
| 228 | +| `PrepareClaudeSandbox(folder, sandbox)` | Prépare Claude dans une sandbox sbx (issue #81) : dans `folder` (créé ; `~` est le dossier personnel ; un dossier relatif est refusé) écrit le `sbxenv.yaml` de la sandbox `sandbox` — le contenu de `agents/snippets/claude-acp`, kit `docker.io/sbx/claude-acp` (fourni par un tiers) — sauf s'il en existe déjà un, et crée `workspace/`. Renvoie ce que `ReadSandboxEnv` renvoie pour lui, plus `file` et `written` (false : un fichier existant a été gardé). | | ||
| 228 | | `ChooseSandboxEnv()` | Affiche le sélecteur de fichier natif, depuis le dossier personnel, pour un fichier d'environnement sbx ; renvoie son chemin, ou `""` en cas d'annulation. | | 229 | | `ChooseSandboxEnv()` | Affiche le sélecteur de fichier natif, depuis le dossier personnel, pour un fichier d'environnement sbx ; renvoie son chemin, ou `""` en cas d'annulation. | |
| 229 | | `ChooseAgentConfig()` | De même, pour le fichier de configuration d'un agent (YAML). | | 230 | | `ChooseAgentConfig()` | De même, pour le fichier de configuration d'un agent (YAML). | |
| 230 | | `ReadCompose(path)` | Lit un fichier Docker Compose pour l'assistant : `folder`, et pour chaque service `name, container, createCommand, stopCommand, removeCommand`. Un fichier sans services est une erreur. | | 231 | | `ReadCompose(path)` | Lit un fichier Docker Compose pour l'assistant : `folder`, et pour chaque service `name, container, createCommand, stopCommand, removeCommand`. Un fichier sans services est une erreur. | |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/configservice.ts +14 -0 | @@ -94,6 +94,20 @@ export function Open(path: string): $CancellablePromise<void> { | ||
| 94 | 94 | return $Call.ByID(1253958173, path); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | +/** | |
| 98 | + * PrepareClaudeSandbox prepares a Claude agent in an sbx sandbox (issue | |
| 99 | + * #81): in folder (created if needed, "~" is the home folder) it writes the | |
| 100 | + * sbxenv.yaml of a sandbox called sandbox, unless one is already there, and | |
| 101 | + * creates the workspace/ folder Claude works in. It returns what the | |
| 102 | + * assistant fills in, as when an sbxenv.yaml is dropped on it. | |
| 103 | + * | |
| 104 | + * prepared, err := service.PrepareClaudeSandbox("~/agents/claude", "claude-sbx") | |
| 105 | + * // prepared.Workspace == "/Users/me/agents/claude/workspace", prepared.CreateCommand == "sbx env create --force" | |
| 106 | + */ | |
| 107 | +export function PrepareClaudeSandbox(folder: string, sandbox: string): $CancellablePromise<$models.PreparedSandbox> { | |
| 108 | + return $Call.ByID(1375109349, folder, sandbox); | |
| 109 | +} | |
| 110 | + | |
| 97 | 111 | /** |
| 98 | 112 | * ReadCompose reads the Docker Compose file at path (dropped on the |
| 99 | 113 | * assistant, or chosen with ChooseCompose). |
| @@ -94,6 +94,20 @@ export function Open(path: string): $CancellablePromise<void> { | |||
| 94 | return $Call.ByID(1253958173, path); | 94 | return $Call.ByID(1253958173, path); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | +/** | ||
| 98 | + * PrepareClaudeSandbox prepares a Claude agent in an sbx sandbox (issue | ||
| 99 | + * #81): in folder (created if needed, "~" is the home folder) it writes the | ||
| 100 | + * sbxenv.yaml of a sandbox called sandbox, unless one is already there, and | ||
| 101 | + * creates the workspace/ folder Claude works in. It returns what the | ||
| 102 | + * assistant fills in, as when an sbxenv.yaml is dropped on it. | ||
| 103 | + * | ||
| 104 | + * prepared, err := service.PrepareClaudeSandbox("~/agents/claude", "claude-sbx") | ||
| 105 | + * // prepared.Workspace == "/Users/me/agents/claude/workspace", prepared.CreateCommand == "sbx env create --force" | ||
| 106 | + */ | ||
| 107 | +export function PrepareClaudeSandbox(folder: string, sandbox: string): $CancellablePromise<$models.PreparedSandbox> { | ||
| 108 | + return $Call.ByID(1375109349, folder, sandbox); | ||
| 109 | +} | ||
| 110 | + | ||
| 97 | /** | 111 | /** |
| 98 | * ReadCompose reads the Docker Compose file at path (dropped on the | 112 | * ReadCompose reads the Docker Compose file at path (dropped on the |
| 99 | * assistant, or chosen with ChooseCompose). | 113 | * assistant, or chosen with ChooseCompose). |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/index.ts +1 -0 | @@ -23,6 +23,7 @@ export type { | ||
| 23 | 23 | ConfigView, |
| 24 | 24 | LinkedFile, |
| 25 | 25 | OlderView, |
| 26 | + PreparedSandbox, | |
| 26 | 27 | ProblemView, |
| 27 | 28 | ResetResult, |
| 28 | 29 | SandboxEnv, |
| @@ -23,6 +23,7 @@ export type { | |||
| 23 | ConfigView, | 23 | ConfigView, |
| 24 | LinkedFile, | 24 | LinkedFile, |
| 25 | OlderView, | 25 | OlderView, |
| 26 | + PreparedSandbox, | ||
| 26 | ProblemView, | 27 | ProblemView, |
| 27 | ResetResult, | 28 | ResetResult, |
| 28 | SandboxEnv, | 29 | SandboxEnv, |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/models.ts +16 -0 | @@ -135,6 +135,22 @@ export interface OlderView { | ||
| 135 | 135 | "more": boolean; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | +/** | |
| 139 | + * PreparedSandbox is a sandbox prepared by PrepareClaudeSandbox: what the | |
| 140 | + * assistant fills in, and whether the sbxenv.yaml was written or was | |
| 141 | + * already there (it is never overwritten). | |
| 142 | + */ | |
| 143 | +export interface PreparedSandbox { | |
| 144 | + "name": string; | |
| 145 | + "workspace": string; | |
| 146 | + "sandboxFolder": string; | |
| 147 | + "createCommand": string; | |
| 148 | + "stopCommand": string; | |
| 149 | + "removeCommand": string; | |
| 150 | + "file": string; | |
| 151 | + "written": boolean; | |
| 152 | +} | |
| 153 | + | |
| 138 | 154 | /** |
| 139 | 155 | * ProblemView is a problem of the text being edited, located for the editor. |
| 140 | 156 | */ |
| @@ -135,6 +135,22 @@ export interface OlderView { | |||
| 135 | "more": boolean; | 135 | "more": boolean; |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | +/** | ||
| 139 | + * PreparedSandbox is a sandbox prepared by PrepareClaudeSandbox: what the | ||
| 140 | + * assistant fills in, and whether the sbxenv.yaml was written or was | ||
| 141 | + * already there (it is never overwritten). | ||
| 142 | + */ | ||
| 143 | +export interface PreparedSandbox { | ||
| 144 | + "name": string; | ||
| 145 | + "workspace": string; | ||
| 146 | + "sandboxFolder": string; | ||
| 147 | + "createCommand": string; | ||
| 148 | + "stopCommand": string; | ||
| 149 | + "removeCommand": string; | ||
| 150 | + "file": string; | ||
| 151 | + "written": boolean; | ||
| 152 | +} | ||
| 153 | + | ||
| 138 | /** | 154 | /** |
| 139 | * ProblemView is a problem of the text being edited, located for the editor. | 155 | * ProblemView is a problem of the text being edited, located for the editor. |
| 140 | */ | 156 | */ |
modified
frontend/src/lib/agent/AddAgentForm.svelte +86 -4 | @@ -7,7 +7,7 @@ | ||
| 7 | 7 | import { ConfigService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' |
| 8 | 8 | import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events' |
| 9 | 9 | import { FilesDropped } from '../../../bindings/events' |
| 10 | - import { argumentsFor, emptyForm, knownPrograms, nameFromTitle, problemsOf, withAgentConfig, withComposeService, withSandboxEnv, type ComposeServiceValues, type Environment, type Missing } from '../agentform' | |
| 10 | + import { argumentsFor, emptyForm, isClaudeSandbox, nameFromTitle, problemsOf, programsFor, sandboxNameFor, withAgentConfig, withComposeService, withPreparedSandbox, withSandboxEnv, type ComposeServiceValues, type Environment, type Missing } from '../agentform' | |
| 11 | 11 | import { subscribe } from '../events' |
| 12 | 12 | import AgentAvatar from './AgentAvatar.svelte' |
| 13 | 13 | import { agentAdded, appState } from '../state.svelte' |
| @@ -100,6 +100,54 @@ | ||
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | |
| 103 | + // Claude in an sbx sandbox (issue #81): Sidekicks writes the sandbox's | |
| 104 | + // sbxenv.yaml and its workspace/ folder, then fills the form from them. | |
| 105 | + // The folder and the sandbox follow the agent's name until edited. | |
| 106 | + let claudeFolder = $state('') | |
| 107 | + let claudeSandbox = $state('') | |
| 108 | + let claudeFolderEdited = $state(false) | |
| 109 | + let claudeSandboxEdited = $state(false) | |
| 110 | + let preparing = $state(false) | |
| 111 | + let prepared = $state<{ file: string; written: boolean } | null>(null) | |
| 112 | + let prepareProblem = $state('') | |
| 113 | + const claude = $derived(isClaudeSandbox(form)) | |
| 114 | + | |
| 115 | + $effect(() => { | |
| 116 | + const name = form.name.trim() || 'claude' | |
| 117 | + if (!claudeFolderEdited) claudeFolder = `~/agents/${name}` | |
| 118 | + if (!claudeSandboxEdited) claudeSandbox = sandboxNameFor(name) | |
| 119 | + }) | |
| 120 | + | |
| 121 | + async function chooseClaudeFolder() { | |
| 122 | + try { | |
| 123 | + const folder = await ConfigService.ChooseFolder() | |
| 124 | + if (folder) { | |
| 125 | + claudeFolder = folder | |
| 126 | + claudeFolderEdited = true | |
| 127 | + } | |
| 128 | + } catch (error) { | |
| 129 | + prepareProblem = error instanceof Error ? error.message : String(error) | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | + async function prepareClaude(): Promise<boolean> { | |
| 134 | + prepareProblem = '' | |
| 135 | + preparing = true | |
| 136 | + try { | |
| 137 | + const result = await ConfigService.PrepareClaudeSandbox(claudeFolder, claudeSandbox) | |
| 138 | + form = withPreparedSandbox(form, result) | |
| 139 | + envFile = result.file | |
| 140 | + envProblem = '' | |
| 141 | + prepared = { file: result.file, written: result.written } | |
| 142 | + return true | |
| 143 | + } catch (error) { | |
| 144 | + prepareProblem = error instanceof Error ? error.message : String(error) | |
| 145 | + return false | |
| 146 | + } finally { | |
| 147 | + preparing = false | |
| 148 | + } | |
| 149 | + } | |
| 150 | + | |
| 103 | 151 | function useAgentConfig(path: string) { |
| 104 | 152 | if (!/\.ya?ml$/i.test(path)) { |
| 105 | 153 | configProblem = t('assistant.agentConfig.notYaml') |
| @@ -140,6 +188,8 @@ | ||
| 140 | 188 | tried = true |
| 141 | 189 | refused = [] |
| 142 | 190 | failure = '' |
| 191 | + // Claude in a sandbox not prepared yet: prepare it now, with the folder shown. | |
| 192 | + if (claude && !prepared && !(await prepareClaude())) return | |
| 143 | 193 | if (missing.length > 0) return |
| 144 | 194 | adding = true |
| 145 | 195 | try { |
| @@ -258,14 +308,42 @@ | ||
| 258 | 308 | {t('assistant.program')} |
| 259 | 309 | <input bind:value={form.program} oninput={onProgram} list="known-programs" placeholder={t('assistant.programPlaceholder')} aria-invalid={has('program')} aria-describedby="program-hint" spellcheck="false" autocapitalize="off" /> |
| 260 | 310 | <datalist id="known-programs"> |
| 261 | - {#each knownPrograms as program (program)}<option value={program}></option>{/each} | |
| 311 | + {#each programsFor(form.environment) as program (program)}<option value={program}></option>{/each} | |
| 262 | 312 | </datalist> |
| 263 | - <small id="program-hint" class:problem={has('program')}>{has('program') ? t('assistant.missing.program') : t('assistant.programHint')}</small> | |
| 313 | + <small id="program-hint" class:problem={has('program')}>{has('program') ? t('assistant.missing.program') : form.environment === 'sbx' ? t('assistant.programHintSbx') : t('assistant.programHint')}</small> | |
| 264 | 314 | </label> |
| 315 | + {#if claude} | |
| 316 | + <div class="claude"> | |
| 317 | + <p> | |
| 318 | + <strong>{t('assistant.claude.title')}</strong> | |
| 319 | + <small>{t('assistant.claude.intro')}</small> | |
| 320 | + <small>{t('assistant.claude.thirdParty')}</small> | |
| 321 | + </p> | |
| 322 | + <label for="claude-folder">{t('assistant.claude.folder')}</label> | |
| 323 | + <div class="row centered"> | |
| 324 | + <input id="claude-folder" class="grow" bind:value={claudeFolder} oninput={() => { claudeFolderEdited = true; prepared = null }} spellcheck="false" autocapitalize="off" /> | |
| 325 | + <button type="button" onclick={chooseClaudeFolder}>{t('assistant.choose')}</button> | |
| 326 | + </div> | |
| 327 | + <label> | |
| 328 | + {t('assistant.claude.sandbox')} | |
| 329 | + <input bind:value={claudeSandbox} oninput={() => { claudeSandboxEdited = true; prepared = null }} spellcheck="false" autocapitalize="off" /> | |
| 330 | + </label> | |
| 331 | + <div class="row centered"> | |
| 332 | + <button type="button" class="primary" onclick={prepareClaude} disabled={preparing}>{preparing ? t('assistant.claude.preparing') : t('assistant.claude.prepare')}</button> | |
| 333 | + {#if prepareProblem} | |
| 334 | + <small class="problem grow" role="alert">{t('assistant.claude.failed', { error: prepareProblem })}</small> | |
| 335 | + {:else if prepared} | |
| 336 | + <small class="grow" role="status">{prepared.written ? t('assistant.claude.written', { file: prepared.file }) : t('assistant.claude.kept', { file: prepared.file })}</small> | |
| 337 | + {/if} | |
| 338 | + </div> | |
| 339 | + <small>{t('assistant.claude.key')}</small> | |
| 340 | + </div> | |
| 341 | + {/if} | |
| 265 | 342 | <!-- Wherever the agent runs: sbx mounts the shared host folders at the |
| 266 | 343 | same path, and so must the container (as with docker exec today), so |
| 267 | 344 | the file's path on this computer is also its path there. --> |
| 268 | - <div id={configTarget} class="dropzone" data-file-drop-target> | |
| 345 | + <!-- claude-agent-acp has no configuration file to give. --> | |
| 346 | + <div id={configTarget} class="dropzone" class:hidden={claude} data-file-drop-target> | |
| 269 | 347 | <div class="row centered"> |
| 270 | 348 | <p class="grow"> |
| 271 | 349 | <strong>{t('assistant.agentConfig.title')}</strong> |
| @@ -340,5 +418,9 @@ | ||
| 340 | 418 | :global(.dropzone.file-drop-target-active) { border-color: var(--accent); background: var(--bg); } |
| 341 | 419 | :global(.dropzone.file-drop-target-active) .drop { color: var(--accent); } |
| 342 | 420 | .actions { display: flex; justify-content: flex-end; gap: 8px; } |
| 421 | + .claude { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 12px; } | |
| 422 | + .claude p { margin: 0; display: flex; flex-direction: column; gap: 2px; } | |
| 423 | + .claude small { overflow-wrap: anywhere; } | |
| 424 | + .hidden { display: none; } | |
| 343 | 425 | .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } |
| 344 | 426 | </style> |
| @@ -7,7 +7,7 @@ | |||
| 7 | import { ConfigService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | 7 | import { ConfigService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' |
| 8 | import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events' | 8 | import type { FilesDroppedPayload } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/events' |
| 9 | import { FilesDropped } from '../../../bindings/events' | 9 | import { FilesDropped } from '../../../bindings/events' |
| 10 | - import { argumentsFor, emptyForm, knownPrograms, nameFromTitle, problemsOf, withAgentConfig, withComposeService, withSandboxEnv, type ComposeServiceValues, type Environment, type Missing } from '../agentform' | 10 | + import { argumentsFor, emptyForm, isClaudeSandbox, nameFromTitle, problemsOf, programsFor, sandboxNameFor, withAgentConfig, withComposeService, withPreparedSandbox, withSandboxEnv, type ComposeServiceValues, type Environment, type Missing } from '../agentform' |
| 11 | import { subscribe } from '../events' | 11 | import { subscribe } from '../events' |
| 12 | import AgentAvatar from './AgentAvatar.svelte' | 12 | import AgentAvatar from './AgentAvatar.svelte' |
| 13 | import { agentAdded, appState } from '../state.svelte' | 13 | import { agentAdded, appState } from '../state.svelte' |
| @@ -100,6 +100,54 @@ | |||
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | + // Claude in an sbx sandbox (issue #81): Sidekicks writes the sandbox's | ||
| 104 | + // sbxenv.yaml and its workspace/ folder, then fills the form from them. | ||
| 105 | + // The folder and the sandbox follow the agent's name until edited. | ||
| 106 | + let claudeFolder = $state('') | ||
| 107 | + let claudeSandbox = $state('') | ||
| 108 | + let claudeFolderEdited = $state(false) | ||
| 109 | + let claudeSandboxEdited = $state(false) | ||
| 110 | + let preparing = $state(false) | ||
| 111 | + let prepared = $state<{ file: string; written: boolean } | null>(null) | ||
| 112 | + let prepareProblem = $state('') | ||
| 113 | + const claude = $derived(isClaudeSandbox(form)) | ||
| 114 | + | ||
| 115 | + $effect(() => { | ||
| 116 | + const name = form.name.trim() || 'claude' | ||
| 117 | + if (!claudeFolderEdited) claudeFolder = `~/agents/${name}` | ||
| 118 | + if (!claudeSandboxEdited) claudeSandbox = sandboxNameFor(name) | ||
| 119 | + }) | ||
| 120 | + | ||
| 121 | + async function chooseClaudeFolder() { | ||
| 122 | + try { | ||
| 123 | + const folder = await ConfigService.ChooseFolder() | ||
| 124 | + if (folder) { | ||
| 125 | + claudeFolder = folder | ||
| 126 | + claudeFolderEdited = true | ||
| 127 | + } | ||
| 128 | + } catch (error) { | ||
| 129 | + prepareProblem = error instanceof Error ? error.message : String(error) | ||
| 130 | + } | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + async function prepareClaude(): Promise<boolean> { | ||
| 134 | + prepareProblem = '' | ||
| 135 | + preparing = true | ||
| 136 | + try { | ||
| 137 | + const result = await ConfigService.PrepareClaudeSandbox(claudeFolder, claudeSandbox) | ||
| 138 | + form = withPreparedSandbox(form, result) | ||
| 139 | + envFile = result.file | ||
| 140 | + envProblem = '' | ||
| 141 | + prepared = { file: result.file, written: result.written } | ||
| 142 | + return true | ||
| 143 | + } catch (error) { | ||
| 144 | + prepareProblem = error instanceof Error ? error.message : String(error) | ||
| 145 | + return false | ||
| 146 | + } finally { | ||
| 147 | + preparing = false | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + | ||
| 103 | function useAgentConfig(path: string) { | 151 | function useAgentConfig(path: string) { |
| 104 | if (!/\.ya?ml$/i.test(path)) { | 152 | if (!/\.ya?ml$/i.test(path)) { |
| 105 | configProblem = t('assistant.agentConfig.notYaml') | 153 | configProblem = t('assistant.agentConfig.notYaml') |
| @@ -140,6 +188,8 @@ | |||
| 140 | tried = true | 188 | tried = true |
| 141 | refused = [] | 189 | refused = [] |
| 142 | failure = '' | 190 | failure = '' |
| 191 | + // Claude in a sandbox not prepared yet: prepare it now, with the folder shown. | ||
| 192 | + if (claude && !prepared && !(await prepareClaude())) return | ||
| 143 | if (missing.length > 0) return | 193 | if (missing.length > 0) return |
| 144 | adding = true | 194 | adding = true |
| 145 | try { | 195 | try { |
| @@ -258,14 +308,42 @@ | |||
| 258 | {t('assistant.program')} | 308 | {t('assistant.program')} |
| 259 | <input bind:value={form.program} oninput={onProgram} list="known-programs" placeholder={t('assistant.programPlaceholder')} aria-invalid={has('program')} aria-describedby="program-hint" spellcheck="false" autocapitalize="off" /> | 309 | <input bind:value={form.program} oninput={onProgram} list="known-programs" placeholder={t('assistant.programPlaceholder')} aria-invalid={has('program')} aria-describedby="program-hint" spellcheck="false" autocapitalize="off" /> |
| 260 | <datalist id="known-programs"> | 310 | <datalist id="known-programs"> |
| 261 | - {#each knownPrograms as program (program)}<option value={program}></option>{/each} | 311 | + {#each programsFor(form.environment) as program (program)}<option value={program}></option>{/each} |
| 262 | </datalist> | 312 | </datalist> |
| 263 | - <small id="program-hint" class:problem={has('program')}>{has('program') ? t('assistant.missing.program') : t('assistant.programHint')}</small> | 313 | + <small id="program-hint" class:problem={has('program')}>{has('program') ? t('assistant.missing.program') : form.environment === 'sbx' ? t('assistant.programHintSbx') : t('assistant.programHint')}</small> |
| 264 | </label> | 314 | </label> |
| 315 | + {#if claude} | ||
| 316 | + <div class="claude"> | ||
| 317 | + <p> | ||
| 318 | + <strong>{t('assistant.claude.title')}</strong> | ||
| 319 | + <small>{t('assistant.claude.intro')}</small> | ||
| 320 | + <small>{t('assistant.claude.thirdParty')}</small> | ||
| 321 | + </p> | ||
| 322 | + <label for="claude-folder">{t('assistant.claude.folder')}</label> | ||
| 323 | + <div class="row centered"> | ||
| 324 | + <input id="claude-folder" class="grow" bind:value={claudeFolder} oninput={() => { claudeFolderEdited = true; prepared = null }} spellcheck="false" autocapitalize="off" /> | ||
| 325 | + <button type="button" onclick={chooseClaudeFolder}>{t('assistant.choose')}</button> | ||
| 326 | + </div> | ||
| 327 | + <label> | ||
| 328 | + {t('assistant.claude.sandbox')} | ||
| 329 | + <input bind:value={claudeSandbox} oninput={() => { claudeSandboxEdited = true; prepared = null }} spellcheck="false" autocapitalize="off" /> | ||
| 330 | + </label> | ||
| 331 | + <div class="row centered"> | ||
| 332 | + <button type="button" class="primary" onclick={prepareClaude} disabled={preparing}>{preparing ? t('assistant.claude.preparing') : t('assistant.claude.prepare')}</button> | ||
| 333 | + {#if prepareProblem} | ||
| 334 | + <small class="problem grow" role="alert">{t('assistant.claude.failed', { error: prepareProblem })}</small> | ||
| 335 | + {:else if prepared} | ||
| 336 | + <small class="grow" role="status">{prepared.written ? t('assistant.claude.written', { file: prepared.file }) : t('assistant.claude.kept', { file: prepared.file })}</small> | ||
| 337 | + {/if} | ||
| 338 | + </div> | ||
| 339 | + <small>{t('assistant.claude.key')}</small> | ||
| 340 | + </div> | ||
| 341 | + {/if} | ||
| 265 | <!-- Wherever the agent runs: sbx mounts the shared host folders at the | 342 | <!-- Wherever the agent runs: sbx mounts the shared host folders at the |
| 266 | same path, and so must the container (as with docker exec today), so | 343 | same path, and so must the container (as with docker exec today), so |
| 267 | the file's path on this computer is also its path there. --> | 344 | the file's path on this computer is also its path there. --> |
| 268 | - <div id={configTarget} class="dropzone" data-file-drop-target> | 345 | + <!-- claude-agent-acp has no configuration file to give. --> |
| 346 | + <div id={configTarget} class="dropzone" class:hidden={claude} data-file-drop-target> | ||
| 269 | <div class="row centered"> | 347 | <div class="row centered"> |
| 270 | <p class="grow"> | 348 | <p class="grow"> |
| 271 | <strong>{t('assistant.agentConfig.title')}</strong> | 349 | <strong>{t('assistant.agentConfig.title')}</strong> |
| @@ -340,5 +418,9 @@ | |||
| 340 | :global(.dropzone.file-drop-target-active) { border-color: var(--accent); background: var(--bg); } | 418 | :global(.dropzone.file-drop-target-active) { border-color: var(--accent); background: var(--bg); } |
| 341 | :global(.dropzone.file-drop-target-active) .drop { color: var(--accent); } | 419 | :global(.dropzone.file-drop-target-active) .drop { color: var(--accent); } |
| 342 | .actions { display: flex; justify-content: flex-end; gap: 8px; } | 420 | .actions { display: flex; justify-content: flex-end; gap: 8px; } |
| 421 | + .claude { display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--accent); border-radius: var(--radius); padding: 10px 12px; } | ||
| 422 | + .claude p { margin: 0; display: flex; flex-direction: column; gap: 2px; } | ||
| 423 | + .claude small { overflow-wrap: anywhere; } | ||
| 424 | + .hidden { display: none; } | ||
| 343 | .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } | 425 | .primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; } |
| 344 | </style> | 426 | </style> |
modified
frontend/src/lib/agentform.test.ts +31 -1 | @@ -1,7 +1,7 @@ | ||
| 1 | 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE |
| 2 | 2 | |
| 3 | 3 | import { describe, expect, it } from 'vitest' |
| 4 | -import { argumentsFor, emptyForm, folderOf, nameFromTitle, problemsOf, quoteArgument, withAgentConfig, withComposeService, withSandboxEnv } from './agentform' | |
| 4 | +import { argumentsFor, emptyForm, folderOf, isClaudeSandbox, nameFromTitle, problemsOf, programsFor, quoteArgument, sandboxNameFor, withAgentConfig, withComposeService, withPreparedSandbox, withSandboxEnv } from './agentform' | |
| 5 | 5 | |
| 6 | 6 | describe('nameFromTitle', () => { |
| 7 | 7 | it('folds accents, lowercases and joins words', () => { |
| @@ -98,3 +98,33 @@ describe('withComposeService', () => { | ||
| 98 | 98 | }) |
| 99 | 99 | }) |
| 100 | 100 | }) |
| 101 | + | |
| 102 | +describe('Claude in an sbx sandbox (issue #81)', () => { | |
| 103 | + it('offers claude-agent-acp in a sandbox only', () => { | |
| 104 | + expect(programsFor('sbx')).toContain('claude-agent-acp') | |
| 105 | + expect(programsFor('local')).not.toContain('claude-agent-acp') | |
| 106 | + expect(programsFor('container')).not.toContain('claude-agent-acp') | |
| 107 | + }) | |
| 108 | + | |
| 109 | + it('recognises the form', () => { | |
| 110 | + expect(isClaudeSandbox({ ...emptyForm(), environment: 'sbx', program: ' claude-agent-acp ' })).toBe(true) | |
| 111 | + expect(isClaudeSandbox({ ...emptyForm(), environment: 'local', program: 'claude-agent-acp' })).toBe(false) | |
| 112 | + }) | |
| 113 | + | |
| 114 | + it('proposes a sandbox name', () => { | |
| 115 | + expect(sandboxNameFor('claude')).toBe('claude-sbx') | |
| 116 | + expect(sandboxNameFor(' ')).toBe('claude-sbx') | |
| 117 | + }) | |
| 118 | + | |
| 119 | + it('fills the form from the prepared sandbox', () => { | |
| 120 | + const form = { ...emptyForm(), name: 'claude', program: 'claude-agent-acp', arguments: '--old', workspace: '/somewhere' } | |
| 121 | + const filled = withPreparedSandbox(form, { | |
| 122 | + name: 'claude-sbx', workspace: '/agents/claude/workspace', sandboxFolder: '/agents/claude', | |
| 123 | + createCommand: 'sbx env create --force', stopCommand: 'sbx stop claude-sbx', removeCommand: 'sbx env rm --force', | |
| 124 | + }) | |
| 125 | + expect(filled).toMatchObject({ | |
| 126 | + environment: 'sbx', box: 'claude-sbx', workspace: '/agents/claude/workspace', arguments: '', sandboxFolder: '/agents/claude', | |
| 127 | + createCommand: 'sbx env create --force', stopCommand: 'sbx stop claude-sbx', removeCommand: 'sbx env rm --force', | |
| 128 | + }) | |
| 129 | + }) | |
| 130 | +}) | |
| @@ -1,7 +1,7 @@ | |||
| 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | 1 | // Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE |
| 2 | 2 | ||
| 3 | import { describe, expect, it } from 'vitest' | 3 | import { describe, expect, it } from 'vitest' |
| 4 | -import { argumentsFor, emptyForm, folderOf, nameFromTitle, problemsOf, quoteArgument, withAgentConfig, withComposeService, withSandboxEnv } from './agentform' | 4 | +import { argumentsFor, emptyForm, folderOf, isClaudeSandbox, nameFromTitle, problemsOf, programsFor, quoteArgument, sandboxNameFor, withAgentConfig, withComposeService, withPreparedSandbox, withSandboxEnv } from './agentform' |
| 5 | 5 | ||
| 6 | describe('nameFromTitle', () => { | 6 | describe('nameFromTitle', () => { |
| 7 | it('folds accents, lowercases and joins words', () => { | 7 | it('folds accents, lowercases and joins words', () => { |
| @@ -98,3 +98,33 @@ describe('withComposeService', () => { | |||
| 98 | }) | 98 | }) |
| 99 | }) | 99 | }) |
| 100 | }) | 100 | }) |
| 101 | + | ||
| 102 | +describe('Claude in an sbx sandbox (issue #81)', () => { | ||
| 103 | + it('offers claude-agent-acp in a sandbox only', () => { | ||
| 104 | + expect(programsFor('sbx')).toContain('claude-agent-acp') | ||
| 105 | + expect(programsFor('local')).not.toContain('claude-agent-acp') | ||
| 106 | + expect(programsFor('container')).not.toContain('claude-agent-acp') | ||
| 107 | + }) | ||
| 108 | + | ||
| 109 | + it('recognises the form', () => { | ||
| 110 | + expect(isClaudeSandbox({ ...emptyForm(), environment: 'sbx', program: ' claude-agent-acp ' })).toBe(true) | ||
| 111 | + expect(isClaudeSandbox({ ...emptyForm(), environment: 'local', program: 'claude-agent-acp' })).toBe(false) | ||
| 112 | + }) | ||
| 113 | + | ||
| 114 | + it('proposes a sandbox name', () => { | ||
| 115 | + expect(sandboxNameFor('claude')).toBe('claude-sbx') | ||
| 116 | + expect(sandboxNameFor(' ')).toBe('claude-sbx') | ||
| 117 | + }) | ||
| 118 | + | ||
| 119 | + it('fills the form from the prepared sandbox', () => { | ||
| 120 | + const form = { ...emptyForm(), name: 'claude', program: 'claude-agent-acp', arguments: '--old', workspace: '/somewhere' } | ||
| 121 | + const filled = withPreparedSandbox(form, { | ||
| 122 | + name: 'claude-sbx', workspace: '/agents/claude/workspace', sandboxFolder: '/agents/claude', | ||
| 123 | + createCommand: 'sbx env create --force', stopCommand: 'sbx stop claude-sbx', removeCommand: 'sbx env rm --force', | ||
| 124 | + }) | ||
| 125 | + expect(filled).toMatchObject({ | ||
| 126 | + environment: 'sbx', box: 'claude-sbx', workspace: '/agents/claude/workspace', arguments: '', sandboxFolder: '/agents/claude', | ||
| 127 | + createCommand: 'sbx env create --force', stopCommand: 'sbx stop claude-sbx', removeCommand: 'sbx env rm --force', | ||
| 128 | + }) | ||
| 129 | + }) | ||
| 130 | +}) | ||
modified
frontend/src/lib/agentform.ts +43 -0 | @@ -110,6 +110,49 @@ export function problemsOf(form: AgentFormValues): Missing[] { | ||
| 110 | 110 | */ |
| 111 | 111 | export const knownPrograms = ['mm', 'docker-agent', 'docker agent'] as const |
| 112 | 112 | |
| 113 | +/** Claude Code's ACP adapter, offered in an sbx sandbox only (issue #81). */ | |
| 114 | +export const claudeProgram = 'claude-agent-acp' | |
| 115 | + | |
| 116 | +/** | |
| 117 | + * The programs the "Program" field offers where the agent runs: in an sbx | |
| 118 | + * sandbox, also claude-agent-acp, whose sandbox Sidekicks can prepare. | |
| 119 | + * | |
| 120 | + * @example | |
| 121 | + * programsFor('sbx') // ['mm', 'docker-agent', 'docker agent', 'claude-agent-acp'] | |
| 122 | + */ | |
| 123 | +export function programsFor(environment: Environment): string[] { | |
| 124 | + return environment === 'sbx' ? [...knownPrograms, claudeProgram] : [...knownPrograms] | |
| 125 | +} | |
| 126 | + | |
| 127 | +/** Whether the form describes Claude in an sbx sandbox: Sidekicks can prepare its sandbox. */ | |
| 128 | +export function isClaudeSandbox(form: AgentFormValues): boolean { | |
| 129 | + return form.environment === 'sbx' && form.program.trim() === claudeProgram | |
| 130 | +} | |
| 131 | + | |
| 132 | +/** | |
| 133 | + * The sandbox name proposed for an agent: its name followed by -sbx. | |
| 134 | + * | |
| 135 | + * @example | |
| 136 | + * sandboxNameFor('claude') // 'claude-sbx' | |
| 137 | + * sandboxNameFor('') // 'claude-sbx' | |
| 138 | + */ | |
| 139 | +export function sandboxNameFor(name: string): string { | |
| 140 | + return `${name.trim() || 'claude'}-sbx` | |
| 141 | +} | |
| 142 | + | |
| 143 | +/** | |
| 144 | + * Fills the form from a sandbox Sidekicks prepared (issue #81): as with a | |
| 145 | + * dropped sbxenv.yaml, and the agent's folder is the sandbox's workspace | |
| 146 | + * folder; claude-agent-acp takes no argument. | |
| 147 | + * | |
| 148 | + * @example | |
| 149 | + * withPreparedSandbox(form, { name: 'claude-sbx', workspace: '/agents/claude/workspace', … }) | |
| 150 | + * // { …, box: 'claude-sbx', workspace: '/agents/claude/workspace', arguments: '' } | |
| 151 | + */ | |
| 152 | +export function withPreparedSandbox(form: AgentFormValues, env: SandboxEnvValues): AgentFormValues { | |
| 153 | + return { ...withSandboxEnv(form, env), workspace: env.workspace || form.workspace, arguments: '' } | |
| 154 | +} | |
| 155 | + | |
| 113 | 156 | /** |
| 114 | 157 | * Quotes an argument for a field typed like a terminal line, as the backend |
| 115 | 158 | * splits it: double quotes when it holds a space or a quote, single quotes |
| @@ -110,6 +110,49 @@ export function problemsOf(form: AgentFormValues): Missing[] { | |||
| 110 | */ | 110 | */ |
| 111 | export const knownPrograms = ['mm', 'docker-agent', 'docker agent'] as const | 111 | export const knownPrograms = ['mm', 'docker-agent', 'docker agent'] as const |
| 112 | 112 | ||
| 113 | +/** Claude Code's ACP adapter, offered in an sbx sandbox only (issue #81). */ | ||
| 114 | +export const claudeProgram = 'claude-agent-acp' | ||
| 115 | + | ||
| 116 | +/** | ||
| 117 | + * The programs the "Program" field offers where the agent runs: in an sbx | ||
| 118 | + * sandbox, also claude-agent-acp, whose sandbox Sidekicks can prepare. | ||
| 119 | + * | ||
| 120 | + * @example | ||
| 121 | + * programsFor('sbx') // ['mm', 'docker-agent', 'docker agent', 'claude-agent-acp'] | ||
| 122 | + */ | ||
| 123 | +export function programsFor(environment: Environment): string[] { | ||
| 124 | + return environment === 'sbx' ? [...knownPrograms, claudeProgram] : [...knownPrograms] | ||
| 125 | +} | ||
| 126 | + | ||
| 127 | +/** Whether the form describes Claude in an sbx sandbox: Sidekicks can prepare its sandbox. */ | ||
| 128 | +export function isClaudeSandbox(form: AgentFormValues): boolean { | ||
| 129 | + return form.environment === 'sbx' && form.program.trim() === claudeProgram | ||
| 130 | +} | ||
| 131 | + | ||
| 132 | +/** | ||
| 133 | + * The sandbox name proposed for an agent: its name followed by -sbx. | ||
| 134 | + * | ||
| 135 | + * @example | ||
| 136 | + * sandboxNameFor('claude') // 'claude-sbx' | ||
| 137 | + * sandboxNameFor('') // 'claude-sbx' | ||
| 138 | + */ | ||
| 139 | +export function sandboxNameFor(name: string): string { | ||
| 140 | + return `${name.trim() || 'claude'}-sbx` | ||
| 141 | +} | ||
| 142 | + | ||
| 143 | +/** | ||
| 144 | + * Fills the form from a sandbox Sidekicks prepared (issue #81): as with a | ||
| 145 | + * dropped sbxenv.yaml, and the agent's folder is the sandbox's workspace | ||
| 146 | + * folder; claude-agent-acp takes no argument. | ||
| 147 | + * | ||
| 148 | + * @example | ||
| 149 | + * withPreparedSandbox(form, { name: 'claude-sbx', workspace: '/agents/claude/workspace', … }) | ||
| 150 | + * // { …, box: 'claude-sbx', workspace: '/agents/claude/workspace', arguments: '' } | ||
| 151 | + */ | ||
| 152 | +export function withPreparedSandbox(form: AgentFormValues, env: SandboxEnvValues): AgentFormValues { | ||
| 153 | + return { ...withSandboxEnv(form, env), workspace: env.workspace || form.workspace, arguments: '' } | ||
| 154 | +} | ||
| 155 | + | ||
| 113 | /** | 156 | /** |
| 114 | * Quotes an argument for a field typed like a terminal line, as the backend | 157 | * Quotes an argument for a field typed like a terminal line, as the backend |
| 115 | * splits it: double quotes when it holds a space or a quote, single quotes | 158 | * splits it: double quotes when it holds a space or a quote, single quotes |
modified
frontend/src/lib/i18n/messages.ts +24 -0 | @@ -346,6 +346,18 @@ export const en = { | ||
| 346 | 346 | 'assistant.program': 'Program', |
| 347 | 347 | 'assistant.programPlaceholder': 'mm', |
| 348 | 348 | 'assistant.programHint': 'The agent\'s program, as you would type it in a terminal: choose one in the list or type another. It must speak ACP.', |
| 349 | + 'assistant.programHintSbx': 'The agent\'s program inside the sandbox, as you would type it in a terminal: choose one in the list or type another. It must speak ACP. claude-agent-acp: Sidekicks prepares the sandbox for Claude.', | |
| 350 | + 'assistant.claude.title': 'Claude in an sbx sandbox', | |
| 351 | + 'assistant.claude.intro': 'Sidekicks writes the sandbox\'s sbxenv.yaml and a workspace/ folder (where Claude works) in the folder below, then fills in the rest of this form. An sbxenv.yaml already there is kept as it is.', | |
| 352 | + 'assistant.claude.thirdParty': 'The sandbox uses the docker.io/sbx/claude-acp kit, which a third party provides, not Sidekicks: what it contains, its updates and its availability depend on that third party.', | |
| 353 | + 'assistant.claude.folder': 'Folder of the sandbox', | |
| 354 | + 'assistant.claude.sandbox': 'Name of the sandbox', | |
| 355 | + 'assistant.claude.prepare': 'Prepare the sandbox', | |
| 356 | + 'assistant.claude.preparing': 'Preparing…', | |
| 357 | + 'assistant.claude.written': 'Written: {file}. The form is filled in.', | |
| 358 | + 'assistant.claude.kept': 'Kept the existing {file}. The form is filled in from it.', | |
| 359 | + 'assistant.claude.failed': 'The sandbox cannot be prepared: {error}', | |
| 360 | + 'assistant.claude.key': 'Store your Anthropic API key in sbx before starting Claude: sbx adds it to Claude\'s requests, it is written nowhere in the folder. See the guide "Add a Claude agent in an sbx sandbox".', | |
| 349 | 361 | 'assistant.arguments': 'Arguments', |
| 350 | 362 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', |
| 351 | 363 | 'assistant.workspace': 'Agent\'s folder', |
| @@ -719,6 +731,18 @@ export const fr: Record<MessageKey, string> = { | ||
| 719 | 731 | 'assistant.program': 'Programme', |
| 720 | 732 | 'assistant.programPlaceholder': 'mm', |
| 721 | 733 | 'assistant.programHint': "Le programme de l'agent, tel que vous le taperiez dans un terminal : choisissez-en un dans la liste ou tapez-en un autre. Il doit parler ACP.", |
| 734 | + 'assistant.programHintSbx': "Le programme de l'agent dans la sandbox, tel que vous le taperiez dans un terminal : choisissez-en un dans la liste ou tapez-en un autre. Il doit parler ACP. claude-agent-acp : Sidekicks prépare la sandbox pour Claude.", | |
| 735 | + 'assistant.claude.title': 'Claude dans une sandbox sbx', | |
| 736 | + 'assistant.claude.intro': "Sidekicks écrit le sbxenv.yaml de la sandbox et un dossier workspace/ (où Claude travaille) dans le dossier ci-dessous, puis remplit le reste du formulaire. Un sbxenv.yaml déjà présent est gardé tel quel.", | |
| 737 | + 'assistant.claude.thirdParty': "La sandbox utilise le kit docker.io/sbx/claude-acp, fourni par un tiers et non par Sidekicks : son contenu, ses mises à jour et sa disponibilité dépendent de ce tiers.", | |
| 738 | + 'assistant.claude.folder': 'Dossier de la sandbox', | |
| 739 | + 'assistant.claude.sandbox': 'Nom de la sandbox', | |
| 740 | + 'assistant.claude.prepare': 'Préparer la sandbox', | |
| 741 | + 'assistant.claude.preparing': 'Préparation…', | |
| 742 | + 'assistant.claude.written': 'Écrit : {file}. Le formulaire est rempli.', | |
| 743 | + 'assistant.claude.kept': 'Le fichier {file} existant est gardé. Le formulaire est rempli à partir de lui.', | |
| 744 | + 'assistant.claude.failed': 'La sandbox ne peut pas être préparée : {error}', | |
| 745 | + 'assistant.claude.key': "Enregistrez votre clé d'API Anthropic dans sbx avant de démarrer Claude : sbx l'ajoute aux requêtes de Claude, elle n'est écrite nulle part dans le dossier. Voir le guide « Ajouter un agent Claude dans une sandbox sbx ».", | |
| 722 | 746 | 'assistant.arguments': 'Arguments', |
| 723 | 747 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', |
| 724 | 748 | 'assistant.workspace': "Dossier de l'agent", |
| @@ -346,6 +346,18 @@ export const en = { | |||
| 346 | 'assistant.program': 'Program', | 346 | 'assistant.program': 'Program', |
| 347 | 'assistant.programPlaceholder': 'mm', | 347 | 'assistant.programPlaceholder': 'mm', |
| 348 | 'assistant.programHint': 'The agent\'s program, as you would type it in a terminal: choose one in the list or type another. It must speak ACP.', | 348 | 'assistant.programHint': 'The agent\'s program, as you would type it in a terminal: choose one in the list or type another. It must speak ACP.', |
| 349 | + 'assistant.programHintSbx': 'The agent\'s program inside the sandbox, as you would type it in a terminal: choose one in the list or type another. It must speak ACP. claude-agent-acp: Sidekicks prepares the sandbox for Claude.', | ||
| 350 | + 'assistant.claude.title': 'Claude in an sbx sandbox', | ||
| 351 | + 'assistant.claude.intro': 'Sidekicks writes the sandbox\'s sbxenv.yaml and a workspace/ folder (where Claude works) in the folder below, then fills in the rest of this form. An sbxenv.yaml already there is kept as it is.', | ||
| 352 | + 'assistant.claude.thirdParty': 'The sandbox uses the docker.io/sbx/claude-acp kit, which a third party provides, not Sidekicks: what it contains, its updates and its availability depend on that third party.', | ||
| 353 | + 'assistant.claude.folder': 'Folder of the sandbox', | ||
| 354 | + 'assistant.claude.sandbox': 'Name of the sandbox', | ||
| 355 | + 'assistant.claude.prepare': 'Prepare the sandbox', | ||
| 356 | + 'assistant.claude.preparing': 'Preparing…', | ||
| 357 | + 'assistant.claude.written': 'Written: {file}. The form is filled in.', | ||
| 358 | + 'assistant.claude.kept': 'Kept the existing {file}. The form is filled in from it.', | ||
| 359 | + 'assistant.claude.failed': 'The sandbox cannot be prepared: {error}', | ||
| 360 | + 'assistant.claude.key': 'Store your Anthropic API key in sbx before starting Claude: sbx adds it to Claude\'s requests, it is written nowhere in the folder. See the guide "Add a Claude agent in an sbx sandbox".', | ||
| 349 | 'assistant.arguments': 'Arguments', | 361 | 'assistant.arguments': 'Arguments', |
| 350 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', | 362 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', |
| 351 | 'assistant.workspace': 'Agent\'s folder', | 363 | 'assistant.workspace': 'Agent\'s folder', |
| @@ -719,6 +731,18 @@ export const fr: Record<MessageKey, string> = { | |||
| 719 | 'assistant.program': 'Programme', | 731 | 'assistant.program': 'Programme', |
| 720 | 'assistant.programPlaceholder': 'mm', | 732 | 'assistant.programPlaceholder': 'mm', |
| 721 | 'assistant.programHint': "Le programme de l'agent, tel que vous le taperiez dans un terminal : choisissez-en un dans la liste ou tapez-en un autre. Il doit parler ACP.", | 733 | 'assistant.programHint': "Le programme de l'agent, tel que vous le taperiez dans un terminal : choisissez-en un dans la liste ou tapez-en un autre. Il doit parler ACP.", |
| 734 | + 'assistant.programHintSbx': "Le programme de l'agent dans la sandbox, tel que vous le taperiez dans un terminal : choisissez-en un dans la liste ou tapez-en un autre. Il doit parler ACP. claude-agent-acp : Sidekicks prépare la sandbox pour Claude.", | ||
| 735 | + 'assistant.claude.title': 'Claude dans une sandbox sbx', | ||
| 736 | + 'assistant.claude.intro': "Sidekicks écrit le sbxenv.yaml de la sandbox et un dossier workspace/ (où Claude travaille) dans le dossier ci-dessous, puis remplit le reste du formulaire. Un sbxenv.yaml déjà présent est gardé tel quel.", | ||
| 737 | + 'assistant.claude.thirdParty': "La sandbox utilise le kit docker.io/sbx/claude-acp, fourni par un tiers et non par Sidekicks : son contenu, ses mises à jour et sa disponibilité dépendent de ce tiers.", | ||
| 738 | + 'assistant.claude.folder': 'Dossier de la sandbox', | ||
| 739 | + 'assistant.claude.sandbox': 'Nom de la sandbox', | ||
| 740 | + 'assistant.claude.prepare': 'Préparer la sandbox', | ||
| 741 | + 'assistant.claude.preparing': 'Préparation…', | ||
| 742 | + 'assistant.claude.written': 'Écrit : {file}. Le formulaire est rempli.', | ||
| 743 | + 'assistant.claude.kept': 'Le fichier {file} existant est gardé. Le formulaire est rempli à partir de lui.', | ||
| 744 | + 'assistant.claude.failed': 'La sandbox ne peut pas être préparée : {error}', | ||
| 745 | + 'assistant.claude.key': "Enregistrez votre clé d'API Anthropic dans sbx avant de démarrer Claude : sbx l'ajoute aux requêtes de Claude, elle n'est écrite nulle part dans le dossier. Voir le guide « Ajouter un agent Claude dans une sandbox sbx ».", | ||
| 722 | 'assistant.arguments': 'Arguments', | 746 | 'assistant.arguments': 'Arguments', |
| 723 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', | 747 | 'assistant.argumentsPlaceholder': '--acp --config agent.yaml', |
| 724 | 'assistant.workspace': "Dossier de l'agent", | 748 | 'assistant.workspace': "Dossier de l'agent", |
added
internal/app/claudesandbox.go +117 -0 | new file mode 100644 | ||
| @@ -0,0 +1,117 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package app | |
| 4 | + | |
| 5 | +import ( | |
| 6 | + "errors" | |
| 7 | + "fmt" | |
| 8 | + "os" | |
| 9 | + "path/filepath" | |
| 10 | + "regexp" | |
| 11 | + "strings" | |
| 12 | + | |
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/lifecycle" | |
| 14 | +) | |
| 15 | + | |
| 16 | +// ClaudeACPProgram is Claude Code's ACP adapter, installed in the | |
| 17 | +// docker.io/sbx/claude-acp kit (issue #81). | |
| 18 | +const ClaudeACPProgram = "claude-agent-acp" | |
| 19 | + | |
| 20 | +// claudeSbxEnv is the sbxenv.yaml of a Claude sandbox, as in | |
| 21 | +// agents/snippets/claude-acp; %s is the sandbox's name. | |
| 22 | +const claudeSbxEnv = `schemaVersion: "1" | |
| 23 | + | |
| 24 | +name: %s | |
| 25 | +agent: claude | |
| 26 | + | |
| 27 | +# The folder Claude works in, relative to this file. Sidekicks shows it as | |
| 28 | +# the agent's folder. | |
| 29 | +workspace: ./workspace | |
| 30 | + | |
| 31 | +kits: | |
| 32 | + - docker.io/sbx/claude-acp:latest | |
| 33 | + | |
| 34 | +# sbx injects the Anthropic API key, stored in sbx, into the requests to | |
| 35 | +# these domains: the key is written neither here nor in the sandbox. | |
| 36 | +bindings: | |
| 37 | + anthropic: | |
| 38 | + apiKey: | |
| 39 | + domains: | |
| 40 | + - api.anthropic.com | |
| 41 | + - console.anthropic.com | |
| 42 | + | |
| 43 | +sandboxOptions: | |
| 44 | + pullPolicy: always | |
| 45 | +` | |
| 46 | + | |
| 47 | +// sandboxName is what a sandbox name may be: it goes into commands and YAML. | |
| 48 | +var sandboxName = regexp.MustCompile(`^[a-z0-9][a-z0-9_.-]{0,62}$`) | |
| 49 | + | |
| 50 | +// PreparedSandbox is a sandbox prepared by PrepareClaudeSandbox: what the | |
| 51 | +// assistant fills in, and whether the sbxenv.yaml was written or was | |
| 52 | +// already there (it is never overwritten). | |
| 53 | +type PreparedSandbox struct { | |
| 54 | + SandboxEnv | |
| 55 | + File string `json:"file"` | |
| 56 | + Written bool `json:"written"` | |
| 57 | +} | |
| 58 | + | |
| 59 | +// PrepareClaudeSandbox prepares a Claude agent in an sbx sandbox (issue | |
| 60 | +// #81): in folder (created if needed, "~" is the home folder) it writes the | |
| 61 | +// sbxenv.yaml of a sandbox called sandbox, unless one is already there, and | |
| 62 | +// creates the workspace/ folder Claude works in. It returns what the | |
| 63 | +// assistant fills in, as when an sbxenv.yaml is dropped on it. | |
| 64 | +// | |
| 65 | +// prepared, err := service.PrepareClaudeSandbox("~/agents/claude", "claude-sbx") | |
| 66 | +// // prepared.Workspace == "/Users/me/agents/claude/workspace", prepared.CreateCommand == "sbx env create --force" | |
| 67 | +func (s *ConfigService) PrepareClaudeSandbox(folder, sandbox string) (PreparedSandbox, error) { | |
| 68 | + folder, sandbox = strings.TrimSpace(folder), strings.TrimSpace(sandbox) | |
| 69 | + if !sandboxName.MatchString(sandbox) { | |
| 70 | + return PreparedSandbox{}, fmt.Errorf("%q is not a sandbox name: use lowercase letters, digits, -, _ or dots", sandbox) | |
| 71 | + } | |
| 72 | + folder, err := absoluteFolder(folder) | |
| 73 | + if err != nil { | |
| 74 | + return PreparedSandbox{}, err | |
| 75 | + } | |
| 76 | + if err := os.MkdirAll(filepath.Join(folder, "workspace"), 0o755); err != nil { | |
| 77 | + return PreparedSandbox{}, err | |
| 78 | + } | |
| 79 | + file := filepath.Join(folder, lifecycle.SbxEnvFileName) | |
| 80 | + written := false | |
| 81 | + out, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644) | |
| 82 | + switch { | |
| 83 | + case err == nil: | |
| 84 | + _, err = fmt.Fprintf(out, claudeSbxEnv, sandbox) | |
| 85 | + if closeErr := out.Close(); err == nil { | |
| 86 | + err = closeErr | |
| 87 | + } | |
| 88 | + if err != nil { | |
| 89 | + return PreparedSandbox{}, err | |
| 90 | + } | |
| 91 | + written = true | |
| 92 | + case !errors.Is(err, os.ErrExist): | |
| 93 | + return PreparedSandbox{}, err | |
| 94 | + } | |
| 95 | + env, err := s.ReadSandboxEnv(file) | |
| 96 | + if err != nil { | |
| 97 | + return PreparedSandbox{}, err | |
| 98 | + } | |
| 99 | + return PreparedSandbox{SandboxEnv: env, File: file, Written: written}, nil | |
| 100 | +} | |
| 101 | + | |
| 102 | +// absoluteFolder expands "~" and refuses a relative folder: sbx mounts the | |
| 103 | +// agent's folder at the same path, which must not depend on where | |
| 104 | +// Sidekicks was started. | |
| 105 | +func absoluteFolder(folder string) (string, error) { | |
| 106 | + if folder == "~" || strings.HasPrefix(folder, "~/") { | |
| 107 | + home, err := os.UserHomeDir() | |
| 108 | + if err != nil { | |
| 109 | + return "", err | |
| 110 | + } | |
| 111 | + folder = filepath.Join(home, strings.TrimPrefix(folder, "~")) | |
| 112 | + } | |
| 113 | + if folder == "" || !filepath.IsAbs(folder) { | |
| 114 | + return "", fmt.Errorf("%q: give the full path of the folder (or start it with ~/)", folder) | |
| 115 | + } | |
| 116 | + return filepath.Clean(folder), nil | |
| 117 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package app | ||
| 4 | + | ||
| 5 | +import ( | ||
| 6 | + "errors" | ||
| 7 | + "fmt" | ||
| 8 | + "os" | ||
| 9 | + "path/filepath" | ||
| 10 | + "regexp" | ||
| 11 | + "strings" | ||
| 12 | + | ||
| 13 | + "git.rickub.com/bots-garden/sidekicks/internal/lifecycle" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +// ClaudeACPProgram is Claude Code's ACP adapter, installed in the | ||
| 17 | +// docker.io/sbx/claude-acp kit (issue #81). | ||
| 18 | +const ClaudeACPProgram = "claude-agent-acp" | ||
| 19 | + | ||
| 20 | +// claudeSbxEnv is the sbxenv.yaml of a Claude sandbox, as in | ||
| 21 | +// agents/snippets/claude-acp; %s is the sandbox's name. | ||
| 22 | +const claudeSbxEnv = `schemaVersion: "1" | ||
| 23 | + | ||
| 24 | +name: %s | ||
| 25 | +agent: claude | ||
| 26 | + | ||
| 27 | +# The folder Claude works in, relative to this file. Sidekicks shows it as | ||
| 28 | +# the agent's folder. | ||
| 29 | +workspace: ./workspace | ||
| 30 | + | ||
| 31 | +kits: | ||
| 32 | + - docker.io/sbx/claude-acp:latest | ||
| 33 | + | ||
| 34 | +# sbx injects the Anthropic API key, stored in sbx, into the requests to | ||
| 35 | +# these domains: the key is written neither here nor in the sandbox. | ||
| 36 | +bindings: | ||
| 37 | + anthropic: | ||
| 38 | + apiKey: | ||
| 39 | + domains: | ||
| 40 | + - api.anthropic.com | ||
| 41 | + - console.anthropic.com | ||
| 42 | + | ||
| 43 | +sandboxOptions: | ||
| 44 | + pullPolicy: always | ||
| 45 | +` | ||
| 46 | + | ||
| 47 | +// sandboxName is what a sandbox name may be: it goes into commands and YAML. | ||
| 48 | +var sandboxName = regexp.MustCompile(`^[a-z0-9][a-z0-9_.-]{0,62}$`) | ||
| 49 | + | ||
| 50 | +// PreparedSandbox is a sandbox prepared by PrepareClaudeSandbox: what the | ||
| 51 | +// assistant fills in, and whether the sbxenv.yaml was written or was | ||
| 52 | +// already there (it is never overwritten). | ||
| 53 | +type PreparedSandbox struct { | ||
| 54 | + SandboxEnv | ||
| 55 | + File string `json:"file"` | ||
| 56 | + Written bool `json:"written"` | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +// PrepareClaudeSandbox prepares a Claude agent in an sbx sandbox (issue | ||
| 60 | +// #81): in folder (created if needed, "~" is the home folder) it writes the | ||
| 61 | +// sbxenv.yaml of a sandbox called sandbox, unless one is already there, and | ||
| 62 | +// creates the workspace/ folder Claude works in. It returns what the | ||
| 63 | +// assistant fills in, as when an sbxenv.yaml is dropped on it. | ||
| 64 | +// | ||
| 65 | +// prepared, err := service.PrepareClaudeSandbox("~/agents/claude", "claude-sbx") | ||
| 66 | +// // prepared.Workspace == "/Users/me/agents/claude/workspace", prepared.CreateCommand == "sbx env create --force" | ||
| 67 | +func (s *ConfigService) PrepareClaudeSandbox(folder, sandbox string) (PreparedSandbox, error) { | ||
| 68 | + folder, sandbox = strings.TrimSpace(folder), strings.TrimSpace(sandbox) | ||
| 69 | + if !sandboxName.MatchString(sandbox) { | ||
| 70 | + return PreparedSandbox{}, fmt.Errorf("%q is not a sandbox name: use lowercase letters, digits, -, _ or dots", sandbox) | ||
| 71 | + } | ||
| 72 | + folder, err := absoluteFolder(folder) | ||
| 73 | + if err != nil { | ||
| 74 | + return PreparedSandbox{}, err | ||
| 75 | + } | ||
| 76 | + if err := os.MkdirAll(filepath.Join(folder, "workspace"), 0o755); err != nil { | ||
| 77 | + return PreparedSandbox{}, err | ||
| 78 | + } | ||
| 79 | + file := filepath.Join(folder, lifecycle.SbxEnvFileName) | ||
| 80 | + written := false | ||
| 81 | + out, err := os.OpenFile(file, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0o644) | ||
| 82 | + switch { | ||
| 83 | + case err == nil: | ||
| 84 | + _, err = fmt.Fprintf(out, claudeSbxEnv, sandbox) | ||
| 85 | + if closeErr := out.Close(); err == nil { | ||
| 86 | + err = closeErr | ||
| 87 | + } | ||
| 88 | + if err != nil { | ||
| 89 | + return PreparedSandbox{}, err | ||
| 90 | + } | ||
| 91 | + written = true | ||
| 92 | + case !errors.Is(err, os.ErrExist): | ||
| 93 | + return PreparedSandbox{}, err | ||
| 94 | + } | ||
| 95 | + env, err := s.ReadSandboxEnv(file) | ||
| 96 | + if err != nil { | ||
| 97 | + return PreparedSandbox{}, err | ||
| 98 | + } | ||
| 99 | + return PreparedSandbox{SandboxEnv: env, File: file, Written: written}, nil | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +// absoluteFolder expands "~" and refuses a relative folder: sbx mounts the | ||
| 103 | +// agent's folder at the same path, which must not depend on where | ||
| 104 | +// Sidekicks was started. | ||
| 105 | +func absoluteFolder(folder string) (string, error) { | ||
| 106 | + if folder == "~" || strings.HasPrefix(folder, "~/") { | ||
| 107 | + home, err := os.UserHomeDir() | ||
| 108 | + if err != nil { | ||
| 109 | + return "", err | ||
| 110 | + } | ||
| 111 | + folder = filepath.Join(home, strings.TrimPrefix(folder, "~")) | ||
| 112 | + } | ||
| 113 | + if folder == "" || !filepath.IsAbs(folder) { | ||
| 114 | + return "", fmt.Errorf("%q: give the full path of the folder (or start it with ~/)", folder) | ||
| 115 | + } | ||
| 116 | + return filepath.Clean(folder), nil | ||
| 117 | +} | ||
modified
internal/app/sandboxes_test.go +65 -0 | @@ -13,6 +13,7 @@ import ( | ||
| 13 | 13 | "git.rickub.com/bots-garden/sidekicks/internal/agents" |
| 14 | 14 | "git.rickub.com/bots-garden/sidekicks/internal/app" |
| 15 | 15 | "git.rickub.com/bots-garden/sidekicks/internal/config" |
| 16 | + "go.yaml.in/yaml/v3" | |
| 16 | 17 | ) |
| 17 | 18 | |
| 18 | 19 | // fakeSbx keeps its sandboxes in a file next to it: "ls -q" lists them, |
| @@ -179,3 +180,67 @@ func TestReadComposeFillsTheAssistant(t *testing.T) { | ||
| 179 | 180 | t.Fatal("another file is refused") |
| 180 | 181 | } |
| 181 | 182 | } |
| 183 | + | |
| 184 | +func TestPrepareClaudeSandboxWritesTheSnippetsEnvironment(t *testing.T) { | |
| 185 | + dir := t.TempDir() | |
| 186 | + folder := filepath.Join(dir, "agents", "claude") | |
| 187 | + service := &app.ConfigService{Core: app.New(config.Location{Path: filepath.Join(dir, "config.yaml"), Source: config.SourceFlag}, app.Options{Starter: starter})} | |
| 188 | + prepared, err := service.PrepareClaudeSandbox(folder, "claude-sbx") | |
| 189 | + if err != nil { | |
| 190 | + t.Fatal(err) | |
| 191 | + } | |
| 192 | + want := app.SandboxEnv{ | |
| 193 | + Name: "claude-sbx", Workspace: filepath.Join(folder, "workspace"), SandboxFolder: folder, | |
| 194 | + CreateCommand: "sbx env create --force", StopCommand: "sbx stop claude-sbx", RemoveCommand: "sbx env rm --force", | |
| 195 | + } | |
| 196 | + if prepared.SandboxEnv != want || !prepared.Written || prepared.File != filepath.Join(folder, "sbxenv.yaml") { | |
| 197 | + t.Fatalf("got %+v\nwant %+v", prepared, want) | |
| 198 | + } | |
| 199 | + if info, err := os.Stat(filepath.Join(folder, "workspace")); err != nil || !info.IsDir() { | |
| 200 | + t.Fatal("the workspace folder is created") | |
| 201 | + } | |
| 202 | + // The same environment as agents/snippets/claude-acp, apart from the name. | |
| 203 | + written, _ := os.ReadFile(prepared.File) | |
| 204 | + snippet, err := os.ReadFile(filepath.Join("..", "..", "agents", "snippets", "claude-acp", "sbxenv.yaml")) | |
| 205 | + if err != nil { | |
| 206 | + t.Fatal(err) | |
| 207 | + } | |
| 208 | + if got, want := yamlWithout(t, written, "name"), yamlWithout(t, snippet, "name"); got != want { | |
| 209 | + t.Fatalf("the generated sbxenv.yaml differs from the snippet:\n%s\n---\n%s", got, want) | |
| 210 | + } | |
| 211 | +} | |
| 212 | + | |
| 213 | +func TestPrepareClaudeSandboxKeepsAnExistingFile(t *testing.T) { | |
| 214 | + dir := t.TempDir() | |
| 215 | + service := &app.ConfigService{Core: app.New(config.Location{Path: filepath.Join(dir, "config.yaml"), Source: config.SourceFlag}, app.Options{Starter: starter})} | |
| 216 | + write(t, filepath.Join(dir, "sbxenv.yaml"), "schemaVersion: \"1\"\nname: mine\nagent: claude\n") | |
| 217 | + prepared, err := service.PrepareClaudeSandbox(dir, "claude-sbx") | |
| 218 | + if err != nil || prepared.Written || prepared.Name != "mine" { | |
| 219 | + t.Fatalf("an existing sbxenv.yaml is read, never overwritten: %+v %v", prepared, err) | |
| 220 | + } | |
| 221 | + if content, _ := os.ReadFile(filepath.Join(dir, "sbxenv.yaml")); !strings.Contains(string(content), "name: mine") { | |
| 222 | + t.Fatalf("overwritten: %s", content) | |
| 223 | + } | |
| 224 | + if _, err := service.PrepareClaudeSandbox("relative/folder", "claude-sbx"); err == nil { | |
| 225 | + t.Fatal("a relative folder is refused") | |
| 226 | + } | |
| 227 | + if _, err := service.PrepareClaudeSandbox(dir, "Bad Name"); err == nil { | |
| 228 | + t.Fatal("an invalid sandbox name is refused") | |
| 229 | + } | |
| 230 | +} | |
| 231 | + | |
| 232 | +// yamlWithout decodes a YAML mapping, drops key, and encodes it again, so | |
| 233 | +// that two files compare by content, not by comments or layout. | |
| 234 | +func yamlWithout(t *testing.T, content []byte, key string) string { | |
| 235 | + t.Helper() | |
| 236 | + var values map[string]any | |
| 237 | + if err := yaml.Unmarshal(content, &values); err != nil { | |
| 238 | + t.Fatal(err) | |
| 239 | + } | |
| 240 | + delete(values, key) | |
| 241 | + out, err := yaml.Marshal(values) | |
| 242 | + if err != nil { | |
| 243 | + t.Fatal(err) | |
| 244 | + } | |
| 245 | + return string(out) | |
| 246 | +} | |
| @@ -13,6 +13,7 @@ import ( | |||
| 13 | "git.rickub.com/bots-garden/sidekicks/internal/agents" | 13 | "git.rickub.com/bots-garden/sidekicks/internal/agents" |
| 14 | "git.rickub.com/bots-garden/sidekicks/internal/app" | 14 | "git.rickub.com/bots-garden/sidekicks/internal/app" |
| 15 | "git.rickub.com/bots-garden/sidekicks/internal/config" | 15 | "git.rickub.com/bots-garden/sidekicks/internal/config" |
| 16 | + "go.yaml.in/yaml/v3" | ||
| 16 | ) | 17 | ) |
| 17 | 18 | ||
| 18 | // fakeSbx keeps its sandboxes in a file next to it: "ls -q" lists them, | 19 | // fakeSbx keeps its sandboxes in a file next to it: "ls -q" lists them, |
| @@ -179,3 +180,67 @@ func TestReadComposeFillsTheAssistant(t *testing.T) { | |||
| 179 | t.Fatal("another file is refused") | 180 | t.Fatal("another file is refused") |
| 180 | } | 181 | } |
| 181 | } | 182 | } |
| 183 | + | ||
| 184 | +func TestPrepareClaudeSandboxWritesTheSnippetsEnvironment(t *testing.T) { | ||
| 185 | + dir := t.TempDir() | ||
| 186 | + folder := filepath.Join(dir, "agents", "claude") | ||
| 187 | + service := &app.ConfigService{Core: app.New(config.Location{Path: filepath.Join(dir, "config.yaml"), Source: config.SourceFlag}, app.Options{Starter: starter})} | ||
| 188 | + prepared, err := service.PrepareClaudeSandbox(folder, "claude-sbx") | ||
| 189 | + if err != nil { | ||
| 190 | + t.Fatal(err) | ||
| 191 | + } | ||
| 192 | + want := app.SandboxEnv{ | ||
| 193 | + Name: "claude-sbx", Workspace: filepath.Join(folder, "workspace"), SandboxFolder: folder, | ||
| 194 | + CreateCommand: "sbx env create --force", StopCommand: "sbx stop claude-sbx", RemoveCommand: "sbx env rm --force", | ||
| 195 | + } | ||
| 196 | + if prepared.SandboxEnv != want || !prepared.Written || prepared.File != filepath.Join(folder, "sbxenv.yaml") { | ||
| 197 | + t.Fatalf("got %+v\nwant %+v", prepared, want) | ||
| 198 | + } | ||
| 199 | + if info, err := os.Stat(filepath.Join(folder, "workspace")); err != nil || !info.IsDir() { | ||
| 200 | + t.Fatal("the workspace folder is created") | ||
| 201 | + } | ||
| 202 | + // The same environment as agents/snippets/claude-acp, apart from the name. | ||
| 203 | + written, _ := os.ReadFile(prepared.File) | ||
| 204 | + snippet, err := os.ReadFile(filepath.Join("..", "..", "agents", "snippets", "claude-acp", "sbxenv.yaml")) | ||
| 205 | + if err != nil { | ||
| 206 | + t.Fatal(err) | ||
| 207 | + } | ||
| 208 | + if got, want := yamlWithout(t, written, "name"), yamlWithout(t, snippet, "name"); got != want { | ||
| 209 | + t.Fatalf("the generated sbxenv.yaml differs from the snippet:\n%s\n---\n%s", got, want) | ||
| 210 | + } | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +func TestPrepareClaudeSandboxKeepsAnExistingFile(t *testing.T) { | ||
| 214 | + dir := t.TempDir() | ||
| 215 | + service := &app.ConfigService{Core: app.New(config.Location{Path: filepath.Join(dir, "config.yaml"), Source: config.SourceFlag}, app.Options{Starter: starter})} | ||
| 216 | + write(t, filepath.Join(dir, "sbxenv.yaml"), "schemaVersion: \"1\"\nname: mine\nagent: claude\n") | ||
| 217 | + prepared, err := service.PrepareClaudeSandbox(dir, "claude-sbx") | ||
| 218 | + if err != nil || prepared.Written || prepared.Name != "mine" { | ||
| 219 | + t.Fatalf("an existing sbxenv.yaml is read, never overwritten: %+v %v", prepared, err) | ||
| 220 | + } | ||
| 221 | + if content, _ := os.ReadFile(filepath.Join(dir, "sbxenv.yaml")); !strings.Contains(string(content), "name: mine") { | ||
| 222 | + t.Fatalf("overwritten: %s", content) | ||
| 223 | + } | ||
| 224 | + if _, err := service.PrepareClaudeSandbox("relative/folder", "claude-sbx"); err == nil { | ||
| 225 | + t.Fatal("a relative folder is refused") | ||
| 226 | + } | ||
| 227 | + if _, err := service.PrepareClaudeSandbox(dir, "Bad Name"); err == nil { | ||
| 228 | + t.Fatal("an invalid sandbox name is refused") | ||
| 229 | + } | ||
| 230 | +} | ||
| 231 | + | ||
| 232 | +// yamlWithout decodes a YAML mapping, drops key, and encodes it again, so | ||
| 233 | +// that two files compare by content, not by comments or layout. | ||
| 234 | +func yamlWithout(t *testing.T, content []byte, key string) string { | ||
| 235 | + t.Helper() | ||
| 236 | + var values map[string]any | ||
| 237 | + if err := yaml.Unmarshal(content, &values); err != nil { | ||
| 238 | + t.Fatal(err) | ||
| 239 | + } | ||
| 240 | + delete(values, key) | ||
| 241 | + out, err := yaml.Marshal(values) | ||
| 242 | + if err != nil { | ||
| 243 | + t.Fatal(err) | ||
| 244 | + } | ||
| 245 | + return string(out) | ||
| 246 | +} | ||