added
.memory/handoffs/2026-11-15-107-codex-chatgpt.md +7 -0 | new file mode 100644 | ||
| @@ -0,0 +1,7 @@ | ||
| 1 | +# 2026-11-15 — #107 Codex ChatGPT sign-in | |
| 2 | + | |
| 3 | +- Branch `feature/107-codex-chatgpt`, not committed (bindings staged). | |
| 4 | +- On the Mac: create a Codex agent with "Later", send a message; the error now holds sbx's last lines (Technical details). If the ChatGPT button does not appear, add the real question's wording to the `error.openaiSignIn` pattern in frontend/src/lib/errors.ts (+ its test). | |
| 5 | +- `sbx secret set openai --oauth` without a TTY: unknown whether it prints the URL or only opens the browser; the UI copes with both (button if a URL, "your browser opens" otherwise). Unknown whether `sbx secret ls --service openai` lists an oauth secret in the SCOPE SERVICE columns `HasSecret` reads. | |
| 6 | +- Fake sbx for this test: see the ui3 script pattern in history (env create fails with the question unless secrets has openai). | |
| 7 | +- Closed: owner tested on the Mac, merged into main. | |
| new file mode 100644 | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | +# 2026-11-15 — #107 Codex ChatGPT sign-in | ||
| 2 | + | ||
| 3 | +- Branch `feature/107-codex-chatgpt`, not committed (bindings staged). | ||
| 4 | +- On the Mac: create a Codex agent with "Later", send a message; the error now holds sbx's last lines (Technical details). If the ChatGPT button does not appear, add the real question's wording to the `error.openaiSignIn` pattern in frontend/src/lib/errors.ts (+ its test). | ||
| 5 | +- `sbx secret set openai --oauth` without a TTY: unknown whether it prints the URL or only opens the browser; the UI copes with both (button if a URL, "your browser opens" otherwise). Unknown whether `sbx secret ls --service openai` lists an oauth secret in the SCOPE SERVICE columns `HasSecret` reads. | ||
| 6 | +- Fake sbx for this test: see the ui3 script pattern in history (env create fails with the question unless secrets has openai). | ||
| 7 | +- Closed: owner tested on the Mac, merged into main. | ||
modified
.memory/history.md +9 -0 | @@ -333,3 +333,12 @@ | ||
| 333 | 333 | - Checks: lint-go, svelte-check, lint-headers, all tests, bindings-check. Xvfb with a Python fake ACP agent answering -32000 "Authentication required" and a fake sbx (exec runs locally): auto switch, claude typed, restart, button. Not verified: real claude /login in a sandbox (#106 task 6). Not committed. |
| 334 | 334 | - **2026-11-15 — header spacing** (owner: in the header, the name of a wizard sbx agent with a logo is too close to it and not centred): ConversationPanel `.title` and AgentView/CreateSbxAgent `h2` are flex, centred, gap 8px (the space text node collapsed inside {#if}); member chips gap 5px; AgentView meta line: text in `.facts` so it wraps beside the state dot instead of under it. Checked under Xvfb. Same branch feature/105-106-claude-login, not committed. |
| 335 | 335 | - **2026-11-15 — #105 and #106 closed** (owner tested with Claude on the Mac: it works); feature/105-106-claude-login merged into main (not pushed). #104 (overlapping) left open. |
| 336 | +- **2026-11-15 — #104 closed** (owner: covered by #105/#106). | |
| 337 | + | |
| 338 | +## 2026-11-15 — #107 Codex: optional key, ChatGPT sign-in (branch feature/107-codex-chatgpt) | |
| 339 | + | |
| 340 | +- Asked: "close 104, implement 107". | |
| 341 | +- Done: `Sbx.StartOAuth` (oauth.go; `startLogin` now takes a `flow` {failure, anyURL, okOnExit}; `LoginState.OK`), `Kind.OAuth` (codex), `OAuthLogin*` service methods (`signIn.start` takes a ready func: device code vs URL only), `agents.OAuthKind` → `Status.oauth`; lifecycle `command` errors carry the last 3 printed lines (` · `-joined) — needed so sbx's question can be recognised; errors.ts `error.openaiSignIn` (guessed patterns); `ErrorText` prop `agent` → ChatGPT `SbxLogin oauth` under that error or under authRequired for a Codex agent, then Restart; wizard key step for oauth kinds; docs EN/FR, release notes. | |
| 342 | +- Checks: lint-go, svelte-check, headers, all tests, bindings-check; Xvfb with a fake sbx (env create asks without credential; --oauth waits for a file) end to end. | |
| 343 | +- Not verified: real sbx question text and `--oauth` output without a TTY (#107 tasks 1, 6). Not committed. | |
| 344 | +- **2026-11-15 — #107 closed** (owner tested Codex on the Mac: it works); feature/107-codex-chatgpt merged into main (not pushed). | |
| @@ -333,3 +333,12 @@ | |||
| 333 | - Checks: lint-go, svelte-check, lint-headers, all tests, bindings-check. Xvfb with a Python fake ACP agent answering -32000 "Authentication required" and a fake sbx (exec runs locally): auto switch, claude typed, restart, button. Not verified: real claude /login in a sandbox (#106 task 6). Not committed. | 333 | - Checks: lint-go, svelte-check, lint-headers, all tests, bindings-check. Xvfb with a Python fake ACP agent answering -32000 "Authentication required" and a fake sbx (exec runs locally): auto switch, claude typed, restart, button. Not verified: real claude /login in a sandbox (#106 task 6). Not committed. |
| 334 | - **2026-11-15 — header spacing** (owner: in the header, the name of a wizard sbx agent with a logo is too close to it and not centred): ConversationPanel `.title` and AgentView/CreateSbxAgent `h2` are flex, centred, gap 8px (the space text node collapsed inside {#if}); member chips gap 5px; AgentView meta line: text in `.facts` so it wraps beside the state dot instead of under it. Checked under Xvfb. Same branch feature/105-106-claude-login, not committed. | 334 | - **2026-11-15 — header spacing** (owner: in the header, the name of a wizard sbx agent with a logo is too close to it and not centred): ConversationPanel `.title` and AgentView/CreateSbxAgent `h2` are flex, centred, gap 8px (the space text node collapsed inside {#if}); member chips gap 5px; AgentView meta line: text in `.facts` so it wraps beside the state dot instead of under it. Checked under Xvfb. Same branch feature/105-106-claude-login, not committed. |
| 335 | - **2026-11-15 — #105 and #106 closed** (owner tested with Claude on the Mac: it works); feature/105-106-claude-login merged into main (not pushed). #104 (overlapping) left open. | 335 | - **2026-11-15 — #105 and #106 closed** (owner tested with Claude on the Mac: it works); feature/105-106-claude-login merged into main (not pushed). #104 (overlapping) left open. |
| 336 | +- **2026-11-15 — #104 closed** (owner: covered by #105/#106). | ||
| 337 | + | ||
| 338 | +## 2026-11-15 — #107 Codex: optional key, ChatGPT sign-in (branch feature/107-codex-chatgpt) | ||
| 339 | + | ||
| 340 | +- Asked: "close 104, implement 107". | ||
| 341 | +- Done: `Sbx.StartOAuth` (oauth.go; `startLogin` now takes a `flow` {failure, anyURL, okOnExit}; `LoginState.OK`), `Kind.OAuth` (codex), `OAuthLogin*` service methods (`signIn.start` takes a ready func: device code vs URL only), `agents.OAuthKind` → `Status.oauth`; lifecycle `command` errors carry the last 3 printed lines (` · `-joined) — needed so sbx's question can be recognised; errors.ts `error.openaiSignIn` (guessed patterns); `ErrorText` prop `agent` → ChatGPT `SbxLogin oauth` under that error or under authRequired for a Codex agent, then Restart; wizard key step for oauth kinds; docs EN/FR, release notes. | ||
| 342 | +- Checks: lint-go, svelte-check, headers, all tests, bindings-check; Xvfb with a fake sbx (env create asks without credential; --oauth waits for a file) end to end. | ||
| 343 | +- Not verified: real sbx question text and `--oauth` output without a TTY (#107 tasks 1, 6). Not committed. | ||
| 344 | +- **2026-11-15 — #107 closed** (owner tested Codex on the Mac: it works); feature/107-codex-chatgpt merged into main (not pushed). | ||
modified
.tickets/issues/0104-assistant-des-sandboxes-claude-se-connecter-avec.yaml +13 -3 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 104 |
| 3 | 3 | title: "Assistant des sandboxes, Claude : se connecter avec /login au lieu d'une clé d'API" |
| 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-15T08:00:42.000Z |
| 9 | -updatedAt: 2026-11-15T08:00:42.000Z | |
| 9 | +updatedAt: 2026-11-15T08:52:40.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - kind::feature |
| 12 | 12 | - area::ui |
| @@ -92,4 +92,14 @@ tasks: | ||
| 92 | 92 | name: k33g |
| 93 | 93 | email: ph.charriere@gmail.com |
| 94 | 94 | createdAt: 2026-11-15T08:00:42.000Z |
| 95 | -comments: [] | |
| 95 | +comments: | |
| 96 | + - id: 1 | |
| 97 | + author: | |
| 98 | + name: k33g | |
| 99 | + email: ph.charriere@gmail.com | |
| 100 | + createdAt: 2026-11-15T08:52:40.000Z | |
| 101 | + body: | | |
| 102 | + Fermé par l'owner : couvert par [#105](.tickets/issues/0105-assistant-des-sandboxes-claude-sans-cle-d-api-di.yaml) | |
| 103 | + et [#106](.tickets/issues/0106-claude-en-sandbox-sans-authentification-ouvrir-l.yaml) — l'étape de la clé n'est | |
| 104 | + plus bloquante et la connexion par compte se fait avec /login dans le terminal de la sandbox (pas dans la | |
| 105 | + conversation). Tâches laissées ouvertes : non faites sous cette forme. | |
| @@ -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: 104 | 2 | id: 104 |
| 3 | title: "Assistant des sandboxes, Claude : se connecter avec /login au lieu d'une clé d'API" | 3 | title: "Assistant des sandboxes, Claude : se connecter avec /login au lieu d'une clé d'API" |
| 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-15T08:00:42.000Z | 8 | createdAt: 2026-11-15T08:00:42.000Z |
| 9 | -updatedAt: 2026-11-15T08:00:42.000Z | 9 | +updatedAt: 2026-11-15T08:52:40.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - kind::feature | 11 | - kind::feature |
| 12 | - area::ui | 12 | - area::ui |
| @@ -92,4 +92,14 @@ tasks: | |||
| 92 | name: k33g | 92 | name: k33g |
| 93 | email: ph.charriere@gmail.com | 93 | email: ph.charriere@gmail.com |
| 94 | createdAt: 2026-11-15T08:00:42.000Z | 94 | createdAt: 2026-11-15T08:00:42.000Z |
| 95 | -comments: [] | 95 | +comments: |
| 96 | + - id: 1 | ||
| 97 | + author: | ||
| 98 | + name: k33g | ||
| 99 | + email: ph.charriere@gmail.com | ||
| 100 | + createdAt: 2026-11-15T08:52:40.000Z | ||
| 101 | + body: | | ||
| 102 | + Fermé par l'owner : couvert par [#105](.tickets/issues/0105-assistant-des-sandboxes-claude-sans-cle-d-api-di.yaml) | ||
| 103 | + et [#106](.tickets/issues/0106-claude-en-sandbox-sans-authentification-ouvrir-l.yaml) — l'étape de la clé n'est | ||
| 104 | + plus bloquante et la connexion par compte se fait avec /login dans le terminal de la sandbox (pas dans la | ||
| 105 | + conversation). Tâches laissées ouvertes : non faites sous cette forme. | ||
modified
.tickets/issues/0107-assistant-des-sandboxes-codex-cle-facultative-et.yaml +49 -9 | @@ -1,12 +1,12 @@ | ||
| 1 | 1 | # Managed by IssueSpec. Hand edits are welcome; keep the schema valid. |
| 2 | 2 | id: 107 |
| 3 | 3 | title: "Assistant des sandboxes, Codex : clé facultative et connexion ChatGPT (sbx secret set openai --oauth)" |
| 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-15T08:16:29.000Z |
| 9 | -updatedAt: 2026-11-15T08:16:29.000Z | |
| 9 | +updatedAt: 2026-11-15T09:06:46.000Z | |
| 10 | 10 | labels: |
| 11 | 11 | - kind::feature |
| 12 | 12 | - area::workspace |
| @@ -61,50 +61,90 @@ body: | | ||
| 61 | 61 | tasks: |
| 62 | 62 | - id: 1 |
| 63 | 63 | title: "Relever sur le Mac la question de sbx env create sans identifiant OpenAI, et la sortie de sbx secret set openai --oauth" |
| 64 | - state: open | |
| 64 | + state: closed | |
| 65 | 65 | priority: high |
| 66 | 66 | author: |
| 67 | 67 | name: k33g |
| 68 | 68 | email: ph.charriere@gmail.com |
| 69 | 69 | createdAt: 2026-11-15T08:16:29.000Z |
| 70 | + updatedAt: 2026-11-15T09:06:46.000Z | |
| 71 | + closedAt: 2026-11-15T09:06:46.000Z | |
| 70 | 72 | - id: 2 |
| 71 | 73 | title: "Go : lancer sbx secret set openai --oauth et suivre sa fin (comme sbx login) ; HasSecret avec un secret oauth" |
| 72 | - state: open | |
| 74 | + state: closed | |
| 73 | 75 | priority: high |
| 74 | 76 | author: |
| 75 | 77 | name: k33g |
| 76 | 78 | email: ph.charriere@gmail.com |
| 77 | 79 | createdAt: 2026-11-15T08:16:29.000Z |
| 80 | + updatedAt: 2026-11-15T08:57:51.000Z | |
| 81 | + closedAt: 2026-11-15T08:57:51.000Z | |
| 78 | 82 | - id: 3 |
| 79 | 83 | title: "Étape de la clé Codex : connexion ChatGPT / clé d'API / plus tard, sans blocage (EN + FR)" |
| 80 | - state: open | |
| 84 | + state: closed | |
| 81 | 85 | priority: high |
| 82 | 86 | author: |
| 83 | 87 | name: k33g |
| 84 | 88 | email: ph.charriere@gmail.com |
| 85 | 89 | createdAt: 2026-11-15T08:16:29.000Z |
| 90 | + updatedAt: 2026-11-15T08:57:51.000Z | |
| 91 | + closedAt: 2026-11-15T08:57:51.000Z | |
| 86 | 92 | - id: 4 |
| 87 | 93 | title: "Création : reconnaître la question d'authentification, proposer la connexion sous l'erreur, puis redémarrer l'agent" |
| 88 | - state: open | |
| 94 | + state: closed | |
| 89 | 95 | priority: high |
| 90 | 96 | author: |
| 91 | 97 | name: k33g |
| 92 | 98 | email: ph.charriere@gmail.com |
| 93 | 99 | createdAt: 2026-11-15T08:16:29.000Z |
| 100 | + updatedAt: 2026-11-15T08:57:51.000Z | |
| 101 | + closedAt: 2026-11-15T08:57:51.000Z | |
| 94 | 102 | - id: 5 |
| 95 | 103 | title: "Tests Go + vitest, doc EN + FR, notes de release v1.6.0" |
| 96 | - state: open | |
| 104 | + state: closed | |
| 97 | 105 | priority: medium |
| 98 | 106 | author: |
| 99 | 107 | name: k33g |
| 100 | 108 | email: ph.charriere@gmail.com |
| 101 | 109 | createdAt: 2026-11-15T08:16:29.000Z |
| 110 | + updatedAt: 2026-11-15T08:57:51.000Z | |
| 111 | + closedAt: 2026-11-15T08:57:51.000Z | |
| 102 | 112 | - id: 6 |
| 103 | 113 | title: "Tester sur le Mac : Codex avec compte ChatGPT, et Codex créé sans identifiant" |
| 104 | - state: open | |
| 114 | + state: closed | |
| 105 | 115 | priority: high |
| 106 | 116 | author: |
| 107 | 117 | name: k33g |
| 108 | 118 | email: ph.charriere@gmail.com |
| 109 | 119 | createdAt: 2026-11-15T08:16:29.000Z |
| 110 | -comments: [] | |
| 120 | + updatedAt: 2026-11-15T09:06:46.000Z | |
| 121 | + closedAt: 2026-11-15T09:06:46.000Z | |
| 122 | +comments: | |
| 123 | + - id: 1 | |
| 124 | + author: | |
| 125 | + name: k33g | |
| 126 | + email: ph.charriere@gmail.com | |
| 127 | + createdAt: 2026-11-15T08:57:51.000Z | |
| 128 | + body: | | |
| 129 | + Fait sur `feature/107-codex-chatgpt` (sortie réelle de sbx non relevée : tâche 1 reste ouverte). | |
| 130 | + | |
| 131 | + - Go : `Sbx.StartOAuth(service)` (`sbx secret set <service> --oauth`, lu comme `sbx login` : première URL https, | |
| 132 | + succès = fin sans erreur, `LoginState.ok`), `Kind.OAuth` (Codex), `OAuthLogin` / `OAuthLoginStatus` / | |
| 133 | + `CancelOAuthLogin` ; `Status.oauth` (`codex` pour `codex-acp` en sbx). | |
| 134 | + - **Les commandes du cycle de vie mettent leurs 3 dernières lignes dans leur erreur** : avant, la question de sbx | |
| 135 | + n'était que dans le journal et l'erreur disait « create codex: exit status 1 ». | |
| 136 | + - Front : règle `error.openaiSignIn` (motifs devinés : « authenticate on/in the web/browser », « no OpenAI | |
| 137 | + credential », « sign in with ChatGPT », « secret set openai ») ; `ErrorText` (prop `agent`) affiche le bouton | |
| 138 | + ChatGPT sous cette erreur — et sous « Authentication required » pour un agent Codex — puis redémarre l'agent ; | |
| 139 | + assistant : connexion ChatGPT / clé / plus tard, note non bloquante. | |
| 140 | + - Vérifié sous Xvfb avec un faux sbx (question à `env create` sans identifiant, `--oauth` qui attend) : bouton dans | |
| 141 | + la conversation et le panneau Agents, page, connexion, redémarrage, sandbox créée ; assistant. | |
| 142 | + - À vérifier sur le Mac : le texte réel de la question (si la règle ne le reconnaît pas, ajouter son motif dans | |
| 143 | + errors.ts — il est maintenant visible dans « Détails techniques »), la sortie de `--oauth` sans terminal. | |
| 144 | + - id: 2 | |
| 145 | + author: | |
| 146 | + name: k33g | |
| 147 | + email: ph.charriere@gmail.com | |
| 148 | + createdAt: 2026-11-15T09:06:46.000Z | |
| 149 | + body: | | |
| 150 | + Testé sur le Mac par l'owner avec Codex : ça fonctionne. Mergé dans main. Ticket fermé. | |
| @@ -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: 107 | 2 | id: 107 |
| 3 | title: "Assistant des sandboxes, Codex : clé facultative et connexion ChatGPT (sbx secret set openai --oauth)" | 3 | title: "Assistant des sandboxes, Codex : clé facultative et connexion ChatGPT (sbx secret set openai --oauth)" |
| 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-15T08:16:29.000Z | 8 | createdAt: 2026-11-15T08:16:29.000Z |
| 9 | -updatedAt: 2026-11-15T08:16:29.000Z | 9 | +updatedAt: 2026-11-15T09:06:46.000Z |
| 10 | labels: | 10 | labels: |
| 11 | - kind::feature | 11 | - kind::feature |
| 12 | - area::workspace | 12 | - area::workspace |
| @@ -61,50 +61,90 @@ body: | | |||
| 61 | tasks: | 61 | tasks: |
| 62 | - id: 1 | 62 | - id: 1 |
| 63 | title: "Relever sur le Mac la question de sbx env create sans identifiant OpenAI, et la sortie de sbx secret set openai --oauth" | 63 | title: "Relever sur le Mac la question de sbx env create sans identifiant OpenAI, et la sortie de sbx secret set openai --oauth" |
| 64 | - state: open | 64 | + state: closed |
| 65 | priority: high | 65 | priority: high |
| 66 | author: | 66 | author: |
| 67 | name: k33g | 67 | name: k33g |
| 68 | email: ph.charriere@gmail.com | 68 | email: ph.charriere@gmail.com |
| 69 | createdAt: 2026-11-15T08:16:29.000Z | 69 | createdAt: 2026-11-15T08:16:29.000Z |
| 70 | + updatedAt: 2026-11-15T09:06:46.000Z | ||
| 71 | + closedAt: 2026-11-15T09:06:46.000Z | ||
| 70 | - id: 2 | 72 | - id: 2 |
| 71 | title: "Go : lancer sbx secret set openai --oauth et suivre sa fin (comme sbx login) ; HasSecret avec un secret oauth" | 73 | title: "Go : lancer sbx secret set openai --oauth et suivre sa fin (comme sbx login) ; HasSecret avec un secret oauth" |
| 72 | - state: open | 74 | + state: closed |
| 73 | priority: high | 75 | priority: high |
| 74 | author: | 76 | author: |
| 75 | name: k33g | 77 | name: k33g |
| 76 | email: ph.charriere@gmail.com | 78 | email: ph.charriere@gmail.com |
| 77 | createdAt: 2026-11-15T08:16:29.000Z | 79 | createdAt: 2026-11-15T08:16:29.000Z |
| 80 | + updatedAt: 2026-11-15T08:57:51.000Z | ||
| 81 | + closedAt: 2026-11-15T08:57:51.000Z | ||
| 78 | - id: 3 | 82 | - id: 3 |
| 79 | title: "Étape de la clé Codex : connexion ChatGPT / clé d'API / plus tard, sans blocage (EN + FR)" | 83 | title: "Étape de la clé Codex : connexion ChatGPT / clé d'API / plus tard, sans blocage (EN + FR)" |
| 80 | - state: open | 84 | + state: closed |
| 81 | priority: high | 85 | priority: high |
| 82 | author: | 86 | author: |
| 83 | name: k33g | 87 | name: k33g |
| 84 | email: ph.charriere@gmail.com | 88 | email: ph.charriere@gmail.com |
| 85 | createdAt: 2026-11-15T08:16:29.000Z | 89 | createdAt: 2026-11-15T08:16:29.000Z |
| 90 | + updatedAt: 2026-11-15T08:57:51.000Z | ||
| 91 | + closedAt: 2026-11-15T08:57:51.000Z | ||
| 86 | - id: 4 | 92 | - id: 4 |
| 87 | title: "Création : reconnaître la question d'authentification, proposer la connexion sous l'erreur, puis redémarrer l'agent" | 93 | title: "Création : reconnaître la question d'authentification, proposer la connexion sous l'erreur, puis redémarrer l'agent" |
| 88 | - state: open | 94 | + state: closed |
| 89 | priority: high | 95 | priority: high |
| 90 | author: | 96 | author: |
| 91 | name: k33g | 97 | name: k33g |
| 92 | email: ph.charriere@gmail.com | 98 | email: ph.charriere@gmail.com |
| 93 | createdAt: 2026-11-15T08:16:29.000Z | 99 | createdAt: 2026-11-15T08:16:29.000Z |
| 100 | + updatedAt: 2026-11-15T08:57:51.000Z | ||
| 101 | + closedAt: 2026-11-15T08:57:51.000Z | ||
| 94 | - id: 5 | 102 | - id: 5 |
| 95 | title: "Tests Go + vitest, doc EN + FR, notes de release v1.6.0" | 103 | title: "Tests Go + vitest, doc EN + FR, notes de release v1.6.0" |
| 96 | - state: open | 104 | + state: closed |
| 97 | priority: medium | 105 | priority: medium |
| 98 | author: | 106 | author: |
| 99 | name: k33g | 107 | name: k33g |
| 100 | email: ph.charriere@gmail.com | 108 | email: ph.charriere@gmail.com |
| 101 | createdAt: 2026-11-15T08:16:29.000Z | 109 | createdAt: 2026-11-15T08:16:29.000Z |
| 110 | + updatedAt: 2026-11-15T08:57:51.000Z | ||
| 111 | + closedAt: 2026-11-15T08:57:51.000Z | ||
| 102 | - id: 6 | 112 | - id: 6 |
| 103 | title: "Tester sur le Mac : Codex avec compte ChatGPT, et Codex créé sans identifiant" | 113 | title: "Tester sur le Mac : Codex avec compte ChatGPT, et Codex créé sans identifiant" |
| 104 | - state: open | 114 | + state: closed |
| 105 | priority: high | 115 | priority: high |
| 106 | author: | 116 | author: |
| 107 | name: k33g | 117 | name: k33g |
| 108 | email: ph.charriere@gmail.com | 118 | email: ph.charriere@gmail.com |
| 109 | createdAt: 2026-11-15T08:16:29.000Z | 119 | createdAt: 2026-11-15T08:16:29.000Z |
| 110 | -comments: [] | 120 | + updatedAt: 2026-11-15T09:06:46.000Z |
| 121 | + closedAt: 2026-11-15T09:06:46.000Z | ||
| 122 | +comments: | ||
| 123 | + - id: 1 | ||
| 124 | + author: | ||
| 125 | + name: k33g | ||
| 126 | + email: ph.charriere@gmail.com | ||
| 127 | + createdAt: 2026-11-15T08:57:51.000Z | ||
| 128 | + body: | | ||
| 129 | + Fait sur `feature/107-codex-chatgpt` (sortie réelle de sbx non relevée : tâche 1 reste ouverte). | ||
| 130 | + | ||
| 131 | + - Go : `Sbx.StartOAuth(service)` (`sbx secret set <service> --oauth`, lu comme `sbx login` : première URL https, | ||
| 132 | + succès = fin sans erreur, `LoginState.ok`), `Kind.OAuth` (Codex), `OAuthLogin` / `OAuthLoginStatus` / | ||
| 133 | + `CancelOAuthLogin` ; `Status.oauth` (`codex` pour `codex-acp` en sbx). | ||
| 134 | + - **Les commandes du cycle de vie mettent leurs 3 dernières lignes dans leur erreur** : avant, la question de sbx | ||
| 135 | + n'était que dans le journal et l'erreur disait « create codex: exit status 1 ». | ||
| 136 | + - Front : règle `error.openaiSignIn` (motifs devinés : « authenticate on/in the web/browser », « no OpenAI | ||
| 137 | + credential », « sign in with ChatGPT », « secret set openai ») ; `ErrorText` (prop `agent`) affiche le bouton | ||
| 138 | + ChatGPT sous cette erreur — et sous « Authentication required » pour un agent Codex — puis redémarre l'agent ; | ||
| 139 | + assistant : connexion ChatGPT / clé / plus tard, note non bloquante. | ||
| 140 | + - Vérifié sous Xvfb avec un faux sbx (question à `env create` sans identifiant, `--oauth` qui attend) : bouton dans | ||
| 141 | + la conversation et le panneau Agents, page, connexion, redémarrage, sandbox créée ; assistant. | ||
| 142 | + - À vérifier sur le Mac : le texte réel de la question (si la règle ne le reconnaît pas, ajouter son motif dans | ||
| 143 | + errors.ts — il est maintenant visible dans « Détails techniques »), la sortie de `--oauth` sans terminal. | ||
| 144 | + - id: 2 | ||
| 145 | + author: | ||
| 146 | + name: k33g | ||
| 147 | + email: ph.charriere@gmail.com | ||
| 148 | + createdAt: 2026-11-15T09:06:46.000Z | ||
| 149 | + body: | | ||
| 150 | + Testé sur le Mac par l'owner avec Codex : ça fonctionne. Mergé dans main. Ticket fermé. | ||
modified
docs/en/how-to/create-an-agent-in-a-sandbox.md +2 -0 | @@ -8,6 +8,7 @@ This guide shows how to create a new Claude, Gemini, Codex, Vibe or Copilot agen | ||
| 8 | 8 | 2. Choose the agent: **Claude** (Anthropic's Claude Code), **Gemini** (Google's, through Antigravity), **Codex** (OpenAI's), **Vibe** (Mistral AI's) or **Copilot** (GitHub's Copilot CLI). |
| 9 | 9 | 3. If sbx does not hold its key yet, paste it in **API key** and click **Save the key**. **Get a key…** opens the page where the company gives you one. Sidekicks hands the key to sbx, which keeps it and gives it to your sandboxes for their calls to that company only; it is never written in a file. A key already saved is shown as **✓ Your … key is stored in sbx**. |
| 10 | 10 | For **Copilot**, it is not an API key but a **GitHub token** allowed to use Copilot, and your GitHub account needs a Copilot subscription. If the GitHub CLI (`gh`) is installed, the simplest is **Use my GitHub account**: Sidekicks takes its token (`gh auth token`) without showing it. When `gh` is not signed in yet, **Sign in to GitHub** shows a code and **Open the sign-in page**: check the code on the page, confirm, and the assistant goes on by itself. Without `gh`, **Create a token on GitHub…** opens the page of a fine-grained token: give it the **Copilot Requests** permission, paste it in **GitHub token** and click **Save the token**. sbx stores it twice — `copilot`, for the sandbox's calls to Copilot, and `github`, for `git` and `gh` in the sandbox: the agent can then work on your GitHub repositories with your account. |
| 11 | + For **Codex**, you can use your **ChatGPT account** instead of an API key: **Sign in with my ChatGPT account** runs `sbx secret set openai --oauth`, which opens your browser; sign in there, and the assistant goes on by itself once sbx has kept the sign-in (in your keychain: the sandbox never sees it). You can also click **Later**: see below. | |
| 11 | 12 | 4. Give the agent its last details: **Name shown**, **Name** (what you call it with, `@claude`, and the name of its folder and of its sandbox: lowercase letters, digits and `-`, starting with a letter) and an **Emoji** (the agent's logo is chosen first). The **Name** follows the **Name shown** (`Marcel (assistant)` gives `marcel-assistant`) until you type it yourself; Sidekicks always suggests one nobody uses yet, and says so before you click when the one you typed is taken. |
| 12 | 13 | 5. Click **Add the agent**. Its conversation opens. Its sandbox is created the first time you write to it, so that first answer takes a while: the conversation shows what is happening — the step, the time elapsed, what sbx is downloading. The details are in the agent's log (**Log** panel). |
| 13 | 14 | |
| @@ -20,6 +21,7 @@ The agent's folder is created in the **Sidekicks-Agents** folder of your Documen | ||
| 20 | 21 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. |
| 21 | 22 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe, `copilot` and `github` for Copilot — for example `sbx secret set copilot --command 'gh auth token'` then the same with `github`) in a terminal. |
| 22 | 23 | - **Claude without an API key** (issues #105 and #106): click **Later** and sign in with your Claude account instead. The assistant says so. At the first answer, Claude ends with "The agent is not signed in": Sidekicks opens the agent's **Terminal**, runs `claude` in its sandbox and tells you what to do — type `/login`, choose your account and follow the steps (copy the link into your browser if asked). Then click **I am signed in: restart the agent**: you are back in the conversation; send your message again. If you closed that terminal, **Sign in in its terminal** under the error opens it again. |
| 24 | +- **Codex without a key nor a ChatGPT sign-in** (issue #107): when its sandbox is created, sbx asks whether to sign in to OpenAI on the web. Sidekicks cannot answer that question, so the agent stops with "sbx asks to sign in to OpenAI…" and a **Sign in with my ChatGPT account** button — in the conversation and in the Agents panel. Sign in in your browser: the agent starts again by itself. | |
| 23 | 25 | |
| 24 | 26 | ## Variants |
| 25 | 27 | |
| @@ -8,6 +8,7 @@ This guide shows how to create a new Claude, Gemini, Codex, Vibe or Copilot agen | |||
| 8 | 2. Choose the agent: **Claude** (Anthropic's Claude Code), **Gemini** (Google's, through Antigravity), **Codex** (OpenAI's), **Vibe** (Mistral AI's) or **Copilot** (GitHub's Copilot CLI). | 8 | 2. Choose the agent: **Claude** (Anthropic's Claude Code), **Gemini** (Google's, through Antigravity), **Codex** (OpenAI's), **Vibe** (Mistral AI's) or **Copilot** (GitHub's Copilot CLI). |
| 9 | 3. If sbx does not hold its key yet, paste it in **API key** and click **Save the key**. **Get a key…** opens the page where the company gives you one. Sidekicks hands the key to sbx, which keeps it and gives it to your sandboxes for their calls to that company only; it is never written in a file. A key already saved is shown as **✓ Your … key is stored in sbx**. | 9 | 3. If sbx does not hold its key yet, paste it in **API key** and click **Save the key**. **Get a key…** opens the page where the company gives you one. Sidekicks hands the key to sbx, which keeps it and gives it to your sandboxes for their calls to that company only; it is never written in a file. A key already saved is shown as **✓ Your … key is stored in sbx**. |
| 10 | For **Copilot**, it is not an API key but a **GitHub token** allowed to use Copilot, and your GitHub account needs a Copilot subscription. If the GitHub CLI (`gh`) is installed, the simplest is **Use my GitHub account**: Sidekicks takes its token (`gh auth token`) without showing it. When `gh` is not signed in yet, **Sign in to GitHub** shows a code and **Open the sign-in page**: check the code on the page, confirm, and the assistant goes on by itself. Without `gh`, **Create a token on GitHub…** opens the page of a fine-grained token: give it the **Copilot Requests** permission, paste it in **GitHub token** and click **Save the token**. sbx stores it twice — `copilot`, for the sandbox's calls to Copilot, and `github`, for `git` and `gh` in the sandbox: the agent can then work on your GitHub repositories with your account. | 10 | For **Copilot**, it is not an API key but a **GitHub token** allowed to use Copilot, and your GitHub account needs a Copilot subscription. If the GitHub CLI (`gh`) is installed, the simplest is **Use my GitHub account**: Sidekicks takes its token (`gh auth token`) without showing it. When `gh` is not signed in yet, **Sign in to GitHub** shows a code and **Open the sign-in page**: check the code on the page, confirm, and the assistant goes on by itself. Without `gh`, **Create a token on GitHub…** opens the page of a fine-grained token: give it the **Copilot Requests** permission, paste it in **GitHub token** and click **Save the token**. sbx stores it twice — `copilot`, for the sandbox's calls to Copilot, and `github`, for `git` and `gh` in the sandbox: the agent can then work on your GitHub repositories with your account. |
| 11 | + For **Codex**, you can use your **ChatGPT account** instead of an API key: **Sign in with my ChatGPT account** runs `sbx secret set openai --oauth`, which opens your browser; sign in there, and the assistant goes on by itself once sbx has kept the sign-in (in your keychain: the sandbox never sees it). You can also click **Later**: see below. | ||
| 11 | 4. Give the agent its last details: **Name shown**, **Name** (what you call it with, `@claude`, and the name of its folder and of its sandbox: lowercase letters, digits and `-`, starting with a letter) and an **Emoji** (the agent's logo is chosen first). The **Name** follows the **Name shown** (`Marcel (assistant)` gives `marcel-assistant`) until you type it yourself; Sidekicks always suggests one nobody uses yet, and says so before you click when the one you typed is taken. | 12 | 4. Give the agent its last details: **Name shown**, **Name** (what you call it with, `@claude`, and the name of its folder and of its sandbox: lowercase letters, digits and `-`, starting with a letter) and an **Emoji** (the agent's logo is chosen first). The **Name** follows the **Name shown** (`Marcel (assistant)` gives `marcel-assistant`) until you type it yourself; Sidekicks always suggests one nobody uses yet, and says so before you click when the one you typed is taken. |
| 12 | 5. Click **Add the agent**. Its conversation opens. Its sandbox is created the first time you write to it, so that first answer takes a while: the conversation shows what is happening — the step, the time elapsed, what sbx is downloading. The details are in the agent's log (**Log** panel). | 13 | 5. Click **Add the agent**. Its conversation opens. Its sandbox is created the first time you write to it, so that first answer takes a while: the conversation shows what is happening — the step, the time elapsed, what sbx is downloading. The details are in the agent's log (**Log** panel). |
| 13 | 14 | ||
| @@ -20,6 +21,7 @@ The agent's folder is created in the **Sidekicks-Agents** folder of your Documen | |||
| 20 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. | 21 | - **"Another agent already has this name"**, **"A folder with this name already exists"** or **"A sandbox with this name already exists"**: change the **Name** and click **Add the agent** again. An existing folder or sandbox is never changed. |
| 21 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe, `copilot` and `github` for Copilot — for example `sbx secret set copilot --command 'gh auth token'` then the same with `github`) in a terminal. | 22 | - **"No … key in sbx yet"** (after **Later**): the agent cannot answer. Run the assistant again to save the key, or type `sbx secret set anthropic` (`google` for Gemini, `openai` for Codex, `mistral` for Vibe, `copilot` and `github` for Copilot — for example `sbx secret set copilot --command 'gh auth token'` then the same with `github`) in a terminal. |
| 22 | - **Claude without an API key** (issues #105 and #106): click **Later** and sign in with your Claude account instead. The assistant says so. At the first answer, Claude ends with "The agent is not signed in": Sidekicks opens the agent's **Terminal**, runs `claude` in its sandbox and tells you what to do — type `/login`, choose your account and follow the steps (copy the link into your browser if asked). Then click **I am signed in: restart the agent**: you are back in the conversation; send your message again. If you closed that terminal, **Sign in in its terminal** under the error opens it again. | 23 | - **Claude without an API key** (issues #105 and #106): click **Later** and sign in with your Claude account instead. The assistant says so. At the first answer, Claude ends with "The agent is not signed in": Sidekicks opens the agent's **Terminal**, runs `claude` in its sandbox and tells you what to do — type `/login`, choose your account and follow the steps (copy the link into your browser if asked). Then click **I am signed in: restart the agent**: you are back in the conversation; send your message again. If you closed that terminal, **Sign in in its terminal** under the error opens it again. |
| 24 | +- **Codex without a key nor a ChatGPT sign-in** (issue #107): when its sandbox is created, sbx asks whether to sign in to OpenAI on the web. Sidekicks cannot answer that question, so the agent stops with "sbx asks to sign in to OpenAI…" and a **Sign in with my ChatGPT account** button — in the conversation and in the Agents panel. Sign in in your browser: the agent starts again by itself. | ||
| 23 | 25 | ||
| 24 | ## Variants | 26 | ## Variants |
| 25 | 27 | ||
modified
docs/en/reference/agents-and-events.md +3 -2 | @@ -47,7 +47,7 @@ The Go names and types are in `internal/events`; the TypeScript constants and ty | ||
| 47 | 47 | |
| 48 | 48 | | Service | Method | Effect | |
| 49 | 49 | | --- | --- | --- | |
| 50 | -| `AgentService` | `List()` | Every agent with `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (and, while starting, `step, since` as `agent:progress` gives them; `signIn`: the program its terminal runs to sign in with an account instead of an API key — `claude` for `claude-agent-acp` in an sbx sandbox, issues #105 and #106), in configuration order. | | |
| 50 | +| `AgentService` | `List()` | Every agent with `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (and, while starting, `step, since` as `agent:progress` gives them; `signIn`: the program its terminal runs to sign in with an account instead of an API key — `claude` for `claude-agent-acp` in an sbx sandbox, issues #105 and #106; `oauth`: the kind whose account sign-in it takes — `codex` for `codex-acp` in an sbx sandbox, issue #107), in configuration order. | | |
| 51 | 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | As in the transitions above; an error is returned to the interface. A start first recreates a missing sandbox when `runtime.lifecycle.create` is set. | |
| 52 | 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Stops the agent, then runs `runtime.lifecycle.stop` or `remove` (container or sandbox); the output goes to the agent's log. | |
| 53 | 53 | | | `Unload(name)` | Has a running, idle agent that announced the `unload` command unload its model (issue #51): `/unload` is sent in a session of its own, which no conversation shows; the answer goes to the agent's log as `unload: …` lines. Errors: unknown agent, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | |
| @@ -267,7 +267,7 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | ||
| 267 | 267 | |
| 268 | 268 | | Method | Effect | |
| 269 | 269 | | --- | --- | |
| 270 | -| `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn}` (`signIn`: the program to run in the agent's terminal to sign in with an account — Claude: `claude`, then `/login`, issue #105) (`token`: the secret is a token of the user's account, not an API key — Copilot; the assistant says "token"; `fromGh`: it can come from `gh auth token`). A kind may give its secret to more sbx services (Copilot: `github` too, with `api.github.com` and `github.com` in its `bindings`). | | |
| 270 | +| `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn, oauth}` (`oauth`: the service also takes a sign-in with an account, `sbx secret set <service> --oauth` — Codex: ChatGPT, issue #107) (`signIn`: the program to run in the agent's terminal to sign in with an account — Claude: `claude`, then `/login`, issue #105) (`token`: the secret is a token of the user's account, not an API key — Copilot; the assistant says "token"; `fromGh`: it can come from `gh auth token`). A kind may give its secret to more sbx services (Copilot: `github` too, with `api.github.com` and `github.com` in its `bindings`). | | |
| 271 | 271 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`hasKey`: every service of the kind holds a secret; `gh`, `ghSignedIn`: for a kind with `fromGh`, whether gh is installed and has a token) (`taken`: the names used by an agent, a folder or a sandbox, issue #99): whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | |
| 272 | 272 | | `SetKey(kind, key)` | `sbx secret set <service>` for each service of the kind, with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | |
| 273 | 273 | | `Login()` | Runs `sbx login` (issue #97) — or joins the one in progress — and returns once sbx printed its device code and URL, 20 seconds at most: `{code, url, done, user, error, output[]}`. The code is the first `XXXX-XXXX`, the URL the first `https://…` naming `login`; `output` keeps every line for when sbx prints something else. Its standard input is empty: a question asked on the keyboard gets no answer. | |
| @@ -275,6 +275,7 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | ||
| 275 | 275 | | `CancelLogin()` | Stops `sbx login`; also done when Sidekicks quits. | |
| 276 | 276 | | `UseGitHub(kind)` | For a kind with `fromGh` (issue #103): runs `gh auth token` and stores what it prints as with `SetKey` — as `sbx secret set <service> --command 'gh auth token'` would, for each service. `gh is not signed in to GitHub` when gh has no token, `gh is not installed` without gh (`gh` in PATH, `/opt/homebrew/bin`, `/usr/local/bin`). The token is never shown, written or logged. | |
| 277 | 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Like `Login`, `LoginStatus` and `CancelLogin`, for `gh auth login --web --hostname github.com --git-protocol https` (issue #103): its code (`XXXX-XXXX`), its URL (`https://github.com/login/device`), then `user` from `✓ Logged in as <user>`. | |
| 278 | +| `OAuthLogin(kind)`, `OAuthLoginStatus()`, `CancelOAuthLogin()` | For a kind with `oauth` (issue #107): runs `sbx secret set <service> --oauth`, which opens a browser window; returns once it printed a page to open (`url`, or after 20 seconds), then like `LoginStatus`. `ok` when sbx ended without an error (it names nobody). | | |
| 278 | 279 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | |
| 279 | 280 | |
| 280 | 281 | ## Tools offered to the agents |
| @@ -47,7 +47,7 @@ The Go names and types are in `internal/events`; the TypeScript constants and ty | |||
| 47 | 47 | ||
| 48 | | Service | Method | Effect | | 48 | | Service | Method | Effect | |
| 49 | | --- | --- | --- | | 49 | | --- | --- | --- | |
| 50 | -| `AgentService` | `List()` | Every agent with `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (and, while starting, `step, since` as `agent:progress` gives them; `signIn`: the program its terminal runs to sign in with an account instead of an API key — `claude` for `claude-agent-acp` in an sbx sandbox, issues #105 and #106), in configuration order. | | 50 | +| `AgentService` | `List()` | Every agent with `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (and, while starting, `step, since` as `agent:progress` gives them; `signIn`: the program its terminal runs to sign in with an account instead of an API key — `claude` for `claude-agent-acp` in an sbx sandbox, issues #105 and #106; `oauth`: the kind whose account sign-in it takes — `codex` for `codex-acp` in an sbx sandbox, issue #107), in configuration order. | |
| 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | As in the transitions above; an error is returned to the interface. A start first recreates a missing sandbox when `runtime.lifecycle.create` is set. | | 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | As in the transitions above; an error is returned to the interface. A start first recreates a missing sandbox when `runtime.lifecycle.create` is set. | |
| 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Stops the agent, then runs `runtime.lifecycle.stop` or `remove` (container or sandbox); the output goes to the agent's log. | | 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Stops the agent, then runs `runtime.lifecycle.stop` or `remove` (container or sandbox); the output goes to the agent's log. | |
| 53 | | | `Unload(name)` | Has a running, idle agent that announced the `unload` command unload its model (issue #51): `/unload` is sent in a session of its own, which no conversation shows; the answer goes to the agent's log as `unload: …` lines. Errors: unknown agent, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | | 53 | | | `Unload(name)` | Has a running, idle agent that announced the `unload` command unload its model (issue #51): `/unload` is sent in a session of its own, which no conversation shows; the answer goes to the agent's log as `unload: …` lines. Errors: unknown agent, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | |
| @@ -267,7 +267,7 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | |||
| 267 | 267 | ||
| 268 | | Method | Effect | | 268 | | Method | Effect | |
| 269 | | --- | --- | | 269 | | --- | --- | |
| 270 | -| `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn}` (`signIn`: the program to run in the agent's terminal to sign in with an account — Claude: `claude`, then `/login`, issue #105) (`token`: the secret is a token of the user's account, not an API key — Copilot; the assistant says "token"; `fromGh`: it can come from `gh auth token`). A kind may give its secret to more sbx services (Copilot: `github` too, with `api.github.com` and `github.com` in its `bindings`). | | 270 | +| `Kinds()` | The catalogue, in order: `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn, oauth}` (`oauth`: the service also takes a sign-in with an account, `sbx secret set <service> --oauth` — Codex: ChatGPT, issue #107) (`signIn`: the program to run in the agent's terminal to sign in with an account — Claude: `claude`, then `/login`, issue #105) (`token`: the secret is a token of the user's account, not an API key — Copilot; the assistant says "token"; `fromGh`: it can come from `gh auth token`). A kind may give its secret to more sbx services (Copilot: `github` too, with `api.github.com` and `github.com` in its `bindings`). | |
| 271 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`hasKey`: every service of the kind holds a secret; `gh`, `ghSignedIn`: for a kind with `fromGh`, whether gh is installed and has a token) (`taken`: the names used by an agent, a folder or a sandbox, issue #99): whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | | 271 | | `Check(kind)` | `sbx is not installed` when sbx cannot be found (`sbx` in PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Returns `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`hasKey`: every service of the kind holds a secret; `gh`, `ghSignedIn`: for a kind with `fromGh`, whether gh is installed and has a token) (`taken`: the names used by an agent, a folder or a sandbox, issue #99): whether `sbx secret ls --service <service>` shows a global secret, and the first free name among `<kind>`, `<kind>-2`… — free as an agent of the configuration, a folder of the agents' folder and a sandbox (`sbx ls -q`). | |
| 272 | | `SetKey(kind, key)` | `sbx secret set <service>` for each service of the kind, with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | | 272 | | `SetKey(kind, key)` | `sbx secret set <service>` for each service of the kind, with the key on its standard input — never in its arguments, a file or a log; an error never repeats it. Global: every sandbox gets it. | |
| 273 | | `Login()` | Runs `sbx login` (issue #97) — or joins the one in progress — and returns once sbx printed its device code and URL, 20 seconds at most: `{code, url, done, user, error, output[]}`. The code is the first `XXXX-XXXX`, the URL the first `https://…` naming `login`; `output` keeps every line for when sbx prints something else. Its standard input is empty: a question asked on the keyboard gets no answer. | | 273 | | `Login()` | Runs `sbx login` (issue #97) — or joins the one in progress — and returns once sbx printed its device code and URL, 20 seconds at most: `{code, url, done, user, error, output[]}`. The code is the first `XXXX-XXXX`, the URL the first `https://…` naming `login`; `output` keeps every line for when sbx prints something else. Its standard input is empty: a question asked on the keyboard gets no answer. | |
| @@ -275,6 +275,7 @@ The assistant that creates an agent in a Docker Sandbox (issue #96, [How to crea | |||
| 275 | | `CancelLogin()` | Stops `sbx login`; also done when Sidekicks quits. | | 275 | | `CancelLogin()` | Stops `sbx login`; also done when Sidekicks quits. | |
| 276 | | `UseGitHub(kind)` | For a kind with `fromGh` (issue #103): runs `gh auth token` and stores what it prints as with `SetKey` — as `sbx secret set <service> --command 'gh auth token'` would, for each service. `gh is not signed in to GitHub` when gh has no token, `gh is not installed` without gh (`gh` in PATH, `/opt/homebrew/bin`, `/usr/local/bin`). The token is never shown, written or logged. | | 276 | | `UseGitHub(kind)` | For a kind with `fromGh` (issue #103): runs `gh auth token` and stores what it prints as with `SetKey` — as `sbx secret set <service> --command 'gh auth token'` would, for each service. `gh is not signed in to GitHub` when gh has no token, `gh is not installed` without gh (`gh` in PATH, `/opt/homebrew/bin`, `/usr/local/bin`). The token is never shown, written or logged. | |
| 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Like `Login`, `LoginStatus` and `CancelLogin`, for `gh auth login --web --hostname github.com --git-protocol https` (issue #103): its code (`XXXX-XXXX`), its URL (`https://github.com/login/device`), then `user` from `✓ Logged in as <user>`. | | 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Like `Login`, `LoginStatus` and `CancelLogin`, for `gh auth login --web --hostname github.com --git-protocol https` (issue #103): its code (`XXXX-XXXX`), its URL (`https://github.com/login/device`), then `user` from `✓ Logged in as <user>`. | |
| 278 | +| `OAuthLogin(kind)`, `OAuthLoginStatus()`, `CancelOAuthLogin()` | For a kind with `oauth` (issue #107): runs `sbx secret set <service> --oauth`, which opens a browser window; returns once it printed a page to open (`url`, or after 20 seconds), then like `LoginStatus`. `ok` when sbx ended without an error (it names nobody). | | ||
| 278 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | | 279 | | `Create({kind, name, title, icon})` | Writes `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, the kind's `agent:` and kit, `workspace: ./workspace`, `bindings` of its service, `pullPolicy: always`, English comments) and `workspace/`, then adds the agent: `sbx exec -i <name> <program>`, workspace `<folder>/workspace`, `runtime.lifecycle` in `<folder>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — the sandbox is created at the first start. Returns `{problem, problems[], name, folder}`: `problem` is `invalidName` (lowercase letters, digits and `-`: no `_`, which sbx refuses), `nameTaken`, `folderExists` or `sandboxExists` when nothing was written. | |
| 279 | 280 | ||
| 280 | ## Tools offered to the agents | 281 | ## Tools offered to the agents |
modified
docs/fr/how-to/creer-un-agent-dans-une-sandbox.md +2 -0 | @@ -8,6 +8,7 @@ Ce guide montre comment créer un nouvel agent Claude, Gemini, Codex, Vibe ou Co | ||
| 8 | 8 | 2. Choisissez l'agent : **Claude** (Claude Code, d'Anthropic), **Gemini** (de Google, via Antigravity), **Codex** (d'OpenAI), **Vibe** (de Mistral AI) ou **Copilot** (Copilot CLI, de GitHub). |
| 9 | 9 | 3. Si sbx n'a pas encore sa clé, collez-la dans **Clé d'API** et cliquez sur **Enregistrer la clé**. **Obtenir une clé…** ouvre la page où l'éditeur vous en donne une. Sidekicks confie la clé à sbx, qui la garde et la fournit à vos sandboxes seulement pour leurs appels à cet éditeur ; elle n'est jamais écrite dans un fichier. Une clé déjà enregistrée s'affiche **✓ Votre clé … est enregistrée dans sbx**. |
| 10 | 10 | Pour **Copilot**, ce n'est pas une clé d'API mais un **jeton GitHub** autorisé à utiliser Copilot, et votre compte GitHub doit avoir un abonnement Copilot. Si l'outil GitHub (`gh`) est installé, le plus simple est **Utiliser mon compte GitHub** : Sidekicks prend son jeton (`gh auth token`) sans l'afficher. Quand `gh` n'est pas encore connecté, **Se connecter à GitHub** affiche un code et **Ouvrir la page de connexion** : vérifiez le code sur la page, confirmez, et l'assistant continue tout seul. Sans `gh`, **Créer un jeton sur GitHub…** ouvre la page d'un jeton « fine-grained » : donnez-lui la permission **Copilot Requests**, collez-le dans **Jeton GitHub** et cliquez sur **Enregistrer le jeton**. sbx l'enregistre deux fois — `copilot`, pour les appels de la sandbox à Copilot, et `github`, pour `git` et `gh` dans la sandbox : l'agent peut alors travailler sur vos dépôts GitHub avec votre compte. |
| 11 | + Pour **Codex**, vous pouvez utiliser votre **compte ChatGPT** au lieu d'une clé d'API : **Me connecter avec mon compte ChatGPT** lance `sbx secret set openai --oauth`, qui ouvre votre navigateur ; connectez-vous-y, et l'assistant continue tout seul une fois que sbx a gardé la connexion (dans votre trousseau : la sandbox ne la voit jamais). Vous pouvez aussi cliquer sur **Plus tard** : voir ci-dessous. | |
| 11 | 12 | 4. Donnez à l'agent ses derniers détails : **Nom affiché**, **Nom** (ce qui l'appelle, `@claude`, et le nom de son dossier et de sa sandbox : minuscules, chiffres et `-`, en commençant par une lettre) et un **Emoji** (le logo de l'agent est choisi d'abord). Le **Nom** suit le **Nom affiché** (`Marcel (assistant)` donne `marcel-assistant`) tant que vous ne le tapez pas vous-même ; Sidekicks en propose toujours un que personne n'utilise encore, et prévient avant le clic quand celui que vous avez tapé est pris. |
| 12 | 13 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation s'ouvre. Sa sandbox est créée la première fois que vous lui écrivez : cette première réponse prend un moment ; la conversation montre ce qui se passe — l'étape, le temps écoulé, ce que sbx télécharge. Le détail est dans le journal de l'agent (panneau **Journal**). |
| 13 | 14 | |
| @@ -20,6 +21,7 @@ Le dossier de l'agent est créé dans le dossier **Sidekicks-Agents** de vos Doc | ||
| 20 | 21 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. |
| 21 | 22 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe, `copilot` et `github` pour Copilot — par exemple `sbx secret set copilot --command 'gh auth token'` puis la même avec `github`) dans un terminal. |
| 22 | 23 | - **Claude sans clé d'API** (issues #105 et #106) : cliquez sur **Plus tard** et connectez-vous plutôt avec votre compte Claude. L'assistant le dit. À la première réponse, Claude se termine par « L'agent n'est pas connecté » : Sidekicks ouvre le **Terminal** de l'agent, lance `claude` dans sa sandbox et vous dit quoi faire — tapez `/login`, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Cliquez ensuite sur **Je suis connecté : redémarrer l'agent** : vous revenez à la conversation ; renvoyez votre message. Si vous avez fermé ce terminal, **Se connecter dans son terminal** sous l'erreur le rouvre. |
| 24 | +- **Codex sans clé ni connexion ChatGPT** (issue #107) : à la création de sa sandbox, sbx demande s'il faut se connecter à OpenAI sur le web. Sidekicks ne peut pas répondre à cette question : l'agent s'arrête avec « sbx demande de se connecter à OpenAI… » et un bouton **Me connecter avec mon compte ChatGPT** — dans la conversation et dans le panneau Agents. Connectez-vous dans votre navigateur : l'agent redémarre tout seul. | |
| 23 | 25 | |
| 24 | 26 | ## Variantes |
| 25 | 27 | |
| @@ -8,6 +8,7 @@ Ce guide montre comment créer un nouvel agent Claude, Gemini, Codex, Vibe ou Co | |||
| 8 | 2. Choisissez l'agent : **Claude** (Claude Code, d'Anthropic), **Gemini** (de Google, via Antigravity), **Codex** (d'OpenAI), **Vibe** (de Mistral AI) ou **Copilot** (Copilot CLI, de GitHub). | 8 | 2. Choisissez l'agent : **Claude** (Claude Code, d'Anthropic), **Gemini** (de Google, via Antigravity), **Codex** (d'OpenAI), **Vibe** (de Mistral AI) ou **Copilot** (Copilot CLI, de GitHub). |
| 9 | 3. Si sbx n'a pas encore sa clé, collez-la dans **Clé d'API** et cliquez sur **Enregistrer la clé**. **Obtenir une clé…** ouvre la page où l'éditeur vous en donne une. Sidekicks confie la clé à sbx, qui la garde et la fournit à vos sandboxes seulement pour leurs appels à cet éditeur ; elle n'est jamais écrite dans un fichier. Une clé déjà enregistrée s'affiche **✓ Votre clé … est enregistrée dans sbx**. | 9 | 3. Si sbx n'a pas encore sa clé, collez-la dans **Clé d'API** et cliquez sur **Enregistrer la clé**. **Obtenir une clé…** ouvre la page où l'éditeur vous en donne une. Sidekicks confie la clé à sbx, qui la garde et la fournit à vos sandboxes seulement pour leurs appels à cet éditeur ; elle n'est jamais écrite dans un fichier. Une clé déjà enregistrée s'affiche **✓ Votre clé … est enregistrée dans sbx**. |
| 10 | Pour **Copilot**, ce n'est pas une clé d'API mais un **jeton GitHub** autorisé à utiliser Copilot, et votre compte GitHub doit avoir un abonnement Copilot. Si l'outil GitHub (`gh`) est installé, le plus simple est **Utiliser mon compte GitHub** : Sidekicks prend son jeton (`gh auth token`) sans l'afficher. Quand `gh` n'est pas encore connecté, **Se connecter à GitHub** affiche un code et **Ouvrir la page de connexion** : vérifiez le code sur la page, confirmez, et l'assistant continue tout seul. Sans `gh`, **Créer un jeton sur GitHub…** ouvre la page d'un jeton « fine-grained » : donnez-lui la permission **Copilot Requests**, collez-le dans **Jeton GitHub** et cliquez sur **Enregistrer le jeton**. sbx l'enregistre deux fois — `copilot`, pour les appels de la sandbox à Copilot, et `github`, pour `git` et `gh` dans la sandbox : l'agent peut alors travailler sur vos dépôts GitHub avec votre compte. | 10 | Pour **Copilot**, ce n'est pas une clé d'API mais un **jeton GitHub** autorisé à utiliser Copilot, et votre compte GitHub doit avoir un abonnement Copilot. Si l'outil GitHub (`gh`) est installé, le plus simple est **Utiliser mon compte GitHub** : Sidekicks prend son jeton (`gh auth token`) sans l'afficher. Quand `gh` n'est pas encore connecté, **Se connecter à GitHub** affiche un code et **Ouvrir la page de connexion** : vérifiez le code sur la page, confirmez, et l'assistant continue tout seul. Sans `gh`, **Créer un jeton sur GitHub…** ouvre la page d'un jeton « fine-grained » : donnez-lui la permission **Copilot Requests**, collez-le dans **Jeton GitHub** et cliquez sur **Enregistrer le jeton**. sbx l'enregistre deux fois — `copilot`, pour les appels de la sandbox à Copilot, et `github`, pour `git` et `gh` dans la sandbox : l'agent peut alors travailler sur vos dépôts GitHub avec votre compte. |
| 11 | + Pour **Codex**, vous pouvez utiliser votre **compte ChatGPT** au lieu d'une clé d'API : **Me connecter avec mon compte ChatGPT** lance `sbx secret set openai --oauth`, qui ouvre votre navigateur ; connectez-vous-y, et l'assistant continue tout seul une fois que sbx a gardé la connexion (dans votre trousseau : la sandbox ne la voit jamais). Vous pouvez aussi cliquer sur **Plus tard** : voir ci-dessous. | ||
| 11 | 4. Donnez à l'agent ses derniers détails : **Nom affiché**, **Nom** (ce qui l'appelle, `@claude`, et le nom de son dossier et de sa sandbox : minuscules, chiffres et `-`, en commençant par une lettre) et un **Emoji** (le logo de l'agent est choisi d'abord). Le **Nom** suit le **Nom affiché** (`Marcel (assistant)` donne `marcel-assistant`) tant que vous ne le tapez pas vous-même ; Sidekicks en propose toujours un que personne n'utilise encore, et prévient avant le clic quand celui que vous avez tapé est pris. | 12 | 4. Donnez à l'agent ses derniers détails : **Nom affiché**, **Nom** (ce qui l'appelle, `@claude`, et le nom de son dossier et de sa sandbox : minuscules, chiffres et `-`, en commençant par une lettre) et un **Emoji** (le logo de l'agent est choisi d'abord). Le **Nom** suit le **Nom affiché** (`Marcel (assistant)` donne `marcel-assistant`) tant que vous ne le tapez pas vous-même ; Sidekicks en propose toujours un que personne n'utilise encore, et prévient avant le clic quand celui que vous avez tapé est pris. |
| 12 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation s'ouvre. Sa sandbox est créée la première fois que vous lui écrivez : cette première réponse prend un moment ; la conversation montre ce qui se passe — l'étape, le temps écoulé, ce que sbx télécharge. Le détail est dans le journal de l'agent (panneau **Journal**). | 13 | 5. Cliquez sur **Ajouter l'agent**. Sa conversation s'ouvre. Sa sandbox est créée la première fois que vous lui écrivez : cette première réponse prend un moment ; la conversation montre ce qui se passe — l'étape, le temps écoulé, ce que sbx télécharge. Le détail est dans le journal de l'agent (panneau **Journal**). |
| 13 | 14 | ||
| @@ -20,6 +21,7 @@ Le dossier de l'agent est créé dans le dossier **Sidekicks-Agents** de vos Doc | |||
| 20 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. | 21 | - **« Un autre agent porte déjà ce nom »**, **« Un dossier porte déjà ce nom »** ou **« Une sandbox porte déjà ce nom »** : changez le **Nom** et cliquez de nouveau sur **Ajouter l'agent**. Un dossier ou une sandbox existants ne sont jamais modifiés. |
| 21 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe, `copilot` et `github` pour Copilot — par exemple `sbx secret set copilot --command 'gh auth token'` puis la même avec `github`) dans un terminal. | 22 | - **« Pas encore de clé … dans sbx »** (après **Plus tard**) : l'agent ne peut pas répondre. Relancez l'assistant pour enregistrer la clé, ou tapez `sbx secret set anthropic` (`google` pour Gemini, `openai` pour Codex, `mistral` pour Vibe, `copilot` et `github` pour Copilot — par exemple `sbx secret set copilot --command 'gh auth token'` puis la même avec `github`) dans un terminal. |
| 22 | - **Claude sans clé d'API** (issues #105 et #106) : cliquez sur **Plus tard** et connectez-vous plutôt avec votre compte Claude. L'assistant le dit. À la première réponse, Claude se termine par « L'agent n'est pas connecté » : Sidekicks ouvre le **Terminal** de l'agent, lance `claude` dans sa sandbox et vous dit quoi faire — tapez `/login`, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Cliquez ensuite sur **Je suis connecté : redémarrer l'agent** : vous revenez à la conversation ; renvoyez votre message. Si vous avez fermé ce terminal, **Se connecter dans son terminal** sous l'erreur le rouvre. | 23 | - **Claude sans clé d'API** (issues #105 et #106) : cliquez sur **Plus tard** et connectez-vous plutôt avec votre compte Claude. L'assistant le dit. À la première réponse, Claude se termine par « L'agent n'est pas connecté » : Sidekicks ouvre le **Terminal** de l'agent, lance `claude` dans sa sandbox et vous dit quoi faire — tapez `/login`, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Cliquez ensuite sur **Je suis connecté : redémarrer l'agent** : vous revenez à la conversation ; renvoyez votre message. Si vous avez fermé ce terminal, **Se connecter dans son terminal** sous l'erreur le rouvre. |
| 24 | +- **Codex sans clé ni connexion ChatGPT** (issue #107) : à la création de sa sandbox, sbx demande s'il faut se connecter à OpenAI sur le web. Sidekicks ne peut pas répondre à cette question : l'agent s'arrête avec « sbx demande de se connecter à OpenAI… » et un bouton **Me connecter avec mon compte ChatGPT** — dans la conversation et dans le panneau Agents. Connectez-vous dans votre navigateur : l'agent redémarre tout seul. | ||
| 23 | 25 | ||
| 24 | ## Variantes | 26 | ## Variantes |
| 25 | 27 | ||
modified
docs/fr/reference/agents-et-evenements.md +3 -2 | @@ -47,7 +47,7 @@ Les noms et types Go sont dans `internal/events` ; les constantes et types TypeS | ||
| 47 | 47 | |
| 48 | 48 | | Service | Méthode | Effet | |
| 49 | 49 | | --- | --- | --- | |
| 50 | -| `AgentService` | `List()` | Tous les agents avec `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (et, pendant un démarrage, `step, since` comme les donne `agent:progress` ; `signIn` : le programme que son terminal lance pour se connecter avec un compte au lieu d'une clé d'API — `claude` pour `claude-agent-acp` dans une sandbox sbx, issues #105 et #106), dans l'ordre de la configuration. | | |
| 50 | +| `AgentService` | `List()` | Tous les agents avec `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (et, pendant un démarrage, `step, since` comme les donne `agent:progress` ; `signIn` : le programme que son terminal lance pour se connecter avec un compte au lieu d'une clé d'API — `claude` pour `claude-agent-acp` dans une sandbox sbx, issues #105 et #106 ; `oauth` : le type dont il prend la connexion par compte — `codex` pour `codex-acp` dans une sandbox sbx, issue #107), dans l'ordre de la configuration. | | |
| 51 | 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | Comme dans les transitions ci-dessus ; une erreur est renvoyée à l'interface. Un démarrage recrée d'abord une sandbox absente si `runtime.lifecycle.create` est défini. | |
| 52 | 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Arrête l'agent, puis lance `runtime.lifecycle.stop` ou `remove` (conteneur ou sandbox) ; la sortie va dans le journal de l'agent. | |
| 53 | 53 | | | `Unload(name)` | Demande à un agent en marche et inactif, qui a annoncé la commande `unload`, de décharger son modèle (ticket #51) : `/unload` est envoyé dans une session à part, qu'aucune conversation ne montre ; la réponse va dans le journal de l'agent, en lignes `unload: …`. Erreurs : agent inconnu, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | |
| @@ -267,7 +267,7 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | ||
| 267 | 267 | |
| 268 | 268 | | Méthode | Effet | |
| 269 | 269 | | --- | --- | |
| 270 | -| `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn}` (`signIn` : le programme à lancer dans le terminal de l'agent pour se connecter avec un compte — Claude : `claude`, puis `/login`, issue #105) (`token` : le secret est un jeton du compte de l'utilisateur, pas une clé d'API — Copilot ; l'assistant dit « jeton » ; `fromGh` : il peut venir de `gh auth token`). Un type peut donner son secret à d'autres services sbx (Copilot : `github` aussi, avec `api.github.com` et `github.com` dans ses `bindings`). | | |
| 270 | +| `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn, oauth}` (`oauth` : le service accepte aussi une connexion avec un compte, `sbx secret set <service> --oauth` — Codex : ChatGPT, issue #107) (`signIn` : le programme à lancer dans le terminal de l'agent pour se connecter avec un compte — Claude : `claude`, puis `/login`, issue #105) (`token` : le secret est un jeton du compte de l'utilisateur, pas une clé d'API — Copilot ; l'assistant dit « jeton » ; `fromGh` : il peut venir de `gh auth token`). Un type peut donner son secret à d'autres services sbx (Copilot : `github` aussi, avec `api.github.com` et `github.com` dans ses `bindings`). | | |
| 271 | 271 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`taken` : les noms pris par un agent, un dossier ou une sandbox, issue #99 ; `hasKey` : chaque service du type a un secret ; `gh`, `ghSignedIn` : pour un type avec `fromGh`, si gh est installé et a un jeton) : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | |
| 272 | 272 | | `SetKey(kind, key)` | `sbx secret set <service>`, pour chaque service du type, avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | |
| 273 | 273 | | `Login()` | Lance `sbx login` (issue #97) — ou rejoint celui en cours — et revient dès que sbx a affiché son code et son adresse, 20 secondes au plus : `{code, url, done, user, error, output[]}`. Le code est le premier `XXXX-XXXX`, l'adresse le premier `https://…` qui contient `login` ; `output` garde chaque ligne pour le cas où sbx affiche autre chose. Son entrée standard est vide : une question posée au clavier n'a pas de réponse. | |
| @@ -275,6 +275,7 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | ||
| 275 | 275 | | `CancelLogin()` | Arrête `sbx login` ; fait aussi quand Sidekicks se ferme. | |
| 276 | 276 | | `UseGitHub(kind)` | Pour un type avec `fromGh` (issue #103) : lance `gh auth token` et enregistre ce qu'il affiche comme `SetKey` — comme le ferait `sbx secret set <service> --command 'gh auth token'`, pour chaque service. `gh is not signed in to GitHub` quand gh n'a pas de jeton, `gh is not installed` sans gh (`gh` dans le PATH, `/opt/homebrew/bin`, `/usr/local/bin`). Le jeton n'est jamais affiché, écrit ni journalisé. | |
| 277 | 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Comme `Login`, `LoginStatus` et `CancelLogin`, pour `gh auth login --web --hostname github.com --git-protocol https` (issue #103) : son code (`XXXX-XXXX`), son URL (`https://github.com/login/device`), puis `user` d'après `✓ Logged in as <user>`. | |
| 278 | +| `OAuthLogin(kind)`, `OAuthLoginStatus()`, `CancelOAuthLogin()` | Pour un type avec `oauth` (issue #107) : lance `sbx secret set <service> --oauth`, qui ouvre une fenêtre du navigateur ; rend la main dès qu'il a affiché une page à ouvrir (`url`, ou après 20 secondes), puis comme `LoginStatus`. `ok` quand sbx s'est terminé sans erreur (il ne nomme personne). | | |
| 278 | 279 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | |
| 279 | 280 | |
| 280 | 281 | ## Outils proposés aux agents |
| @@ -47,7 +47,7 @@ Les noms et types Go sont dans `internal/events` ; les constantes et types TypeS | |||
| 47 | 47 | ||
| 48 | | Service | Méthode | Effet | | 48 | | Service | Méthode | Effet | |
| 49 | | --- | --- | --- | | 49 | | --- | --- | --- | |
| 50 | -| `AgentService` | `List()` | Tous les agents avec `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (et, pendant un démarrage, `step, since` comme les donne `agent:progress` ; `signIn` : le programme que son terminal lance pour se connecter avec un compte au lieu d'une clé d'API — `claude` pour `claude-agent-acp` dans une sandbox sbx, issues #105 et #106), dans l'ordre de la configuration. | | 50 | +| `AgentService` | `List()` | Tous les agents avec `name, title, icon, description, state, error, outdated, runtime, canStopSandbox, canRemoveSandbox` (et, pendant un démarrage, `step, since` comme les donne `agent:progress` ; `signIn` : le programme que son terminal lance pour se connecter avec un compte au lieu d'une clé d'API — `claude` pour `claude-agent-acp` dans une sandbox sbx, issues #105 et #106 ; `oauth` : le type dont il prend la connexion par compte — `codex` pour `codex-acp` dans une sandbox sbx, issue #107), dans l'ordre de la configuration. | |
| 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | Comme dans les transitions ci-dessus ; une erreur est renvoyée à l'interface. Un démarrage recrée d'abord une sandbox absente si `runtime.lifecycle.create` est défini. | | 51 | | | `Start(name)`, `Stop(name)`, `Restart(name)` | Comme dans les transitions ci-dessus ; une erreur est renvoyée à l'interface. Un démarrage recrée d'abord une sandbox absente si `runtime.lifecycle.create` est défini. | |
| 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Arrête l'agent, puis lance `runtime.lifecycle.stop` ou `remove` (conteneur ou sandbox) ; la sortie va dans le journal de l'agent. | | 52 | | | `StopSandbox(name)`, `RemoveSandbox(name)` | Arrête l'agent, puis lance `runtime.lifecycle.stop` ou `remove` (conteneur ou sandbox) ; la sortie va dans le journal de l'agent. | |
| 53 | | | `Unload(name)` | Demande à un agent en marche et inactif, qui a annoncé la commande `unload`, de décharger son modèle (ticket #51) : `/unload` est envoyé dans une session à part, qu'aucune conversation ne montre ; la réponse va dans le journal de l'agent, en lignes `unload: …`. Erreurs : agent inconnu, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | | 53 | | | `Unload(name)` | Demande à un agent en marche et inactif, qui a annoncé la commande `unload`, de décharger son modèle (ticket #51) : `/unload` est envoyé dans une session à part, qu'aucune conversation ne montre ; la réponse va dans le journal de l'agent, en lignes `unload: …`. Erreurs : agent inconnu, `the agent is not running…`, `the agent is answering…`, `this agent cannot unload its model…`. | |
| @@ -267,7 +267,7 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | |||
| 267 | 267 | ||
| 268 | | Méthode | Effet | | 268 | | Méthode | Effet | |
| 269 | | --- | --- | | 269 | | --- | --- | |
| 270 | -| `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn}` (`signIn` : le programme à lancer dans le terminal de l'agent pour se connecter avec un compte — Claude : `claude`, puis `/login`, issue #105) (`token` : le secret est un jeton du compte de l'utilisateur, pas une clé d'API — Copilot ; l'assistant dit « jeton » ; `fromGh` : il peut venir de `gh auth token`). Un type peut donner son secret à d'autres services sbx (Copilot : `github` aussi, avec `api.github.com` et `github.com` dans ses `bindings`). | | 270 | +| `Kinds()` | Le catalogue, dans l'ordre : `{id, title, icon, agent, kit, program, service, keyUrl, token, fromGh, signIn, oauth}` (`oauth` : le service accepte aussi une connexion avec un compte, `sbx secret set <service> --oauth` — Codex : ChatGPT, issue #107) (`signIn` : le programme à lancer dans le terminal de l'agent pour se connecter avec un compte — Claude : `claude`, puis `/login`, issue #105) (`token` : le secret est un jeton du compte de l'utilisateur, pas une clé d'API — Copilot ; l'assistant dit « jeton » ; `fromGh` : il peut venir de `gh auth token`). Un type peut donner son secret à d'autres services sbx (Copilot : `github` aussi, avec `api.github.com` et `github.com` dans ses `bindings`). | |
| 271 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`taken` : les noms pris par un agent, un dossier ou une sandbox, issue #99 ; `hasKey` : chaque service du type a un secret ; `gh`, `ghSignedIn` : pour un type avec `fromGh`, si gh est installé et a un jeton) : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | | 271 | | `Check(kind)` | `sbx is not installed` quand sbx est introuvable (`sbx` dans le PATH, `/usr/local/bin`, `/opt/homebrew/bin`). Renvoie `{hasKey, name, agentsFolder, taken[], gh, ghSignedIn}` (`taken` : les noms pris par un agent, un dossier ou une sandbox, issue #99 ; `hasKey` : chaque service du type a un secret ; `gh`, `ghSignedIn` : pour un type avec `fromGh`, si gh est installé et a un jeton) : si `sbx secret ls --service <service>` montre un secret global, et le premier nom libre parmi `<type>`, `<type>-2`… — libre comme agent de la configuration, dossier du dossier des agents et sandbox (`sbx ls -q`). | |
| 272 | | `SetKey(kind, key)` | `sbx secret set <service>`, pour chaque service du type, avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | | 272 | | `SetKey(kind, key)` | `sbx secret set <service>`, pour chaque service du type, avec la clé sur son entrée standard — jamais dans ses arguments, un fichier ou un journal ; une erreur ne la répète jamais. Globale : toutes les sandboxes l'ont. | |
| 273 | | `Login()` | Lance `sbx login` (issue #97) — ou rejoint celui en cours — et revient dès que sbx a affiché son code et son adresse, 20 secondes au plus : `{code, url, done, user, error, output[]}`. Le code est le premier `XXXX-XXXX`, l'adresse le premier `https://…` qui contient `login` ; `output` garde chaque ligne pour le cas où sbx affiche autre chose. Son entrée standard est vide : une question posée au clavier n'a pas de réponse. | | 273 | | `Login()` | Lance `sbx login` (issue #97) — ou rejoint celui en cours — et revient dès que sbx a affiché son code et son adresse, 20 secondes au plus : `{code, url, done, user, error, output[]}`. Le code est le premier `XXXX-XXXX`, l'adresse le premier `https://…` qui contient `login` ; `output` garde chaque ligne pour le cas où sbx affiche autre chose. Son entrée standard est vide : une question posée au clavier n'a pas de réponse. | |
| @@ -275,6 +275,7 @@ L'assistant qui crée un agent dans une Docker Sandbox (issue #96, [Créer un ag | |||
| 275 | | `CancelLogin()` | Arrête `sbx login` ; fait aussi quand Sidekicks se ferme. | | 275 | | `CancelLogin()` | Arrête `sbx login` ; fait aussi quand Sidekicks se ferme. | |
| 276 | | `UseGitHub(kind)` | Pour un type avec `fromGh` (issue #103) : lance `gh auth token` et enregistre ce qu'il affiche comme `SetKey` — comme le ferait `sbx secret set <service> --command 'gh auth token'`, pour chaque service. `gh is not signed in to GitHub` quand gh n'a pas de jeton, `gh is not installed` sans gh (`gh` dans le PATH, `/opt/homebrew/bin`, `/usr/local/bin`). Le jeton n'est jamais affiché, écrit ni journalisé. | | 276 | | `UseGitHub(kind)` | Pour un type avec `fromGh` (issue #103) : lance `gh auth token` et enregistre ce qu'il affiche comme `SetKey` — comme le ferait `sbx secret set <service> --command 'gh auth token'`, pour chaque service. `gh is not signed in to GitHub` quand gh n'a pas de jeton, `gh is not installed` sans gh (`gh` dans le PATH, `/opt/homebrew/bin`, `/usr/local/bin`). Le jeton n'est jamais affiché, écrit ni journalisé. | |
| 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Comme `Login`, `LoginStatus` et `CancelLogin`, pour `gh auth login --web --hostname github.com --git-protocol https` (issue #103) : son code (`XXXX-XXXX`), son URL (`https://github.com/login/device`), puis `user` d'après `✓ Logged in as <user>`. | | 277 | | `GitHubLogin()`, `GitHubLoginStatus()`, `CancelGitHubLogin()` | Comme `Login`, `LoginStatus` et `CancelLogin`, pour `gh auth login --web --hostname github.com --git-protocol https` (issue #103) : son code (`XXXX-XXXX`), son URL (`https://github.com/login/device`), puis `user` d'après `✓ Logged in as <user>`. | |
| 278 | +| `OAuthLogin(kind)`, `OAuthLoginStatus()`, `CancelOAuthLogin()` | Pour un type avec `oauth` (issue #107) : lance `sbx secret set <service> --oauth`, qui ouvre une fenêtre du navigateur ; rend la main dès qu'il a affiché une page à ouvrir (`url`, ou après 20 secondes), puis comme `LoginStatus`. `ok` quand sbx s'est terminé sans erreur (il ne nomme personne). | | ||
| 278 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | | 279 | | `Create({kind, name, title, icon})` | Écrit `<agentsFolder>/<name>/sbxenv.yaml` (`name: <name>`, l'`agent:` et le kit du type, `workspace: ./workspace`, les `bindings` de son service, `pullPolicy: always`, commentaires en anglais) et `workspace/`, puis ajoute l'agent : `sbx exec -i <name> <programme>`, dossier `<dossier>/workspace`, `runtime.lifecycle` dans `<dossier>` (`sbx env create --force`, `sbx stop <name>`, `sbx env rm --force`) — la sandbox est créée au premier démarrage. Renvoie `{problem, problems[], name, folder}` : `problem` vaut `invalidName` (minuscules, chiffres et `-` : pas de `_`, que sbx refuse), `nameTaken`, `folderExists` ou `sandboxExists` quand rien n'a été écrit. | |
| 279 | 280 | ||
| 280 | ## Outils proposés aux agents | 281 | ## Outils proposés aux agents |
modified
docs/release-notes/v1.6.0.fr.md +7 -1 | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | [English](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.md) |
| 4 | 4 | |
| 5 | -Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandboxes, et permet à un agent Claude de se connecter avec votre compte Claude au lieu d'une clé d'API. | |
| 5 | +Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandboxes, et permet aux agents Claude et Codex de se connecter avec votre compte Claude ou ChatGPT au lieu d'une clé d'API. | |
| 6 | 6 | |
| 7 | 7 | ## Nouveautés |
| 8 | 8 | |
| @@ -17,6 +17,12 @@ Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandb | ||
| 17 | 17 | - Dans l'assistant des sandboxes, Claude n'exige plus de clé d'API : cliquez sur **Plus tard**, et l'assistant explique que vous vous connecterez avec votre compte Claude par `/login` dans le terminal de l'agent. |
| 18 | 18 | - Quand un agent Claude répond « Authentication required », Sidekicks ouvre son **Terminal**, lance `claude` dans la sandbox et vous dit de taper `/login`. **Je suis connecté : redémarrer l'agent** vous ramène à la conversation ; **Se connecter dans son terminal**, sous l'erreur, le rouvre. |
| 19 | 19 | |
| 20 | +### Codex avec votre compte ChatGPT (#107) | |
| 21 | + | |
| 22 | +- Dans l'assistant des sandboxes, Codex n'exige plus de clé d'API : **Me connecter avec mon compte ChatGPT** lance `sbx secret set openai --oauth`, qui ouvre votre navigateur ; sbx garde la connexion dans votre trousseau. **Plus tard** continue sans l'une ni l'autre. | |
| 23 | +- Sans clé ni connexion, sbx demande à la création de la sandbox s'il faut se connecter à OpenAI sur le web — une question à laquelle Sidekicks ne peut pas répondre. L'agent s'arrête maintenant avec une phrase qui le dit et un bouton **Me connecter avec mon compte ChatGPT** ; une fois connecté, l'agent redémarre. | |
| 24 | +- Une commande de sandbox ou de conteneur qui échoue montre maintenant ses dernières lignes dans son erreur, pas seulement « exit status 1 ». | |
| 25 | + | |
| 20 | 26 | → [Créer un agent Claude, Gemini, Codex, Vibe ou Copilot dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) |
| 21 | 27 | |
| 22 | 28 | ## Bon à savoir pour la mise à jour |
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | [English](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.md) | 3 | [English](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.md) |
| 4 | 4 | ||
| 5 | -Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandboxes, et permet à un agent Claude de se connecter avec votre compte Claude au lieu d'une clé d'API. | 5 | +Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandboxes, et permet aux agents Claude et Codex de se connecter avec votre compte Claude ou ChatGPT au lieu d'une clé d'API. |
| 6 | 6 | ||
| 7 | ## Nouveautés | 7 | ## Nouveautés |
| 8 | 8 | ||
| @@ -17,6 +17,12 @@ Sidekicks 1.6.0 ajoute GitHub Copilot aux agents que crée l'assistant des sandb | |||
| 17 | - Dans l'assistant des sandboxes, Claude n'exige plus de clé d'API : cliquez sur **Plus tard**, et l'assistant explique que vous vous connecterez avec votre compte Claude par `/login` dans le terminal de l'agent. | 17 | - Dans l'assistant des sandboxes, Claude n'exige plus de clé d'API : cliquez sur **Plus tard**, et l'assistant explique que vous vous connecterez avec votre compte Claude par `/login` dans le terminal de l'agent. |
| 18 | - Quand un agent Claude répond « Authentication required », Sidekicks ouvre son **Terminal**, lance `claude` dans la sandbox et vous dit de taper `/login`. **Je suis connecté : redémarrer l'agent** vous ramène à la conversation ; **Se connecter dans son terminal**, sous l'erreur, le rouvre. | 18 | - Quand un agent Claude répond « Authentication required », Sidekicks ouvre son **Terminal**, lance `claude` dans la sandbox et vous dit de taper `/login`. **Je suis connecté : redémarrer l'agent** vous ramène à la conversation ; **Se connecter dans son terminal**, sous l'erreur, le rouvre. |
| 19 | 19 | ||
| 20 | +### Codex avec votre compte ChatGPT (#107) | ||
| 21 | + | ||
| 22 | +- Dans l'assistant des sandboxes, Codex n'exige plus de clé d'API : **Me connecter avec mon compte ChatGPT** lance `sbx secret set openai --oauth`, qui ouvre votre navigateur ; sbx garde la connexion dans votre trousseau. **Plus tard** continue sans l'une ni l'autre. | ||
| 23 | +- Sans clé ni connexion, sbx demande à la création de la sandbox s'il faut se connecter à OpenAI sur le web — une question à laquelle Sidekicks ne peut pas répondre. L'agent s'arrête maintenant avec une phrase qui le dit et un bouton **Me connecter avec mon compte ChatGPT** ; une fois connecté, l'agent redémarre. | ||
| 24 | +- Une commande de sandbox ou de conteneur qui échoue montre maintenant ses dernières lignes dans son erreur, pas seulement « exit status 1 ». | ||
| 25 | + | ||
| 20 | → [Créer un agent Claude, Gemini, Codex, Vibe ou Copilot dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) | 26 | → [Créer un agent Claude, Gemini, Codex, Vibe ou Copilot dans une sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/fr/how-to/creer-un-agent-dans-une-sandbox.md) |
| 21 | 27 | ||
| 22 | ## Bon à savoir pour la mise à jour | 28 | ## Bon à savoir pour la mise à jour |
modified
docs/release-notes/v1.6.0.md +7 -1 | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | [Français](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.fr.md) |
| 4 | 4 | |
| 5 | -Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, and lets a Claude agent sign in with your Claude account instead of an API key. | |
| 5 | +Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, and lets Claude and Codex agents sign in with your Claude or ChatGPT account instead of an API key. | |
| 6 | 6 | |
| 7 | 7 | ## What's new |
| 8 | 8 | |
| @@ -17,6 +17,12 @@ Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, | ||
| 17 | 17 | - In the sandbox assistant, Claude no longer needs an API key: click **Later**, and the assistant explains that you will sign in with your Claude account with `/login` in the agent's terminal. |
| 18 | 18 | - When a Claude agent answers "Authentication required", Sidekicks opens its **Terminal**, runs `claude` in the sandbox and tells you to type `/login`. **I am signed in: restart the agent** brings you back to the conversation; **Sign in in its terminal**, under the error, opens it again. |
| 19 | 19 | |
| 20 | +### Codex with your ChatGPT account (#107) | |
| 21 | + | |
| 22 | +- In the sandbox assistant, Codex no longer needs an API key: **Sign in with my ChatGPT account** runs `sbx secret set openai --oauth`, which opens your browser; sbx keeps the sign-in in your keychain. **Later** goes on without either. | |
| 23 | +- Without a key nor a sign-in, sbx asks whether to sign in to OpenAI on the web when it creates the sandbox — a question Sidekicks cannot answer. The agent now stops with a sentence that says so and a **Sign in with my ChatGPT account** button; once signed in, the agent starts again. | |
| 24 | +- A sandbox or container command that fails now shows its last lines in its error, not only "exit status 1". | |
| 25 | + | |
| 20 | 26 | → [Create a Claude, Gemini, Codex, Vibe or Copilot agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) |
| 21 | 27 | |
| 22 | 28 | ## Worth knowing when upgrading |
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | [Français](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.fr.md) | 3 | [Français](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/release-notes/v1.6.0.fr.md) |
| 4 | 4 | ||
| 5 | -Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, and lets a Claude agent sign in with your Claude account instead of an API key. | 5 | +Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, and lets Claude and Codex agents sign in with your Claude or ChatGPT account instead of an API key. |
| 6 | 6 | ||
| 7 | ## What's new | 7 | ## What's new |
| 8 | 8 | ||
| @@ -17,6 +17,12 @@ Sidekicks 1.6.0 adds GitHub Copilot to the agents the sandbox assistant creates, | |||
| 17 | - In the sandbox assistant, Claude no longer needs an API key: click **Later**, and the assistant explains that you will sign in with your Claude account with `/login` in the agent's terminal. | 17 | - In the sandbox assistant, Claude no longer needs an API key: click **Later**, and the assistant explains that you will sign in with your Claude account with `/login` in the agent's terminal. |
| 18 | - When a Claude agent answers "Authentication required", Sidekicks opens its **Terminal**, runs `claude` in the sandbox and tells you to type `/login`. **I am signed in: restart the agent** brings you back to the conversation; **Sign in in its terminal**, under the error, opens it again. | 18 | - When a Claude agent answers "Authentication required", Sidekicks opens its **Terminal**, runs `claude` in the sandbox and tells you to type `/login`. **I am signed in: restart the agent** brings you back to the conversation; **Sign in in its terminal**, under the error, opens it again. |
| 19 | 19 | ||
| 20 | +### Codex with your ChatGPT account (#107) | ||
| 21 | + | ||
| 22 | +- In the sandbox assistant, Codex no longer needs an API key: **Sign in with my ChatGPT account** runs `sbx secret set openai --oauth`, which opens your browser; sbx keeps the sign-in in your keychain. **Later** goes on without either. | ||
| 23 | +- Without a key nor a sign-in, sbx asks whether to sign in to OpenAI on the web when it creates the sandbox — a question Sidekicks cannot answer. The agent now stops with a sentence that says so and a **Sign in with my ChatGPT account** button; once signed in, the agent starts again. | ||
| 24 | +- A sandbox or container command that fails now shows its last lines in its error, not only "exit status 1". | ||
| 25 | + | ||
| 20 | → [Create a Claude, Gemini, Codex, Vibe or Copilot agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) | 26 | → [Create a Claude, Gemini, Codex, Vibe or Copilot agent in a sandbox](https://rickub.com/bots-garden/sidekicks/blob/v1.6.0/docs/en/how-to/create-an-agent-in-a-sandbox.md) |
| 21 | 27 | ||
| 22 | ## Worth knowing when upgrading | 28 | ## Worth knowing when upgrading |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/agents/models.ts +6 -0 | @@ -64,4 +64,10 @@ export interface Status { | ||
| 64 | 64 | * instead of an API key ("claude", issues #105 and #106), or "". |
| 65 | 65 | */ |
| 66 | 66 | "signIn"?: string; |
| 67 | + | |
| 68 | + /** | |
| 69 | + * OAuth is the kind of the sandbox assistant whose account sign-in it | |
| 70 | + * takes ("codex": ChatGPT, issue #107), or "". | |
| 71 | + */ | |
| 72 | + "oauth"?: string; | |
| 67 | 73 | } |
| @@ -64,4 +64,10 @@ export interface Status { | |||
| 64 | * instead of an API key ("claude", issues #105 and #106), or "". | 64 | * instead of an API key ("claude", issues #105 and #106), or "". |
| 65 | */ | 65 | */ |
| 66 | "signIn"?: string; | 66 | "signIn"?: string; |
| 67 | + | ||
| 68 | + /** | ||
| 69 | + * OAuth is the kind of the sandbox assistant whose account sign-in it | ||
| 70 | + * takes ("codex": ChatGPT, issue #107), or "". | ||
| 71 | + */ | ||
| 72 | + "oauth"?: string; | ||
| 67 | } | 73 | } |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/app/sbxcreatorservice.ts +25 -0 | @@ -42,6 +42,14 @@ export function CancelLogin(): $CancellablePromise<void> { | ||
| 42 | 42 | return $Call.ByID(1506734565); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | +/** | |
| 46 | + * CancelOAuthLogin stops the account sign-in, if it runs. Also done when | |
| 47 | + * Sidekicks quits. | |
| 48 | + */ | |
| 49 | +export function CancelOAuthLogin(): $CancellablePromise<void> { | |
| 50 | + return $Call.ByID(576966692); | |
| 51 | +} | |
| 52 | + | |
| 45 | 53 | /** |
| 46 | 54 | * Check checks that sbx is installed ("sbx is not installed" otherwise), |
| 47 | 55 | * whether the kind's key is stored (for each of its services), and suggests |
| @@ -101,6 +109,23 @@ export function LoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | ||
| 101 | 109 | return $Call.ByID(931111353); |
| 102 | 110 | } |
| 103 | 111 | |
| 112 | +/** | |
| 113 | + * OAuthLogin starts the account sign-in of a kind with OAuth (issue #107): | |
| 114 | + * `sbx secret set <service> --oauth`, which opens a browser window on this | |
| 115 | + * computer — or joins the one in progress. It returns once sbx printed the | |
| 116 | + * page to open, or ended. | |
| 117 | + */ | |
| 118 | +export function OAuthLogin(kindID: string): $CancellablePromise<sbxcreate$0.LoginState> { | |
| 119 | + return $Call.ByID(1053267022, kindID); | |
| 120 | +} | |
| 121 | + | |
| 122 | +/** | |
| 123 | + * OAuthLoginStatus waits — 20 seconds at most — for the account sign-in to end. | |
| 124 | + */ | |
| 125 | +export function OAuthLoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | |
| 126 | + return $Call.ByID(3203294192); | |
| 127 | +} | |
| 128 | + | |
| 104 | 129 | /** |
| 105 | 130 | * SetKey stores the kind's key in sbx, for every sandbox and each of the |
| 106 | 131 | * kind's services. The key goes to sbx on its standard input; it is never |
| @@ -42,6 +42,14 @@ export function CancelLogin(): $CancellablePromise<void> { | |||
| 42 | return $Call.ByID(1506734565); | 42 | return $Call.ByID(1506734565); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | +/** | ||
| 46 | + * CancelOAuthLogin stops the account sign-in, if it runs. Also done when | ||
| 47 | + * Sidekicks quits. | ||
| 48 | + */ | ||
| 49 | +export function CancelOAuthLogin(): $CancellablePromise<void> { | ||
| 50 | + return $Call.ByID(576966692); | ||
| 51 | +} | ||
| 52 | + | ||
| 45 | /** | 53 | /** |
| 46 | * Check checks that sbx is installed ("sbx is not installed" otherwise), | 54 | * Check checks that sbx is installed ("sbx is not installed" otherwise), |
| 47 | * whether the kind's key is stored (for each of its services), and suggests | 55 | * whether the kind's key is stored (for each of its services), and suggests |
| @@ -101,6 +109,23 @@ export function LoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | |||
| 101 | return $Call.ByID(931111353); | 109 | return $Call.ByID(931111353); |
| 102 | } | 110 | } |
| 103 | 111 | ||
| 112 | +/** | ||
| 113 | + * OAuthLogin starts the account sign-in of a kind with OAuth (issue #107): | ||
| 114 | + * `sbx secret set <service> --oauth`, which opens a browser window on this | ||
| 115 | + * computer — or joins the one in progress. It returns once sbx printed the | ||
| 116 | + * page to open, or ended. | ||
| 117 | + */ | ||
| 118 | +export function OAuthLogin(kindID: string): $CancellablePromise<sbxcreate$0.LoginState> { | ||
| 119 | + return $Call.ByID(1053267022, kindID); | ||
| 120 | +} | ||
| 121 | + | ||
| 122 | +/** | ||
| 123 | + * OAuthLoginStatus waits — 20 seconds at most — for the account sign-in to end. | ||
| 124 | + */ | ||
| 125 | +export function OAuthLoginStatus(): $CancellablePromise<sbxcreate$0.LoginState> { | ||
| 126 | + return $Call.ByID(3203294192); | ||
| 127 | +} | ||
| 128 | + | ||
| 104 | /** | 129 | /** |
| 105 | * SetKey stores the kind's key in sbx, for every sandbox and each of the | 130 | * SetKey stores the kind's key in sbx, for every sandbox and each of the |
| 106 | * kind's services. The key goes to sbx on its standard input; it is never | 131 | * kind's services. The key goes to sbx on its standard input; it is never |
modified
frontend/bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate/models.ts +13 -0 | @@ -54,6 +54,13 @@ export interface Kind { | ||
| 54 | 54 | * an account instead of the key ("claude": then /login, issue #105). |
| 55 | 55 | */ |
| 56 | 56 | "signIn": string; |
| 57 | + | |
| 58 | + /** | |
| 59 | + * OAuth is true when the service also takes a sign-in with an account | |
| 60 | + * in a browser, stored by `sbx secret set <service> --oauth` (Codex: | |
| 61 | + * ChatGPT, issue #107). | |
| 62 | + */ | |
| 63 | + "oauth": boolean; | |
| 57 | 64 | } |
| 58 | 65 | |
| 59 | 66 | /** |
| @@ -74,6 +81,12 @@ export interface LoginState { | ||
| 74 | 81 | "user": string; |
| 75 | 82 | "error": string; |
| 76 | 83 | |
| 84 | + /** | |
| 85 | + * OK: the sign-in succeeded — someone signed in (User), or a command | |
| 86 | + * that names nobody ended well (sbx secret set --oauth, issue #107). | |
| 87 | + */ | |
| 88 | + "ok": boolean; | |
| 89 | + | |
| 77 | 90 | /** |
| 78 | 91 | * Output is what sbx printed, for when its lines are not the expected ones. |
| 79 | 92 | */ |
| @@ -54,6 +54,13 @@ export interface Kind { | |||
| 54 | * an account instead of the key ("claude": then /login, issue #105). | 54 | * an account instead of the key ("claude": then /login, issue #105). |
| 55 | */ | 55 | */ |
| 56 | "signIn": string; | 56 | "signIn": string; |
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * OAuth is true when the service also takes a sign-in with an account | ||
| 60 | + * in a browser, stored by `sbx secret set <service> --oauth` (Codex: | ||
| 61 | + * ChatGPT, issue #107). | ||
| 62 | + */ | ||
| 63 | + "oauth": boolean; | ||
| 57 | } | 64 | } |
| 58 | 65 | ||
| 59 | /** | 66 | /** |
| @@ -74,6 +81,12 @@ export interface LoginState { | |||
| 74 | "user": string; | 81 | "user": string; |
| 75 | "error": string; | 82 | "error": string; |
| 76 | 83 | ||
| 84 | + /** | ||
| 85 | + * OK: the sign-in succeeded — someone signed in (User), or a command | ||
| 86 | + * that names nobody ended well (sbx secret set --oauth, issue #107). | ||
| 87 | + */ | ||
| 88 | + "ok": boolean; | ||
| 89 | + | ||
| 77 | /** | 90 | /** |
| 78 | * Output is what sbx printed, for when its lines are not the expected ones. | 91 | * Output is what sbx printed, for when its lines are not the expected ones. |
| 79 | */ | 92 | */ |
modified
frontend/src/lib/agent/CreateSbxAgent.svelte +8 -1 | @@ -188,6 +188,11 @@ | ||
| 188 | 188 | {/if} |
| 189 | 189 | <p class="hint">{t('sbxCreator.token.orPaste')}</p> |
| 190 | 190 | {/if} |
| 191 | + {#if kind.oauth} | |
| 192 | + <p>{t('sbxCreator.oauth.choice', { title: kind.title })}</p> | |
| 193 | + <SbxLogin oauth={kind.id} onDone={check} /> | |
| 194 | + <p class="hint">{t('sbxCreator.oauth.orKey')}</p> | |
| 195 | + {/if} | |
| 191 | 196 | <button type="button" class="link" onclick={() => kind && Browser.OpenURL(kind.keyUrl)}>{t(keyText('get', kind.token))}</button> |
| 192 | 197 | <label> |
| 193 | 198 | {t(keyText('label', kind.token))} |
| @@ -207,7 +212,9 @@ | ||
| 207 | 212 | {#if hasKey} |
| 208 | 213 | <p class="ok">{t(keyText('stored', kind.token), { title: kind.title })} <button type="button" class="link" onclick={() => (step = 'key')}>{t(keyText('replace', kind.token))}</button></p> |
| 209 | 214 | {:else} |
| 210 | - {#if kind.signIn} | |
| 215 | + {#if kind.oauth} | |
| 216 | + <p class="note" role="status">{t('sbxCreator.oauth.later', { title: kind.title })}</p> | |
| 217 | + {:else if kind.signIn} | |
| 211 | 218 | <p class="note" role="status">{t('sbxCreator.signIn.later', { title: kind.title, program: kind.signIn })}</p> |
| 212 | 219 | {:else} |
| 213 | 220 | <p class="warning" role="alert">{t(keyText('missing', kind.token), { title: kind.title, service: kind.service })}</p> |
| @@ -188,6 +188,11 @@ | |||
| 188 | {/if} | 188 | {/if} |
| 189 | <p class="hint">{t('sbxCreator.token.orPaste')}</p> | 189 | <p class="hint">{t('sbxCreator.token.orPaste')}</p> |
| 190 | {/if} | 190 | {/if} |
| 191 | + {#if kind.oauth} | ||
| 192 | + <p>{t('sbxCreator.oauth.choice', { title: kind.title })}</p> | ||
| 193 | + <SbxLogin oauth={kind.id} onDone={check} /> | ||
| 194 | + <p class="hint">{t('sbxCreator.oauth.orKey')}</p> | ||
| 195 | + {/if} | ||
| 191 | <button type="button" class="link" onclick={() => kind && Browser.OpenURL(kind.keyUrl)}>{t(keyText('get', kind.token))}</button> | 196 | <button type="button" class="link" onclick={() => kind && Browser.OpenURL(kind.keyUrl)}>{t(keyText('get', kind.token))}</button> |
| 192 | <label> | 197 | <label> |
| 193 | {t(keyText('label', kind.token))} | 198 | {t(keyText('label', kind.token))} |
| @@ -207,7 +212,9 @@ | |||
| 207 | {#if hasKey} | 212 | {#if hasKey} |
| 208 | <p class="ok">{t(keyText('stored', kind.token), { title: kind.title })} <button type="button" class="link" onclick={() => (step = 'key')}>{t(keyText('replace', kind.token))}</button></p> | 213 | <p class="ok">{t(keyText('stored', kind.token), { title: kind.title })} <button type="button" class="link" onclick={() => (step = 'key')}>{t(keyText('replace', kind.token))}</button></p> |
| 209 | {:else} | 214 | {:else} |
| 210 | - {#if kind.signIn} | 215 | + {#if kind.oauth} |
| 216 | + <p class="note" role="status">{t('sbxCreator.oauth.later', { title: kind.title })}</p> | ||
| 217 | + {:else if kind.signIn} | ||
| 211 | <p class="note" role="status">{t('sbxCreator.signIn.later', { title: kind.title, program: kind.signIn })}</p> | 218 | <p class="note" role="status">{t('sbxCreator.signIn.later', { title: kind.title, program: kind.signIn })}</p> |
| 212 | {:else} | 219 | {:else} |
| 213 | <p class="warning" role="alert">{t(keyText('missing', kind.token), { title: kind.title, service: kind.service })}</p> | 220 | <p class="warning" role="alert">{t(keyText('missing', kind.token), { title: kind.title, service: kind.service })}</p> |
modified
frontend/src/lib/chat/ErrorText.svelte +17 -1 | @@ -5,17 +5,33 @@ | ||
| 5 | 5 | // Usage: <ErrorText raw={agent.error} /> |
| 6 | 6 | // sbx not signed in to Docker (issue #97) also offers to sign in; |
| 7 | 7 | // onSignedIn runs once it is done (an assistant checks again). |
| 8 | + // For an agent (agent: its name) that signs in with an account through sbx | |
| 9 | + // (Codex with ChatGPT, issue #107), sbx's question or "Authentication | |
| 10 | + // required" offers that sign-in, then restarts the agent. | |
| 8 | 11 | import { explain } from '../errors' |
| 9 | 12 | import { t } from '../i18n/index.svelte' |
| 13 | + import { act, appState } from '../state.svelte' | |
| 14 | + import { AgentService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | |
| 10 | 15 | import SbxLogin from './SbxLogin.svelte' |
| 11 | 16 | |
| 12 | - let { raw, onSignedIn }: { raw: string; onSignedIn?: () => void } = $props() | |
| 17 | + let { raw, onSignedIn, agent = '' }: { raw: string; onSignedIn?: () => void; agent?: string } = $props() | |
| 13 | 18 | const explanation = $derived(explain(raw)) |
| 19 | + const agentOAuth = $derived(agent ? (appState.agents.find((candidate) => candidate.name === agent)?.oauth ?? '') : '') | |
| 20 | + // The kind whose account sign-in to offer here, or ''. | |
| 21 | + const oauth = $derived( | |
| 22 | + explanation?.key === 'error.openaiSignIn' ? agentOAuth || 'codex' : explanation?.key === 'error.authRequired' ? agentOAuth : '', | |
| 23 | + ) | |
| 24 | + | |
| 25 | + function oauthDone() { | |
| 26 | + if (agent) void act(() => AgentService.Restart(agent)) | |
| 27 | + else onSignedIn?.() | |
| 28 | + } | |
| 14 | 29 | </script> |
| 15 | 30 | |
| 16 | 31 | {#if explanation} |
| 17 | 32 | <span class="explained">{t(explanation.key, explanation.vars)}</span> |
| 18 | 33 | {#if explanation.key === 'error.sbxNotSignedIn'}<SbxLogin onDone={onSignedIn} />{/if} |
| 34 | + {#if oauth}<SbxLogin {oauth} onDone={oauthDone} />{/if} | |
| 19 | 35 | <details> |
| 20 | 36 | <summary>{t('error.details')}</summary> |
| 21 | 37 | <code>{raw}</code> |
| @@ -5,17 +5,33 @@ | |||
| 5 | // Usage: <ErrorText raw={agent.error} /> | 5 | // Usage: <ErrorText raw={agent.error} /> |
| 6 | // sbx not signed in to Docker (issue #97) also offers to sign in; | 6 | // sbx not signed in to Docker (issue #97) also offers to sign in; |
| 7 | // onSignedIn runs once it is done (an assistant checks again). | 7 | // onSignedIn runs once it is done (an assistant checks again). |
| 8 | + // For an agent (agent: its name) that signs in with an account through sbx | ||
| 9 | + // (Codex with ChatGPT, issue #107), sbx's question or "Authentication | ||
| 10 | + // required" offers that sign-in, then restarts the agent. | ||
| 8 | import { explain } from '../errors' | 11 | import { explain } from '../errors' |
| 9 | import { t } from '../i18n/index.svelte' | 12 | import { t } from '../i18n/index.svelte' |
| 13 | + import { act, appState } from '../state.svelte' | ||
| 14 | + import { AgentService } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/app' | ||
| 10 | import SbxLogin from './SbxLogin.svelte' | 15 | import SbxLogin from './SbxLogin.svelte' |
| 11 | 16 | ||
| 12 | - let { raw, onSignedIn }: { raw: string; onSignedIn?: () => void } = $props() | 17 | + let { raw, onSignedIn, agent = '' }: { raw: string; onSignedIn?: () => void; agent?: string } = $props() |
| 13 | const explanation = $derived(explain(raw)) | 18 | const explanation = $derived(explain(raw)) |
| 19 | + const agentOAuth = $derived(agent ? (appState.agents.find((candidate) => candidate.name === agent)?.oauth ?? '') : '') | ||
| 20 | + // The kind whose account sign-in to offer here, or ''. | ||
| 21 | + const oauth = $derived( | ||
| 22 | + explanation?.key === 'error.openaiSignIn' ? agentOAuth || 'codex' : explanation?.key === 'error.authRequired' ? agentOAuth : '', | ||
| 23 | + ) | ||
| 24 | + | ||
| 25 | + function oauthDone() { | ||
| 26 | + if (agent) void act(() => AgentService.Restart(agent)) | ||
| 27 | + else onSignedIn?.() | ||
| 28 | + } | ||
| 14 | </script> | 29 | </script> |
| 15 | 30 | ||
| 16 | {#if explanation} | 31 | {#if explanation} |
| 17 | <span class="explained">{t(explanation.key, explanation.vars)}</span> | 32 | <span class="explained">{t(explanation.key, explanation.vars)}</span> |
| 18 | {#if explanation.key === 'error.sbxNotSignedIn'}<SbxLogin onDone={onSignedIn} />{/if} | 33 | {#if explanation.key === 'error.sbxNotSignedIn'}<SbxLogin onDone={onSignedIn} />{/if} |
| 34 | + {#if oauth}<SbxLogin {oauth} onDone={oauthDone} />{/if} | ||
| 19 | <details> | 35 | <details> |
| 20 | <summary>{t('error.details')}</summary> | 36 | <summary>{t('error.details')}</summary> |
| 21 | <code>{raw}</code> | 37 | <code>{raw}</code> |
modified
frontend/src/lib/chat/MessageView.svelte +2 -2 | @@ -48,7 +48,7 @@ | ||
| 48 | 48 | </script> |
| 49 | 49 | |
| 50 | 50 | {#if message.role === 'system'} |
| 51 | - <p class="system">{hasMessage(systemKey) ? t(systemKey, { agent: author, example }) : author}{#if message.error}<br /><span class="detail"><ErrorText raw={message.error} /></span>{/if}</p> | |
| 51 | + <p class="system">{hasMessage(systemKey) ? t(systemKey, { agent: author, example }) : author}{#if message.error}<br /><span class="detail"><ErrorText raw={message.error} agent={message.agent} /></span>{/if}</p> | |
| 52 | 52 | {:else} |
| 53 | 53 | <article class="message {message.role}"> |
| 54 | 54 | <div class="author"> |
| @@ -80,7 +80,7 @@ | ||
| 80 | 80 | <p class="ending">{t(stopKey)}</p> |
| 81 | 81 | {/if} |
| 82 | 82 | {#if message.error && message.role === 'agent'} |
| 83 | - <div class="error">{t('message.error')} <ErrorText raw={message.error} /> | |
| 83 | + <div class="error">{t('message.error')} <ErrorText raw={message.error} agent={message.agent} /> | |
| 84 | 84 | {#if needsSignIn(message.error, appState.agents.find((candidate) => candidate.name === message.agent)?.signIn)} |
| 85 | 85 | <button type="button" class="sign-in" onclick={() => message.agent && signInInTerminal(message.agent)}>{t('signIn.open')}</button> |
| 86 | 86 | {/if} |
| @@ -48,7 +48,7 @@ | |||
| 48 | </script> | 48 | </script> |
| 49 | 49 | ||
| 50 | {#if message.role === 'system'} | 50 | {#if message.role === 'system'} |
| 51 | - <p class="system">{hasMessage(systemKey) ? t(systemKey, { agent: author, example }) : author}{#if message.error}<br /><span class="detail"><ErrorText raw={message.error} /></span>{/if}</p> | 51 | + <p class="system">{hasMessage(systemKey) ? t(systemKey, { agent: author, example }) : author}{#if message.error}<br /><span class="detail"><ErrorText raw={message.error} agent={message.agent} /></span>{/if}</p> |
| 52 | {:else} | 52 | {:else} |
| 53 | <article class="message {message.role}"> | 53 | <article class="message {message.role}"> |
| 54 | <div class="author"> | 54 | <div class="author"> |
| @@ -80,7 +80,7 @@ | |||
| 80 | <p class="ending">{t(stopKey)}</p> | 80 | <p class="ending">{t(stopKey)}</p> |
| 81 | {/if} | 81 | {/if} |
| 82 | {#if message.error && message.role === 'agent'} | 82 | {#if message.error && message.role === 'agent'} |
| 83 | - <div class="error">{t('message.error')} <ErrorText raw={message.error} /> | 83 | + <div class="error">{t('message.error')} <ErrorText raw={message.error} agent={message.agent} /> |
| 84 | {#if needsSignIn(message.error, appState.agents.find((candidate) => candidate.name === message.agent)?.signIn)} | 84 | {#if needsSignIn(message.error, appState.agents.find((candidate) => candidate.name === message.agent)?.signIn)} |
| 85 | <button type="button" class="sign-in" onclick={() => message.agent && signInInTerminal(message.agent)}>{t('signIn.open')}</button> | 85 | <button type="button" class="sign-in" onclick={() => message.agent && signInInTerminal(message.agent)}>{t('signIn.open')}</button> |
| 86 | {/if} | 86 | {/if} |
modified
frontend/src/lib/chat/SbxLogin.svelte +11 -8 | @@ -14,13 +14,15 @@ | ||
| 14 | 14 | import type { LoginState } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate' |
| 15 | 15 | import Spinner from './Spinner.svelte' |
| 16 | 16 | |
| 17 | - let { onDone, github = false }: { onDone?: () => void; github?: boolean } = $props() | |
| 17 | + // oauth is a kind of the sandbox assistant whose account sign-in to run | |
| 18 | + // (`sbx secret set <service> --oauth`: Codex with ChatGPT, issue #107). | |
| 19 | + let { onDone, github = false, oauth = '' }: { onDone?: () => void; github?: boolean; oauth?: string } = $props() | |
| 18 | 20 | |
| 19 | - // The service's calls, and the texts that name Docker or GitHub. | |
| 20 | - const begin = () => (github ? SbxCreatorService.GitHubLogin() : SbxCreatorService.Login()) | |
| 21 | - const status = () => (github ? SbxCreatorService.GitHubLoginStatus() : SbxCreatorService.LoginStatus()) | |
| 22 | - const stop = () => (github ? SbxCreatorService.CancelGitHubLogin() : SbxCreatorService.CancelLogin()) | |
| 23 | - const prefix = $derived(github ? 'ghLogin' : 'sbxLogin') | |
| 21 | + // The service's calls, and the texts that name Docker, GitHub or ChatGPT. | |
| 22 | + const begin = () => (oauth ? SbxCreatorService.OAuthLogin(oauth) : github ? SbxCreatorService.GitHubLogin() : SbxCreatorService.Login()) | |
| 23 | + const status = () => (oauth ? SbxCreatorService.OAuthLoginStatus() : github ? SbxCreatorService.GitHubLoginStatus() : SbxCreatorService.LoginStatus()) | |
| 24 | + const stop = () => (oauth ? SbxCreatorService.CancelOAuthLogin() : github ? SbxCreatorService.CancelGitHubLogin() : SbxCreatorService.CancelLogin()) | |
| 25 | + const prefix = $derived(oauth ? 'oauthLogin' : github ? 'ghLogin' : 'sbxLogin') | |
| 24 | 26 | |
| 25 | 27 | type Step = 'idle' | 'starting' | 'waiting' | 'signed' | 'failed' |
| 26 | 28 | let step = $state<Step>('idle') |
| @@ -37,7 +39,7 @@ | ||
| 37 | 39 | // Ask again until sbx ends: each call waits up to 20 seconds. |
| 38 | 40 | while (active && login && !login.done) login = await status() |
| 39 | 41 | if (!active || !login) return |
| 40 | - if (login.user) { | |
| 42 | + if (login.ok || login.user) { | |
| 41 | 43 | step = 'signed' |
| 42 | 44 | onDone?.() |
| 43 | 45 | } else { |
| @@ -74,7 +76,8 @@ | ||
| 74 | 76 | {#if login.url} |
| 75 | 77 | <button type="button" class="primary" onclick={() => login && Browser.OpenURL(login.url)}>{t('sbxLogin.open')}</button> |
| 76 | 78 | {:else} |
| 77 | - <pre>{(login.output ?? []).join('\n')}</pre> | |
| 79 | + {#if oauth}<p>{t('oauthLogin.browser')}</p>{/if} | |
| 80 | + {#if (login.output ?? []).length > 0}<pre>{(login.output ?? []).join('\n')}</pre>{/if} | |
| 78 | 81 | {/if} |
| 79 | 82 | <p role="status"><Spinner /> {t('sbxLogin.waiting')}</p> |
| 80 | 83 | <button type="button" onclick={cancel}>{t('creator.cancel')}</button> |
| @@ -14,13 +14,15 @@ | |||
| 14 | import type { LoginState } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate' | 14 | import type { LoginState } from '../../../bindings/git.rickub.com/bots-garden/sidekicks/internal/sbxcreate' |
| 15 | import Spinner from './Spinner.svelte' | 15 | import Spinner from './Spinner.svelte' |
| 16 | 16 | ||
| 17 | - let { onDone, github = false }: { onDone?: () => void; github?: boolean } = $props() | 17 | + // oauth is a kind of the sandbox assistant whose account sign-in to run |
| 18 | + // (`sbx secret set <service> --oauth`: Codex with ChatGPT, issue #107). | ||
| 19 | + let { onDone, github = false, oauth = '' }: { onDone?: () => void; github?: boolean; oauth?: string } = $props() | ||
| 18 | 20 | ||
| 19 | - // The service's calls, and the texts that name Docker or GitHub. | 21 | + // The service's calls, and the texts that name Docker, GitHub or ChatGPT. |
| 20 | - const begin = () => (github ? SbxCreatorService.GitHubLogin() : SbxCreatorService.Login()) | 22 | + const begin = () => (oauth ? SbxCreatorService.OAuthLogin(oauth) : github ? SbxCreatorService.GitHubLogin() : SbxCreatorService.Login()) |
| 21 | - const status = () => (github ? SbxCreatorService.GitHubLoginStatus() : SbxCreatorService.LoginStatus()) | 23 | + const status = () => (oauth ? SbxCreatorService.OAuthLoginStatus() : github ? SbxCreatorService.GitHubLoginStatus() : SbxCreatorService.LoginStatus()) |
| 22 | - const stop = () => (github ? SbxCreatorService.CancelGitHubLogin() : SbxCreatorService.CancelLogin()) | 24 | + const stop = () => (oauth ? SbxCreatorService.CancelOAuthLogin() : github ? SbxCreatorService.CancelGitHubLogin() : SbxCreatorService.CancelLogin()) |
| 23 | - const prefix = $derived(github ? 'ghLogin' : 'sbxLogin') | 25 | + const prefix = $derived(oauth ? 'oauthLogin' : github ? 'ghLogin' : 'sbxLogin') |
| 24 | 26 | ||
| 25 | type Step = 'idle' | 'starting' | 'waiting' | 'signed' | 'failed' | 27 | type Step = 'idle' | 'starting' | 'waiting' | 'signed' | 'failed' |
| 26 | let step = $state<Step>('idle') | 28 | let step = $state<Step>('idle') |
| @@ -37,7 +39,7 @@ | |||
| 37 | // Ask again until sbx ends: each call waits up to 20 seconds. | 39 | // Ask again until sbx ends: each call waits up to 20 seconds. |
| 38 | while (active && login && !login.done) login = await status() | 40 | while (active && login && !login.done) login = await status() |
| 39 | if (!active || !login) return | 41 | if (!active || !login) return |
| 40 | - if (login.user) { | 42 | + if (login.ok || login.user) { |
| 41 | step = 'signed' | 43 | step = 'signed' |
| 42 | onDone?.() | 44 | onDone?.() |
| 43 | } else { | 45 | } else { |
| @@ -74,7 +76,8 @@ | |||
| 74 | {#if login.url} | 76 | {#if login.url} |
| 75 | <button type="button" class="primary" onclick={() => login && Browser.OpenURL(login.url)}>{t('sbxLogin.open')}</button> | 77 | <button type="button" class="primary" onclick={() => login && Browser.OpenURL(login.url)}>{t('sbxLogin.open')}</button> |
| 76 | {:else} | 78 | {:else} |
| 77 | - <pre>{(login.output ?? []).join('\n')}</pre> | 79 | + {#if oauth}<p>{t('oauthLogin.browser')}</p>{/if} |
| 80 | + {#if (login.output ?? []).length > 0}<pre>{(login.output ?? []).join('\n')}</pre>{/if} | ||
| 78 | {/if} | 81 | {/if} |
| 79 | <p role="status"><Spinner /> {t('sbxLogin.waiting')}</p> | 82 | <p role="status"><Spinner /> {t('sbxLogin.waiting')}</p> |
| 80 | <button type="button" onclick={cancel}>{t('creator.cancel')}</button> | 83 | <button type="button" onclick={cancel}>{t('creator.cancel')}</button> |
modified
frontend/src/lib/errors.test.ts +2 -0 | @@ -22,6 +22,8 @@ describe('explain', () => { | ||
| 22 | 22 | expect(explain('sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart')?.key).toBe('error.sbxNotSignedIn') |
| 23 | 23 | expect(explain('You are not authenticated to Docker. Starting the sign-in flow...')?.key).toBe('error.sbxNotSignedIn') |
| 24 | 24 | expect(explain('gh is not signed in to GitHub')?.key).toBe('error.ghNotSignedIn') |
| 25 | + expect(explain('Do you want to authenticate on the web? [y/N]')?.key).toBe('error.openaiSignIn') | |
| 26 | + expect(explain('sbx env create: exit status 1: no OpenAI credential stored: run sbx secret set openai --oauth')?.key).toBe('error.openaiSignIn') | |
| 25 | 27 | }) |
| 26 | 28 | |
| 27 | 29 | it('recognises the limit of running agents', () => { |
| @@ -22,6 +22,8 @@ describe('explain', () => { | |||
| 22 | expect(explain('sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart')?.key).toBe('error.sbxNotSignedIn') | 22 | expect(explain('sbx ls: exit status 1: error: not signed in to Docker try: sbx login or: sbx daemon restart')?.key).toBe('error.sbxNotSignedIn') |
| 23 | expect(explain('You are not authenticated to Docker. Starting the sign-in flow...')?.key).toBe('error.sbxNotSignedIn') | 23 | expect(explain('You are not authenticated to Docker. Starting the sign-in flow...')?.key).toBe('error.sbxNotSignedIn') |
| 24 | expect(explain('gh is not signed in to GitHub')?.key).toBe('error.ghNotSignedIn') | 24 | expect(explain('gh is not signed in to GitHub')?.key).toBe('error.ghNotSignedIn') |
| 25 | + expect(explain('Do you want to authenticate on the web? [y/N]')?.key).toBe('error.openaiSignIn') | ||
| 26 | + expect(explain('sbx env create: exit status 1: no OpenAI credential stored: run sbx secret set openai --oauth')?.key).toBe('error.openaiSignIn') | ||
| 25 | }) | 27 | }) |
| 26 | 28 | ||
| 27 | it('recognises the limit of running agents', () => { | 29 | it('recognises the limit of running agents', () => { |
modified
frontend/src/lib/errors.ts +3 -0 | @@ -23,6 +23,9 @@ interface Rule { | ||
| 23 | 23 | const rules: Rule[] = [ |
| 24 | 24 | // sbx before `sbx login` (issue #97): ErrorText offers to sign in. |
| 25 | 25 | { pattern: /not signed in to Docker|not authenticated to Docker/i, key: 'error.sbxNotSignedIn' }, |
| 26 | + // sbx asking, while creating a Codex sandbox, whether to sign in to OpenAI | |
| 27 | + // on the web (issue #107): ErrorText offers the ChatGPT sign-in. | |
| 28 | + { pattern: /authenticate (?:on|in|with|via|using) (?:the |your )?(?:web|browser)|no OpenAI credential|sign in with ChatGPT|secret set openai/i, key: 'error.openaiSignIn' }, | |
| 26 | 29 | // An agent without a key nor a signed-in account (issues #105, #106). |
| 27 | 30 | { pattern: /Authentication required/i, key: 'error.authRequired' }, |
| 28 | 31 | // gh without a token (issue #103). |
| @@ -23,6 +23,9 @@ interface Rule { | |||
| 23 | const rules: Rule[] = [ | 23 | const rules: Rule[] = [ |
| 24 | // sbx before `sbx login` (issue #97): ErrorText offers to sign in. | 24 | // sbx before `sbx login` (issue #97): ErrorText offers to sign in. |
| 25 | { pattern: /not signed in to Docker|not authenticated to Docker/i, key: 'error.sbxNotSignedIn' }, | 25 | { pattern: /not signed in to Docker|not authenticated to Docker/i, key: 'error.sbxNotSignedIn' }, |
| 26 | + // sbx asking, while creating a Codex sandbox, whether to sign in to OpenAI | ||
| 27 | + // on the web (issue #107): ErrorText offers the ChatGPT sign-in. | ||
| 28 | + { pattern: /authenticate (?:on|in|with|via|using) (?:the |your )?(?:web|browser)|no OpenAI credential|sign in with ChatGPT|secret set openai/i, key: 'error.openaiSignIn' }, | ||
| 26 | // An agent without a key nor a signed-in account (issues #105, #106). | 29 | // An agent without a key nor a signed-in account (issues #105, #106). |
| 27 | { pattern: /Authentication required/i, key: 'error.authRequired' }, | 30 | { pattern: /Authentication required/i, key: 'error.authRequired' }, |
| 28 | // gh without a token (issue #103). | 31 | // gh without a token (issue #103). |
modified
frontend/src/lib/i18n/messages.ts +16 -0 | @@ -182,6 +182,14 @@ export const en = { | ||
| 182 | 182 | 'ghLogin.signed': '✓ Signed in to GitHub as {user}.', |
| 183 | 183 | 'ghLogin.failed': 'The sign-in did not succeed. Try again, or type gh auth login in a terminal.', |
| 184 | 184 | 'error.ghNotSignedIn': 'The GitHub CLI (gh) is not signed in to GitHub: sign in with it first.', |
| 185 | + 'oauthLogin.start': 'Sign in with my ChatGPT account', | |
| 186 | + 'oauthLogin.browser': 'Your browser opens: sign in there with your ChatGPT account.', | |
| 187 | + 'oauthLogin.signed': '✓ Signed in with your ChatGPT account: sbx keeps the sign-in.', | |
| 188 | + 'oauthLogin.failed': 'The sign-in did not succeed. Try again, or type sbx secret set openai --oauth in a terminal.', | |
| 189 | + 'error.openaiSignIn': 'sbx asks to sign in to OpenAI before creating the sandbox: sign in with your ChatGPT account (or save an OpenAI API key), then the agent starts again.', | |
| 190 | + 'sbxCreator.oauth.choice': '{title} works with an OpenAI API key or with your ChatGPT account. Signing in opens your browser; sbx keeps the sign-in in your keychain, and the sandbox never sees it.', | |
| 191 | + 'sbxCreator.oauth.orKey': 'Or paste an OpenAI API key:', | |
| 192 | + 'sbxCreator.oauth.later': 'No OpenAI key nor ChatGPT sign-in in sbx yet. You can go on: if sbx asks to sign in when it creates the sandbox, Sidekicks shows a "Sign in with my ChatGPT account" button under the error.', | |
| 185 | 193 | 'error.authRequired': 'The agent is not signed in: it has no API key, and nobody signed in with an account yet.', |
| 186 | 194 | 'signIn.open': 'Sign in in its terminal', |
| 187 | 195 | 'signIn.terminal': '{agent} is not signed in. {program} is starting in this terminal: type /login, choose your account and follow the steps (copy the link into your browser if asked). Then click the button: the agent restarts and you can send your message again.', |
| @@ -695,6 +703,14 @@ export const fr: Record<MessageKey, string> = { | ||
| 695 | 703 | 'ghLogin.signed': '✓ Connecté à GitHub en tant que {user}.', |
| 696 | 704 | 'ghLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez gh auth login dans un terminal.", |
| 697 | 705 | 'error.ghNotSignedIn': "L'outil GitHub (gh) n'est pas connecté à GitHub : connectez-le d'abord.", |
| 706 | + 'oauthLogin.start': 'Me connecter avec mon compte ChatGPT', | |
| 707 | + 'oauthLogin.browser': 'Votre navigateur s\'ouvre : connectez-vous-y avec votre compte ChatGPT.', | |
| 708 | + 'oauthLogin.signed': '✓ Connecté avec votre compte ChatGPT : sbx garde la connexion.', | |
| 709 | + 'oauthLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez sbx secret set openai --oauth dans un terminal.", | |
| 710 | + 'error.openaiSignIn': "sbx demande de se connecter à OpenAI avant de créer la sandbox : connectez-vous avec votre compte ChatGPT (ou enregistrez une clé d'API OpenAI), puis l'agent redémarre.", | |
| 711 | + 'sbxCreator.oauth.choice': "{title} fonctionne avec une clé d'API OpenAI ou avec votre compte ChatGPT. La connexion ouvre votre navigateur ; sbx garde la connexion dans votre trousseau, et la sandbox ne la voit jamais.", | |
| 712 | + 'sbxCreator.oauth.orKey': "Ou collez une clé d'API OpenAI :", | |
| 713 | + 'sbxCreator.oauth.later': "Pas encore de clé OpenAI ni de connexion ChatGPT dans sbx. Vous pouvez continuer : si sbx demande de se connecter en créant la sandbox, Sidekicks affiche un bouton « Me connecter avec mon compte ChatGPT » sous l'erreur.", | |
| 698 | 714 | 'error.authRequired': "L'agent n'est pas connecté : il n'a pas de clé d'API, et personne ne s'est encore connecté avec un compte.", |
| 699 | 715 | 'signIn.open': 'Se connecter dans son terminal', |
| 700 | 716 | 'signIn.terminal': "{agent} n'est pas connecté. {program} démarre dans ce terminal : tapez /login, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Puis cliquez sur le bouton : l'agent redémarre et vous pouvez renvoyer votre message.", |
| @@ -182,6 +182,14 @@ export const en = { | |||
| 182 | 'ghLogin.signed': '✓ Signed in to GitHub as {user}.', | 182 | 'ghLogin.signed': '✓ Signed in to GitHub as {user}.', |
| 183 | 'ghLogin.failed': 'The sign-in did not succeed. Try again, or type gh auth login in a terminal.', | 183 | 'ghLogin.failed': 'The sign-in did not succeed. Try again, or type gh auth login in a terminal.', |
| 184 | 'error.ghNotSignedIn': 'The GitHub CLI (gh) is not signed in to GitHub: sign in with it first.', | 184 | 'error.ghNotSignedIn': 'The GitHub CLI (gh) is not signed in to GitHub: sign in with it first.', |
| 185 | + 'oauthLogin.start': 'Sign in with my ChatGPT account', | ||
| 186 | + 'oauthLogin.browser': 'Your browser opens: sign in there with your ChatGPT account.', | ||
| 187 | + 'oauthLogin.signed': '✓ Signed in with your ChatGPT account: sbx keeps the sign-in.', | ||
| 188 | + 'oauthLogin.failed': 'The sign-in did not succeed. Try again, or type sbx secret set openai --oauth in a terminal.', | ||
| 189 | + 'error.openaiSignIn': 'sbx asks to sign in to OpenAI before creating the sandbox: sign in with your ChatGPT account (or save an OpenAI API key), then the agent starts again.', | ||
| 190 | + 'sbxCreator.oauth.choice': '{title} works with an OpenAI API key or with your ChatGPT account. Signing in opens your browser; sbx keeps the sign-in in your keychain, and the sandbox never sees it.', | ||
| 191 | + 'sbxCreator.oauth.orKey': 'Or paste an OpenAI API key:', | ||
| 192 | + 'sbxCreator.oauth.later': 'No OpenAI key nor ChatGPT sign-in in sbx yet. You can go on: if sbx asks to sign in when it creates the sandbox, Sidekicks shows a "Sign in with my ChatGPT account" button under the error.', | ||
| 185 | 'error.authRequired': 'The agent is not signed in: it has no API key, and nobody signed in with an account yet.', | 193 | 'error.authRequired': 'The agent is not signed in: it has no API key, and nobody signed in with an account yet.', |
| 186 | 'signIn.open': 'Sign in in its terminal', | 194 | 'signIn.open': 'Sign in in its terminal', |
| 187 | 'signIn.terminal': '{agent} is not signed in. {program} is starting in this terminal: type /login, choose your account and follow the steps (copy the link into your browser if asked). Then click the button: the agent restarts and you can send your message again.', | 195 | 'signIn.terminal': '{agent} is not signed in. {program} is starting in this terminal: type /login, choose your account and follow the steps (copy the link into your browser if asked). Then click the button: the agent restarts and you can send your message again.', |
| @@ -695,6 +703,14 @@ export const fr: Record<MessageKey, string> = { | |||
| 695 | 'ghLogin.signed': '✓ Connecté à GitHub en tant que {user}.', | 703 | 'ghLogin.signed': '✓ Connecté à GitHub en tant que {user}.', |
| 696 | 'ghLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez gh auth login dans un terminal.", | 704 | 'ghLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez gh auth login dans un terminal.", |
| 697 | 'error.ghNotSignedIn': "L'outil GitHub (gh) n'est pas connecté à GitHub : connectez-le d'abord.", | 705 | 'error.ghNotSignedIn': "L'outil GitHub (gh) n'est pas connecté à GitHub : connectez-le d'abord.", |
| 706 | + 'oauthLogin.start': 'Me connecter avec mon compte ChatGPT', | ||
| 707 | + 'oauthLogin.browser': 'Votre navigateur s\'ouvre : connectez-vous-y avec votre compte ChatGPT.', | ||
| 708 | + 'oauthLogin.signed': '✓ Connecté avec votre compte ChatGPT : sbx garde la connexion.', | ||
| 709 | + 'oauthLogin.failed': "La connexion n'a pas abouti. Réessayez, ou tapez sbx secret set openai --oauth dans un terminal.", | ||
| 710 | + 'error.openaiSignIn': "sbx demande de se connecter à OpenAI avant de créer la sandbox : connectez-vous avec votre compte ChatGPT (ou enregistrez une clé d'API OpenAI), puis l'agent redémarre.", | ||
| 711 | + 'sbxCreator.oauth.choice': "{title} fonctionne avec une clé d'API OpenAI ou avec votre compte ChatGPT. La connexion ouvre votre navigateur ; sbx garde la connexion dans votre trousseau, et la sandbox ne la voit jamais.", | ||
| 712 | + 'sbxCreator.oauth.orKey': "Ou collez une clé d'API OpenAI :", | ||
| 713 | + 'sbxCreator.oauth.later': "Pas encore de clé OpenAI ni de connexion ChatGPT dans sbx. Vous pouvez continuer : si sbx demande de se connecter en créant la sandbox, Sidekicks affiche un bouton « Me connecter avec mon compte ChatGPT » sous l'erreur.", | ||
| 698 | 'error.authRequired': "L'agent n'est pas connecté : il n'a pas de clé d'API, et personne ne s'est encore connecté avec un compte.", | 714 | 'error.authRequired': "L'agent n'est pas connecté : il n'a pas de clé d'API, et personne ne s'est encore connecté avec un compte.", |
| 699 | 'signIn.open': 'Se connecter dans son terminal', | 715 | 'signIn.open': 'Se connecter dans son terminal', |
| 700 | 'signIn.terminal': "{agent} n'est pas connecté. {program} démarre dans ce terminal : tapez /login, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Puis cliquez sur le bouton : l'agent redémarre et vous pouvez renvoyer votre message.", | 716 | 'signIn.terminal': "{agent} n'est pas connecté. {program} démarre dans ce terminal : tapez /login, choisissez votre compte et suivez les étapes (copiez le lien dans votre navigateur si on vous le demande). Puis cliquez sur le bouton : l'agent redémarre et vous pouvez renvoyer votre message.", |
modified
frontend/src/lib/panels/AgentsPanel.svelte +1 -1 | @@ -54,7 +54,7 @@ | ||
| 54 | 54 | {/if} |
| 55 | 55 | </span> |
| 56 | 56 | {#if agent.error} |
| 57 | - <div class="failure"><ErrorText raw={agent.error} /></div> | |
| 57 | + <div class="failure"><ErrorText raw={agent.error} agent={agent.name} /></div> | |
| 58 | 58 | {/if} |
| 59 | 59 | </li> |
| 60 | 60 | {/each} |
| @@ -54,7 +54,7 @@ | |||
| 54 | {/if} | 54 | {/if} |
| 55 | </span> | 55 | </span> |
| 56 | {#if agent.error} | 56 | {#if agent.error} |
| 57 | - <div class="failure"><ErrorText raw={agent.error} /></div> | 57 | + <div class="failure"><ErrorText raw={agent.error} agent={agent.name} /></div> |
| 58 | {/if} | 58 | {/if} |
| 59 | </li> | 59 | </li> |
| 60 | {/each} | 60 | {/each} |
modified
internal/agents/manager.go +4 -0 | @@ -129,6 +129,9 @@ type Status struct { | ||
| 129 | 129 | // SignIn is the program its terminal runs to sign in with an account |
| 130 | 130 | // instead of an API key ("claude", issues #105 and #106), or "". |
| 131 | 131 | SignIn string `json:"signIn,omitempty"` |
| 132 | + // OAuth is the kind of the sandbox assistant whose account sign-in it | |
| 133 | + // takes ("codex": ChatGPT, issue #107), or "". | |
| 134 | + OAuth string `json:"oauth,omitempty"` | |
| 132 | 135 | } |
| 133 | 136 | |
| 134 | 137 | // Manager owns the agent processes. It is safe for concurrent use. |
| @@ -204,6 +207,7 @@ func (a *agent) status() Status { | ||
| 204 | 207 | CanStopSandbox: len(a.definition.Runtime.Lifecycle.Stop) > 0, |
| 205 | 208 | CanRemoveSandbox: len(a.definition.Runtime.Lifecycle.Remove) > 0, |
| 206 | 209 | SignIn: SignInProgram(a.definition), |
| 210 | + OAuth: OAuthKind(a.definition), | |
| 207 | 211 | } |
| 208 | 212 | if a.state == StateStarting { |
| 209 | 213 | status.Step, status.Since = a.step, a.since.UnixMilli() |
| @@ -129,6 +129,9 @@ type Status struct { | |||
| 129 | // SignIn is the program its terminal runs to sign in with an account | 129 | // SignIn is the program its terminal runs to sign in with an account |
| 130 | // instead of an API key ("claude", issues #105 and #106), or "". | 130 | // instead of an API key ("claude", issues #105 and #106), or "". |
| 131 | SignIn string `json:"signIn,omitempty"` | 131 | SignIn string `json:"signIn,omitempty"` |
| 132 | + // OAuth is the kind of the sandbox assistant whose account sign-in it | ||
| 133 | + // takes ("codex": ChatGPT, issue #107), or "". | ||
| 134 | + OAuth string `json:"oauth,omitempty"` | ||
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | // Manager owns the agent processes. It is safe for concurrent use. | 137 | // Manager owns the agent processes. It is safe for concurrent use. |
| @@ -204,6 +207,7 @@ func (a *agent) status() Status { | |||
| 204 | CanStopSandbox: len(a.definition.Runtime.Lifecycle.Stop) > 0, | 207 | CanStopSandbox: len(a.definition.Runtime.Lifecycle.Stop) > 0, |
| 205 | CanRemoveSandbox: len(a.definition.Runtime.Lifecycle.Remove) > 0, | 208 | CanRemoveSandbox: len(a.definition.Runtime.Lifecycle.Remove) > 0, |
| 206 | SignIn: SignInProgram(a.definition), | 209 | SignIn: SignInProgram(a.definition), |
| 210 | + OAuth: OAuthKind(a.definition), | ||
| 207 | } | 211 | } |
| 208 | if a.state == StateStarting { | 212 | if a.state == StateStarting { |
| 209 | status.Step, status.Since = a.step, a.since.UnixMilli() | 213 | status.Step, status.Since = a.step, a.since.UnixMilli() |
modified
internal/agents/signin.go +23 -2 | @@ -24,13 +24,34 @@ var signInPrograms = map[string]string{ | ||
| 24 | 24 | // |
| 25 | 25 | // SignInProgram(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: config.Runtime{Type: "sbx"}}) // "claude" |
| 26 | 26 | func SignInProgram(definition config.Agent) string { |
| 27 | + return programIn(definition, signInPrograms) | |
| 28 | +} | |
| 29 | + | |
| 30 | +// programIn is what table gives for the first word of definition's command | |
| 31 | +// line that it knows, or "" — only for an agent in an sbx sandbox. | |
| 32 | +func programIn(definition config.Agent, table map[string]string) string { | |
| 27 | 33 | if definition.Runtime.Type != "sbx" { |
| 28 | 34 | return "" |
| 29 | 35 | } |
| 30 | 36 | for _, word := range append([]string{definition.Command}, definition.Args...) { |
| 31 | - if program, ok := signInPrograms[path.Base(strings.TrimSpace(word))]; ok { | |
| 32 | - return program | |
| 37 | + if value, ok := table[path.Base(strings.TrimSpace(word))]; ok { | |
| 38 | + return value | |
| 33 | 39 | } |
| 34 | 40 | } |
| 35 | 41 | return "" |
| 36 | 42 | } |
| 43 | + | |
| 44 | +// oauthKinds maps the ACP program of an agent in an sbx sandbox to the kind | |
| 45 | +// of the sandbox assistant whose account sign-in it takes (issue #107): | |
| 46 | +// Codex signs in with ChatGPT through `sbx secret set openai --oauth`. | |
| 47 | +var oauthKinds = map[string]string{ | |
| 48 | + "codex-acp": "codex", | |
| 49 | +} | |
| 50 | + | |
| 51 | +// OAuthKind is the kind (sbxcreate.Catalogue) whose account sign-in | |
| 52 | +// definition takes, or "": only agents in an sbx sandbox. | |
| 53 | +// | |
| 54 | +// OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: config.Runtime{Type: "sbx"}}) // "codex" | |
| 55 | +func OAuthKind(definition config.Agent) string { | |
| 56 | + return programIn(definition, oauthKinds) | |
| 57 | +} | |
| @@ -24,13 +24,34 @@ var signInPrograms = map[string]string{ | |||
| 24 | // | 24 | // |
| 25 | // SignInProgram(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: config.Runtime{Type: "sbx"}}) // "claude" | 25 | // SignInProgram(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: config.Runtime{Type: "sbx"}}) // "claude" |
| 26 | func SignInProgram(definition config.Agent) string { | 26 | func SignInProgram(definition config.Agent) string { |
| 27 | + return programIn(definition, signInPrograms) | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +// programIn is what table gives for the first word of definition's command | ||
| 31 | +// line that it knows, or "" — only for an agent in an sbx sandbox. | ||
| 32 | +func programIn(definition config.Agent, table map[string]string) string { | ||
| 27 | if definition.Runtime.Type != "sbx" { | 33 | if definition.Runtime.Type != "sbx" { |
| 28 | return "" | 34 | return "" |
| 29 | } | 35 | } |
| 30 | for _, word := range append([]string{definition.Command}, definition.Args...) { | 36 | for _, word := range append([]string{definition.Command}, definition.Args...) { |
| 31 | - if program, ok := signInPrograms[path.Base(strings.TrimSpace(word))]; ok { | 37 | + if value, ok := table[path.Base(strings.TrimSpace(word))]; ok { |
| 32 | - return program | 38 | + return value |
| 33 | } | 39 | } |
| 34 | } | 40 | } |
| 35 | return "" | 41 | return "" |
| 36 | } | 42 | } |
| 43 | + | ||
| 44 | +// oauthKinds maps the ACP program of an agent in an sbx sandbox to the kind | ||
| 45 | +// of the sandbox assistant whose account sign-in it takes (issue #107): | ||
| 46 | +// Codex signs in with ChatGPT through `sbx secret set openai --oauth`. | ||
| 47 | +var oauthKinds = map[string]string{ | ||
| 48 | + "codex-acp": "codex", | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +// OAuthKind is the kind (sbxcreate.Catalogue) whose account sign-in | ||
| 52 | +// definition takes, or "": only agents in an sbx sandbox. | ||
| 53 | +// | ||
| 54 | +// OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: config.Runtime{Type: "sbx"}}) // "codex" | ||
| 55 | +func OAuthKind(definition config.Agent) string { | ||
| 56 | + return programIn(definition, oauthKinds) | ||
| 57 | +} | ||
modified
internal/agents/signin_test.go +15 -0 | @@ -27,3 +27,18 @@ func TestSignInProgramIsClaudeForClaudeInASandboxOnly(t *testing.T) { | ||
| 27 | 27 | } |
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | + | |
| 31 | +// Issue #107: a Codex agent in a sandbox signs in with the codex kind's | |
| 32 | +// ChatGPT sign-in. | |
| 33 | +func TestOAuthKindIsCodexForCodexInASandboxOnly(t *testing.T) { | |
| 34 | + sbx := config.Runtime{Type: "sbx"} | |
| 35 | + if got := agents.OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: sbx}); got != "codex" { | |
| 36 | + t.Fatalf("codex: %q", got) | |
| 37 | + } | |
| 38 | + if got := agents.OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: sbx}); got != "" { | |
| 39 | + t.Fatalf("claude: %q", got) | |
| 40 | + } | |
| 41 | + if got := agents.OAuthKind(config.Agent{Command: "codex-acp"}); got != "" { | |
| 42 | + t.Fatalf("local: %q", got) | |
| 43 | + } | |
| 44 | +} | |
| @@ -27,3 +27,18 @@ func TestSignInProgramIsClaudeForClaudeInASandboxOnly(t *testing.T) { | |||
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| 29 | } | 29 | } |
| 30 | + | ||
| 31 | +// Issue #107: a Codex agent in a sandbox signs in with the codex kind's | ||
| 32 | +// ChatGPT sign-in. | ||
| 33 | +func TestOAuthKindIsCodexForCodexInASandboxOnly(t *testing.T) { | ||
| 34 | + sbx := config.Runtime{Type: "sbx"} | ||
| 35 | + if got := agents.OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "codex", "codex-acp"}, Runtime: sbx}); got != "codex" { | ||
| 36 | + t.Fatalf("codex: %q", got) | ||
| 37 | + } | ||
| 38 | + if got := agents.OAuthKind(config.Agent{Command: "sbx", Args: []string{"exec", "-i", "claude", "claude-agent-acp"}, Runtime: sbx}); got != "" { | ||
| 39 | + t.Fatalf("claude: %q", got) | ||
| 40 | + } | ||
| 41 | + if got := agents.OAuthKind(config.Agent{Command: "codex-acp"}); got != "" { | ||
| 42 | + t.Fatalf("local: %q", got) | ||
| 43 | + } | ||
| 44 | +} | ||
modified
internal/app/app.go +3 -0 | @@ -98,6 +98,8 @@ type Core struct { | ||
| 98 | 98 | signIn signIn |
| 99 | 99 | // ghSignIn is the `gh auth login` in progress (issue #103). |
| 100 | 100 | ghSignIn signIn |
| 101 | + // oauthSignIn is the `sbx secret set <service> --oauth` in progress (issue #107). | |
| 102 | + oauthSignIn signIn | |
| 101 | 103 | } |
| 102 | 104 | |
| 103 | 105 | // New loads the configuration at location — creating the default file first |
| @@ -303,6 +305,7 @@ func (c *Core) Shutdown(ctx context.Context) { | ||
| 303 | 305 | (&CreatorService{Core: c}).Cancel() |
| 304 | 306 | (&SbxCreatorService{Core: c}).CancelLogin() |
| 305 | 307 | (&SbxCreatorService{Core: c}).CancelGitHubLogin() |
| 308 | + (&SbxCreatorService{Core: c}).CancelOAuthLogin() | |
| 306 | 309 | c.closeChannels() |
| 307 | 310 | c.stopWorkspaces() |
| 308 | 311 | c.manager.StopAll(ctx) |
| @@ -98,6 +98,8 @@ type Core struct { | |||
| 98 | signIn signIn | 98 | signIn signIn |
| 99 | // ghSignIn is the `gh auth login` in progress (issue #103). | 99 | // ghSignIn is the `gh auth login` in progress (issue #103). |
| 100 | ghSignIn signIn | 100 | ghSignIn signIn |
| 101 | + // oauthSignIn is the `sbx secret set <service> --oauth` in progress (issue #107). | ||
| 102 | + oauthSignIn signIn | ||
| 101 | } | 103 | } |
| 102 | 104 | ||
| 103 | // New loads the configuration at location — creating the default file first | 105 | // New loads the configuration at location — creating the default file first |
| @@ -303,6 +305,7 @@ func (c *Core) Shutdown(ctx context.Context) { | |||
| 303 | (&CreatorService{Core: c}).Cancel() | 305 | (&CreatorService{Core: c}).Cancel() |
| 304 | (&SbxCreatorService{Core: c}).CancelLogin() | 306 | (&SbxCreatorService{Core: c}).CancelLogin() |
| 305 | (&SbxCreatorService{Core: c}).CancelGitHubLogin() | 307 | (&SbxCreatorService{Core: c}).CancelGitHubLogin() |
| 308 | + (&SbxCreatorService{Core: c}).CancelOAuthLogin() | ||
| 306 | c.closeChannels() | 309 | c.closeChannels() |
| 307 | c.stopWorkspaces() | 310 | c.stopWorkspaces() |
| 308 | c.manager.StopAll(ctx) | 311 | c.manager.StopAll(ctx) |
modified
internal/app/sbxcreator.go +36 -7 | @@ -239,9 +239,13 @@ type signIn struct { | ||
| 239 | 239 | // LoginStatus again while the user has not confirmed. |
| 240 | 240 | const loginWait = 20 * time.Second |
| 241 | 241 | |
| 242 | +// deviceCode: a device-code sign-in is ready to show once it printed its | |
| 243 | +// code and its URL. | |
| 244 | +func deviceCode(state sbxcreate.LoginState) bool { return state.URL != "" && state.Code != "" } | |
| 245 | + | |
| 242 | 246 | // start starts a sign-in — or joins the one in progress — and returns once |
| 243 | -// it printed the code and the URL the user confirms in a browser (or ended). | |
| 244 | -func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, error)) (sbxcreate.LoginState, error) { | |
| 247 | +// it is ready to show (or ended). | |
| 248 | +func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, error), ready func(sbxcreate.LoginState) bool) (sbxcreate.LoginState, error) { | |
| 245 | 249 | in.mu.Lock() |
| 246 | 250 | login := in.login |
| 247 | 251 | if login == nil || login.State().Done { |
| @@ -255,9 +259,7 @@ func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, err | ||
| 255 | 259 | in.mu.Unlock() |
| 256 | 260 | ctx, cancel := context.WithTimeout(ctx, loginWait) |
| 257 | 261 | defer cancel() |
| 258 | - return login.Wait(ctx, func(state sbxcreate.LoginState) bool { | |
| 259 | - return state.Done || (state.URL != "" && state.Code != "") | |
| 260 | - }), nil | |
| 262 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { return state.Done || ready(state) }), nil | |
| 261 | 263 | } |
| 262 | 264 | |
| 263 | 265 | // status waits — 20 seconds at most — for the sign-in to end, and returns |
| @@ -286,7 +288,7 @@ func (in *signIn) cancel() { | ||
| 286 | 288 | // Login starts `sbx login` — or joins the one in progress — and returns once |
| 287 | 289 | // sbx printed the code and the URL the user confirms in a browser (or ended). |
| 288 | 290 | func (s *SbxCreatorService) Login(ctx context.Context) (sbxcreate.LoginState, error) { |
| 289 | - return s.Core.signIn.start(ctx, s.Core.sbx().StartLogin) | |
| 291 | + return s.Core.signIn.start(ctx, s.Core.sbx().StartLogin, deviceCode) | |
| 290 | 292 | } |
| 291 | 293 | |
| 292 | 294 | // LoginStatus waits — 20 seconds at most — for `sbx login` to end, and |
| @@ -301,7 +303,7 @@ func (s *SbxCreatorService) CancelLogin() { s.Core.signIn.cancel() } | ||
| 301 | 303 | // GitHubLogin starts `gh auth login --web` (issue #103) — or joins the one |
| 302 | 304 | // in progress — like Login: it returns once gh printed its code and URL. |
| 303 | 305 | func (s *SbxCreatorService) GitHubLogin(ctx context.Context) (sbxcreate.LoginState, error) { |
| 304 | - return s.Core.ghSignIn.start(ctx, s.Core.gh().StartLogin) | |
| 306 | + return s.Core.ghSignIn.start(ctx, s.Core.gh().StartLogin, deviceCode) | |
| 305 | 307 | } |
| 306 | 308 | |
| 307 | 309 | // GitHubLoginStatus waits — 20 seconds at most — for `gh auth login` to end. |
| @@ -312,3 +314,30 @@ func (s *SbxCreatorService) GitHubLoginStatus(ctx context.Context) (sbxcreate.Lo | ||
| 312 | 314 | // CancelGitHubLogin stops `gh auth login`, if it runs. Also done when |
| 313 | 315 | // Sidekicks quits. |
| 314 | 316 | func (s *SbxCreatorService) CancelGitHubLogin() { s.Core.ghSignIn.cancel() } |
| 317 | + | |
| 318 | +// OAuthLogin starts the account sign-in of a kind with OAuth (issue #107): | |
| 319 | +// `sbx secret set <service> --oauth`, which opens a browser window on this | |
| 320 | +// computer — or joins the one in progress. It returns once sbx printed the | |
| 321 | +// page to open, or ended. | |
| 322 | +func (s *SbxCreatorService) OAuthLogin(ctx context.Context, kindID string) (sbxcreate.LoginState, error) { | |
| 323 | + kind, err := kindOf(kindID) | |
| 324 | + if err != nil { | |
| 325 | + return sbxcreate.LoginState{}, err | |
| 326 | + } | |
| 327 | + if !kind.OAuth { | |
| 328 | + return sbxcreate.LoginState{}, fmt.Errorf("%s has no account sign-in", kind.Title) | |
| 329 | + } | |
| 330 | + sbx := s.Core.sbx() | |
| 331 | + // No code: the page to open is enough (sbx may also open it itself). | |
| 332 | + return s.Core.oauthSignIn.start(ctx, func() (*sbxcreate.Login, error) { return sbx.StartOAuth(kind.Service) }, | |
| 333 | + func(state sbxcreate.LoginState) bool { return state.URL != "" }) | |
| 334 | +} | |
| 335 | + | |
| 336 | +// OAuthLoginStatus waits — 20 seconds at most — for the account sign-in to end. | |
| 337 | +func (s *SbxCreatorService) OAuthLoginStatus(ctx context.Context) (sbxcreate.LoginState, error) { | |
| 338 | + return s.Core.oauthSignIn.status(ctx) | |
| 339 | +} | |
| 340 | + | |
| 341 | +// CancelOAuthLogin stops the account sign-in, if it runs. Also done when | |
| 342 | +// Sidekicks quits. | |
| 343 | +func (s *SbxCreatorService) CancelOAuthLogin() { s.Core.oauthSignIn.cancel() } | |
| @@ -239,9 +239,13 @@ type signIn struct { | |||
| 239 | // LoginStatus again while the user has not confirmed. | 239 | // LoginStatus again while the user has not confirmed. |
| 240 | const loginWait = 20 * time.Second | 240 | const loginWait = 20 * time.Second |
| 241 | 241 | ||
| 242 | +// deviceCode: a device-code sign-in is ready to show once it printed its | ||
| 243 | +// code and its URL. | ||
| 244 | +func deviceCode(state sbxcreate.LoginState) bool { return state.URL != "" && state.Code != "" } | ||
| 245 | + | ||
| 242 | // start starts a sign-in — or joins the one in progress — and returns once | 246 | // start starts a sign-in — or joins the one in progress — and returns once |
| 243 | -// it printed the code and the URL the user confirms in a browser (or ended). | 247 | +// it is ready to show (or ended). |
| 244 | -func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, error)) (sbxcreate.LoginState, error) { | 248 | +func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, error), ready func(sbxcreate.LoginState) bool) (sbxcreate.LoginState, error) { |
| 245 | in.mu.Lock() | 249 | in.mu.Lock() |
| 246 | login := in.login | 250 | login := in.login |
| 247 | if login == nil || login.State().Done { | 251 | if login == nil || login.State().Done { |
| @@ -255,9 +259,7 @@ func (in *signIn) start(ctx context.Context, begin func() (*sbxcreate.Login, err | |||
| 255 | in.mu.Unlock() | 259 | in.mu.Unlock() |
| 256 | ctx, cancel := context.WithTimeout(ctx, loginWait) | 260 | ctx, cancel := context.WithTimeout(ctx, loginWait) |
| 257 | defer cancel() | 261 | defer cancel() |
| 258 | - return login.Wait(ctx, func(state sbxcreate.LoginState) bool { | 262 | + return login.Wait(ctx, func(state sbxcreate.LoginState) bool { return state.Done || ready(state) }), nil |
| 259 | - return state.Done || (state.URL != "" && state.Code != "") | ||
| 260 | - }), nil | ||
| 261 | } | 263 | } |
| 262 | 264 | ||
| 263 | // status waits — 20 seconds at most — for the sign-in to end, and returns | 265 | // status waits — 20 seconds at most — for the sign-in to end, and returns |
| @@ -286,7 +288,7 @@ func (in *signIn) cancel() { | |||
| 286 | // Login starts `sbx login` — or joins the one in progress — and returns once | 288 | // Login starts `sbx login` — or joins the one in progress — and returns once |
| 287 | // sbx printed the code and the URL the user confirms in a browser (or ended). | 289 | // sbx printed the code and the URL the user confirms in a browser (or ended). |
| 288 | func (s *SbxCreatorService) Login(ctx context.Context) (sbxcreate.LoginState, error) { | 290 | func (s *SbxCreatorService) Login(ctx context.Context) (sbxcreate.LoginState, error) { |
| 289 | - return s.Core.signIn.start(ctx, s.Core.sbx().StartLogin) | 291 | + return s.Core.signIn.start(ctx, s.Core.sbx().StartLogin, deviceCode) |
| 290 | } | 292 | } |
| 291 | 293 | ||
| 292 | // LoginStatus waits — 20 seconds at most — for `sbx login` to end, and | 294 | // LoginStatus waits — 20 seconds at most — for `sbx login` to end, and |
| @@ -301,7 +303,7 @@ func (s *SbxCreatorService) CancelLogin() { s.Core.signIn.cancel() } | |||
| 301 | // GitHubLogin starts `gh auth login --web` (issue #103) — or joins the one | 303 | // GitHubLogin starts `gh auth login --web` (issue #103) — or joins the one |
| 302 | // in progress — like Login: it returns once gh printed its code and URL. | 304 | // in progress — like Login: it returns once gh printed its code and URL. |
| 303 | func (s *SbxCreatorService) GitHubLogin(ctx context.Context) (sbxcreate.LoginState, error) { | 305 | func (s *SbxCreatorService) GitHubLogin(ctx context.Context) (sbxcreate.LoginState, error) { |
| 304 | - return s.Core.ghSignIn.start(ctx, s.Core.gh().StartLogin) | 306 | + return s.Core.ghSignIn.start(ctx, s.Core.gh().StartLogin, deviceCode) |
| 305 | } | 307 | } |
| 306 | 308 | ||
| 307 | // GitHubLoginStatus waits — 20 seconds at most — for `gh auth login` to end. | 309 | // GitHubLoginStatus waits — 20 seconds at most — for `gh auth login` to end. |
| @@ -312,3 +314,30 @@ func (s *SbxCreatorService) GitHubLoginStatus(ctx context.Context) (sbxcreate.Lo | |||
| 312 | // CancelGitHubLogin stops `gh auth login`, if it runs. Also done when | 314 | // CancelGitHubLogin stops `gh auth login`, if it runs. Also done when |
| 313 | // Sidekicks quits. | 315 | // Sidekicks quits. |
| 314 | func (s *SbxCreatorService) CancelGitHubLogin() { s.Core.ghSignIn.cancel() } | 316 | func (s *SbxCreatorService) CancelGitHubLogin() { s.Core.ghSignIn.cancel() } |
| 317 | + | ||
| 318 | +// OAuthLogin starts the account sign-in of a kind with OAuth (issue #107): | ||
| 319 | +// `sbx secret set <service> --oauth`, which opens a browser window on this | ||
| 320 | +// computer — or joins the one in progress. It returns once sbx printed the | ||
| 321 | +// page to open, or ended. | ||
| 322 | +func (s *SbxCreatorService) OAuthLogin(ctx context.Context, kindID string) (sbxcreate.LoginState, error) { | ||
| 323 | + kind, err := kindOf(kindID) | ||
| 324 | + if err != nil { | ||
| 325 | + return sbxcreate.LoginState{}, err | ||
| 326 | + } | ||
| 327 | + if !kind.OAuth { | ||
| 328 | + return sbxcreate.LoginState{}, fmt.Errorf("%s has no account sign-in", kind.Title) | ||
| 329 | + } | ||
| 330 | + sbx := s.Core.sbx() | ||
| 331 | + // No code: the page to open is enough (sbx may also open it itself). | ||
| 332 | + return s.Core.oauthSignIn.start(ctx, func() (*sbxcreate.Login, error) { return sbx.StartOAuth(kind.Service) }, | ||
| 333 | + func(state sbxcreate.LoginState) bool { return state.URL != "" }) | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +// OAuthLoginStatus waits — 20 seconds at most — for the account sign-in to end. | ||
| 337 | +func (s *SbxCreatorService) OAuthLoginStatus(ctx context.Context) (sbxcreate.LoginState, error) { | ||
| 338 | + return s.Core.oauthSignIn.status(ctx) | ||
| 339 | +} | ||
| 340 | + | ||
| 341 | +// CancelOAuthLogin stops the account sign-in, if it runs. Also done when | ||
| 342 | +// Sidekicks quits. | ||
| 343 | +func (s *SbxCreatorService) CancelOAuthLogin() { s.Core.oauthSignIn.cancel() } | ||
modified
internal/app/sbxcreator_test.go +26 -0 | @@ -255,3 +255,29 @@ func TestGitHubLoginShowsGhsCodeThenWhoSignedIn(t *testing.T) { | ||
| 255 | 255 | t.Fatalf("signed in now: %v", err) |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | + | |
| 259 | +// Issue #107: Codex signs in with ChatGPT through `sbx secret set openai | |
| 260 | +// --oauth`; then its key counts as stored. Claude has no such sign-in. | |
| 261 | +func TestOAuthLoginStoresCodexsSignIn(t *testing.T) { | |
| 262 | + service, _, _, bin := sbxFixture(t, "") | |
| 263 | + if check, _ := service.Check(context.Background(), "codex"); check.HasKey { | |
| 264 | + t.Fatal("no key yet") | |
| 265 | + } | |
| 266 | + state, err := service.OAuthLogin(context.Background(), "codex") | |
| 267 | + if err == nil && !state.Done { | |
| 268 | + state, err = service.OAuthLoginStatus(context.Background()) | |
| 269 | + } | |
| 270 | + if err != nil || !state.OK { | |
| 271 | + t.Fatalf("oauth: %+v %v", state, err) | |
| 272 | + } | |
| 273 | + calls, _ := os.ReadFile(filepath.Join(bin, "calls")) | |
| 274 | + if !strings.Contains(string(calls), "secret set openai --oauth") { | |
| 275 | + t.Fatalf("calls %q", calls) | |
| 276 | + } | |
| 277 | + if check, _ := service.Check(context.Background(), "codex"); !check.HasKey { | |
| 278 | + t.Fatal("the sign-in is stored") | |
| 279 | + } | |
| 280 | + if _, err := service.OAuthLogin(context.Background(), "claude"); err == nil { | |
| 281 | + t.Fatal("Claude has no account sign-in here") | |
| 282 | + } | |
| 283 | +} | |
| @@ -255,3 +255,29 @@ func TestGitHubLoginShowsGhsCodeThenWhoSignedIn(t *testing.T) { | |||
| 255 | t.Fatalf("signed in now: %v", err) | 255 | t.Fatalf("signed in now: %v", err) |
| 256 | } | 256 | } |
| 257 | } | 257 | } |
| 258 | + | ||
| 259 | +// Issue #107: Codex signs in with ChatGPT through `sbx secret set openai | ||
| 260 | +// --oauth`; then its key counts as stored. Claude has no such sign-in. | ||
| 261 | +func TestOAuthLoginStoresCodexsSignIn(t *testing.T) { | ||
| 262 | + service, _, _, bin := sbxFixture(t, "") | ||
| 263 | + if check, _ := service.Check(context.Background(), "codex"); check.HasKey { | ||
| 264 | + t.Fatal("no key yet") | ||
| 265 | + } | ||
| 266 | + state, err := service.OAuthLogin(context.Background(), "codex") | ||
| 267 | + if err == nil && !state.Done { | ||
| 268 | + state, err = service.OAuthLoginStatus(context.Background()) | ||
| 269 | + } | ||
| 270 | + if err != nil || !state.OK { | ||
| 271 | + t.Fatalf("oauth: %+v %v", state, err) | ||
| 272 | + } | ||
| 273 | + calls, _ := os.ReadFile(filepath.Join(bin, "calls")) | ||
| 274 | + if !strings.Contains(string(calls), "secret set openai --oauth") { | ||
| 275 | + t.Fatalf("calls %q", calls) | ||
| 276 | + } | ||
| 277 | + if check, _ := service.Check(context.Background(), "codex"); !check.HasKey { | ||
| 278 | + t.Fatal("the sign-in is stored") | ||
| 279 | + } | ||
| 280 | + if _, err := service.OAuthLogin(context.Background(), "claude"); err == nil { | ||
| 281 | + t.Fatal("Claude has no account sign-in here") | ||
| 282 | + } | ||
| 283 | +} | ||
modified
internal/lifecycle/lifecycle.go +13 -0 | @@ -205,6 +205,9 @@ func boxOf(agent config.Agent) string { | ||
| 205 | 205 | return agent.Runtime.Sandbox |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | +// errorLines is how many of its last lines a failed command's error keeps. | |
| 209 | +const errorLines = 3 | |
| 210 | + | |
| 208 | 211 | // command runs command in the lifecycle folder, with the agent's env; a bare |
| 209 | 212 | // sbx or docker program is the one found by the Runner. |
| 210 | 213 | func (r Runner) command(ctx context.Context, agent config.Agent, command []string, log func(string)) error { |
| @@ -232,6 +235,9 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | ||
| 232 | 235 | reader, writer := io.Pipe() |
| 233 | 236 | process.Stdout, process.Stderr = writer, writer |
| 234 | 237 | var copied sync.WaitGroup |
| 238 | + // The last lines it printed go with its error: they say why (sbx asking | |
| 239 | + // whether to sign in to OpenAI, issue #107, rather than "exit status 1"). | |
| 240 | + var last []string | |
| 235 | 241 | copied.Add(1) |
| 236 | 242 | go func() { |
| 237 | 243 | defer copied.Done() |
| @@ -240,6 +246,10 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | ||
| 240 | 246 | for scanner.Scan() { |
| 241 | 247 | if line := strings.TrimRight(scanner.Text(), "\r"); line != "" { |
| 242 | 248 | log(line) |
| 249 | + last = append(last, strings.TrimSpace(line)) | |
| 250 | + if len(last) > errorLines { | |
| 251 | + last = last[1:] | |
| 252 | + } | |
| 243 | 253 | } |
| 244 | 254 | } |
| 245 | 255 | _, _ = io.Copy(io.Discard, reader) |
| @@ -247,6 +257,9 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | ||
| 247 | 257 | err := process.Run() |
| 248 | 258 | _ = writer.Close() |
| 249 | 259 | copied.Wait() |
| 260 | + if err != nil && len(last) > 0 { | |
| 261 | + return fmt.Errorf("%w: %s", err, strings.Join(last, " · ")) | |
| 262 | + } | |
| 250 | 263 | return err |
| 251 | 264 | } |
| 252 | 265 | |
| @@ -205,6 +205,9 @@ func boxOf(agent config.Agent) string { | |||
| 205 | return agent.Runtime.Sandbox | 205 | return agent.Runtime.Sandbox |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | +// errorLines is how many of its last lines a failed command's error keeps. | ||
| 209 | +const errorLines = 3 | ||
| 210 | + | ||
| 208 | // command runs command in the lifecycle folder, with the agent's env; a bare | 211 | // command runs command in the lifecycle folder, with the agent's env; a bare |
| 209 | // sbx or docker program is the one found by the Runner. | 212 | // sbx or docker program is the one found by the Runner. |
| 210 | func (r Runner) command(ctx context.Context, agent config.Agent, command []string, log func(string)) error { | 213 | func (r Runner) command(ctx context.Context, agent config.Agent, command []string, log func(string)) error { |
| @@ -232,6 +235,9 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | |||
| 232 | reader, writer := io.Pipe() | 235 | reader, writer := io.Pipe() |
| 233 | process.Stdout, process.Stderr = writer, writer | 236 | process.Stdout, process.Stderr = writer, writer |
| 234 | var copied sync.WaitGroup | 237 | var copied sync.WaitGroup |
| 238 | + // The last lines it printed go with its error: they say why (sbx asking | ||
| 239 | + // whether to sign in to OpenAI, issue #107, rather than "exit status 1"). | ||
| 240 | + var last []string | ||
| 235 | copied.Add(1) | 241 | copied.Add(1) |
| 236 | go func() { | 242 | go func() { |
| 237 | defer copied.Done() | 243 | defer copied.Done() |
| @@ -240,6 +246,10 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | |||
| 240 | for scanner.Scan() { | 246 | for scanner.Scan() { |
| 241 | if line := strings.TrimRight(scanner.Text(), "\r"); line != "" { | 247 | if line := strings.TrimRight(scanner.Text(), "\r"); line != "" { |
| 242 | log(line) | 248 | log(line) |
| 249 | + last = append(last, strings.TrimSpace(line)) | ||
| 250 | + if len(last) > errorLines { | ||
| 251 | + last = last[1:] | ||
| 252 | + } | ||
| 243 | } | 253 | } |
| 244 | } | 254 | } |
| 245 | _, _ = io.Copy(io.Discard, reader) | 255 | _, _ = io.Copy(io.Discard, reader) |
| @@ -247,6 +257,9 @@ func (r Runner) command(ctx context.Context, agent config.Agent, command []strin | |||
| 247 | err := process.Run() | 257 | err := process.Run() |
| 248 | _ = writer.Close() | 258 | _ = writer.Close() |
| 249 | copied.Wait() | 259 | copied.Wait() |
| 260 | + if err != nil && len(last) > 0 { | ||
| 261 | + return fmt.Errorf("%w: %s", err, strings.Join(last, " · ")) | ||
| 262 | + } | ||
| 250 | return err | 263 | return err |
| 251 | } | 264 | } |
| 252 | 265 | ||
modified
internal/lifecycle/lifecycle_test.go +12 -0 | @@ -171,6 +171,18 @@ func TestRunReportsAFailingCommand(t *testing.T) { | ||
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | +// A failing command's error holds the last lines it printed: they say why | |
| 175 | +// (issue #107: sbx asking whether to sign in to OpenAI, not "exit status 1"). | |
| 176 | +func TestAFailingCommandSaysWhatItPrinted(t *testing.T) { | |
| 177 | + f := setup(t) | |
| 178 | + agent := milo(t.TempDir()) | |
| 179 | + agent.Runtime.Lifecycle.Stop = []string{"sh", "-c", "echo one; echo two; echo three; echo 'Authenticate on the web? [y/N]' >&2; exit 1"} | |
| 180 | + err := f.runner.Run(ctx, agent, lifecycle.Stop, f.log) | |
| 181 | + if err == nil || !strings.HasSuffix(err.Error(), "exit status 1: two · three · Authenticate on the web? [y/N]") { | |
| 182 | + t.Fatalf("want the last three lines, got %v", err) | |
| 183 | + } | |
| 184 | +} | |
| 185 | + | |
| 174 | 186 | // A command sees PWD set to its folder, like in a terminal (issue #94: the |
| 175 | 187 | // compose.yaml of mm dockerinit mounts ${PWD}). |
| 176 | 188 | func TestACommandRunsWithPWDSetToItsFolder(t *testing.T) { |
| @@ -171,6 +171,18 @@ func TestRunReportsAFailingCommand(t *testing.T) { | |||
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | +// A failing command's error holds the last lines it printed: they say why | ||
| 175 | +// (issue #107: sbx asking whether to sign in to OpenAI, not "exit status 1"). | ||
| 176 | +func TestAFailingCommandSaysWhatItPrinted(t *testing.T) { | ||
| 177 | + f := setup(t) | ||
| 178 | + agent := milo(t.TempDir()) | ||
| 179 | + agent.Runtime.Lifecycle.Stop = []string{"sh", "-c", "echo one; echo two; echo three; echo 'Authenticate on the web? [y/N]' >&2; exit 1"} | ||
| 180 | + err := f.runner.Run(ctx, agent, lifecycle.Stop, f.log) | ||
| 181 | + if err == nil || !strings.HasSuffix(err.Error(), "exit status 1: two · three · Authenticate on the web? [y/N]") { | ||
| 182 | + t.Fatalf("want the last three lines, got %v", err) | ||
| 183 | + } | ||
| 184 | +} | ||
| 185 | + | ||
| 174 | // A command sees PWD set to its folder, like in a terminal (issue #94: the | 186 | // A command sees PWD set to its folder, like in a terminal (issue #94: the |
| 175 | // compose.yaml of mm dockerinit mounts ${PWD}). | 187 | // compose.yaml of mm dockerinit mounts ${PWD}). |
| 176 | func TestACommandRunsWithPWDSetToItsFolder(t *testing.T) { | 188 | func TestACommandRunsWithPWDSetToItsFolder(t *testing.T) { |
modified
internal/sbxcreate/gh.go +1 -1 | @@ -82,5 +82,5 @@ func (g GH) StartLogin() (*Login, error) { | ||
| 82 | 82 | if err != nil { |
| 83 | 83 | return nil, err |
| 84 | 84 | } |
| 85 | - return startLogin(program, []string{"auth", "login", "--web", "--hostname", "github.com", "--git-protocol", "https"}, "gh auth login ended without signing in") | |
| 85 | + return startLogin(program, []string{"auth", "login", "--web", "--hostname", "github.com", "--git-protocol", "https"}, flow{failure: "gh auth login ended without signing in"}) | |
| 86 | 86 | } |
| @@ -82,5 +82,5 @@ func (g GH) StartLogin() (*Login, error) { | |||
| 82 | if err != nil { | 82 | if err != nil { |
| 83 | return nil, err | 83 | return nil, err |
| 84 | } | 84 | } |
| 85 | - return startLogin(program, []string{"auth", "login", "--web", "--hostname", "github.com", "--git-protocol", "https"}, "gh auth login ended without signing in") | 85 | + return startLogin(program, []string{"auth", "login", "--web", "--hostname", "github.com", "--git-protocol", "https"}, flow{failure: "gh auth login ended without signing in"}) |
| 86 | } | 86 | } |
modified
internal/sbxcreate/login.go +24 -7 | @@ -35,6 +35,9 @@ type LoginState struct { | ||
| 35 | 35 | Done bool `json:"done"` |
| 36 | 36 | User string `json:"user"` |
| 37 | 37 | Error string `json:"error"` |
| 38 | + // OK: the sign-in succeeded — someone signed in (User), or a command | |
| 39 | + // that names nobody ended well (sbx secret set --oauth, issue #107). | |
| 40 | + OK bool `json:"ok"` | |
| 38 | 41 | // Output is what sbx printed, for when its lines are not the expected ones. |
| 39 | 42 | Output []string `json:"output"` |
| 40 | 43 | } |
| @@ -49,8 +52,7 @@ var ( | ||
| 49 | 52 | // Login is a `sbx login` in progress. |
| 50 | 53 | type Login struct { |
| 51 | 54 | cancel context.CancelFunc |
| 52 | - // failure is the error when the command ended without signing in. | |
| 53 | - failure string | |
| 55 | + flow flow | |
| 54 | 56 | |
| 55 | 57 | mu sync.Mutex |
| 56 | 58 | state LoginState |
| @@ -64,18 +66,30 @@ func (s Sbx) StartLogin() (*Login, error) { | ||
| 64 | 66 | if err != nil { |
| 65 | 67 | return nil, err |
| 66 | 68 | } |
| 67 | - return startLogin(program, []string{"login"}, "sbx login ended without signing in") | |
| 69 | + return startLogin(program, []string{"login"}, flow{failure: "sbx login ended without signing in"}) | |
| 70 | +} | |
| 71 | + | |
| 72 | +// flow is how to read a sign-in command. | |
| 73 | +type flow struct { | |
| 74 | + // failure is the error when the command ended without signing in. | |
| 75 | + failure string | |
| 76 | + // anyURL: the first https URL is the page to open, whatever it names | |
| 77 | + // (an OAuth page); otherwise only a URL naming "login". | |
| 78 | + anyURL bool | |
| 79 | + // okOnExit: the command names nobody; ending without an error is the | |
| 80 | + // success. | |
| 81 | + okOnExit bool | |
| 68 | 82 | } |
| 69 | 83 | |
| 70 | 84 | // startLogin runs a device-code sign-in (sbx login, gh auth login --web) |
| 71 | 85 | // and reads its lines. |
| 72 | -func startLogin(program string, args []string, failure string) (*Login, error) { | |
| 86 | +func startLogin(program string, args []string, how flow) (*Login, error) { | |
| 73 | 87 | ctx, cancel := context.WithCancel(context.Background()) |
| 74 | 88 | command := exec.CommandContext(ctx, program, args...) |
| 75 | 89 | command.Stdin = strings.NewReader("") |
| 76 | 90 | reader, writer := io.Pipe() |
| 77 | 91 | command.Stdout, command.Stderr = writer, writer |
| 78 | - l := &Login{cancel: cancel, failure: failure, changed: make(chan struct{}), state: LoginState{Output: []string{}}} | |
| 92 | + l := &Login{cancel: cancel, flow: how, changed: make(chan struct{}), state: LoginState{Output: []string{}}} | |
| 79 | 93 | if err := command.Start(); err != nil { |
| 80 | 94 | cancel() |
| 81 | 95 | return nil, err |
| @@ -114,7 +128,7 @@ func (l *Login) line(text string) { | ||
| 114 | 128 | } |
| 115 | 129 | l.update(func(state *LoginState) { |
| 116 | 130 | state.Output = append(state.Output, text) |
| 117 | - if url := urlPattern.FindString(text); url != "" && state.URL == "" && strings.Contains(url, "login") { | |
| 131 | + if url := urlPattern.FindString(text); url != "" && state.URL == "" && (l.flow.anyURL || strings.Contains(url, "login")) { | |
| 118 | 132 | // gh: "Open this URL to continue in your web browser: https://github.com/login/device". |
| 119 | 133 | state.URL = strings.TrimRight(url, ".,;)") |
| 120 | 134 | if code := codePattern.FindStringSubmatch(url); code != nil && state.Code == "" { |
| @@ -137,12 +151,15 @@ func (l *Login) finish(err error, cancelled bool) { | ||
| 137 | 151 | state.Done = true |
| 138 | 152 | switch { |
| 139 | 153 | case state.User != "": |
| 154 | + state.OK = true | |
| 140 | 155 | case cancelled: |
| 141 | 156 | state.Error = "cancelled" |
| 142 | 157 | case err != nil: |
| 143 | 158 | state.Error = err.Error() |
| 159 | + case l.flow.okOnExit: | |
| 160 | + state.OK = true | |
| 144 | 161 | default: |
| 145 | - state.Error = l.failure | |
| 162 | + state.Error = l.flow.failure | |
| 146 | 163 | } |
| 147 | 164 | }) |
| 148 | 165 | } |
| @@ -35,6 +35,9 @@ type LoginState struct { | |||
| 35 | Done bool `json:"done"` | 35 | Done bool `json:"done"` |
| 36 | User string `json:"user"` | 36 | User string `json:"user"` |
| 37 | Error string `json:"error"` | 37 | Error string `json:"error"` |
| 38 | + // OK: the sign-in succeeded — someone signed in (User), or a command | ||
| 39 | + // that names nobody ended well (sbx secret set --oauth, issue #107). | ||
| 40 | + OK bool `json:"ok"` | ||
| 38 | // Output is what sbx printed, for when its lines are not the expected ones. | 41 | // Output is what sbx printed, for when its lines are not the expected ones. |
| 39 | Output []string `json:"output"` | 42 | Output []string `json:"output"` |
| 40 | } | 43 | } |
| @@ -49,8 +52,7 @@ var ( | |||
| 49 | // Login is a `sbx login` in progress. | 52 | // Login is a `sbx login` in progress. |
| 50 | type Login struct { | 53 | type Login struct { |
| 51 | cancel context.CancelFunc | 54 | cancel context.CancelFunc |
| 52 | - // failure is the error when the command ended without signing in. | 55 | + flow flow |
| 53 | - failure string | ||
| 54 | 56 | ||
| 55 | mu sync.Mutex | 57 | mu sync.Mutex |
| 56 | state LoginState | 58 | state LoginState |
| @@ -64,18 +66,30 @@ func (s Sbx) StartLogin() (*Login, error) { | |||
| 64 | if err != nil { | 66 | if err != nil { |
| 65 | return nil, err | 67 | return nil, err |
| 66 | } | 68 | } |
| 67 | - return startLogin(program, []string{"login"}, "sbx login ended without signing in") | 69 | + return startLogin(program, []string{"login"}, flow{failure: "sbx login ended without signing in"}) |
| 70 | +} | ||
| 71 | + | ||
| 72 | +// flow is how to read a sign-in command. | ||
| 73 | +type flow struct { | ||
| 74 | + // failure is the error when the command ended without signing in. | ||
| 75 | + failure string | ||
| 76 | + // anyURL: the first https URL is the page to open, whatever it names | ||
| 77 | + // (an OAuth page); otherwise only a URL naming "login". | ||
| 78 | + anyURL bool | ||
| 79 | + // okOnExit: the command names nobody; ending without an error is the | ||
| 80 | + // success. | ||
| 81 | + okOnExit bool | ||
| 68 | } | 82 | } |
| 69 | 83 | ||
| 70 | // startLogin runs a device-code sign-in (sbx login, gh auth login --web) | 84 | // startLogin runs a device-code sign-in (sbx login, gh auth login --web) |
| 71 | // and reads its lines. | 85 | // and reads its lines. |
| 72 | -func startLogin(program string, args []string, failure string) (*Login, error) { | 86 | +func startLogin(program string, args []string, how flow) (*Login, error) { |
| 73 | ctx, cancel := context.WithCancel(context.Background()) | 87 | ctx, cancel := context.WithCancel(context.Background()) |
| 74 | command := exec.CommandContext(ctx, program, args...) | 88 | command := exec.CommandContext(ctx, program, args...) |
| 75 | command.Stdin = strings.NewReader("") | 89 | command.Stdin = strings.NewReader("") |
| 76 | reader, writer := io.Pipe() | 90 | reader, writer := io.Pipe() |
| 77 | command.Stdout, command.Stderr = writer, writer | 91 | command.Stdout, command.Stderr = writer, writer |
| 78 | - l := &Login{cancel: cancel, failure: failure, changed: make(chan struct{}), state: LoginState{Output: []string{}}} | 92 | + l := &Login{cancel: cancel, flow: how, changed: make(chan struct{}), state: LoginState{Output: []string{}}} |
| 79 | if err := command.Start(); err != nil { | 93 | if err := command.Start(); err != nil { |
| 80 | cancel() | 94 | cancel() |
| 81 | return nil, err | 95 | return nil, err |
| @@ -114,7 +128,7 @@ func (l *Login) line(text string) { | |||
| 114 | } | 128 | } |
| 115 | l.update(func(state *LoginState) { | 129 | l.update(func(state *LoginState) { |
| 116 | state.Output = append(state.Output, text) | 130 | state.Output = append(state.Output, text) |
| 117 | - if url := urlPattern.FindString(text); url != "" && state.URL == "" && strings.Contains(url, "login") { | 131 | + if url := urlPattern.FindString(text); url != "" && state.URL == "" && (l.flow.anyURL || strings.Contains(url, "login")) { |
| 118 | // gh: "Open this URL to continue in your web browser: https://github.com/login/device". | 132 | // gh: "Open this URL to continue in your web browser: https://github.com/login/device". |
| 119 | state.URL = strings.TrimRight(url, ".,;)") | 133 | state.URL = strings.TrimRight(url, ".,;)") |
| 120 | if code := codePattern.FindStringSubmatch(url); code != nil && state.Code == "" { | 134 | if code := codePattern.FindStringSubmatch(url); code != nil && state.Code == "" { |
| @@ -137,12 +151,15 @@ func (l *Login) finish(err error, cancelled bool) { | |||
| 137 | state.Done = true | 151 | state.Done = true |
| 138 | switch { | 152 | switch { |
| 139 | case state.User != "": | 153 | case state.User != "": |
| 154 | + state.OK = true | ||
| 140 | case cancelled: | 155 | case cancelled: |
| 141 | state.Error = "cancelled" | 156 | state.Error = "cancelled" |
| 142 | case err != nil: | 157 | case err != nil: |
| 143 | state.Error = err.Error() | 158 | state.Error = err.Error() |
| 159 | + case l.flow.okOnExit: | ||
| 160 | + state.OK = true | ||
| 144 | default: | 161 | default: |
| 145 | - state.Error = l.failure | 162 | + state.Error = l.flow.failure |
| 146 | } | 163 | } |
| 147 | }) | 164 | }) |
| 148 | } | 165 | } |
modified
internal/sbxcreate/login_test.go +46 -0 | @@ -144,3 +144,49 @@ func TestWithoutGHTheAssistantSaysSo(t *testing.T) { | ||
| 144 | 144 | t.Fatalf("StartLogin: %v", err) |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | + | |
| 148 | +// oauthScript is `sbx secret set openai --oauth` in short (issue #107): it | |
| 149 | +// prints the page it opens, waits for the file confirmed, then ends well; | |
| 150 | +// with the file refuse it fails. | |
| 151 | +const oauthScript = `#!/bin/sh | |
| 152 | +here=$(dirname "$0") | |
| 153 | +[ "$1 $2 $3 $4" = "secret set openai --oauth" ] || exit 1 | |
| 154 | +echo "Opening your browser to sign in: https://auth.openai.com/oauth/authorize?client_id=x" | |
| 155 | +if [ -f "$here/refuse" ]; then echo "error: the sign-in was refused" >&2; exit 1; fi | |
| 156 | +while [ ! -f "$here/confirmed" ]; do sleep 0.05; done | |
| 157 | +echo "Secret stored." | |
| 158 | +` | |
| 159 | + | |
| 160 | +func TestOAuthOpensThePageThenSucceedsWhenSbxEndsWell(t *testing.T) { | |
| 161 | + dir := t.TempDir() | |
| 162 | + if err := os.WriteFile(filepath.Join(dir, "sbx"), []byte(oauthScript), 0o755); err != nil { | |
| 163 | + t.Fatal(err) | |
| 164 | + } | |
| 165 | + sbx := sbxcreate.Sbx{Command: filepath.Join(dir, "sbx")} | |
| 166 | + login, err := sbx.StartOAuth("openai") | |
| 167 | + if err != nil { | |
| 168 | + t.Fatal(err) | |
| 169 | + } | |
| 170 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.URL != "" }) | |
| 171 | + if state.URL != "https://auth.openai.com/oauth/authorize?client_id=x" || state.Code != "" || state.Done { | |
| 172 | + t.Fatalf("waiting: %+v", state) | |
| 173 | + } | |
| 174 | + if err := os.WriteFile(filepath.Join(dir, "confirmed"), nil, 0o644); err != nil { | |
| 175 | + t.Fatal(err) | |
| 176 | + } | |
| 177 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | |
| 178 | + if !state.OK || state.Error != "" || state.User != "" { | |
| 179 | + t.Fatalf("done: %+v", state) | |
| 180 | + } | |
| 181 | + if err := os.WriteFile(filepath.Join(dir, "refuse"), nil, 0o644); err != nil { | |
| 182 | + t.Fatal(err) | |
| 183 | + } | |
| 184 | + login, err = sbx.StartOAuth("openai") | |
| 185 | + if err != nil { | |
| 186 | + t.Fatal(err) | |
| 187 | + } | |
| 188 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | |
| 189 | + if state.OK || state.Error == "" { | |
| 190 | + t.Fatalf("refused: %+v", state) | |
| 191 | + } | |
| 192 | +} | |
| @@ -144,3 +144,49 @@ func TestWithoutGHTheAssistantSaysSo(t *testing.T) { | |||
| 144 | t.Fatalf("StartLogin: %v", err) | 144 | t.Fatalf("StartLogin: %v", err) |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | + | ||
| 148 | +// oauthScript is `sbx secret set openai --oauth` in short (issue #107): it | ||
| 149 | +// prints the page it opens, waits for the file confirmed, then ends well; | ||
| 150 | +// with the file refuse it fails. | ||
| 151 | +const oauthScript = `#!/bin/sh | ||
| 152 | +here=$(dirname "$0") | ||
| 153 | +[ "$1 $2 $3 $4" = "secret set openai --oauth" ] || exit 1 | ||
| 154 | +echo "Opening your browser to sign in: https://auth.openai.com/oauth/authorize?client_id=x" | ||
| 155 | +if [ -f "$here/refuse" ]; then echo "error: the sign-in was refused" >&2; exit 1; fi | ||
| 156 | +while [ ! -f "$here/confirmed" ]; do sleep 0.05; done | ||
| 157 | +echo "Secret stored." | ||
| 158 | +` | ||
| 159 | + | ||
| 160 | +func TestOAuthOpensThePageThenSucceedsWhenSbxEndsWell(t *testing.T) { | ||
| 161 | + dir := t.TempDir() | ||
| 162 | + if err := os.WriteFile(filepath.Join(dir, "sbx"), []byte(oauthScript), 0o755); err != nil { | ||
| 163 | + t.Fatal(err) | ||
| 164 | + } | ||
| 165 | + sbx := sbxcreate.Sbx{Command: filepath.Join(dir, "sbx")} | ||
| 166 | + login, err := sbx.StartOAuth("openai") | ||
| 167 | + if err != nil { | ||
| 168 | + t.Fatal(err) | ||
| 169 | + } | ||
| 170 | + state := waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.URL != "" }) | ||
| 171 | + if state.URL != "https://auth.openai.com/oauth/authorize?client_id=x" || state.Code != "" || state.Done { | ||
| 172 | + t.Fatalf("waiting: %+v", state) | ||
| 173 | + } | ||
| 174 | + if err := os.WriteFile(filepath.Join(dir, "confirmed"), nil, 0o644); err != nil { | ||
| 175 | + t.Fatal(err) | ||
| 176 | + } | ||
| 177 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | ||
| 178 | + if !state.OK || state.Error != "" || state.User != "" { | ||
| 179 | + t.Fatalf("done: %+v", state) | ||
| 180 | + } | ||
| 181 | + if err := os.WriteFile(filepath.Join(dir, "refuse"), nil, 0o644); err != nil { | ||
| 182 | + t.Fatal(err) | ||
| 183 | + } | ||
| 184 | + login, err = sbx.StartOAuth("openai") | ||
| 185 | + if err != nil { | ||
| 186 | + t.Fatal(err) | ||
| 187 | + } | ||
| 188 | + state = waitLogin(t, login, func(s sbxcreate.LoginState) bool { return s.Done }) | ||
| 189 | + if state.OK || state.Error == "" { | ||
| 190 | + t.Fatalf("refused: %+v", state) | ||
| 191 | + } | ||
| 192 | +} | ||
added
internal/sbxcreate/oauth.go +23 -0 | new file mode 100644 | ||
| @@ -0,0 +1,23 @@ | ||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | |
| 2 | + | |
| 3 | +package sbxcreate | |
| 4 | + | |
| 5 | +// Signing in with an account instead of an API key (issue #107): for Codex, | |
| 6 | +// `sbx secret set openai --oauth` opens a browser window on this computer, | |
| 7 | +// where the user signs in with their ChatGPT account, then stores the tokens | |
| 8 | +// in the system keychain. Without it, creating a Codex sandbox asks on the | |
| 9 | +// keyboard whether to authenticate on the web — a question Sidekicks cannot | |
| 10 | +// answer, since its lifecycle commands have no standard input. | |
| 11 | + | |
| 12 | +// StartOAuth runs `sbx secret set <service> --oauth` and reads it like | |
| 13 | +// sbx login: the first https URL it prints is the page to open (sbx may | |
| 14 | +// open it itself), and ending without an error is the success. | |
| 15 | +func (s Sbx) StartOAuth(service string) (*Login, error) { | |
| 16 | + program, err := s.program() | |
| 17 | + if err != nil { | |
| 18 | + return nil, err | |
| 19 | + } | |
| 20 | + return startLogin(program, []string{"secret", "set", service, "--oauth"}, flow{ | |
| 21 | + failure: "sbx secret set " + service + " --oauth ended without signing in", anyURL: true, okOnExit: true, | |
| 22 | + }) | |
| 23 | +} | |
| new file mode 100644 | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | +// Copyright (c) 2026 Philippe Charrière — Sidekicks Source-Available License 1.0, see LICENSE | ||
| 2 | + | ||
| 3 | +package sbxcreate | ||
| 4 | + | ||
| 5 | +// Signing in with an account instead of an API key (issue #107): for Codex, | ||
| 6 | +// `sbx secret set openai --oauth` opens a browser window on this computer, | ||
| 7 | +// where the user signs in with their ChatGPT account, then stores the tokens | ||
| 8 | +// in the system keychain. Without it, creating a Codex sandbox asks on the | ||
| 9 | +// keyboard whether to authenticate on the web — a question Sidekicks cannot | ||
| 10 | +// answer, since its lifecycle commands have no standard input. | ||
| 11 | + | ||
| 12 | +// StartOAuth runs `sbx secret set <service> --oauth` and reads it like | ||
| 13 | +// sbx login: the first https URL it prints is the page to open (sbx may | ||
| 14 | +// open it itself), and ending without an error is the success. | ||
| 15 | +func (s Sbx) StartOAuth(service string) (*Login, error) { | ||
| 16 | + program, err := s.program() | ||
| 17 | + if err != nil { | ||
| 18 | + return nil, err | ||
| 19 | + } | ||
| 20 | + return startLogin(program, []string{"secret", "set", service, "--oauth"}, flow{ | ||
| 21 | + failure: "sbx secret set " + service + " --oauth ended without signing in", anyURL: true, okOnExit: true, | ||
| 22 | + }) | ||
| 23 | +} | ||
modified
internal/sbxcreate/sbxcreate.go +6 -2 | @@ -57,7 +57,11 @@ type Kind struct { | ||
| 57 | 57 | FromGH bool `json:"fromGh"` |
| 58 | 58 | // SignIn is the program to run in the agent's terminal to sign in with |
| 59 | 59 | // an account instead of the key ("claude": then /login, issue #105). |
| 60 | - SignIn string `json:"signIn"` | |
| 60 | + SignIn string `json:"signIn"` | |
| 61 | + // OAuth is true when the service also takes a sign-in with an account | |
| 62 | + // in a browser, stored by `sbx secret set <service> --oauth` (Codex: | |
| 63 | + // ChatGPT, issue #107). | |
| 64 | + OAuth bool `json:"oauth"` | |
| 61 | 65 | Bindings Binding `json:"-"` |
| 62 | 66 | // Shared is the other sbx services that get the same secret, each with |
| 63 | 67 | // its domains (Copilot's token also goes to github, for git and gh). |
| @@ -102,7 +106,7 @@ var Catalogue = []Kind{ | ||
| 102 | 106 | { |
| 103 | 107 | ID: "codex", Title: "Codex", Icon: "logo:openai", |
| 104 | 108 | Agent: "codex", Kit: "docker.io/sbx/codex-acp:latest", Program: "codex-acp", |
| 105 | - Service: "openai", KeyURL: "https://platform.openai.com/api-keys", | |
| 109 | + Service: "openai", KeyURL: "https://platform.openai.com/api-keys", OAuth: true, | |
| 106 | 110 | Bindings: Binding{APIKey: []string{"api.openai.com", "openai.com"}, OAuth: []string{"auth.openai.com", "chatgpt.com"}}, |
| 107 | 111 | }, |
| 108 | 112 | { |
| @@ -57,7 +57,11 @@ type Kind struct { | |||
| 57 | FromGH bool `json:"fromGh"` | 57 | FromGH bool `json:"fromGh"` |
| 58 | // SignIn is the program to run in the agent's terminal to sign in with | 58 | // SignIn is the program to run in the agent's terminal to sign in with |
| 59 | // an account instead of the key ("claude": then /login, issue #105). | 59 | // an account instead of the key ("claude": then /login, issue #105). |
| 60 | - SignIn string `json:"signIn"` | 60 | + SignIn string `json:"signIn"` |
| 61 | + // OAuth is true when the service also takes a sign-in with an account | ||
| 62 | + // in a browser, stored by `sbx secret set <service> --oauth` (Codex: | ||
| 63 | + // ChatGPT, issue #107). | ||
| 64 | + OAuth bool `json:"oauth"` | ||
| 61 | Bindings Binding `json:"-"` | 65 | Bindings Binding `json:"-"` |
| 62 | // Shared is the other sbx services that get the same secret, each with | 66 | // Shared is the other sbx services that get the same secret, each with |
| 63 | // its domains (Copilot's token also goes to github, for git and gh). | 67 | // its domains (Copilot's token also goes to github, for git and gh). |
| @@ -102,7 +106,7 @@ var Catalogue = []Kind{ | |||
| 102 | { | 106 | { |
| 103 | ID: "codex", Title: "Codex", Icon: "logo:openai", | 107 | ID: "codex", Title: "Codex", Icon: "logo:openai", |
| 104 | Agent: "codex", Kit: "docker.io/sbx/codex-acp:latest", Program: "codex-acp", | 108 | Agent: "codex", Kit: "docker.io/sbx/codex-acp:latest", Program: "codex-acp", |
| 105 | - Service: "openai", KeyURL: "https://platform.openai.com/api-keys", | 109 | + Service: "openai", KeyURL: "https://platform.openai.com/api-keys", OAuth: true, |
| 106 | Bindings: Binding{APIKey: []string{"api.openai.com", "openai.com"}, OAuth: []string{"auth.openai.com", "chatgpt.com"}}, | 110 | Bindings: Binding{APIKey: []string{"api.openai.com", "openai.com"}, OAuth: []string{"auth.openai.com", "chatgpt.com"}}, |
| 107 | }, | 111 | }, |
| 108 | { | 112 | { |